Skip to content

Commit

Permalink
mds: more description for failed authpin
Browse files Browse the repository at this point in the history
Fixes: http://tracker.ceph.com/issues/24840
Signed-off-by: Yan, Zheng <zyan@redhat.com>
(cherry picked from commit 6eb6712)
  • Loading branch information
ukernel authored and Prashant D committed Aug 29, 2018
1 parent 203acd7 commit a72d82b
Show file tree
Hide file tree
Showing 8 changed files with 57 additions and 22 deletions.
4 changes: 2 additions & 2 deletions src/mds/CDentry.cc
Expand Up @@ -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)
Expand Down
2 changes: 1 addition & 1 deletion src/mds/CDentry.h
Expand Up @@ -206,7 +206,7 @@ class CDentry : public MDSCacheObject, public LRUObject, public Counter<CDentry>
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);
Expand Down
20 changes: 20 additions & 0 deletions src/mds/CDir.cc
Expand Up @@ -2934,6 +2934,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)
Expand Down
11 changes: 1 addition & 10 deletions src/mds/CDir.h
Expand Up @@ -717,16 +717,7 @@ class CDir : public MDSCacheObject, public Counter<CDir> {
void abort_import(utime_t now);

// -- 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; }
Expand Down
20 changes: 14 additions & 6 deletions src/mds/CInode.cc
Expand Up @@ -2536,12 +2536,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)
Expand Down
2 changes: 1 addition & 1 deletion src/mds/CInode.h
Expand Up @@ -1054,7 +1054,7 @@ class CInode : public MDSCacheObject, public InodeStoreBase, public Counter<CIno

// -- 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;

Expand Down
11 changes: 10 additions & 1 deletion src/mds/Locker.cc
Expand Up @@ -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();
Expand All @@ -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();
Expand All @@ -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));

Expand Down
9 changes: 8 additions & 1 deletion src/mds/MDSCacheObject.h
Expand Up @@ -235,7 +235,14 @@ class MDSCacheObject {

// --------------------------------------------
// 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;
Expand Down

0 comments on commit a72d82b

Please sign in to comment.