@@ -152,35 +152,23 @@ class C_Flush_Journal : public MDSInternalContext {
152152 << " segments to expire" << dendl;
153153
154154 if (!expiry_gather.has_subs ()) {
155- trim_segments ();
155+ trim_expired_segments ();
156156 return ;
157157 }
158158
159- Context *ctx = new LambdaContext ([this ](int r) {
160- handle_expire_segments (r);
161- });
159+ /* Because this context may be finished with the MDLog::submit_mutex held,
160+ * complete it in the MDS finisher thread.
161+ */
162+ Context *ctx = new C_OnFinisher (new LambdaContext ([this ,mds=mds](int r) {
163+ ceph_assert (r == 0 ); // MDLog is not allowed to raise errors via
164+ // wait_for_expiry
165+ std::lock_guard locker (mds->mds_lock );
166+ trim_expired_segments ();
167+ }), mds->finisher );
162168 expiry_gather.set_finisher (new MDSInternalContextWrapper (mds, ctx));
163169 expiry_gather.activate ();
164170 }
165171
166- void handle_expire_segments (int r) {
167- dout (20 ) << __func__ << " : r=" << r << dendl;
168-
169- ceph_assert (r == 0 ); // MDLog is not allowed to raise errors via
170- // wait_for_expiry
171- trim_segments ();
172- }
173-
174- void trim_segments () {
175- dout (20 ) << __func__ << dendl;
176-
177- Context *ctx = new C_OnFinisher (new LambdaContext ([this ](int ) {
178- std::lock_guard locker (mds->mds_lock );
179- trim_expired_segments ();
180- }), mds->finisher );
181- ctx->complete (0 );
182- }
183-
184172 void trim_expired_segments () {
185173 ceph_assert (ceph_mutex_is_locked_by_me (mds->mds_lock ));
186174 dout (5 ) << __func__ << " : expiry complete, expire_pos/trim_pos is now "
0 commit comments