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)
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);
}
}
+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)
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; }
}
// 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)
// -- 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;
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();
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();
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));
// --------------------------------------------
// 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;