From c304d367219415dcfdc7d05802540d5801d03ace Mon Sep 17 00:00:00 2001 From: YunyeZhao Date: Tue, 8 Sep 2026 16:37:10 +0800 Subject: [PATCH] anolis: Revert "gfs2: add some missing log locking" ANBZ: #38588 The backport leaves the 5.10-specific deferred gfs2_withdraw() call in __gfs2_log_flush() while moving lock handling to its callers. This runs the withdraw path while holding sd_log_flush_lock, where stopping GFS2 threads or reacquiring the lock can deadlock the filesystem. Revert it to keep deferred withdraw outside the log flush lock. This reverts commit c27b9c851985de5223950197100f9de9e1b0b1d3. Signed-off-by: YunyeZhao --- fs/gfs2/log.c | 29 +++++++++-------------------- 1 file changed, 9 insertions(+), 20 deletions(-) diff --git a/fs/gfs2/log.c b/fs/gfs2/log.c index 03f7142f8517..a667d315b156 100644 --- a/fs/gfs2/log.c +++ b/fs/gfs2/log.c @@ -954,19 +954,20 @@ static void trans_drain(struct gfs2_trans *tr) } /** - * __gfs2_log_flush - flush incore transaction(s) + * gfs2_log_flush - flush incore transaction(s) * @sdp: the filesystem * @gl: The glock structure to flush. If NULL, flush the whole incore log * @flags: The log header flags: GFS2_LOG_HEAD_FLUSH_* and debug flags * */ -static void __gfs2_log_flush(struct gfs2_sbd *sdp, struct gfs2_glock *gl, - u32 flags) +void gfs2_log_flush(struct gfs2_sbd *sdp, struct gfs2_glock *gl, u32 flags) { struct gfs2_trans *tr = NULL; enum gfs2_freeze_state state = atomic_read(&sdp->sd_freeze_state); + down_write(&sdp->sd_log_flush_lock); + /* * Do this check while holding the log_flush_lock to prevent new * buffers from being added to the ail via gfs2_pin() @@ -1055,6 +1056,7 @@ static void __gfs2_log_flush(struct gfs2_sbd *sdp, struct gfs2_glock *gl, out_end: trace_gfs2_log_flush(sdp, 0, flags); out: + up_write(&sdp->sd_log_flush_lock); gfs2_trans_free(sdp, tr); if (gfs2_withdrawing(sdp)) gfs2_withdraw(sdp); @@ -1077,13 +1079,6 @@ static void __gfs2_log_flush(struct gfs2_sbd *sdp, struct gfs2_glock *gl, goto out_end; } -void gfs2_log_flush(struct gfs2_sbd *sdp, struct gfs2_glock *gl, u32 flags) -{ - down_write(&sdp->sd_log_flush_lock); - __gfs2_log_flush(sdp, gl, flags); - up_write(&sdp->sd_log_flush_lock); -} - /** * gfs2_merge_trans - Merge a new transaction into a cached transaction * @old: Original transaction to be expanded @@ -1242,24 +1237,18 @@ int gfs2_logd(void *data) did_flush = false; if (gfs2_jrnl_flush_reqd(sdp) || t == 0) { - down_write(&sdp->sd_log_flush_lock); gfs2_ail1_empty(sdp, 0); - __gfs2_log_flush(sdp, NULL, - GFS2_LOG_HEAD_FLUSH_NORMAL | - GFS2_LFC_LOGD_JFLUSH_REQD); - up_write(&sdp->sd_log_flush_lock); + gfs2_log_flush(sdp, NULL, GFS2_LOG_HEAD_FLUSH_NORMAL | + GFS2_LFC_LOGD_JFLUSH_REQD); did_flush = true; } if (gfs2_ail_flush_reqd(sdp)) { - down_write(&sdp->sd_log_flush_lock); gfs2_ail1_start(sdp); gfs2_ail1_wait(sdp); gfs2_ail1_empty(sdp, 0); - __gfs2_log_flush(sdp, NULL, - GFS2_LOG_HEAD_FLUSH_NORMAL | - GFS2_LFC_LOGD_AIL_FLUSH_REQD); - up_write(&sdp->sd_log_flush_lock); + gfs2_log_flush(sdp, NULL, GFS2_LOG_HEAD_FLUSH_NORMAL | + GFS2_LFC_LOGD_AIL_FLUSH_REQD); did_flush = true; } -- Gitee