]> git.apps.os.sepia.ceph.com Git - ceph.git/commitdiff
mds: more description for failed authpin 23589/head
authorYan, Zheng <zyan@redhat.com>
Wed, 15 Aug 2018 12:18:41 +0000 (20:18 +0800)
committerYan, Zheng <zyan@redhat.com>
Wed, 15 Aug 2018 12:46:23 +0000 (20:46 +0800)
Fixes: http://tracker.ceph.com/issues/24840
Signed-off-by: Yan, Zheng <zyan@redhat.com>
src/mds/CDentry.cc
src/mds/CDentry.h
src/mds/CDir.cc
src/mds/CDir.h
src/mds/CInode.cc
src/mds/CInode.h
src/mds/Locker.cc
src/mds/MDSCacheObject.h

index f21e5b2f83c2ab4c1e8665da75723135793a11c7..6018afdbff8b9b8fbd1f7114da5106954c39e007 100644 (file)
@@ -334,10 +334,10 @@ int CDentry::get_num_dir_auth_pins() const
   return auth_pins;
 }
 
-bool CDentry::can_auth_pin() const
+bool CDentry::can_auth_pin(int *err_ret) const
 {
   assert(dir);
-  return dir->can_auth_pin();
+  return dir->can_auth_pin(err_ret);
 }
 
 void CDentry::auth_pin(void *by)
index 556a03a437a05d939f2be331b858c715d0face47..e5eadd3e024a25b626f084b6088c4b4ed5f23561 100644 (file)
@@ -207,7 +207,7 @@ public:
   void _put() override;
 
   // auth pins
-  bool can_auth_pin() const override;
+  bool can_auth_pin(int *err_ret=nullptr) const override;
   void auth_pin(void *by) override;
   void auth_unpin(void *by) override;
   void adjust_nested_auth_pins(int adjustment, int diradj, void *by);
index 43d3a7d3aeccae784889fc8e407a01f4db49a039..b76fcf5f30186a91671eb3c931027f9f82b15a28 100644 (file)
@@ -2948,6 +2948,26 @@ void CDir::unfreeze_tree()
   }
 }
 
+bool CDir::can_auth_pin(int *err_ret) const
+{
+  int err;
+  if (!is_auth()) {
+    err = ERR_NOT_AUTH;
+  } else if (is_freezing_dir() || is_frozen_dir()) {
+    err = ERR_FRAGMENTING_DIR;
+  } else {
+    auto p = is_freezing_or_frozen_tree();
+    if (p.first || p.second) {
+      err = ERR_EXPORTING_TREE;
+    } else {
+      err = 0;
+    }
+  }
+  if (err && err_ret)
+    *err_ret = err;
+  return !err;
+}
+
 pair<bool,bool> CDir::is_freezing_or_frozen_tree() const
 {
   if (!num_freezing_trees && !num_frozen_trees)
index c50b775291072549767f11b4cd73593f910e8add..4ae1e677a4ddf502bdf9294b619c6cedccb8086c 100644 (file)
@@ -709,16 +709,7 @@ public:
   void abort_import();
 
   // -- auth pins --
-  bool can_auth_pin() const override {
-    if (!is_auth())
-      return false;
-    if (is_freezing_dir() || is_frozen_dir())
-      return false;
-    auto p = is_freezing_or_frozen_tree();
-    if (p.first || p.second)
-      return false;
-    return true;
-  }
+  bool can_auth_pin(int *err_ret=nullptr) const override;
   int get_cum_auth_pins() const { return auth_pins + nested_auth_pins; }
   int get_auth_pins() const { return auth_pins; }
   int get_nested_auth_pins() const { return nested_auth_pins; }
index 7504a4616abd023db75289dff0d30c2be567f401..62c5f3e4e453cd91a5b09d181abf5bf93eaf589e 100644 (file)
@@ -2561,12 +2561,20 @@ void CInode::clear_ambiguous_auth()
 }
 
 // auth_pins
