Skip to content

Commit c50b91c

Browse files
committed
GFS2: Remove bd_list_tr
This is another clean up in the logging code. This per-transaction list was largely unused. Its main function was to ensure that the number of buffers in a transaction was correct, however that counter was only used to check the number of buffers in the bd_list_tr, plus an assert at the end of each transaction. With the assert now changed to use the calculated buffer counts, we can remove both bd_list_tr and its associated counter. This should make the code easier to understand as well as shrinking a couple of structures. Signed-off-by: Steven Whitehouse <swhiteho@redhat.com>
1 parent dad30e9 commit c50b91c

7 files changed

Lines changed: 21 additions & 56 deletions

File tree

‎fs/gfs2/aops.c‎

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1084,7 +1084,6 @@ int gfs2_releasepage(struct page *page, gfp_t gfp_mask)
10841084
bd = bh->b_private;
10851085
if (bd) {
10861086
gfs2_assert_warn(sdp, bd->bd_bh == bh);
1087-
gfs2_assert_warn(sdp, list_empty(&bd->bd_list_tr));
10881087
if (!list_empty(&bd->bd_le.le_list)) {
10891088
if (!buffer_pinned(bh))
10901089
list_del_init(&bd->bd_le.le_list);

‎fs/gfs2/glops.c‎

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -94,7 +94,6 @@ static void gfs2_ail_empty_gl(struct gfs2_glock *gl)
9494
/* A shortened, inline version of gfs2_trans_begin() */
9595
tr.tr_reserved = 1 + gfs2_struct2blk(sdp, tr.tr_revokes, sizeof(u64));
9696
tr.tr_ip = (unsigned long)__builtin_return_address(0);
97-
INIT_LIST_HEAD(&tr.tr_list_buf);
9897
gfs2_log_reserve(sdp, tr.tr_reserved);
9998
BUG_ON(current->journal_info);
10099
current->journal_info = &tr;

‎fs/gfs2/incore.h‎

Lines changed: 1 addition & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -118,13 +118,7 @@ TAS_BUFFER_FNS(Zeronew, zeronew)
118118
struct gfs2_bufdata {
119119
struct buffer_head *bd_bh;
120120
struct gfs2_glock *bd_gl;
121-
122-
union {
123-
struct list_head list_tr;
124-
u64 blkno;
125-
} u;
126-
#define bd_list_tr u.list_tr
127-
#define bd_blkno u.blkno
121+
u64 bd_blkno;
128122

129123
struct gfs2_log_element bd_le;
130124

@@ -411,13 +405,10 @@ struct gfs2_trans {
411405

412406
int tr_touched;
413407

414-
unsigned int tr_num_buf;
415408
unsigned int tr_num_buf_new;
416409
unsigned int tr_num_databuf_new;
417410
unsigned int tr_num_buf_rm;
418411
unsigned int tr_num_databuf_rm;
419-
struct list_head tr_list_buf;
420-
421412
unsigned int tr_num_revoke;
422413
unsigned int tr_num_revoke_rm;
423414
};

‎fs/gfs2/log.c‎

Lines changed: 0 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -696,21 +696,6 @@ static void log_refund(struct gfs2_sbd *sdp, struct gfs2_trans *tr)
696696
gfs2_log_unlock(sdp);
697697
}
698698

699-
static void buf_lo_incore_commit(struct gfs2_sbd *sdp, struct gfs2_trans *tr)
700-
{
701-
struct list_head *head = &tr->tr_list_buf;
702-
struct gfs2_bufdata *bd;
703-
704-
gfs2_log_lock(sdp);
705-
while (!list_empty(head)) {
706-
bd = list_entry(head->next, struct gfs2_bufdata, bd_list_tr);
707-
list_del_init(&bd->bd_list_tr);
708-
tr->tr_num_buf--;
709-
}
710-
gfs2_log_unlock(sdp);
711-
gfs2_assert_warn(sdp, !tr->tr_num_buf);
712-
}
713-
714699
/**
715700
* gfs2_log_commit - Commit a transaction to the log
716701
* @sdp: the filesystem
@@ -729,8 +714,6 @@ static void buf_lo_incore_commit(struct gfs2_sbd *sdp, struct gfs2_trans *tr)
729714
void gfs2_log_commit(struct gfs2_sbd *sdp, struct gfs2_trans *tr)
730715
{
731716
log_refund(sdp, tr);
732-
buf_lo_incore_commit(sdp, tr);
733-
734717
up_read(&sdp->sd_log_flush_lock);
735718

736719
if (atomic_read(&sdp->sd_log_pinned) > atomic_read(&sdp->sd_log_thresh1) ||

‎fs/gfs2/lops.c‎

Lines changed: 1 addition & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -396,12 +396,8 @@ static void buf_lo_add(struct gfs2_sbd *sdp, struct gfs2_log_element *le)
396396

397397
lock_buffer(bd->bd_bh);
398398
gfs2_log_lock(sdp);
399-
if (!list_empty(&bd->bd_list_tr))
400-
goto out;
401399
tr = current->journal_info;
402400
tr->tr_touched = 1;
403-
tr->tr_num_buf++;
404-
list_add(&bd->bd_list_tr, &tr->tr_list_buf);
405401
if (!list_empty(&le->le_list))
406402
goto out;
407403
set_bit(GLF_LFLUSH, &bd->bd_gl->gl_flags);
@@ -781,18 +777,10 @@ static void databuf_lo_add(struct gfs2_sbd *sdp, struct gfs2_log_element *le)
781777

782778
lock_buffer(bd->bd_bh);
783779
gfs2_log_lock(sdp);
784-
if (tr) {
785-
if (!list_empty(&bd->bd_list_tr))
786-
goto out;
780+
if (tr)
787781
tr->tr_touched = 1;
788-
if (gfs2_is_jdata(ip)) {
789-
tr->tr_num_buf++;
790-
list_add(&bd->bd_list_tr, &tr->tr_list_buf);
791-
}
792-
}
793782
if (!list_empty(&le->le_list))
794783
goto out;
795-
796784
set_bit(GLF_LFLUSH, &bd->bd_gl->gl_flags);
797785
set_bit(GLF_DIRTY, &bd->bd_gl->gl_flags);
798786
if (gfs2_is_jdata(ip)) {

‎fs/gfs2/meta_io.c‎

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -293,7 +293,6 @@ void gfs2_attach_bufdata(struct gfs2_glock *gl, struct buffer_head *bh,
293293
bd->bd_bh = bh;
294294
bd->bd_gl = gl;
295295

296-
INIT_LIST_HEAD(&bd->bd_list_tr);
297296
if (meta)
298297
lops_init_le(&bd->bd_le, &gfs2_buf_lops);
299298
else

‎fs/gfs2/trans.c‎

Lines changed: 19 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -50,8 +50,6 @@ int gfs2_trans_begin(struct gfs2_sbd *sdp, unsigned int blocks,
5050
if (revokes)
5151
tr->tr_reserved += gfs2_struct2blk(sdp, revokes,
5252
sizeof(u64));
53-
INIT_LIST_HEAD(&tr->tr_list_buf);
54-
5553
gfs2_holder_init(sdp->sd_trans_gl, LM_ST_SHARED, 0, &tr->tr_t_gh);
5654

5755
error = gfs2_glock_nq(&tr->tr_t_gh);
@@ -93,10 +91,21 @@ static void gfs2_log_release(struct gfs2_sbd *sdp, unsigned int blks)
9391
up_read(&sdp->sd_log_flush_lock);
9492
}
9593

94+
static void gfs2_print_trans(const struct gfs2_trans *tr)
95+
{
96+
print_symbol(KERN_WARNING "GFS2: Transaction created at: %s\n", tr->tr_ip);
97+
printk(KERN_WARNING "GFS2: blocks=%u revokes=%u reserved=%u touched=%d\n",
98+
tr->tr_blocks, tr->tr_revokes, tr->tr_reserved, tr->tr_touched);
99+
printk(KERN_WARNING "GFS2: Buf %u/%u Databuf %u/%u Revoke %u/%u\n",
100+
tr->tr_num_buf_new, tr->tr_num_buf_rm,
101+
tr->tr_num_databuf_new, tr->tr_num_databuf_rm,
102+
tr->tr_num_revoke, tr->tr_num_revoke_rm);
103+
}
104+
96105
void gfs2_trans_end(struct gfs2_sbd *sdp)
97106
{
98107
struct gfs2_trans *tr = current->journal_info;
99-
108+
s64 nbuf;
100109
BUG_ON(!tr);
101110
current->journal_info = NULL;
102111

@@ -110,16 +119,13 @@ void gfs2_trans_end(struct gfs2_sbd *sdp)
110119
return;
111120
}
112121

113-
if (gfs2_assert_withdraw(sdp, tr->tr_num_buf <= tr->tr_blocks)) {
114-
fs_err(sdp, "tr_num_buf = %u, tr_blocks = %u ",
115-
tr->tr_num_buf, tr->tr_blocks);
116-
print_symbol(KERN_WARNING "GFS2: Transaction created at: %s\n", tr->tr_ip);
117-
}
118-
if (gfs2_assert_withdraw(sdp, tr->tr_num_revoke <= tr->tr_revokes)) {
119-
fs_err(sdp, "tr_num_revoke = %u, tr_revokes = %u ",
120-
tr->tr_num_revoke, tr->tr_revokes);
121-
print_symbol(KERN_WARNING "GFS2: Transaction created at: %s\n", tr->tr_ip);
122-
}
122+
nbuf = tr->tr_num_buf_new + tr->tr_num_databuf_new;
123+
nbuf -= tr->tr_num_buf_rm;
124+
nbuf -= tr->tr_num_databuf_rm;
125+
126+
if (gfs2_assert_withdraw(sdp, (nbuf <= tr->tr_blocks) &&
127+
(tr->tr_num_revoke <= tr->tr_revokes)))
128+
gfs2_print_trans(tr);
123129

124130
gfs2_log_commit(sdp, tr);
125131
if (tr->tr_t_gh.gh_gl) {

0 commit comments

Comments
 (0)