]> git.ipfire.org Git - thirdparty/kernel/linux.git/commitdiff
gfs2: Get rid of duplicate log head lookup
authorAndreas Gruenbacher <agruenba@redhat.com>
Fri, 16 May 2025 02:33:49 +0000 (04:33 +0200)
committerAndreas Gruenbacher <agruenba@redhat.com>
Thu, 22 May 2025 07:12:27 +0000 (09:12 +0200)
Currently at mount time, the recovery code looks up the current log head
and, if necessary, replays the log and writes a recovery header to
indicate that the log is clean.  It does that for each log that may need
recovery.  We also know that our own log will always be checked as part
of that process.  Then, the mount code looks up the log head of our own
log again.

The double log head lookup can be costly, but more importantly, it is
unnecessary because we can trivially compute the position of the log
head after recovery; all we need to do for that is bump the position and
lh_sequence by one when writing a recovery header.

With that in mind, move the call to gfs2_log_pointers_init() into
gfs2_recover_func() and get rid of the double lookup in
gfs2_make_fs_rw().

Signed-off-by: Andreas Gruenbacher <agruenba@redhat.com>
fs/gfs2/recovery.c
fs/gfs2/super.c

index 5e37574820b7c8ec70fba49495f514fdc50a437e..b3a11105df7c08752b59c462deea7015eef86494 100644 (file)
@@ -530,6 +530,9 @@ void gfs2_recover_func(struct work_struct *work)
                        ktime_ms_delta(t_rep, t_tlck));
        }
 
+       if (jd->jd_jid == sdp->sd_lockstruct.ls_jid)
+               gfs2_log_pointers_init(sdp, &head);
+
        gfs2_recovery_done(sdp, jd->jd_jid, LM_RD_SUCCESS);
 
        if (jlocked) {
index b55aa38a485a239244db17b563937bc5dbba4e3e..a9af02ef580d8a39bb7724924539602202c84e4b 100644 (file)
@@ -134,27 +134,18 @@ int gfs2_make_fs_rw(struct gfs2_sbd *sdp)
 {
        struct gfs2_inode *ip = GFS2_I(sdp->sd_jdesc->jd_inode);
        struct gfs2_glock *j_gl = ip->i_gl;
-       struct gfs2_log_header_host head;
        int error;
 
        j_gl->gl_ops->go_inval(j_gl, DIO_METADATA);
        if (gfs2_withdrawing_or_withdrawn(sdp))
                return -EIO;
 
-       error = gfs2_find_jhead(sdp->sd_jdesc, &head, false);
-       if (error) {
-               gfs2_consist(sdp);
-               return error;
-       }
-
-       if (!(head.lh_flags & GFS2_LOG_HEAD_UNMOUNT)) {
-               gfs2_consist(sdp);
+       if (sdp->sd_log_sequence == 0) {
+               fs_err(sdp, "unknown status of our own journal jid %d",
+                      sdp->sd_lockstruct.ls_jid);
                return -EIO;
        }
 
-       /*  Initialize some head of the log stuff  */
-       gfs2_log_pointers_init(sdp, &head);
-
        error = gfs2_quota_init(sdp);
        if (!error && gfs2_withdrawing_or_withdrawn(sdp))
                error = -EIO;