From owner-svn-src-stable@FreeBSD.ORG Tue Aug 27 03:11:50 2013 Return-Path: Delivered-To: svn-src-stable@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [8.8.178.115]) (using TLSv1 with cipher ADH-AES256-SHA (256/256 bits)) (No client certificate requested) by hub.freebsd.org (Postfix) with ESMTP id 05F7EC42; Tue, 27 Aug 2013 03:11:50 +0000 (UTC) (envelope-from kib@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:1900:2254:2068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mx1.freebsd.org (Postfix) with ESMTPS id E386624E6; Tue, 27 Aug 2013 03:11:49 +0000 (UTC) Received: from svn.freebsd.org ([127.0.1.70]) by svn.freebsd.org (8.14.7/8.14.7) with ESMTP id r7R3BnKa035342; Tue, 27 Aug 2013 03:11:49 GMT (envelope-from kib@svn.freebsd.org) Received: (from kib@localhost) by svn.freebsd.org (8.14.7/8.14.5/Submit) id r7R3Bnr0035339; Tue, 27 Aug 2013 03:11:49 GMT (envelope-from kib@svn.freebsd.org) Message-Id: <201308270311.r7R3Bnr0035339@svn.freebsd.org> From: Konstantin Belousov Date: Tue, 27 Aug 2013 03:11:49 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-9@freebsd.org Subject: svn commit: r254947 - stable/9/sys/kern X-SVN-Group: stable-9 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-stable@freebsd.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: SVN commit messages for all the -stable branches of the src tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 27 Aug 2013 03:11:50 -0000 Author: kib Date: Tue Aug 27 03:11:49 2013 New Revision: 254947 URL: http://svnweb.freebsd.org/changeset/base/254947 Log: Partial MFC of r253927 (by attilio): Remove unnecessary soft busy of the page before to do vn_rdwr() in kern_sendfile() which is unnecessary. MFC note: NFS implementation of VOP_READ() sometimes upgrades the vnode lock, which causes drop of the shared lock and sleep for exclusive. As result, busying of the page before the call to vn_rdwr() makes NFS code to wait for vnode lock while page is busy, which contradicts the proper order of vnode lock -> busy. The r250027, merged as part of r250907, started calling vm_page_grab() under the vnode lock. The page grab waits for the page busy state to drain, which makes the parallel sendfile(2) invocations on the same vnode vulnerable to the LOR described above. Note that r250027 only exposed the problem, which might be caused by other means as well, e.g. by parallel sendfile(2) and truncate(2). Sponsored by: The FreeBSD Foundation Modified: stable/9/sys/kern/uipc_syscalls.c Modified: stable/9/sys/kern/uipc_syscalls.c ============================================================================== --- stable/9/sys/kern/uipc_syscalls.c Tue Aug 27 01:40:13 2013 (r254946) +++ stable/9/sys/kern/uipc_syscalls.c Tue Aug 27 03:11:49 2013 (r254947) @@ -2124,11 +2124,6 @@ retry_space: else { ssize_t resid; - /* - * Ensure that our page is still around - * when the I/O completes. - */ - vm_page_io_start(pg); VM_OBJECT_UNLOCK(obj); /* @@ -2144,10 +2139,8 @@ retry_space: IO_VMIO | ((MAXBSIZE / bsize) << IO_SEQSHIFT), td->td_ucred, NOCRED, &resid, td); VFS_UNLOCK_GIANT(vfslocked); - VM_OBJECT_LOCK(obj); - vm_page_io_finish(pg); - if (!error) - VM_OBJECT_UNLOCK(obj); + if (error) + VM_OBJECT_LOCK(obj); mbstat.sf_iocnt++; } if (error) {