All of lore.kernel.org
 help / color / mirror / Atom feed
From: "Yan, Zheng" <zheng.z.yan@intel.com>
To: ceph-devel@vger.kernel.org, sage@inktank.com
Cc: "Yan, Zheng" <zheng.z.yan@intel.com>
Subject: [PATCH 06/14] mds: fix error hanlding in MDCache::handle_discover_reply()
Date: Tue, 11 Dec 2012 16:30:52 +0800	[thread overview]
Message-ID: <1355214660-26354-7-git-send-email-zheng.z.yan@intel.com> (raw)
In-Reply-To: <1355214660-26354-1-git-send-email-zheng.z.yan@intel.com>

From: "Yan, Zheng" <zheng.z.yan@intel.com>

The error hanlding code in MDCache::handle_discover_reply() has two
main issues. MDCache::handle_discover_reply() does not wake waiters
if dir_auth_hint in reply message is equal to itself's nodeid. This
can happen if discover race with subtree importing. Another issue is
that it checks the existence of cached directory fragment to decide
if it should take waiter from inode or from directory fragment. The
check is unreliable because subtree importing can add directory
fragments to the cache.

Signed-off-by: Yan, Zheng <zheng.z.yan@intel.com>
---
 src/mds/MDCache.cc | 54 ++++++++++++++++++++++++++++++++++++------------------
 1 file changed, 36 insertions(+), 18 deletions(-)

diff --git a/src/mds/MDCache.cc b/src/mds/MDCache.cc
index 893b651..eb18eeb 100644
--- a/src/mds/MDCache.cc
+++ b/src/mds/MDCache.cc
@@ -8957,9 +8957,7 @@ void MDCache::handle_discover_reply(MDiscoverReply *m)
   if (m->is_flag_error_dir() && !cur->is_dir()) {
     // not a dir.
     cur->take_waiting(CInode::WAIT_DIR, error);
-  } else if (m->is_flag_error_dir() ||
-	     (m->get_dir_auth_hint() != CDIR_AUTH_UNKNOWN &&
-	      m->get_dir_auth_hint() != mds->get_nodeid())) {
+  } else if (m->is_flag_error_dir() || m->get_dir_auth_hint() != CDIR_AUTH_UNKNOWN) {
     int who = m->get_dir_auth_hint();
     if (who == mds->get_nodeid()) who = -1;
     if (who >= 0)
@@ -8971,27 +8969,47 @@ void MDCache::handle_discover_reply(MDiscoverReply *m)
       frag_t fg = cur->pick_dirfrag(m->get_error_dentry());
       CDir *dir = cur->get_dirfrag(fg);
       filepath relpath(m->get_error_dentry(), 0);
+
+      if (cur->is_waiter_for(CInode::WAIT_DIR)) {
+	if (cur->is_auth() || dir)
+	  cur->take_waiting(CInode::WAIT_DIR, finished);
+	else
+	  discover_path(cur, m->get_wanted_snapid(), relpath, 0, m->get_wanted_xlocked(), who);
+      } else
+	  dout(7) << " doing nothing, nobody is waiting for dir" << dendl;
+
       if (dir) {
 	// don't actaully need the hint, now
-	if (dir->lookup(m->get_error_dentry()) == 0 &&
-	    dir->is_waiting_for_dentry(m->get_error_dentry().c_str(), m->get_wanted_snapid())) 
-	  discover_path(dir, m->get_wanted_snapid(), relpath, 0, m->get_wanted_xlocked()); 
-	else 
-	  dout(7) << " doing nothing, have dir but nobody is waiting on dentry " 
+	if (dir->is_waiting_for_dentry(m->get_error_dentry().c_str(), m->get_wanted_snapid())) {
+	  if (dir->is_auth() || dir->lookup(m->get_error_dentry()))
+	    dir->take_dentry_waiting(m->get_error_dentry(), m->get_wanted_snapid(),
+				     m->get_wanted_snapid(), finished);
+	  else
+	    discover_path(dir, m->get_wanted_snapid(), relpath, 0, m->get_wanted_xlocked());
+	} else
+	  dout(7) << " doing nothing, have dir but nobody is waiting on dentry "
 		  << m->get_error_dentry() << dendl;
-      } else {
-	if (cur->is_waiter_for(CInode::WAIT_DIR)) 
-	  discover_path(cur, m->get_wanted_snapid(), relpath, 0, m->get_wanted_xlocked(), who);
-	else
-	  dout(7) << " doing nothing, nobody is waiting for dir" << dendl;
       }
     } else {
-      // wanted just the dir
+      // wanted dir or ino
       frag_t fg = m->get_base_dir_frag();
-      if (cur->get_dirfrag(fg) == 0 && cur->is_waiter_for(CInode::WAIT_DIR))
-	discover_dir_frag(cur, fg, 0, who);
-      else
-	dout(7) << " doing nothing, nobody is waiting for dir" << dendl;	  
+      CDir *dir = cur->get_dirfrag(fg);
+
+      if (cur->is_waiter_for(CInode::WAIT_DIR)) {
+	if (cur->is_auth() || dir)
+	  cur->take_waiting(CInode::WAIT_DIR, finished);
+	else
+	  discover_dir_frag(cur, fg, 0, who);
+      } else
+	dout(7) << " doing nothing, nobody is waiting for dir" << dendl;
+
+      if (dir && m->get_wanted_ino() && dir->is_waiting_for_ino(m->get_wanted_ino())) {
+	if (dir->is_auth() || get_inode(m->get_wanted_ino()))
+	  dir->take_ino_waiting(m->get_wanted_ino(), finished);
+	else
+	  discover_ino(dir, m->get_wanted_ino(), 0, m->get_wanted_xlocked());
+      } else
+	dout(7) << " doing nothing, nobody is waiting for ino" << dendl;
     }
   }
 
