Skip site navigation (1)Skip section navigation (2)
Date:      Mon, 22 Oct 2012 09:07:12 +0000 (UTC)
From:      Konstantin Belousov <kib@FreeBSD.org>
To:        src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-9@freebsd.org
Subject:   svn commit: r241865 - stable/9/sys/kern
Message-ID:  <201210220907.q9M97CFu075956@svn.freebsd.org>

next in thread | raw e-mail | index | archive | help
Author: kib
Date: Mon Oct 22 09:07:12 2012
New Revision: 241865
URL: http://svn.freebsd.org/changeset/base/241865

Log:
  MFC r241597:
  Acquire the rangelock for truncate(2) as well.

Modified:
  stable/9/sys/kern/vfs_syscalls.c
Directory Properties:
  stable/9/sys/   (props changed)

Modified: stable/9/sys/kern/vfs_syscalls.c
==============================================================================
--- stable/9/sys/kern/vfs_syscalls.c	Mon Oct 22 07:04:34 2012	(r241864)
+++ stable/9/sys/kern/vfs_syscalls.c	Mon Oct 22 09:07:12 2012	(r241865)
@@ -3461,10 +3461,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);
@@ -3473,7 +3473,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);
@@ -3492,8 +3494,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);
 }



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