From: Sage Weil Date: Fri, 17 May 2013 19:12:15 +0000 (-0700) Subject: client: avoid blindly removing dentries X-Git-Tag: v0.81~19^2~10 X-Git-Url: http://git-server-git.apps.pok.os.sepia.ceph.com/?a=commitdiff_plain;h=334c43f54d31131c4970f43d7e43ebb43e6cd22d;p=ceph.git client: avoid blindly removing dentries MetaRequests may have references to these dentries. Instead of removing them and tearing down the directory, just unlink them from the inodes. We could be a bit smarter here if we looked at the reference count, but this works too. Signed-off-by: Sage Weil --- diff --git a/src/client/Client.cc b/src/client/Client.cc index 7337563d063a9..deff09370fde6 100644 --- a/src/client/Client.cc +++ b/src/client/Client.cc @@ -726,10 +726,14 @@ Inode * Client::add_update_inode(InodeStat *st, utime_t from, in->flags |= I_COMPLETE; if (in->dir) { ldout(cct, 10) << " dir is open on empty dir " << in->ino << " with " - << in->dir->dentry_map.size() << " entries, tearing down" << dendl; - while (!in->dir->dentry_map.empty()) + << in->dir->dentry_map.size() << " entries, marking all dentries null" << dendl; + for (map::iterator p = in->dir->dentry_map.begin(); + p != in->dir->dentry_map.end(); + ++p) { unlink(in->dir->dentry_map.begin()->second, true, true); - close_dir(in->dir); + } + if (in->dir->dentry_map.empty()) + close_dir(in->dir); } } @@ -3799,7 +3803,7 @@ void Client::_invalidate_inode_parents(Inode *in) // FIXME: we play lots of unlink/link tricks when handling MDS replies, // so in->dn_set doesn't always reflect the state of kernel's dcache. _schedule_invalidate_dentry_callback(dn, true); - unlink(dn, false); + unlink(dn, true, true); } }