]> git.apps.os.sepia.ceph.com Git - ceph.git/commitdiff
client: fix odd crash on rename
authorSage Weil <sage@newdream.net>
Mon, 12 Sep 2011 01:58:42 +0000 (18:58 -0700)
committerSage Weil <sage@newdream.net>
Mon, 12 Sep 2011 01:58:42 +0000 (18:58 -0700)
If the old_dentry is in the same dir, and it is the last dentry, we need
to keep the dir open.

This is hard to hit because the rename itself will typically instantiate
a null dentry on the target, and it's hard to construct a working where
a racing process makes us drop it.  Fortunately this was triggered
reliably by the snaptest-git-ceph.sh workunit.

Fixes: #1519
Signed-off-by: Sage Weil <sage@newdream.net>
src/client/Client.cc

index ac9840664fa5287ef323bd6f310d1207c20f94bb..1594dcd9240085c592bad41014417707e1ff6018 100644 (file)
@@ -602,7 +602,7 @@ Dentry *Client::insert_dentry_inode(Dir *dir, const string& dname, LeaseStat *dl
   if (!dn || dn->inode == 0) {
     in->get();
     if (old_dentry)
-      unlink(old_dentry, false);
+      unlink(old_dentry, dir == old_dentry->dir);  // keep dir open if its the same dir
     dn = link(dir, dname, in, dn);
     in->put();
     if (set_offset) {