svn commit: r227822 - head/sys/fs/tmpfs

Ivan Voras ivoras at FreeBSD.org
Tue Nov 22 16:18:12 UTC 2011


Author: ivoras
Date: Tue Nov 22 16:18:12 2011
New Revision: 227822
URL: http://svn.freebsd.org/changeset/base/227822

Log:
  Avoid panics from recursive rename operations. Not a perfect patch but
  good enough for now.
  
  PR:		kern/159418
  Submitted by:	Gleb Kurtsou
  Reviewed by:	kib
  MFC after:	1 month

Modified:
  head/sys/fs/tmpfs/tmpfs_vnops.c

Modified: head/sys/fs/tmpfs/tmpfs_vnops.c
==============================================================================
--- head/sys/fs/tmpfs/tmpfs_vnops.c	Tue Nov 22 16:08:12 2011	(r227821)
+++ head/sys/fs/tmpfs/tmpfs_vnops.c	Tue Nov 22 16:18:12 2011	(r227822)
@@ -965,11 +965,8 @@ tmpfs_rename(struct vop_rename_args *v)
 
 	/* If we need to move the directory between entries, lock the
 	 * source so that we can safely operate on it. */
-	if (tdvp != fdvp) {
-		error = vn_lock(fdvp, LK_EXCLUSIVE | LK_RETRY);
-		if (error != 0)
-			goto out;
-	}
+	if (fdvp != tdvp && fdvp != tvp)
+		vn_lock(fdvp, LK_EXCLUSIVE | LK_RETRY);
 	fdnode = VP_TO_TMPFS_DIR(fdvp);
 	fnode = VP_TO_TMPFS_NODE(fvp);
 	de = tmpfs_dir_lookup(fdnode, fnode, fcnp);
@@ -1143,7 +1140,7 @@ tmpfs_rename(struct vop_rename_args *v)
 	error = 0;
 
 out_locked:
-	if (fdnode != tdnode)
+	if (fdvp != tdvp && fdvp != tvp)
 		VOP_UNLOCK(fdvp, 0);
 
 out:


More information about the svn-src-head mailing list