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 <agruenba@redhat.com>
This commit is contained in:
Andreas Gruenbacher 2025-05-16 05:34:20 +02:00
parent 703a4af356
commit 8a43d21876
4 changed files with 12 additions and 16 deletions

View file

@ -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;
}

View file

@ -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;
}

View file

@ -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__ */

View file

@ -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))