Skip site navigation (1)Skip section navigation (2)
Date:      Sat, 30 Oct 2010 20:02:48 +0400
From:      "Alexander Zagrebin" <alexz@visp.ru>
To:        "'Andriy Gapon'" <avg@icyb.net.ua>
Cc:        freebsd-fs@freebsd.org, freebsd-stable@freebsd.org
Subject:   RE: 8.1-STABLE: zfs and sendfile: problem still exists
Message-ID:  <DC08BEA955034E10A8BEA3D52E231F6E@vosz.local>
In-Reply-To: <4CCC2F2A.7020809@icyb.net.ua>
References:  <4CCADD37.7000306@icyb.net.ua>	<20101029152602.GA18613@two.kliksys.ru>	<4CCAF0EB.4080001@icyb.net.ua>	<20101029175105.GB18613@two.kliksys.ru>	<4CCBD443.7010305@icyb.net.ua><4CCBD46E.9030200@icyb.net.ua>	<4CCBD661.3000204@freebsd.org><4CCBEAF6.2030408@freebsd.org>	<20101030101254.GB79691@two.kliksys.ru>	<4CCBF45C.4080208@icyb.net.ua><20101030112520.GD79691@two.kliksys.ru> <4CCC2F2A.7020809@icyb.net.ua>

next in thread | previous in thread | raw e-mail | index | archive | help
> >> Oh, thank you for testing - forgot another piece 
> (VM_ALLOC_WIRE for vm_page_alloc):
> > 
> > Yep, it work. But VM_ALLOC_WIRE not exists in RELENG_8, 
> therefore i slightly modified your patch:
> 
> I apologize for my haste, it should have been VM_ALLOC_WIRED.
> Here is a corrected patch:
> Index: sys/cddl/contrib/opensolaris/uts/common/fs/zfs/zfs_vnops.c
> ===================================================================
> --- 
> sys/cddl/contrib/opensolaris/uts/common/fs/zfs/zfs_vnops.c	
> (revision 214318)
> +++ 
> sys/cddl/contrib/opensolaris/uts/common/fs/zfs/zfs_vnops.c	
> (working copy)
> @@ -67,6 +67,7 @@
>  #include <sys/sf_buf.h>
>  #include <sys/sched.h>
>  #include <sys/acl.h>
> +#include <vm/vm_pageout.h>
> 
>  /*
>   * Programming rules.
> @@ -464,7 +465,7 @@
>  				uiomove_fromphys(&m, off, bytes, uio);
>  			VM_OBJECT_LOCK(obj);
>  			vm_page_wakeup(m);
> -		} else if (m != NULL && uio->uio_segflg == UIO_NOCOPY) {
> +		} else if (uio->uio_segflg == UIO_NOCOPY) {
>  			/*
>  			 * The code below is here to make 
> sendfile(2) work
>  			 * correctly with ZFS. As pointed out by ups@
> @@ -474,9 +475,23 @@
>  			 */
>  			KASSERT(off == 0,
>  			    ("unexpected offset in mappedread 
> for sendfile"));
> -			if (vm_page_sleep_if_busy(m, FALSE, "zfsmrb"))
> +			if (m != NULL && 
> vm_page_sleep_if_busy(m, FALSE, "zfsmrb"))
>  				goto again;
> -			vm_page_busy(m);
> +			if (m == NULL) {
> +				m = vm_page_alloc(obj, 
> OFF_TO_IDX(start),
> +				    VM_ALLOC_NOBUSY | 
> VM_ALLOC_WIRED | VM_ALLOC_NORMAL);
> +				if (m == NULL) {
> +					VM_OBJECT_UNLOCK(obj);
> +					VM_WAIT;
> +					VM_OBJECT_LOCK(obj);
> +					goto again;
> +				}
> +			} else {
> +				vm_page_lock_queues();
> +				vm_page_wire(m);
> +				vm_page_unlock_queues();
> +			}
> +			vm_page_io_start(m);
>  			VM_OBJECT_UNLOCK(obj);
>  			if (dirbytes > 0) {
>  				error = dmu_read_uio(os, zp->z_id, uio,
> @@ -494,7 +509,10 @@
>  			VM_OBJECT_LOCK(obj);
>  			if (error == 0)
>  				m->valid = VM_PAGE_BITS_ALL;
> -			vm_page_wakeup(m);
> +			vm_page_io_finish(m);
> +			vm_page_lock_queues();
> +			vm_page_unwire(m, 0);
> +			vm_page_unlock_queues();
>  			if (error == 0) {
>  				uio->uio_resid -= bytes;
>  				uio->uio_offset += bytes;
> 

Big thanks to Andriy, Igor and all who has paid attention to this problem.
I've tried this patch on the test system running under VirtualBox,
and it seems that it solves the problem.
I'll try to test this patch in real conditions today.

-- 
Alexander Zagrebin




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