From owner-freebsd-fs@FreeBSD.ORG Fri Oct 29 17:50:55 2010 Return-Path: Delivered-To: freebsd-fs@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 68DC61065670; Fri, 29 Oct 2010 17:50:55 +0000 (UTC) (envelope-from ai@kliksys.ru) Received: from gate.kliksys.ru (gate.kliksys.ru [78.110.241.113]) by mx1.freebsd.org (Postfix) with ESMTP id 12BB78FC0A; Fri, 29 Oct 2010 17:50:54 +0000 (UTC) Received: from [192.168.0.204] (helo=two.kliksys.ru) by gate.kliksys.ru with esmtp (Exim 4.71 (FreeBSD)) (envelope-from ) id 1PBt6L-000HYZ-O5; Fri, 29 Oct 2010 21:50:53 +0400 Date: Fri, 29 Oct 2010 21:51:05 +0400 From: Artemiev Igor To: freebsd-stable@freebsd.org, freebsd-fs@freebsd.org Message-ID: <20101029175105.GB18613@two.kliksys.ru> 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> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <4CCAF0EB.4080001@icyb.net.ua> User-Agent: Mutt/1.5.20 (2009-06-14) X-Spam_score: 0.0 Cc: Subject: Re: 8.1-STABLE: zfs and sendfile: problem still exists X-BeenThere: freebsd-fs@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: Filesystems List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 29 Oct 2010 17:50:55 -0000 On Fri, Oct 29, 2010 at 07:06:03PM +0300, Andriy Gapon wrote: > Probably yes, but have to be careful there. > First, do vm_page_grab only for UIO_NOCOPY case. > Second, the first page is already "shared busy" after vm_page_io_start() call in > kern_sendfile; so you might need VM_ALLOC_IGN_SBUSY for that page to avoid a deadlock. RELENG_8 doesn`t have VM_ALLOC_IGN_SBUSY, it appeared only in HEAD. Can you review this patch, Whether correctly I have understood? (didnt test it yet) --- sys/cddl/contrib/opensolaris/uts/common/fs/zfs/zfs_vnops.c.orig 2010-10-29 18:18:23.921078337 +0200 +++ sys/cddl/contrib/opensolaris/uts/common/fs/zfs/zfs_vnops.c 2010-10-29 19:23:48.142513084 +0200 @@ -449,7 +449,7 @@ int bytes = MIN(PAGESIZE - off, len); again: - if ((m = vm_page_lookup(obj, OFF_TO_IDX(start))) != NULL && + if (uio->uio_segflg != UIO_NOCOPY && (m = vm_page_lookup(obj, OFF_TO_IDX(start))) != NULL && vm_page_is_valid(m, off, bytes)) { if (vm_page_sleep_if_busy(m, FALSE, "zfsmrb")) goto again; @@ -464,7 +464,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@ @@ -472,11 +472,9 @@ * but it pessimize performance of sendfile/UFS, that's * why I handle this special case in ZFS code. */ - KASSERT(off == 0, - ("unexpected offset in mappedread for sendfile")); - if (vm_page_sleep_if_busy(m, FALSE, "zfsmrb")) - goto again; - vm_page_busy(m); + if((m = vm_page_lookup(obj, OFF_TO_IDX(start))) == NULL || !vm_page_is_valid(m, off, bytes)) + m = vm_page_grab(obj, OFF_TO_IDX(start), VM_ALLOC_NORMAL|VM_ALLOC_RETRY); + VM_OBJECT_UNLOCK(obj); if (dirbytes > 0) { error = dmu_read_uio(os, zp->z_id, uio,