]> git.ipfire.org Git - thirdparty/kernel/stable.git/commitdiff
gfs2: Get rid of gfs2_log_[un]lock helpers
authorAndreas Gruenbacher <agruenba@redhat.com>
Fri, 20 Mar 2026 15:43:15 +0000 (16:43 +0100)
committerAndreas Gruenbacher <agruenba@redhat.com>
Mon, 23 Mar 2026 19:55:28 +0000 (20:55 +0100)
These two helpers only hide the locking operation; they do not make
the code more readable.

Created with:

sed -i -e 's:gfs2_log_unlock(sdp):spin_unlock(\&sdp->sd_log_lock):' \
       -e 's:gfs2_log_lock(sdp):spin_lock(\&sdp->sd_log_lock):'

Signed-off-by: Andreas Gruenbacher <agruenba@redhat.com>
fs/gfs2/aops.c
fs/gfs2/glops.c
fs/gfs2/log.c
fs/gfs2/log.h
fs/gfs2/lops.c
fs/gfs2/meta_io.c
fs/gfs2/trans.c

index 6a6ded7a61d208c8223732674d7a8dcd1af9c83b..403b5e1fada48ef93ffd09e6b1b52e5bfab95ba0 100644 (file)
@@ -583,7 +583,7 @@ static void gfs2_discard(struct gfs2_sbd *sdp, struct buffer_head *bh)
        struct gfs2_bufdata *bd;
 
        lock_buffer(bh);
-       gfs2_log_lock(sdp);
+       spin_lock(&sdp->sd_log_lock);
        clear_buffer_dirty(bh);
        bd = bh->b_private;
        if (bd) {
@@ -599,7 +599,7 @@ static void gfs2_discard(struct gfs2_sbd *sdp, struct buffer_head *bh)
        clear_buffer_mapped(bh);
        clear_buffer_req(bh);
        clear_buffer_new(bh);
-       gfs2_log_unlock(sdp);
+       spin_unlock(&sdp->sd_log_lock);
        unlock_buffer(bh);
 }
 
@@ -667,7 +667,7 @@ bool gfs2_release_folio(struct folio *folio, gfp_t gfp_mask)
         * again.
         */
 
-       gfs2_log_lock(sdp);
+       spin_lock(&sdp->sd_log_lock);
        bh = head;
        do {
                if (atomic_read(&bh->b_count))
@@ -699,12 +699,12 @@ bool gfs2_release_folio(struct folio *folio, gfp_t gfp_mask)
 
                bh = bh->b_this_page;
        } while (bh != head);
-       gfs2_log_unlock(sdp);
+       spin_unlock(&sdp->sd_log_lock);
 
        return try_to_free_buffers(folio);
 
 cannot_release:
-       gfs2_log_unlock(sdp);
+       spin_unlock(&sdp->sd_log_lock);
        return false;
 }
 