-- 
1.7.11.7


  parent reply	other threads:[~2012-12-11  8:31 UTC|newest]

Thread overview: 17+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2012-12-11  8:30 [PATCH 00/14] fixes for MDS Yan, Zheng
2012-12-11  8:30 ` [PATCH 01/14] mds: fix journaling issue regarding rstat accounting Yan, Zheng
2012-12-11  8:30 ` [PATCH 02/14] mds: alllow handle_client_readdir() fetching freezing dir Yan, Zheng
2012-12-11  8:30 ` [PATCH 03/14] mds: properly mark dirfrag dirty Yan, Zheng
2012-12-11  8:30 ` [PATCH 04/14] mds: no bloom filter for replica dir Yan, Zheng
2012-12-11  8:30 ` [PATCH 05/14] mds: set want_base_dir to false for MDCache::discover_ino() Yan, Zheng
2012-12-11  8:30 ` Yan, Zheng [this message]
2012-12-11  8:30 ` [PATCH 07/14] mds: always send discover if want_xlocked is true Yan, Zheng
2012-12-11  8:30 ` [PATCH 08/14] mds: re-issue caps after importing caps Yan, Zheng
2012-12-11  8:30 ` [PATCH 09/14] mds: take export lock set before sending MExportDirDiscover Yan, Zheng
2012-12-11  8:30 ` [PATCH 10/14] mds: don't retry readdir request after issuing caps Yan, Zheng
2012-12-11  8:30 ` [PATCH 11/14] mds: delay processing cache expire when state >= EXPORT_EXPORTING Yan, Zheng
2012-12-11  8:30 ` [PATCH 12/14] mds: fix file existing check in Server::handle_client_openc() Yan, Zheng
2012-12-11  8:30 ` [PATCH 13/14] mds: fix race between send_dentry_link() and cache expire Yan, Zheng
2012-12-11  8:31 ` [PATCH 14/14] mds: compare sessionmap version before replaying imported sessions Yan, Zheng
2012-12-11  8:33 ` [PATCH 00/14] fixes for MDS Yan, Zheng
2012-12-11 17:11   ` Sage Weil

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1355214660-26354-7-git-send-email-zheng.z.yan@intel.com \
    --to=zheng.z.yan@intel.com \
    --cc=ceph-devel@vger.kernel.org \
    --cc=sage@inktank.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.