From owner-svn-src-head@FreeBSD.ORG Tue Oct 12 17:04:22 2010 Return-Path: Delivered-To: svn-src-head@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 6ADBA1065694; Tue, 12 Oct 2010 17:04:22 +0000 (UTC) (envelope-from avg@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id 3E9CD8FC0C; Tue, 12 Oct 2010 17:04:22 +0000 (UTC) Received: from svn.freebsd.org (localhost [127.0.0.1]) by svn.freebsd.org (8.14.3/8.14.3) with ESMTP id o9CH4M73054349; Tue, 12 Oct 2010 17:04:22 GMT (envelope-from avg@svn.freebsd.org) Received: (from avg@localhost) by svn.freebsd.org (8.14.3/8.14.3/Submit) id o9CH4Mde054347; Tue, 12 Oct 2010 17:04:22 GMT (envelope-from avg@svn.freebsd.org) Message-Id: <201010121704.o9CH4Mde054347@svn.freebsd.org> From: Andriy Gapon Date: Tue, 12 Oct 2010 17:04:22 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org X-SVN-Group: head MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Cc: Subject: svn commit: r213730 - head/sys/cddl/contrib/opensolaris/uts/common/fs/zfs X-BeenThere: svn-src-head@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: SVN commit messages for the src tree for head/-current List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 12 Oct 2010 17:04:22 -0000 Author: avg Date: Tue Oct 12 17:04:21 2010 New Revision: 213730 URL: http://svn.freebsd.org/changeset/base/213730 Log: zfs + sendfile: do not produce partially valid pages for vnode's tail Since r212650 and before this change sendfile(2) could produce a partially valid page for a trailing portion of a ZFS vnode. vm_fault() always wants to see a fully valid page even if it's the last page that partially extends beyond vnode's end. Otherwise it calls vop_getpages() to bring in the page. In the case of ZFS this means that the data is read from the page into the same page and this breaks checks in ZFS mappedread() - a thread that set VPO_BUSY on the page in vm_fault() will get blocked forever waiting for it to be cleared. Many thanks to Kai and Jeremy for reproducing the issue and providing important debugging information and help. Reported by: Kai Gallasch , Jeremy Chadwick Tested by: Kai Gallasch , Jeremy Chadwick Reviewed by: kib MFC after: 3 days To-Do: apply the same treatment to tmpfs + sendfile Modified: head/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/zfs_vnops.c Modified: head/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/zfs_vnops.c ============================================================================== --- head/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/zfs_vnops.c Tue Oct 12 16:52:13 2010 (r213729) +++ head/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/zfs_vnops.c Tue Oct 12 17:04:21 2010 (r213730) @@ -489,6 +489,8 @@ again: * 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 ((m->oflags & VPO_BUSY) != 0) { /* * Reference the page before unlocking and @@ -509,14 +511,15 @@ again: } if (error == 0) { va = zfs_map_page(m, &sf); - error = dmu_read(os, zp->z_id, start + off, - bytes, (void *)(va + off), + error = dmu_read(os, zp->z_id, start, bytes, va, DMU_READ_PREFETCH); + if (bytes != PAGE_SIZE) + bzero(va + bytes, PAGE_SIZE - bytes); zfs_unmap_page(sf); } VM_OBJECT_LOCK(obj); if (error == 0) - vm_page_set_valid(m, off, bytes); + m->valid = VM_PAGE_BITS_ALL; vm_page_wakeup(m); if (error == 0) { uio->uio_resid -= bytes;