Commit c50b91c4 authored by Steven Whitehouse's avatar Steven Whitehouse

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: default avatarSteven Whitehouse <swhiteho@redhat.com>
parent dad30e90
...@@ -1084,7 +1084,6 @@ int gfs2_releasepage(struct page *page, gfp_t gfp_mask) ...@@ -1084,7 +1084,6 @@ int gfs2_releasepage(struct page *page, gfp_t gfp_mask)
bd = bh->b_private; bd = bh->b_private;
if (bd) { if (bd) {
gfs2_assert_warn(sdp, bd->bd_bh == bh); gfs2_assert_warn(sdp, bd->bd_bh == bh);
gfs2_assert_warn(sdp, list_empty(&bd->bd_list_tr));
if (!list_empty(&bd->bd_le.le_list)) { if (!list_empty(&bd->bd_le.le_list)) {
if (!buffer_pinned(bh)) if (!buffer_pinned(bh))
list_del_init(&bd->bd_le.le_list); list_del_init(&bd->bd_le.le_list);
......
...@@ -94,7 +94,6 @@ static void gfs2_ail_empty_gl(struct gfs2_glock *gl) ...@@ -94,7 +94,6 @@ static void gfs2_ail_empty_gl(struct gfs2_glock *gl)
/* A shortened, inline version of gfs2_trans_begin() */ /* A shortened, inline version of gfs2_trans_begin() */
tr.tr_reserved = 1 + gfs2_struct2blk(sdp, tr.tr_revokes, sizeof(u64)); tr.tr_reserved = 1 + gfs2_struct2blk(sdp, tr.tr_revokes, sizeof(u64));
tr.tr_ip = (unsigned long)__builtin_return_address(0); tr.tr_ip = (unsigned long)__builtin_return_address(0);
INIT_LIST_HEAD(&tr.tr_list_buf);
gfs2_log_reserve(sdp, tr.tr_reserved); gfs2_log_reserve(sdp, tr.tr_reserved);
BUG_ON(current->journal_info); BUG_ON(current->journal_info);
current->journal_info = &tr; current->journal_info = &tr;
......
...@@ -118,13 +118,7 @@ TAS_BUFFER_FNS(Zeronew, zeronew) ...@@ -118,13 +118,7 @@ TAS_BUFFER_FNS(Zeronew, zeronew)
struct gfs2_bufdata { struct gfs2_bufdata {
struct buffer_head *bd_bh; struct buffer_head *bd_bh;
struct gfs2_glock *bd_gl; struct gfs2_glock *bd_gl;
u64 bd_blkno;
union {
struct list_head list_tr;
u64 blkno;
} u;
#define bd_list_tr u.list_tr
#define bd_blkno u.blkno
struct gfs2_log_element bd_le; struct gfs2_log_element bd_le;
...@@ -411,13 +405,10 @@ struct gfs2_trans { ...@@ -411,13 +405,10 @@ struct gfs2_trans {
int tr_touched; int tr_touched;
unsigned int tr_num_buf;
unsigned int tr_num_buf_new; unsigned int tr_num_buf_new;
unsigned int tr_num_databuf_new; unsigned int tr_num_databuf_new;
unsigned int tr_num_buf_rm; unsigned int tr_num_buf_rm;
unsigned int tr_num_databuf_rm; unsigned int tr_num_databuf_rm;
struct list_head tr_list_buf;
unsigned int tr_num_revoke; unsigned int tr_num_revoke;
unsigned int tr_num_revoke_rm; unsigned int tr_num_revoke_rm;
}; };
......
...@@ -696,21 +696,6 @@ static void log_refund(struct gfs2_sbd *sdp, struct gfs2_trans *tr) ...@@ -696,21 +696,6 @@ static void log_refund(struct gfs2_sbd *sdp, struct gfs2_trans *tr)
gfs2_log_unlock(sdp); gfs2_log_unlock(sdp);
} }
static void buf_lo_incore_commit(struct gfs2_sbd *sdp, struct gfs2_trans *tr)
{
struct list_head *head = &tr->tr_list_buf;
struct gfs2_bufdata *bd;
gfs2_log_lock(sdp);
while (!list_empty(head)) {
bd = list_entry(head->next, struct gfs2_bufdata, bd_list_tr);
list_del_init(&bd->bd_list_tr);
tr->tr_num_buf--;
}
gfs2_log_unlock(sdp);
gfs2_assert_warn(sdp, !tr->tr_num_buf);
}
/** /**
* gfs2_log_commit - Commit a transaction to the log * gfs2_log_commit - Commit a transaction to the log
* @sdp: the filesystem * @sdp: the filesystem
...@@ -729,8 +714,6 @@ static void buf_lo_incore_commit(struct gfs2_sbd *sdp, struct gfs2_trans *tr) ...@@ -729,8 +714,6 @@ static void buf_lo_incore_commit(struct gfs2_sbd *sdp, struct gfs2_trans *tr)
void gfs2_log_commit(struct gfs2_sbd *sdp, struct gfs2_trans *tr) void gfs2_log_commit(struct gfs2_sbd *sdp, struct gfs2_trans *tr)
{ {
log_refund(sdp, tr); log_refund(sdp, tr);
buf_lo_incore_commit(sdp, tr);
up_read(&sdp->sd_log_flush_lock); up_read(&sdp->sd_log_flush_lock);
if (atomic_read(&sdp->sd_log_pinned) > atomic_read(&sdp->sd_log_thresh1) || if (atomic_read(&sdp->sd_log_pinned) > atomic_read(&sdp->sd_log_thresh1) ||
......
...@@ -396,12 +396,8 @@ static void buf_lo_add(struct gfs2_sbd *sdp, struct gfs2_log_element *le) ...@@ -396,12 +396,8 @@ static void buf_lo_add(struct gfs2_sbd *sdp, struct gfs2_log_element *le)
lock_buffer(bd->bd_bh); lock_buffer(bd->bd_bh);
gfs2_log_lock(sdp); gfs2_log_lock(sdp);
if (!list_empty(&bd->bd_list_tr))
goto out;
tr = current->journal_info; tr = current->journal_info;
tr->tr_touched = 1; tr->tr_touched = 1;
tr->tr_num_buf++;
list_add(&bd->bd_list_tr, &tr->tr_list_buf);
if (!list_empty(&le->le_list)) if (!list_empty(&le->le_list))
goto out; goto out;
set_bit(GLF_LFLUSH, &bd->bd_gl->gl_flags); 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) ...@@ -781,18 +777,10 @@ static void databuf_lo_add(struct gfs2_sbd *sdp, struct gfs2_log_element *le)
lock_buffer(bd->bd_bh); lock_buffer(bd->bd_bh);
gfs2_log_lock(sdp); gfs2_log_lock(sdp);
if (tr) { if (tr)
if (!list_empty(&bd->bd_list_tr))
goto out;
tr->tr_touched = 1; tr->tr_touched = 1;
if (gfs2_is_jdata(ip)) {
tr->tr_num_buf++;
list_add(&bd->bd_list_tr, &tr->tr_list_buf);
}
}
if (!list_empty(&le->le_list)) if (!list_empty(&le->le_list))
goto out; goto out;
set_bit(GLF_LFLUSH, &bd->bd_gl->gl_flags); set_bit(GLF_LFLUSH, &bd->bd_gl->gl_flags);
set_bit(GLF_DIRTY, &bd->bd_gl->gl_flags); set_bit(GLF_DIRTY, &bd->bd_gl->gl_flags);
if (gfs2_is_jdata(ip)) { if (gfs2_is_jdata(ip)) {
......
...@@ -293,7 +293,6 @@ void gfs2_attach_bufdata(struct gfs2_glock *gl, struct buffer_head *bh, ...@@ -293,7 +293,6 @@ void gfs2_attach_bufdata(struct gfs2_glock *gl, struct buffer_head *bh,
bd->bd_bh = bh; bd->bd_bh = bh;
bd->bd_gl = gl; bd->bd_gl = gl;
INIT_LIST_HEAD(&bd->bd_list_tr);
if (meta) if (meta)
lops_init_le(&bd->bd_le, &gfs2_buf_lops); lops_init_le(&bd->bd_le, &gfs2_buf_lops);
else else
......
...@@ -50,8 +50,6 @@ int gfs2_trans_begin(struct gfs2_sbd *sdp, unsigned int blocks, ...@@ -50,8 +50,6 @@ int gfs2_trans_begin(struct gfs2_sbd *sdp, unsigned int blocks,
if (revokes) if (revokes)
tr->tr_reserved += gfs2_struct2blk(sdp, revokes, tr->tr_reserved += gfs2_struct2blk(sdp, revokes,
sizeof(u64)); sizeof(u64));
INIT_LIST_HEAD(&tr->tr_list_buf);
gfs2_holder_init(sdp->sd_trans_gl, LM_ST_SHARED, 0, &tr->tr_t_gh); gfs2_holder_init(sdp->sd_trans_gl, LM_ST_SHARED, 0, &tr->tr_t_gh);
error = gfs2_glock_nq(&tr->tr_t_gh); error = gfs2_glock_nq(&tr->tr_t_gh);
...@@ -93,10 +91,21 @@ static void gfs2_log_release(struct gfs2_sbd *sdp, unsigned int blks) ...@@ -93,10 +91,21 @@ static void gfs2_log_release(struct gfs2_sbd *sdp, unsigned int blks)
up_read(&sdp->sd_log_flush_lock); up_read(&sdp->sd_log_flush_lock);
} }
static void gfs2_print_trans(const struct gfs2_trans *tr)
{
print_symbol(KERN_WARNING "GFS2: Transaction created at: %s\n", tr->tr_ip);
printk(KERN_WARNING "GFS2: blocks=%u revokes=%u reserved=%u touched=%d\n",
tr->tr_blocks, tr->tr_revokes, tr->tr_reserved, tr->tr_touched);
printk(KERN_WARNING "GFS2: Buf %u/%u Databuf %u/%u Revoke %u/%u\n",
tr->tr_num_buf_new, tr->tr_num_buf_rm,
tr->tr_num_databuf_new, tr->tr_num_databuf_rm,
tr->tr_num_revoke, tr->tr_num_revoke_rm);
}
void gfs2_trans_end(struct gfs2_sbd *sdp) void gfs2_trans_end(struct gfs2_sbd *sdp)
{ {
struct gfs2_trans *tr = current->journal_info; struct gfs2_trans *tr = current->journal_info;
s64 nbuf;
BUG_ON(!tr); BUG_ON(!tr);
current->journal_info = NULL; current->journal_info = NULL;
...@@ -110,16 +119,13 @@ void gfs2_trans_end(struct gfs2_sbd *sdp) ...@@ -110,16 +119,13 @@ void gfs2_trans_end(struct gfs2_sbd *sdp)
return; return;
} }
if (gfs2_assert_withdraw(sdp, tr->tr_num_buf <= tr->tr_blocks)) { nbuf = tr->tr_num_buf_new + tr->tr_num_databuf_new;
fs_err(sdp, "tr_num_buf = %u, tr_blocks = %u ", nbuf -= tr->tr_num_buf_rm;
tr->tr_num_buf, tr->tr_blocks); nbuf -= tr->tr_num_databuf_rm;
print_symbol(KERN_WARNING "GFS2: Transaction created at: %s\n", tr->tr_ip);
} if (gfs2_assert_withdraw(sdp, (nbuf <= tr->tr_blocks) &&
if (gfs2_assert_withdraw(sdp, tr->tr_num_revoke <= tr->tr_revokes)) { (tr->tr_num_revoke <= tr->tr_revokes)))
fs_err(sdp, "tr_num_revoke = %u, tr_revokes = %u ", gfs2_print_trans(tr);
tr->tr_num_revoke, tr->tr_revokes);
print_symbol(KERN_WARNING "GFS2: Transaction created at: %s\n", tr->tr_ip);
}
gfs2_log_commit(sdp, tr); gfs2_log_commit(sdp, tr);
if (tr->tr_t_gh.gh_gl) { if (tr->tr_t_gh.gh_gl) {
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment