<< " 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 "