-bool CInode::can_auth_pin() const {
-  if (!is_auth() || is_freezing_inode() || is_frozen_inode() || is_frozen_auth_pin())
-    return false;
-  if (parent)
-    return parent->can_auth_pin();
-  return true;
+bool CInode::can_auth_pin(int *err_ret) const {
+  int err;
+  if (!is_auth()) {
+    err = ERR_NOT_AUTH;
+  } else if (is_freezing_inode() || is_frozen_inode() || is_frozen_auth_pin()) {
+    err = ERR_EXPORTING_INODE;
+  } else {
+    if (parent)
+      return parent->can_auth_pin(err_ret);
+    err = 0;
+  }
+  if (err && err_ret)
+    *err_ret = err;
+  return !err;
 }
 
 void CInode::auth_pin(void *by) 
index ef72340aa25c34b5936c7846d655ea4ba197676e..9ec6e6d78588995fe7369bf967b6b929b20ce691 100644 (file)
@@ -1032,7 +1032,7 @@ public:
 
   // -- auth pins --
   void adjust_nested_auth_pins(int a, void *by);
-  bool can_auth_pin() const override;
+  bool can_auth_pin(int *err_ret=nullptr) const override;
   void auth_pin(void *by) override;
   void auth_unpin(void *by) override;
 
index 2eb5471b98e3b936cc26e035a04658445246f7e3..ebfac8e7d1ce65957fa0908c867e301299db88e6 100644 (file)
@@ -387,6 +387,7 @@ bool Locker::acquire_locks(MDRequestRef& mdr,
        drop_locks(mdr.get());
       if (object->is_ambiguous_auth()) {
        // wait
+       marker.message = "waiting for single auth, object is being migrated";
        dout(10) << " ambiguous auth, waiting to authpin " << *object << dendl;
        object->add_waiter(MDSCacheObject::WAIT_SINGLEAUTH, new C_MDS_RetryRequest(mdcache, mdr));
        mdr->drop_local_auth_pins();
@@ -395,7 +396,8 @@ bool Locker::acquire_locks(MDRequestRef& mdr,
       mustpin_remote[object->authority().first].insert(object);
       continue;
     }
-    if (!object->can_auth_pin()) {
+    int err = 0;
+    if (!object->can_auth_pin(&err)) {
       // wait
       drop_locks(mdr.get());
       mdr->drop_local_auth_pins();
@@ -404,6 +406,13 @@ bool Locker::acquire_locks(MDRequestRef& mdr,
        mdr->aborted = true;
        return false;
       }
+      if (err == MDSCacheObject::ERR_EXPORTING_TREE) {
+       marker.message = "failed to authpin, subtree is being exported";
+      } else if (err == MDSCacheObject::ERR_FRAGMENTING_DIR) {
+       marker.message = "failed to authpin, dir is being fragmented";
+      } else if (err == MDSCacheObject::ERR_EXPORTING_INODE) {
+       marker.message = "failed to authpin, inode is being exported";
+      }
       dout(10) << " can't auth_pin (freezing?), waiting to authpin " << *object << dendl;
       object->add_waiter(MDSCacheObject::WAIT_UNFREEZE, new C_MDS_RetryRequest(mdcache, mdr));
 
index c2bab86b5b06902e3678409a6257c451ee0695b1..357db7902052ed1b202f76f7d495adffdf3dd610 100644 (file)
@@ -235,7 +235,14 @@ protected:
 
   // --------------------------------------------
   // auth pins
-  virtual bool can_auth_pin() const = 0;
+  enum {
+    // can_auth_pin() error codes
+    ERR_NOT_AUTH = 1,
+    ERR_EXPORTING_TREE,
+    ERR_FRAGMENTING_DIR,
+    ERR_EXPORTING_INODE,
+  };
+  virtual bool can_auth_pin(int *err_code=nullptr) const = 0;
   virtual void auth_pin(void *who) = 0;
   virtual void auth_unpin(void *who) = 0;
   virtual bool is_frozen() const = 0;