index ba61649368bf811b9890c2b92f204ba1ddcccf71..aff7e890bf60abd991647ccf25b709dfbd59e096 100644 (file)
@@ -64,7 +64,7 @@ static void __gfs2_ail_flush(struct gfs2_glock *gl, bool fsync,
        struct buffer_head *bh;
        const unsigned long b_state = (1UL << BH_Dirty)|(1UL << BH_Pinned)|(1UL << BH_Lock);
 
-       gfs2_log_lock(sdp);
+       spin_lock(&sdp->sd_log_lock);
        spin_lock(&sdp->sd_ail_lock);
        list_for_each_entry_safe_reverse(bd, tmp, head, bd_ail_gl_list) {
                if (nr_revokes == 0)
@@ -80,7 +80,7 @@ static void __gfs2_ail_flush(struct gfs2_glock *gl, bool fsync,
        }
        GLOCK_BUG_ON(gl, !fsync && atomic_read(&gl->gl_ail_count));
        spin_unlock(&sdp->sd_ail_lock);
-       gfs2_log_unlock(sdp);
+       spin_unlock(&sdp->sd_log_lock);
 }
 
 
@@ -109,10 +109,10 @@ static int gfs2_ail_empty_gl(struct gfs2_glock *gl)
                 * If none of these conditions are true, our revokes are all
                 * flushed and we can return.
                 */
-               gfs2_log_lock(sdp);
+               spin_lock(&sdp->sd_log_lock);
                have_revokes = !list_empty(&sdp->sd_log_revokes);
                log_in_flight = atomic_read(&sdp->sd_log_in_flight);
-               gfs2_log_unlock(sdp);
+               spin_unlock(&sdp->sd_log_lock);
                if (have_revokes)
                        goto flush;
                if (log_in_flight)
index 347df29d610e67abfa74cd8153934aff08d488c1..8a832eba1612444ec5242ebb73b06858a8f59e4c 100644 (file)
@@ -800,9 +800,9 @@ void gfs2_flush_revokes(struct gfs2_sbd *sdp)
        /* number of revokes we still have room for */
        unsigned int max_revokes = atomic_read(&sdp->sd_log_revokes_available);
 
-       gfs2_log_lock(sdp);
+       spin_lock(&sdp->sd_log_lock);
        gfs2_ail1_empty(sdp, max_revokes);
-       gfs2_log_unlock(sdp);
+       spin_unlock(&sdp->sd_log_lock);
 }
 
 /**
@@ -1110,7 +1110,7 @@ repeat:
                goto out_withdraw;
        lops_after_commit(sdp, tr);
 
-       gfs2_log_lock(sdp);
+       spin_lock(&sdp->sd_log_lock);
        sdp->sd_log_blks_reserved = 0;
 
        spin_lock(&sdp->sd_ail_lock);
@@ -1119,7 +1119,7 @@ repeat:
                tr = NULL;
        }
        spin_unlock(&sdp->sd_ail_lock);
-       gfs2_log_unlock(sdp);
+       spin_unlock(&sdp->sd_log_lock);
 
        if (!(flags & GFS2_LOG_HEAD_FLUSH_NORMAL)) {
                if (!sdp->sd_log_idle) {
@@ -1200,7 +1200,7 @@ static void log_refund(struct gfs2_sbd *sdp, struct gfs2_trans *tr)
        unsigned int unused;
        unsigned int maxres;
 
-       gfs2_log_lock(sdp);
+       spin_lock(&sdp->sd_log_lock);
 
        if (sdp->sd_log_tr) {
                gfs2_merge_trans(sdp, tr);
@@ -1218,7 +1218,7 @@ static void log_refund(struct gfs2_sbd *sdp, struct gfs2_trans *tr)
                gfs2_log_release(sdp, unused);
        sdp->sd_log_blks_reserved = reserved;
 
-       gfs2_log_unlock(sdp);
+       spin_unlock(&sdp->sd_log_lock);
 }
 
 static inline int gfs2_jrnl_flush_reqd(struct gfs2_sbd *sdp)
index fc30ebdad83ac9ec21bd24021623473168554e45..ca2cfadd7cce1887e82f640ae6fc00aef6c5288e 100644 (file)
  */
 #define GFS2_LOG_FLUSH_MIN_BLOCKS 4
 
