From: Patrick Donnelly Date: Wed, 14 Aug 2024 18:45:53 +0000 (-0400) Subject: mds: simplify and explain expiry finisher ctx X-Git-Tag: v20.0.0~955^2~7 X-Git-Url: http://git-server-git.apps.pok.os.sepia.ceph.com/?a=commitdiff_plain;h=6828bd0502949fe8f9b8f81b39b7c85d5d8901af;p=ceph.git mds: simplify and explain expiry finisher ctx Signed-off-by: Patrick Donnelly --- diff --git a/src/mds/MDSRank.cc b/src/mds/MDSRank.cc index ec06c8bf4517..85f1c11ada1e 100644 --- a/src/mds/MDSRank.cc +++ b/src/mds/MDSRank.cc @@ -152,35 +152,23 @@ private: << " segments to expire" << dendl; if (!expiry_gather.has_subs()) { - trim_segments(); + trim_expired_segments(); return; } - Context *ctx = new LambdaContext([this](int r) { - handle_expire_segments(r); - }); + /* Because this context may be finished with the MDLog::submit_mutex held, + * complete it in the MDS finisher thread. + */ + Context *ctx = new C_OnFinisher(new LambdaContext([this,mds=mds](int r) { + ceph_assert(r == 0); // MDLog is not allowed to raise errors via + // wait_for_expiry + std::lock_guard locker(mds->mds_lock); + trim_expired_segments(); + }), mds->finisher); expiry_gather.set_finisher(new MDSInternalContextWrapper(mds, ctx)); expiry_gather.activate(); } - void handle_expire_segments(int r) { - dout(20) << __func__ << ": r=" << r << dendl; - - ceph_assert(r == 0); // MDLog is not allowed to raise errors via - // wait_for_expiry - trim_segments(); - } - - void trim_segments() { - dout(20) << __func__ << dendl; - - Context *ctx = new C_OnFinisher(new LambdaContext([this](int) { - std::lock_guard locker(mds->mds_lock); - trim_expired_segments(); - }), mds->finisher); - ctx->complete(0); - } - void trim_expired_segments() { ceph_assert(ceph_mutex_is_locked_by_me(mds->mds_lock)); dout(5) << __func__ << ": expiry complete, expire_pos/trim_pos is now "