Skip to content

Commit a9964a7

Browse files
committed
mds: provide mechanism to authpin while freezing
When a subtree is freezing, it's no longer possible to acquire new authpins. This is a problem when a compound request like quiescing a subtree is trying to acquire authpins for each sub-op. This creates a situation where some quiesce sub-ops complete with authpins (thereby preventing the tree from becoming "frozen") and new sub-ops cannot acquire authpins (because the tree is "freezing"). To circumvent this, allow some authpin requests to proceed if FLAG_BYPASSFREEZING is set. Signed-off-by: Patrick Donnelly <pdonnell@redhat.com>
1 parent 3197a97 commit a9964a7

11 files changed

Lines changed: 38 additions & 15 deletions

File tree

src/mds/CDentry.cc

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -368,10 +368,10 @@ int CDentry::get_num_dir_auth_pins() const
368368
return auth_pins;
369369
}
370370

371-
bool CDentry::can_auth_pin(int *err_ret) const
371+
bool CDentry::can_auth_pin(int *err_ret, bool bypassfreezing) const
372372
{
373373
ceph_assert(dir);
374-
return dir->can_auth_pin(err_ret);
374+
return dir->can_auth_pin(err_ret, bypassfreezing);
375375
}
376376

377377
void CDentry::auth_pin(void *by)

src/mds/CDentry.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -222,7 +222,7 @@ class CDentry : public MDSCacheObject, public LRUObject, public Counter<CDentry>
222222
void _put() override;
223223

224224
// auth pins
225-
bool can_auth_pin(int *err_ret=nullptr) const override;
225+
bool can_auth_pin(int *err_ret=nullptr, bool bypassfreezing=false) const override;
226226
void auth_pin(void *by) override;
227227
void auth_unpin(void *by) override;
228228
void adjust_nested_auth_pins(int diradj, void *by);

src/mds/CDir.cc

Lines changed: 12 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3445,16 +3445,25 @@ void CDir::adjust_freeze_after_rename(CDir *dir)
34453445
mdcache->mds->queue_waiters(unfreeze_waiters);
34463446
}
34473447

