From: Andreas Gruenbacher Date: Fri, 16 May 2025 03:34:20 +0000 (+0200) Subject: gfs2: Simplify gfs2_log_pointers_init X-Git-Tag: v6.16-rc1~212^2~3 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=8a43d2187691f1f2b9db66f6b08afcc8a1b3095a;p=thirdparty%2Flinux.git gfs2: Simplify gfs2_log_pointers_init Move the initialization of sdp->sd_log_sequence and sdp->sd_log_flush_head inside gfs2_log_pointers_init(). Use gfs2_replay_incr_blk(). Before this change, the log head lookup code in freeze_go_xmote_bh() didn't update sdp->sd_log_flush_head. This is now fixed, but the code in freeze_go_xmote_bh() appears to be pretty useless in the first place: on a frozen filesystem, the log head will not change. Signed-off-by: Andreas Gruenbacher --- diff --git a/fs/gfs2/glops.c b/fs/gfs2/glops.c index 116efe335c321..e153db45bbd9c 100644 --- a/fs/gfs2/glops.c +++ b/fs/gfs2/glops.c @@ -607,8 +607,7 @@ static int freeze_go_xmote_bh(struct gfs2_glock *gl) if (gfs2_assert_withdraw_delayed(sdp, head.lh_flags & GFS2_LOG_HEAD_UNMOUNT)) return -EIO; - sdp->sd_log_sequence = head.lh_sequence + 1; - gfs2_log_pointers_init(sdp, head.lh_blkno); + gfs2_log_pointers_init(sdp, &head); } return 0; } diff --git a/fs/gfs2/recovery.c b/fs/gfs2/recovery.c index 7776d2092b9b5..db1238480e91b 100644 --- a/fs/gfs2/recovery.c +++ b/fs/gfs2/recovery.c @@ -270,10 +270,6 @@ static void clean_journal(struct gfs2_jdesc *jd, gfs2_write_log_header(sdp, jd, head->lh_sequence + 1, 0, lblock, GFS2_LOG_HEAD_UNMOUNT | GFS2_LOG_HEAD_RECOVERY, REQ_PREFLUSH | REQ_FUA | REQ_META | REQ_SYNC); - if (jd->jd_jid == sdp->sd_lockstruct.ls_jid) { - sdp->sd_log_flush_head = lblock; - gfs2_log_incr_head(sdp); - } } @@ -581,12 +577,13 @@ int gfs2_recover_journal(struct gfs2_jdesc *jd, bool wait) return wait ? jd->jd_recover_error : 0; } -void gfs2_log_pointers_init(struct gfs2_sbd *sdp, unsigned int value) +void gfs2_log_pointers_init(struct gfs2_sbd *sdp, + struct gfs2_log_header_host *head) { - if (++value == sdp->sd_jdesc->jd_blocks) { - value = 0; - } - sdp->sd_log_tail = value; - sdp->sd_log_flush_tail = value; - sdp->sd_log_head = value; + sdp->sd_log_sequence = head->lh_sequence + 1; + gfs2_replay_incr_blk(sdp->sd_jdesc, &head->lh_blkno); + sdp->sd_log_tail = head->lh_blkno; + sdp->sd_log_flush_head = head->lh_blkno; + sdp->sd_log_flush_tail = head->lh_blkno; + sdp->sd_log_head = head->lh_blkno; } diff --git a/fs/gfs2/recovery.h b/fs/gfs2/recovery.h index 630ac490948d8..5a5ba72ecd756 100644 --- a/fs/gfs2/recovery.h +++ b/fs/gfs2/recovery.h @@ -29,7 +29,8 @@ void gfs2_recover_func(struct work_struct *work); int __get_log_header(struct gfs2_sbd *sdp, const struct gfs2_log_header *lh, unsigned int blkno, struct gfs2_log_header_host *head); -void gfs2_log_pointers_init(struct gfs2_sbd *sdp, unsigned int value); +void gfs2_log_pointers_init(struct gfs2_sbd *sdp, + struct gfs2_log_header_host *head); #endif /* __RECOVERY_DOT_H__ */ diff --git a/fs/gfs2/super.c b/fs/gfs2/super.c index 54f1efd47a3e5..b55aa38a485a2 100644 --- a/fs/gfs2/super.c +++ b/fs/gfs2/super.c @@ -153,8 +153,7 @@ int gfs2_make_fs_rw(struct gfs2_sbd *sdp) } /* Initialize some head of the log stuff */ - sdp->sd_log_sequence = head.lh_sequence + 1; - gfs2_log_pointers_init(sdp, head.lh_blkno); + gfs2_log_pointers_init(sdp, &head); error = gfs2_quota_init(sdp); if (!error && gfs2_withdrawing_or_withdrawn(sdp))