gfs2: Get rid of gfs2_log_[un]lock helpers

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>
This commit is contained in:
Andreas Gruenbacher 2026-03-20 16:43:15 +01:00
parent 7288185ce8
commit 5a15907f99
7 changed files with 37 additions and 61 deletions

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

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

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

View File

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

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

View 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);
}

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