From owner-svn-src-head@FreeBSD.ORG Mon Oct 15 18:15:19 2012 Return-Path: Delivered-To: svn-src-head@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [69.147.83.52]) by hub.freebsd.org (Postfix) with ESMTP id 084FAC33; Mon, 15 Oct 2012 18:15:19 +0000 (UTC) (envelope-from kib@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id CD4DA8FC1E; Mon, 15 Oct 2012 18:15:18 +0000 (UTC) Received: from svn.freebsd.org (localhost [127.0.0.1]) by svn.freebsd.org (8.14.4/8.14.4) with ESMTP id q9FIFIU3044815; Mon, 15 Oct 2012 18:15:18 GMT (envelope-from kib@svn.freebsd.org) Received: (from kib@localhost) by svn.freebsd.org (8.14.4/8.14.4/Submit) id q9FIFI6W044813; Mon, 15 Oct 2012 18:15:18 GMT (envelope-from kib@svn.freebsd.org) Message-Id: <201210151815.q9FIFI6W044813@svn.freebsd.org> From: Konstantin Belousov Date: Mon, 15 Oct 2012 18:15:18 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r241597 - head/sys/kern X-SVN-Group: head MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-head@freebsd.org X-Mailman-Version: 2.1.14 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: Mon, 15 Oct 2012 18:15:19 -0000 Author: kib Date: Mon Oct 15 18:15:18 2012 New Revision: 241597 URL: http://svn.freebsd.org/changeset/base/241597 Log: Acquire the rangelock for truncate(2) as well. Reported and reviewed by: avg Tested by: pho MFC after: 1 week Modified: head/sys/kern/vfs_syscalls.c Modified: head/sys/kern/vfs_syscalls.c ============================================================================== --- head/sys/kern/vfs_syscalls.c Mon Oct 15 17:19:47 2012 (r241596) +++ head/sys/kern/vfs_syscalls.c Mon Oct 15 18:15:18 2012 (r241597) @@ -3433,10 +3433,10 @@ kern_truncate(struct thread *td, char *p { struct mount *mp; struct vnode *vp; + void *rl_cookie; struct vattr vattr; - int error; struct nameidata nd; - int vfslocked; + int error, vfslocked; if (length < 0) return(EINVAL); @@ -3445,7 +3445,9 @@ kern_truncate(struct thread *td, char *p return (error); vfslocked = NDHASGIANT(&nd); vp = nd.ni_vp; + rl_cookie = vn_rangelock_wlock(vp, 0, OFF_MAX); if ((error = vn_start_write(vp, &mp, V_WAIT | PCATCH)) != 0) { + vn_rangelock_unlock(vp, rl_cookie); vrele(vp); VFS_UNLOCK_GIANT(vfslocked); return (error); @@ -3464,8 +3466,10 @@ kern_truncate(struct thread *td, char *p vattr.va_size = length; error = VOP_SETATTR(vp, &vattr, td->td_ucred); } - vput(vp); + VOP_UNLOCK(vp, 0); vn_finished_write(mp); + vn_rangelock_unlock(vp, rl_cookie); + vrele(vp); VFS_UNLOCK_GIANT(vfslocked); return (error); }