-/**
- * gfs2_log_lock - acquire the right to mess with the log manager
- * @sdp: the filesystem
- *
- */
-
-static inline void gfs2_log_lock(struct gfs2_sbd *sdp)
-__acquires(&sdp->sd_log_lock)
-{
-       spin_lock(&sdp->sd_log_lock);
-}
-
-/**
- * gfs2_log_unlock - release the right to mess with the log manager
- * @sdp: the filesystem
- *
- */
-
-static inline void gfs2_log_unlock(struct gfs2_sbd *sdp)
-__releases(&sdp->sd_log_lock)
-{
-       spin_unlock(&sdp->sd_log_lock);
-}
-
 static inline void gfs2_ordered_add_inode(struct gfs2_inode *ip)
 {
        struct gfs2_sbd *sdp = GFS2_SB(&ip->i_inode);
index e03928def87edcd77e033dc52deb396fac8f41db..6dabe73ad790d9cbf6f2725dd3e5e1c40c3781b8 100644 (file)
@@ -648,19 +648,19 @@ static void gfs2_before_commit(struct gfs2_sbd *sdp, unsigned int limit,
        unsigned n;
        __be64 *ptr;
 
-       gfs2_log_lock(sdp);
+       spin_lock(&sdp->sd_log_lock);
        list_sort(NULL, blist, blocknr_cmp);
        bd1 = bd2 = list_prepare_entry(bd1, blist, bd_list);
        while(total) {
                num = total;
                if (total > limit)
                        num = limit;
-               gfs2_log_unlock(sdp);
+               spin_unlock(&sdp->sd_log_lock);
                page = gfs2_get_log_desc(sdp,
                                         is_databuf ? GFS2_LOG_DESC_JDATA :
                                         GFS2_LOG_DESC_METADATA, num + 1, num);
                ld = page_address(page);
-               gfs2_log_lock(sdp);
+               spin_lock(&sdp->sd_log_lock);
                ptr = (__be64 *)(ld + 1);
 
                n = 0;
@@ -674,14 +674,14 @@ static void gfs2_before_commit(struct gfs2_sbd *sdp, unsigned int limit,
                                break;
                }
 
-               gfs2_log_unlock(sdp);
+               spin_unlock(&sdp->sd_log_lock);
                gfs2_log_write_page(sdp, page);
-               gfs2_log_lock(sdp);
+               spin_lock(&sdp->sd_log_lock);
 
                n = 0;
                list_for_each_entry_continue(bd2, blist, bd_list) {
                        get_bh(bd2->bd_bh);
-                       gfs2_log_unlock(sdp);
+                       spin_unlock(&sdp->sd_log_lock);
                        lock_buffer(bd2->bd_bh);
 
                        if (buffer_escaped(bd2->bd_bh)) {
@@ -698,7 +698,7 @@ static void gfs2_before_commit(struct gfs2_sbd *sdp, unsigned int limit,
                        } else {
                                gfs2_log_write_bh(sdp, bd2->bd_bh);
                        }
-                       gfs2_log_lock(sdp);
+                       spin_lock(&sdp->sd_log_lock);
                        if (++n >= num)
                                break;
                }
@@ -706,7 +706,7 @@ static void gfs2_before_commit(struct gfs2_sbd *sdp, unsigned int limit,
                BUG_ON(total < num);
                total -= num;
        }
-       gfs2_log_unlock(sdp);
+       spin_unlock(&sdp->sd_log_lock);
 }
 
 static void buf_lo_before_commit(struct gfs2_sbd *sdp, struct gfs2_trans *tr)
index 3c8e4553102db30c0ae0790769483897bbe8110e..814c86986b96f12188c0d4cdf6cef6408ae0fdb8 100644 (file)
@@ -391,7 +391,7 @@ static void gfs2_ail1_wipe(struct gfs2_sbd *sdp, u64 bstart, u32 blen)
        struct buffer_head *bh;
        u64 end = bstart + blen;
 
-       gfs2_log_lock(sdp);
+       spin_lock(&sdp->sd_log_lock);
        spin_lock(&sdp->sd_ail_lock);
        list_for_each_entry_safe(tr, s, &sdp->sd_ail1_list, tr_list) {
                list_for_each_entry_safe(bd, bs, &tr->tr_ail1_list,
@@ -404,7 +404,7 @@ static void gfs2_ail1_wipe(struct gfs2_sbd *sdp, u64 bstart, u32 blen)
                }
        }
        spin_unlock(&sdp->sd_ail_lock);
-       gfs2_log_unlock(sdp);
+       spin_unlock(&sdp->sd_log_lock);
 }
 
 static struct buffer_head *gfs2_getjdatabuf(struct gfs2_inode *ip, u64 blkno)
@@ -456,11 +456,11 @@ void gfs2_journal_wipe(struct gfs2_inode *ip, u64 bstart, u32 blen)
                }
                if (bh) {
                        lock_buffer(bh);
-                       gfs2_log_lock(sdp);
+                       spin_lock(&sdp->sd_log_lock);
                        spin_lock(&sdp->sd_ail_lock);
                        gfs2_remove_from_journal(bh, ty);
                        spin_unlock(&sdp->sd_ail_lock);
-                       gfs2_log_unlock(sdp);
+                       spin_unlock(&sdp->sd_log_lock);
                        unlock_buffer(bh);
                        brelse(bh);
                }
index 95f2632cdb010db1507f1dba110332d191910505..0ded2d63dbbba8864f6dec31faedce7392ae3836 100644 (file)
@@ -205,17 +205,17 @@ void gfs2_trans_add_data(struct gfs2_glock *gl, struct buffer_head *bh)
                set_bit(TR_TOUCHED, &tr->tr_flags);
                goto out;
        }
