Skip site navigation (1)Skip section navigation (2)
Date:      Fri, 13 Mar 2020 19:48:17 -0400
From:      Mark Johnston <markj@freebsd.org>
To:        Chuck Silvers <chs@freebsd.org>
Cc:        src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org
Subject:   Re: svn commit: r358597 - head/sys/kern
Message-ID:  <20200313234817.GA10027@spy>
In-Reply-To: <202003040022.0240Mpm6074186@repo.freebsd.org>
References:  <202003040022.0240Mpm6074186@repo.freebsd.org>

next in thread | previous in thread | raw e-mail | index | archive | help
On Wed, Mar 04, 2020 at 12:22:51AM +0000, Chuck Silvers wrote:
> Author: chs
> Date: Wed Mar  4 00:22:50 2020
> New Revision: 358597
> URL: https://svnweb.freebsd.org/changeset/base/358597
> 
> Log:
>   if vm_pager_get_pages_async() returns an error, release the sfio->nios
>   refcount that we took earlier that represents the I/O that ended up
>   not being started.

I think a larger bug is that getpages_async is not consistent about
whether it invokes the completion callback in synchronous error cases.
For instance, vop_stdgetpages_async() always calls it, as does
ffs_getpages_async() when the filesystem fragment size is larger than
the page size.  But vnode_pager_generic_getpages() does not.  So if one
is using sendfile on a filesystem that does not implement
getpages_async, an error will cause sendfile_swapin() to unbusy the
input pages multiple times, and release the sfio refcount twice when it
should be done just once.

>   Reviewed by:	glebius
>   Approved by:	imp (mentor)
>   Sponsored by:	Netflix
> 
> Modified:
>   head/sys/kern/kern_sendfile.c
> 
> Modified: head/sys/kern/kern_sendfile.c
> ==============================================================================
> --- head/sys/kern/kern_sendfile.c	Tue Mar  3 23:15:30 2020	(r358596)
> +++ head/sys/kern/kern_sendfile.c	Wed Mar  4 00:22:50 2020	(r358597)
> @@ -454,6 +454,7 @@ sendfile_swapin(vm_object_t obj, struct sf_io *sfio, i
>  				    __func__, pa, j));
>  				vm_page_unwire(pa[j], PQ_INACTIVE);
>  			}
> +			refcount_release(&sfio->nios);
>  			return (EIO);
>  		}
>  



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?20200313234817.GA10027>