Commit 9862ca05 authored by Bob Peterson's avatar Bob Peterson

GFS2: Switch tr_touched to flag in transaction

This patch eliminates the int variable tr_touched in favor of a
new flag in the transaction. This is a step toward reducing contention
on the gfs2_log_lock spin_lock.
Signed-off-by: default avatarBob Peterson <rpeterso@redhat.com>
parent b63f5e84
...@@ -470,15 +470,19 @@ struct gfs2_quota_data { ...@@ -470,15 +470,19 @@ struct gfs2_quota_data {
struct rcu_head qd_rcu; struct rcu_head qd_rcu;
}; };
enum {
TR_TOUCHED = 1,
TR_ATTACHED = 2,
TR_ALLOCED = 3,
};
struct gfs2_trans { struct gfs2_trans {
unsigned long tr_ip; unsigned long tr_ip;
unsigned int tr_blocks; unsigned int tr_blocks;
unsigned int tr_revokes; unsigned int tr_revokes;
unsigned int tr_reserved; unsigned int tr_reserved;
unsigned int tr_touched:1; unsigned long tr_flags;
unsigned int tr_attached:1;
unsigned int tr_alloced:1;
unsigned int tr_num_buf_new; unsigned int tr_num_buf_new;
unsigned int tr_num_databuf_new; unsigned int tr_num_databuf_new;
......
...@@ -799,7 +799,7 @@ void gfs2_log_flush(struct gfs2_sbd *sdp, struct gfs2_glock *gl, ...@@ -799,7 +799,7 @@ void gfs2_log_flush(struct gfs2_sbd *sdp, struct gfs2_glock *gl,
static void gfs2_merge_trans(struct gfs2_trans *old, struct gfs2_trans *new) static void gfs2_merge_trans(struct gfs2_trans *old, struct gfs2_trans *new)
{ {
WARN_ON_ONCE(old->tr_attached != 1); WARN_ON_ONCE(!test_bit(TR_ATTACHED, &old->tr_flags));
old->tr_num_buf_new += new->tr_num_buf_new; old->tr_num_buf_new += new->tr_num_buf_new;
old->tr_num_databuf_new += new->tr_num_databuf_new; old->tr_num_databuf_new += new->tr_num_databuf_new;
...@@ -823,9 +823,9 @@ static void log_refund(struct gfs2_sbd *sdp, struct gfs2_trans *tr) ...@@ -823,9 +823,9 @@ static void log_refund(struct gfs2_sbd *sdp, struct gfs2_trans *tr)
if (sdp->sd_log_tr) { if (sdp->sd_log_tr) {
gfs2_merge_trans(sdp->sd_log_tr, tr); gfs2_merge_trans(sdp->sd_log_tr, tr);
} else if (tr->tr_num_buf_new || tr->tr_num_databuf_new) { } else if (tr->tr_num_buf_new || tr->tr_num_databuf_new) {
gfs2_assert_withdraw(sdp, tr->tr_alloced); gfs2_assert_withdraw(sdp, test_bit(TR_ALLOCED, &tr->tr_flags));
sdp->sd_log_tr = tr; sdp->sd_log_tr = tr;
tr->tr_attached = 1; set_bit(TR_ATTACHED, &tr->tr_flags);
} }
sdp->sd_log_commited_revoke += tr->tr_num_revoke - tr->tr_num_revoke_rm; sdp->sd_log_commited_revoke += tr->tr_num_revoke - tr->tr_num_revoke_rm;
......
...@@ -293,7 +293,7 @@ int gfs2_meta_read(struct gfs2_glock *gl, u64 blkno, int flags, ...@@ -293,7 +293,7 @@ int gfs2_meta_read(struct gfs2_glock *gl, u64 blkno, int flags,
wait_on_buffer(bh); wait_on_buffer(bh);
if (unlikely(!buffer_uptodate(bh))) { if (unlikely(!buffer_uptodate(bh))) {
struct gfs2_trans *tr = current->journal_info; struct gfs2_trans *tr = current->journal_info;
if (tr && tr->tr_touched) if (tr && test_bit(TR_TOUCHED, &tr->tr_flags))
gfs2_io_error_bh(sdp, bh); gfs2_io_error_bh(sdp, bh);
brelse(bh); brelse(bh);
*bhp = NULL; *bhp = NULL;
...@@ -320,7 +320,7 @@ int gfs2_meta_wait(struct gfs2_sbd *sdp, struct buffer_head *bh) ...@@ -320,7 +320,7 @@ int gfs2_meta_wait(struct gfs2_sbd *sdp, struct buffer_head *bh)
if (!buffer_uptodate(bh)) { if (!buffer_uptodate(bh)) {
struct gfs2_trans *tr = current->journal_info; struct gfs2_trans *tr = current->journal_info;
if (tr && tr->tr_touched) if (tr && test_bit(TR_TOUCHED, &tr->tr_flags))
gfs2_io_error_bh(sdp, bh); gfs2_io_error_bh(sdp, bh);
return -EIO; return -EIO;
} }
...@@ -346,7 +346,7 @@ void gfs2_remove_from_journal(struct buffer_head *bh, int meta) ...@@ -346,7 +346,7 @@ void gfs2_remove_from_journal(struct buffer_head *bh, int meta)
tr->tr_num_buf_rm++; tr->tr_num_buf_rm++;
else else
tr->tr_num_databuf_rm++; tr->tr_num_databuf_rm++;
tr->tr_touched = 1; set_bit(TR_TOUCHED, &tr->tr_flags);
was_pinned = 1; was_pinned = 1;
brelse(bh); brelse(bh);
} }
......
...@@ -48,7 +48,7 @@ int gfs2_trans_begin(struct gfs2_sbd *sdp, unsigned int blocks, ...@@ -48,7 +48,7 @@ int gfs2_trans_begin(struct gfs2_sbd *sdp, unsigned int blocks,
tr->tr_blocks = blocks; tr->tr_blocks = blocks;
tr->tr_revokes = revokes; tr->tr_revokes = revokes;
tr->tr_reserved = 1; tr->tr_reserved = 1;
tr->tr_alloced = 1; set_bit(TR_ALLOCED, &tr->tr_flags);
if (blocks) if (blocks)
tr->tr_reserved += 6 + blocks; tr->tr_reserved += 6 + blocks;
if (revokes) if (revokes)
...@@ -78,7 +78,8 @@ static void gfs2_print_trans(const struct gfs2_trans *tr) ...@@ -78,7 +78,8 @@ static void gfs2_print_trans(const struct gfs2_trans *tr)
{ {
pr_warn("Transaction created at: %pSR\n", (void *)tr->tr_ip); pr_warn("Transaction created at: %pSR\n", (void *)tr->tr_ip);
pr_warn("blocks=%u revokes=%u reserved=%u touched=%u\n", pr_warn("blocks=%u revokes=%u reserved=%u touched=%u\n",
tr->tr_blocks, tr->tr_revokes, tr->tr_reserved, tr->tr_touched); tr->tr_blocks, tr->tr_revokes, tr->tr_reserved,
test_bit(TR_TOUCHED, &tr->tr_flags));
pr_warn("Buf %u/%u Databuf %u/%u Revoke %u/%u\n", pr_warn("Buf %u/%u Databuf %u/%u Revoke %u/%u\n",
tr->tr_num_buf_new, tr->tr_num_buf_rm, tr->tr_num_buf_new, tr->tr_num_buf_rm,
tr->tr_num_databuf_new, tr->tr_num_databuf_rm, tr->tr_num_databuf_new, tr->tr_num_databuf_rm,
...@@ -89,12 +90,12 @@ void gfs2_trans_end(struct gfs2_sbd *sdp) ...@@ -89,12 +90,12 @@ void gfs2_trans_end(struct gfs2_sbd *sdp)
{ {
struct gfs2_trans *tr = current->journal_info; struct gfs2_trans *tr = current->journal_info;
s64 nbuf; s64 nbuf;
int alloced = tr->tr_alloced; int alloced = test_bit(TR_ALLOCED, &tr->tr_flags);
BUG_ON(!tr); BUG_ON(!tr);
current->journal_info = NULL; current->journal_info = NULL;
if (!tr->tr_touched) { if (!test_bit(TR_TOUCHED, &tr->tr_flags)) {
gfs2_log_release(sdp, tr->tr_reserved); gfs2_log_release(sdp, tr->tr_reserved);
if (alloced) { if (alloced) {
kfree(tr); kfree(tr);
...@@ -112,7 +113,7 @@ void gfs2_trans_end(struct gfs2_sbd *sdp) ...@@ -112,7 +113,7 @@ void gfs2_trans_end(struct gfs2_sbd *sdp)
gfs2_print_trans(tr); gfs2_print_trans(tr);
gfs2_log_commit(sdp, tr); gfs2_log_commit(sdp, tr);
if (alloced && !tr->tr_attached) if (alloced && !test_bit(TR_ATTACHED, &tr->tr_flags))
kfree(tr); kfree(tr);
up_read(&sdp->sd_log_flush_lock); up_read(&sdp->sd_log_flush_lock);
...@@ -182,7 +183,7 @@ void gfs2_trans_add_data(struct gfs2_glock *gl, struct buffer_head *bh) ...@@ -182,7 +183,7 @@ void gfs2_trans_add_data(struct gfs2_glock *gl, struct buffer_head *bh)
gfs2_log_lock(sdp); gfs2_log_lock(sdp);
} }
gfs2_assert(sdp, bd->bd_gl == gl); gfs2_assert(sdp, bd->bd_gl == gl);
tr->tr_touched = 1; set_bit(TR_TOUCHED, &tr->tr_flags);
if (list_empty(&bd->bd_list)) { if (list_empty(&bd->bd_list)) {
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);
...@@ -201,7 +202,7 @@ static void meta_lo_add(struct gfs2_sbd *sdp, struct gfs2_bufdata *bd) ...@@ -201,7 +202,7 @@ static void meta_lo_add(struct gfs2_sbd *sdp, struct gfs2_bufdata *bd)
enum gfs2_freeze_state state = atomic_read(&sdp->sd_freeze_state); enum gfs2_freeze_state state = atomic_read(&sdp->sd_freeze_state);
tr = current->journal_info; tr = current->journal_info;
tr->tr_touched = 1; set_bit(TR_TOUCHED, &tr->tr_flags);
if (!list_empty(&bd->bd_list)) if (!list_empty(&bd->bd_list))
return; return;
set_bit(GLF_LFLUSH, &bd->bd_gl->gl_flags); set_bit(GLF_LFLUSH, &bd->bd_gl->gl_flags);
...@@ -256,7 +257,7 @@ void gfs2_trans_add_revoke(struct gfs2_sbd *sdp, struct gfs2_bufdata *bd) ...@@ -256,7 +257,7 @@ void gfs2_trans_add_revoke(struct gfs2_sbd *sdp, struct gfs2_bufdata *bd)
BUG_ON(!list_empty(&bd->bd_list)); BUG_ON(!list_empty(&bd->bd_list));
gfs2_add_revoke(sdp, bd); gfs2_add_revoke(sdp, bd);
tr->tr_touched = 1; set_bit(TR_TOUCHED, &tr->tr_flags);
tr->tr_num_revoke++; tr->tr_num_revoke++;
} }
......
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