3448-
bool CDir::can_auth_pin(int *err_ret) const
3448+
bool CDir::can_auth_pin(int *err_ret, bool bypassfreezing) const
34493449
{
34503450
int err;
34513451
if (!is_auth()) {
34523452
err = ERR_NOT_AUTH;
3453-
} else if (is_freezing_dir() || is_frozen_dir()) {
3453+
} else if (is_freezing_dir()) {
3454+
if (bypassfreezing) {
3455+
dout(20) << "allowing authpin with freezing" << dendl;
3456+
err = 0;
3457+
} else {
3458+
err = ERR_FRAGMENTING_DIR;
3459+
}
3460+
} else if (is_frozen_dir()) {
34543461
err = ERR_FRAGMENTING_DIR;
34553462
} else {
34563463
auto p = is_freezing_or_frozen_tree();
3457-
if (p.first || p.second) {
3464+
if (p.first && !bypassfreezing) {
3465+
err = ERR_EXPORTING_TREE;
3466+
} else if (p.second) {
34583467
err = ERR_EXPORTING_TREE;
34593468
} else {
34603469
err = 0;

src/mds/CDir.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -526,7 +526,7 @@ class CDir : public MDSCacheObject, public Counter<CDir> {
526526
void abort_import();
527527

528528
// -- auth pins --
529-
bool can_auth_pin(int *err_ret=nullptr) const override;
529+
bool can_auth_pin(int *err_ret=nullptr, bool bypassfreezing=false) const override;
530530
int get_auth_pins() const { return auth_pins; }
531531
int get_dir_auth_pins() const { return dir_auth_pins; }
532532
void auth_pin(void *who) override;

src/mds/CInode.cc

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2929,11 +2929,18 @@ void CInode::clear_ambiguous_auth()
29292929
}
29302930

29312931
// auth_pins
2932-
bool CInode::can_auth_pin(int *err_ret) const {
2932+
bool CInode::can_auth_pin(int *err_ret, bool bypassfreezing) const {
29332933
int err;
29342934
if (!is_auth()) {
29352935
err = ERR_NOT_AUTH;
2936-
} else if (is_freezing_inode() || is_frozen_inode() || is_frozen_auth_pin()) {
2936+
} else if (is_freezing_inode()) {
2937+
if (bypassfreezing) {
2938+
dout(20) << "allowing authpin with freezing" << dendl;
2939+
err = 0;
2940+
} else {
2941+
err = ERR_EXPORTING_INODE;
2942+
}
2943+
} else if (is_frozen_inode() || is_frozen_auth_pin()) {
29372944
err = ERR_EXPORTING_INODE;
29382945
} else {
29392946
if (parent)

src/mds/CInode.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -926,7 +926,7 @@ class CInode : public MDSCacheObject, public InodeStoreBase, public Counter<CIno
926926
mds_authority_t authority() const override;
927927

928928
// -- auth pins --
929-
bool can_auth_pin(int *err_ret=nullptr) const override;
929+
bool can_auth_pin(int *err_ret=nullptr, bool bypassfreezing=false) const override;
930930
void auth_pin(void *by) override;
931931
void auth_unpin(void *by) override;
932932

src/mds/MDSCacheObject.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -210,7 +210,7 @@ class MDSCacheObject {
210210
ERR_FRAGMENTING_DIR,
211211
ERR_EXPORTING_INODE,
212212
};
213-
virtual bool can_auth_pin(int *err_code=nullptr) const = 0;
213+
virtual bool can_auth_pin(int *err_code=nullptr, bool bypassfreezing=false) const = 0;
214214
virtual void auth_pin(void *who) = 0;
215215
virtual void auth_unpin(void *who) = 0;
216216
virtual bool is_frozen() const = 0;

src/mds/Mutation.cc

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -364,9 +364,9 @@ void MDRequestImpl::clear_ambiguous_auth()
364364
more()->is_ambiguous_auth = false;
365365
}
366366

367-
bool MDRequestImpl::can_auth_pin(MDSCacheObject *object)
367+
bool MDRequestImpl::can_auth_pin(MDSCacheObject *object, bool bypassfreezing)
368368
{
369-
return object->can_auth_pin() ||
369+
return object->can_auth_pin(nullptr, bypassfreezing) ||
370370
(is_auth_pinned(object) && has_more() &&
371371
more()->is_freeze_authpin &&
372372
more()->rename_inode == object);

src/mds/Mutation.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -399,7 +399,7 @@ struct MDRequestImpl : public MutationImpl {
399399
bool freeze_auth_pin(CInode *inode);
400400
void unfreeze_auth_pin(bool clear_inode=false);
401401
void set_remote_frozen_auth_pin(CInode *inode);
402-
bool can_auth_pin(MDSCacheObject *object);
402+
bool can_auth_pin(MDSCacheObject *object, bool bypassfreezing=false);
403403
void drop_local_auth_pins();
404404
void set_ambiguous_auth(CInode *inode);
405405
void clear_ambiguous_auth();

src/mds/Server.cc

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3149,9 +3149,13 @@ void Server::handle_peer_auth_pin(const MDRequestRef& mdr)
31493149
list<MDSCacheObject*> objects;
31503150
CInode *auth_pin_freeze = NULL;
31513151
bool nonblocking = mdr->peer_request->is_nonblocking();
3152+
bool bypassfreezing = mdr->peer_request->is_bypassfreezing();
31523153
bool fail = false, wouldblock = false, readonly = false;
31533154
ref_t<MMDSPeerRequest> reply;
31543155

3156+
dout(15) << " nonblocking=" << nonblocking
3157+
<< " bypassfreezing=" << bypassfreezing << dendl;
3158+
31553159
if (mdcache->is_readonly()) {
31563160
dout(10) << " read-only FS" << dendl;
31573161
readonly = true;
@@ -3183,7 +3187,7 @@ void Server::handle_peer_auth_pin(const MDRequestRef& mdr)
31833187
}
31843188
if (mdr->is_auth_pinned(obj))
31853189
continue;
3186-
if (!mdr->can_auth_pin(obj)) {
3190+
if (!mdr->can_auth_pin(obj, bypassfreezing)) {
31873191
if (nonblocking) {
31883192
dout(10) << " can't auth_pin (freezing?) " << *obj << " nonblocking" << dendl;
31893193
fail = true;

0 commit comments

Comments
 (0)