From: Andreas Gruenbacher <agruenba@redhat.com>
To: gfs2@lists.linux.dev
Cc: Andreas Gruenbacher <agruenba@redhat.com>
Subject: [PATCH 07/18] gfs2: Get rid of gfs2_log_[un]lock helpers
Date: Mon, 13 Apr 2026 16:52:00 +0200 [thread overview]
Message-ID: <20260413145211.881752-8-agruenba@redhat.com> (raw)
In-Reply-To: <20260413145211.881752-1-agruenba@redhat.com>
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 | 10 +++++-----
fs/gfs2/glops.c | 8 ++++----
fs/gfs2/log.c | 12 ++++++------
fs/gfs2/log.h | 24 ------------------------
fs/gfs2/lops.c | 16 ++++++++--------
fs/gfs2/meta_io.c | 8 ++++----
fs/gfs2/trans.c | 20 ++++++++++----------
7 files changed, 37 insertions(+), 61 deletions(-)
diff --git a/fs/gfs2/aops.c b/fs/gfs2/aops.c
index 6a6ded7a61d2..403b5e1fada4 100644
--- a/fs/gfs2/aops.c
+++ b/fs/gfs2/aops.c
@@ -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;
}
diff --git a/fs/gfs2/glops.c b/fs/gfs2/glops.c
index ba61649368bf..aff7e890bf60 100644
--- a/fs/gfs2/glops.c
+++ b/fs/gfs2/glops.c
@@ -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)
diff --git a/fs/gfs2/log.c b/fs/gfs2/log.c
index 347df29d610e..8a832eba1612 100644
--- a/fs/gfs2/log.c
+++ b/fs/gfs2/log.c
@@ -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 @@ void gfs2_log_flush(struct gfs2_sbd *sdp, struct gfs2_glock *gl, u32 flags)
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 @@ void gfs2_log_flush(struct gfs2_sbd *sdp, struct gfs2_glock *gl, u32 flags)
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)
diff --git a/fs/gfs2/log.h b/fs/gfs2/log.h
index fc30ebdad83a..ca2cfadd7cce 100644
--- a/fs/gfs2/log.h
+++ b/fs/gfs2/log.h
@@ -20,30 +20,6 @@
*/
#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);
diff --git a/fs/gfs2/lops.c b/fs/gfs2/lops.c
index e03928def87e..6dabe73ad790 100644
--- a/fs/gfs2/lops.c
+++ b/fs/gfs2/lops.c
@@ -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)
diff --git a/fs/gfs2/meta_io.c b/fs/gfs2/meta_io.c
index 3c8e4553102d..814c86986b96 100644
--- a/fs/gfs2/meta_io.c
+++ b/fs/gfs2/meta_io.c
@@ -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);
}
diff --git a/fs/gfs2/trans.c b/fs/gfs2/trans.c
index 95f2632cdb01..0ded2d63dbbb 100644
--- a/fs/gfs2/trans.c
+++ b/fs/gfs2/trans.c
@@ -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)
--
2.53.0
next prev parent reply other threads:[~2026-04-13 14:52 UTC|newest]
Thread overview: 19+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-04-13 14:51 [PATCH 00/18] gfs2 patches on for-next Andreas Gruenbacher
2026-04-13 14:51 ` [PATCH 01/18] gfs2: Call unlock_new_inode before d_instantiate Andreas Gruenbacher
2026-04-13 14:51 ` [PATCH 02/18] gfs2: Remove unnecessary check in gfs2_evict_inode Andreas Gruenbacher
2026-04-13 14:51 ` [PATCH 03/18] gfs2: Avoid unnecessary transactions in evict_linked_inode Andreas Gruenbacher
2026-04-13 14:51 ` [PATCH 04/18] gfs2: minor evict_[un]linked_inode cleanup Andreas Gruenbacher
2026-04-13 14:51 ` [PATCH 05/18] gfs2: Fix data loss during inode evict Andreas Gruenbacher
2026-04-13 14:51 ` [PATCH 06/18] gfs2: less aggressive low-memory log flushing Andreas Gruenbacher
2026-04-13 14:52 ` Andreas Gruenbacher [this message]
2026-04-13 14:52 ` [PATCH 08/18] gfs2: Move gfs2_remove_from_journal to log.c Andreas Gruenbacher
2026-04-13 14:52 ` [PATCH 09/18] gfs2: Remove trans_drain code duplication Andreas Gruenbacher
2026-04-13 14:52 ` [PATCH 10/18] gfs2: bufdata allocation race Andreas Gruenbacher
2026-04-13 14:52 ` [PATCH 11/18] gfs2: drain ail under sd_log_flush_lock Andreas Gruenbacher
2026-04-13 14:52 ` [PATCH 12/18] gfs2: fix address space truncation during withdraw Andreas Gruenbacher
2026-04-13 14:52 ` [PATCH 13/18] gfs2: add some missing log locking Andreas Gruenbacher
2026-04-13 14:52 ` [PATCH 14/18] gfs2: gfs2_log_flush withdraw fixes Andreas Gruenbacher
2026-04-13 14:52 ` [PATCH 15/18] gfs2: inode directory consistency checks Andreas Gruenbacher
2026-04-13 14:52 ` [PATCH 16/18] gfs2: wait for withdraw earlier during unmount Andreas Gruenbacher
2026-04-13 14:52 ` [PATCH 17/18] gfs2: hide error messages after withdraw Andreas Gruenbacher
2026-04-13 14:52 ` [PATCH 18/18] gfs2: prevent NULL pointer dereference during unmount Andreas Gruenbacher
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20260413145211.881752-8-agruenba@redhat.com \
--to=agruenba@redhat.com \
--cc=gfs2@lists.linux.dev \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox