From 6eb6712be66897e14a8e99fbca38b7984c1d519c Mon Sep 17 00:00:00 2001 From: "Yan, Zheng" Date: Wed, 15 Aug 2018 20:18:41 +0800 Subject: [PATCH] mds: more description for failed authpin Fixes: http://tracker.ceph.com/issues/24840 Signed-off-by: Yan, Zheng --- src/mds/CDentry.cc | 4 ++-- src/mds/CDentry.h | 2 +- src/mds/CDir.cc | 20 ++++++++++++++++++++ src/mds/CDir.h | 11 +---------- src/mds/CInode.cc | 20 ++++++++++++++------ src/mds/CInode.h | 2 +- src/mds/Locker.cc | 11 ++++++++++- src/mds/MDSCacheObject.h | 9 ++++++++- 8 files changed, 57 insertions(+), 22 deletions(-) diff --git a/src/mds/CDentry.cc b/src/mds/CDentry.cc index f21e5b2f83c2a..6018afdbff8b9 100644 --- a/src/mds/CDentry.cc +++ b/src/mds/CDentry.cc @@ -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) diff --git a/src/mds/CDentry.h b/src/mds/CDentry.h index 556a03a437a05..e5eadd3e024a2 100644 --- a/src/mds/CDentry.h +++ b/src/mds/CDentry.h @@ -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); diff --git a/src/mds/CDir.cc b/src/mds/CDir.cc index 43d3a7d3aecca..b76fcf5f30186 100644 --- a/src/mds/CDir.cc +++ b/src/mds/CDir.cc @@ -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 CDir::is_freezing_or_frozen_tree() const { if (!num_freezing_trees && !num_frozen_trees) diff --git a/src/mds/CDir.h b/src/mds/CDir.h index c50b775291072..4ae1e677a4ddf 100644 --- a/src/mds/CDir.h +++ b/src/mds/CDir.h @@ -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; } diff --git a/src/mds/CInode.cc b/src/mds/CInode.cc index 7504a4616abd0..62c5f3e4e453c 100644 --- a/src/mds/CInode.cc +++ b/src/mds/CInode.cc @@ -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) diff --git a/src/mds/CInode.h b/src/mds/CInode.h index ef72340aa25c3..9ec6e6d785889 100644 --- a/src/mds/CInode.h +++ b/src/mds/CInode.h @@ -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; diff --git a/src/mds/Locker.cc b/src/mds/Locker.cc index 2eb5471b98e3b..ebfac8e7d1ce6 100644 --- a/src/mds/Locker.cc +++ b/src/mds/Locker.cc @@ -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)); diff --git a/src/mds/MDSCacheObject.h b/src/mds/MDSCacheObject.h index c2bab86b5b069..357db7902052e 100644 --- a/src/mds/MDSCacheObject.h +++ b/src/mds/MDSCacheObject.h @@ -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; -- 2.39.5