diff mbox

[27/29] mds: check if stray dentry is needed

Message ID 1357290140-17044-28-git-send-email-zheng.z.yan@intel.com (mailing list archive)
State New, archived
Headers show

Commit Message

Yan, Zheng Jan. 4, 2013, 9:02 a.m. UTC
From: "Yan, Zheng" <zheng.z.yan@intel.com>

The necessity of stray dentry can change before the request acquires
all locks.

Signed-off-by: Yan, Zheng <zheng.z.yan@intel.com>
---
 src/mds/Server.cc | 26 ++++++++++++++++----------
 1 file changed, 16 insertions(+), 10 deletions(-)
diff mbox

Patch

diff --git a/src/mds/Server.cc b/src/mds/Server.cc
index 2531005..1557b30 100644
--- a/src/mds/Server.cc
+++ b/src/mds/Server.cc
@@ -4531,11 +4531,14 @@  void Server::handle_client_unlink(MDRequest *mdr)
 
   // -- create stray dentry? --
   CDentry *straydn = mdr->straydn;
-  if (dnl->is_primary() && !straydn) {
-    straydn = mdcache->get_or_create_stray_dentry(dnl->get_inode());
-    mdr->pin(straydn);
-    mdr->straydn = straydn;
-  }
+  if (dnl->is_primary()) {
+    if (!straydn) {
+      straydn = mdcache->get_or_create_stray_dentry(dnl->get_inode());
+      mdr->pin(straydn);
+      mdr->straydn = straydn;
+    }
+  } else if (straydn)
+    straydn = NULL;
   if (straydn)
     dout(10) << " straydn is " << *straydn << dendl;
 
@@ -5274,11 +5277,14 @@  void Server::handle_client_rename(MDRequest *mdr)
 
   // -- create stray dentry? --
   CDentry *straydn = mdr->straydn;
-  if (destdnl->is_primary() && !linkmerge && !straydn) {
-    straydn = mdcache->get_or_create_stray_dentry(destdnl->get_inode());
-    mdr->pin(straydn);
-    mdr->straydn = straydn;
-  }
+  if (destdnl->is_primary() && !linkmerge) {
+    if (!straydn) {
+      straydn = mdcache->get_or_create_stray_dentry(destdnl->get_inode());
+      mdr->pin(straydn);
+      mdr->straydn = straydn;
+    }
+  } else if (straydn)
+    straydn = NULL;
   if (straydn)
     dout(10) << " straydn is " << *straydn << dendl;