Skip site navigation (1)Skip section navigation (2)
Date:      Sat, 30 Oct 2010 11:25:05 +0300
From:      Andriy Gapon <avg@freebsd.org>
To:        Artemiev Igor <ai@kliksys.ru>
Cc:        freebsd-fs@freebsd.org, freebsd-stable@freebsd.org
Subject:   Re: 8.1-STABLE: zfs and sendfile: problem still exists
Message-ID:  <4CCBD661.3000204@freebsd.org>
In-Reply-To: <4CCBD46E.9030200@icyb.net.ua>
References:  <3D1C350B94A44E5D95BAA1596D1EBF13@vosz.local>	<20101029090417.GA17537@two.kliksys.ru>	<4CCABFC2.3040701@icyb.net.ua> <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>

next in thread | previous in thread | raw e-mail | index | archive | help
on 30/10/2010 11:16 Andriy Gapon said the following:
> on 30/10/2010 11:16 Andriy Gapon said the following:
>> Or maybe something like the following?
>> It looks a little bit cleaner to me, but still is not perfect, as I have not
>> handled unnecessary busy-ing of the pages where something more lightweight could
>> have sufficed (e.g. wiring and shared busying).
> 
> Note: I have only compile tested the patch.

Missed one NULL check.

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,8 +475,18 @@
 			 */
 			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;
+			if (m == NULL) {
+				m = vm_page_alloc(obj, OFF_TO_IDX(start),
+					    VM_ALLOC_NOBUSY | VM_ALLOC_SYSTEM);
+				if (m == NULL) {
+					VM_OBJECT_UNLOCK(obj);
+					VM_WAIT;
+					VM_OBJECT_LOCK(obj);
+					goto again;
+				}
+			}
 			vm_page_busy(m);
 			VM_OBJECT_UNLOCK(obj);
 			if (dirbytes > 0) {


-- 
Andriy Gapon



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