-       gfs2_log_lock(sdp);
+       spin_lock(&sdp->sd_log_lock);
        bd = bh->b_private;
        if (bd == NULL) {
-               gfs2_log_unlock(sdp);
+               spin_unlock(&sdp->sd_log_lock);
                unlock_buffer(bh);
                if (bh->b_private == NULL)
                        bd = gfs2_alloc_bufdata(gl, bh);
                else
                        bd = bh->b_private;
                lock_buffer(bh);
-               gfs2_log_lock(sdp);
+               spin_lock(&sdp->sd_log_lock);
        }
        gfs2_assert(sdp, bd->bd_gl == gl);
        set_bit(TR_TOUCHED, &tr->tr_flags);
@@ -226,7 +226,7 @@ void gfs2_trans_add_data(struct gfs2_glock *gl, struct buffer_head *bh)
                tr->tr_num_databuf_new++;
                list_add_tail(&bd->bd_list, &tr->tr_databuf);
        }
-       gfs2_log_unlock(sdp);
+       spin_unlock(&sdp->sd_log_lock);
 out:
        unlock_buffer(bh);
 }
@@ -266,10 +266,10 @@ void gfs2_trans_add_meta(struct gfs2_glock *gl, struct buffer_head *bh)
                set_bit(TR_TOUCHED, &tr->tr_flags);
                goto out;
        }
-       gfs2_log_lock(sdp);
+       spin_lock(&sdp->sd_log_lock);
        bd = bh->b_private;
        if (bd == NULL) {
-               gfs2_log_unlock(sdp);
+               spin_unlock(&sdp->sd_log_lock);
                unlock_buffer(bh);
                folio_lock(bh->b_folio);
                if (bh->b_private == NULL)
@@ -278,7 +278,7 @@ void gfs2_trans_add_meta(struct gfs2_glock *gl, struct buffer_head *bh)
                        bd = bh->b_private;
                folio_unlock(bh->b_folio);
                lock_buffer(bh);
-               gfs2_log_lock(sdp);
+               spin_lock(&sdp->sd_log_lock);
        }
        gfs2_assert(sdp, bd->bd_gl == gl);
        set_bit(TR_TOUCHED, &tr->tr_flags);
@@ -309,7 +309,7 @@ void gfs2_trans_add_meta(struct gfs2_glock *gl, struct buffer_head *bh)
        list_add(&bd->bd_list, &tr->tr_buf);
        tr->tr_num_buf_new++;
 out_unlock:
-       gfs2_log_unlock(sdp);
+       spin_unlock(&sdp->sd_log_lock);
 out:
        unlock_buffer(bh);
 }
@@ -329,7 +329,7 @@ void gfs2_trans_remove_revoke(struct gfs2_sbd *sdp, u64 blkno, unsigned int len)
        struct gfs2_bufdata *bd, *tmp;
        unsigned int n = len;
 
-       gfs2_log_lock(sdp);
+       spin_lock(&sdp->sd_log_lock);
        list_for_each_entry_safe(bd, tmp, &sdp->sd_log_revokes, bd_list) {
                if ((bd->bd_blkno >= blkno) && (bd->bd_blkno < (blkno + len))) {
                        list_del_init(&bd->bd_list);
@@ -343,7 +343,7 @@ void gfs2_trans_remove_revoke(struct gfs2_sbd *sdp, u64 blkno, unsigned int len)
                                break;
                }
        }
-       gfs2_log_unlock(sdp);
+       spin_unlock(&sdp->sd_log_lock);
 }
 
 void gfs2_trans_free(struct gfs2_sbd *sdp, struct gfs2_trans *tr)