svn commit: r241865 - stable/9/sys/kern

Konstantin Belousov kib at FreeBSD.org
Mon Oct 22 09:07:13 UTC 2012


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);
 }


More information about the svn-src-stable-9 mailing list