Skip site navigation (1)Skip section navigation (2)
Date:      Sun, 19 Jun 2011 09:39:58 GMT
From:      Ilya Putsikau <ilya@FreeBSD.org>
To:        Perforce Change Reviews <perforce@FreeBSD.org>
Subject:   PERFORCE change 194963 for review
Message-ID:  <201106190939.p5J9dwcN070615@skunkworks.freebsd.org>

next in thread | raw e-mail | index | archive | help
http://p4web.freebsd.org/@@194963?ac=10

Change 194963 by ilya@ilya_triton2011 on 2011/06/19 09:39:49

	Release and unlock vnodes in rename, check cross fs rename.
	Don't check if target directory is not under the source directory,
	patching fuse sould be easier.

Affected files ...

.. //depot/projects/soc2011/ilya_fuse/fuse_module/fuse_vnops.c#20 edit

Differences ...

==== //depot/projects/soc2011/ilya_fuse/fuse_module/fuse_vnops.c#20 (text+ko) ====

@@ -1442,18 +1442,38 @@
         panic("fuse_vnop_rename(): called on a dead file system");
     }
 
+    if (fvp->v_mount != tdvp->v_mount ||
+        (tvp && fvp->v_mount != tvp->v_mount)) {
+        DEBUG("cross-device rename: %s -> %s\n",
+	    fcnp->cn_nameptr, (tcnp != NULL ? tcnp->cn_nameptr : "(NULL)"));
+        err = EXDEV;
+        goto out;
+    }
+
     cache_purge(fvp);
 
+    /*
+     * FUSE library is expected to check if target directory is not
+     * under the source directory in the file system tree.
+     * Linux performs this check at VFS level.
+     */
     err = fuse_internal_rename(fdvp, fcnp, tdvp, tcnp);
 
-    if (tvp != NULLVP) {
-        if (tvp != fvp) {
-            cache_purge(tvp);
-        }
-        if (err == 0) {
-            vrecycle(tvp, tcnp->cn_thread);
-        }
+    if (tvp != NULL && tvp != fvp) {
+        cache_purge(tvp);
+    }
+
+out:
+    if (tdvp == tvp) {
+        vrele(tdvp);
+    } else {
+        vput(tdvp);
+    }
+    if (tvp != NULL) {
+        vput(tvp);
     }
+    vrele(fdvp);
+    vrele(fvp);
 
     return err;
 }



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