Commit 1ad38c43 authored by Steven Whitehouse's avatar Steven Whitehouse

[GFS2] Clean up gfs2_trans_add_revoke()

The following alters gfs2_trans_add_revoke() to take a struct
gfs2_bufdata as an argument. This eliminates the memory allocation which
was previously required by making use of the already existing struct
gfs2_bufdata. It makes some sanity checks to ensure that the
gfs2_bufdata has been removed from all the lists before its recycled as
a revoke structure. This saves one memory allocation and one free per
revoke structure.

Also as a result, and to simplify the locking, since there is no longer
any blocking code in gfs2_trans_add_revoke() we must hold the log lock
whenever this function is called. This reduces the amount of times we
take and unlock the log lock.
Signed-off-by: default avatarSteven Whitehouse <swhiteho@redhat.com>
parent 0820ab51
...@@ -41,7 +41,6 @@ static void gfs2_ail_empty_gl(struct gfs2_glock *gl) ...@@ -41,7 +41,6 @@ static void gfs2_ail_empty_gl(struct gfs2_glock *gl)
struct list_head *head = &gl->gl_ail_list; struct list_head *head = &gl->gl_ail_list;
struct gfs2_bufdata *bd; struct gfs2_bufdata *bd;
struct buffer_head *bh; struct buffer_head *bh;
u64 blkno;
int error; int error;
blocks = atomic_read(&gl->gl_ail_count); blocks = atomic_read(&gl->gl_ail_count);
...@@ -57,15 +56,12 @@ static void gfs2_ail_empty_gl(struct gfs2_glock *gl) ...@@ -57,15 +56,12 @@ static void gfs2_ail_empty_gl(struct gfs2_glock *gl)
bd = list_entry(head->next, struct gfs2_bufdata, bd = list_entry(head->next, struct gfs2_bufdata,
bd_ail_gl_list); bd_ail_gl_list);
bh = bd->bd_bh; bh = bd->bd_bh;
blkno = bh->b_blocknr;
gfs2_assert_withdraw(sdp, !buffer_busy(bh));
gfs2_remove_from_ail(NULL, bd); gfs2_remove_from_ail(NULL, bd);
gfs2_log_unlock(sdp); bd->bd_bh = NULL;
bh->b_private = NULL;
gfs2_trans_add_revoke(sdp, blkno); bd->bd_blkno = bh->b_blocknr;
gfs2_assert_withdraw(sdp, !buffer_busy(bh));
gfs2_log_lock(sdp); gfs2_trans_add_revoke(sdp, bd);
} }
gfs2_assert_withdraw(sdp, !atomic_read(&gl->gl_ail_count)); gfs2_assert_withdraw(sdp, !atomic_read(&gl->gl_ail_count));
gfs2_log_unlock(sdp); gfs2_log_unlock(sdp);
......
...@@ -71,8 +71,8 @@ unsigned int gfs2_struct2blk(struct gfs2_sbd *sdp, unsigned int nstruct, ...@@ -71,8 +71,8 @@ unsigned int gfs2_struct2blk(struct gfs2_sbd *sdp, unsigned int nstruct,
void gfs2_remove_from_ail(struct address_space *mapping, struct gfs2_bufdata *bd) void gfs2_remove_from_ail(struct address_space *mapping, struct gfs2_bufdata *bd)
{ {
bd->bd_ail = NULL; bd->bd_ail = NULL;
list_del(&bd->bd_ail_st_list); list_del_init(&bd->bd_ail_st_list);
list_del(&bd->bd_ail_gl_list); list_del_init(&bd->bd_ail_gl_list);
atomic_dec(&bd->bd_gl->gl_ail_count); atomic_dec(&bd->bd_gl->gl_ail_count);
if (mapping) if (mapping)
gfs2_meta_cache_flush(GFS2_I(mapping->host)); gfs2_meta_cache_flush(GFS2_I(mapping->host));
......
...@@ -343,11 +343,8 @@ static void revoke_lo_add(struct gfs2_sbd *sdp, struct gfs2_log_element *le) ...@@ -343,11 +343,8 @@ static void revoke_lo_add(struct gfs2_sbd *sdp, struct gfs2_log_element *le)
tr = current->journal_info; tr = current->journal_info;
tr->tr_touched = 1; tr->tr_touched = 1;
tr->tr_num_revoke++; tr->tr_num_revoke++;
gfs2_log_lock(sdp);
sdp->sd_log_num_revoke++; sdp->sd_log_num_revoke++;
list_add(&le->le_list, &sdp->sd_log_le_revoke); list_add(&le->le_list, &sdp->sd_log_le_revoke);
gfs2_log_unlock(sdp);
} }
static void revoke_lo_before_commit(struct gfs2_sbd *sdp) static void revoke_lo_before_commit(struct gfs2_sbd *sdp)
......
...@@ -313,42 +313,31 @@ void gfs2_meta_wipe(struct gfs2_inode *ip, u64 bstart, u32 blen) ...@@ -313,42 +313,31 @@ void gfs2_meta_wipe(struct gfs2_inode *ip, u64 bstart, u32 blen)
while (blen) { while (blen) {
bh = getbuf(ip->i_gl, bstart, NO_CREATE); bh = getbuf(ip->i_gl, bstart, NO_CREATE);
if (bh) { if (bh) {
struct gfs2_bufdata *bd = bh->b_private; struct gfs2_bufdata *bd;
lock_buffer(bh);
gfs2_log_lock(sdp);
bd = bh->b_private;
if (test_clear_buffer_pinned(bh)) { if (test_clear_buffer_pinned(bh)) {
struct gfs2_trans *tr = current->journal_info; struct gfs2_trans *tr = current->journal_info;
struct gfs2_inode *bh_ip =
GFS2_I(bh->b_page->mapping->host);
gfs2_log_lock(sdp);
list_del_init(&bd->bd_le.le_list); list_del_init(&bd->bd_le.le_list);
gfs2_assert_warn(sdp, sdp->sd_log_num_buf); gfs2_assert_warn(sdp, sdp->sd_log_num_buf);
sdp->sd_log_num_buf--; sdp->sd_log_num_buf--;
gfs2_log_unlock(sdp); tr->tr_num_buf_rm++;
if (bh_ip->i_inode.i_private != NULL)
tr->tr_num_databuf_rm++;
else
tr->tr_num_buf_rm++;
brelse(bh); brelse(bh);
} }
if (bd) { if (bd) {
gfs2_log_lock(sdp);
if (bd->bd_ail) { if (bd->bd_ail) {
u64 blkno = bh->b_blocknr; gfs2_remove_from_ail(NULL, bd);
bd->bd_ail = NULL; bh->b_private = NULL;
list_del(&bd->bd_ail_st_list); bd->bd_bh = NULL;
list_del(&bd->bd_ail_gl_list); bd->bd_blkno = bh->b_blocknr;
atomic_dec(&bd->bd_gl->gl_ail_count); gfs2_trans_add_revoke(sdp, bd);
brelse(bh); }
gfs2_log_unlock(sdp);
gfs2_trans_add_revoke(sdp, blkno);
} else
gfs2_log_unlock(sdp);
} }
lock_buffer(bh);
clear_buffer_dirty(bh); clear_buffer_dirty(bh);
clear_buffer_uptodate(bh); clear_buffer_uptodate(bh);
gfs2_log_unlock(sdp);
unlock_buffer(bh); unlock_buffer(bh);
brelse(bh); brelse(bh);
......
...@@ -142,12 +142,12 @@ void gfs2_trans_add_bh(struct gfs2_glock *gl, struct buffer_head *bh, int meta) ...@@ -142,12 +142,12 @@ void gfs2_trans_add_bh(struct gfs2_glock *gl, struct buffer_head *bh, int meta)
lops_add(sdp, &bd->bd_le); lops_add(sdp, &bd->bd_le);
} }
void gfs2_trans_add_revoke(struct gfs2_sbd *sdp, u64 blkno) void gfs2_trans_add_revoke(struct gfs2_sbd *sdp, struct gfs2_bufdata *bd)
{ {
struct gfs2_bufdata *bd = kmem_cache_alloc(gfs2_bufdata_cachep, BUG_ON(!list_empty(&bd->bd_le.le_list));
GFP_NOFS | __GFP_NOFAIL); BUG_ON(!list_empty(&bd->bd_ail_st_list));
BUG_ON(!list_empty(&bd->bd_ail_gl_list));
lops_init_le(&bd->bd_le, &gfs2_revoke_lops); lops_init_le(&bd->bd_le, &gfs2_revoke_lops);
bd->bd_blkno = blkno;
lops_add(sdp, &bd->bd_le); lops_add(sdp, &bd->bd_le);
} }
...@@ -160,7 +160,7 @@ void gfs2_trans_add_unrevoke(struct gfs2_sbd *sdp, u64 blkno) ...@@ -160,7 +160,7 @@ void gfs2_trans_add_unrevoke(struct gfs2_sbd *sdp, u64 blkno)
list_for_each_entry(bd, &sdp->sd_log_le_revoke, bd_le.le_list) { list_for_each_entry(bd, &sdp->sd_log_le_revoke, bd_le.le_list) {
if (bd->bd_blkno == blkno) { if (bd->bd_blkno == blkno) {
list_del(&bd->bd_le.le_list); list_del_init(&bd->bd_le.le_list);
gfs2_assert_withdraw(sdp, sdp->sd_log_num_revoke); gfs2_assert_withdraw(sdp, sdp->sd_log_num_revoke);
sdp->sd_log_num_revoke--; sdp->sd_log_num_revoke--;
found = 1; found = 1;
......
...@@ -32,7 +32,7 @@ void gfs2_trans_end(struct gfs2_sbd *sdp); ...@@ -32,7 +32,7 @@ void gfs2_trans_end(struct gfs2_sbd *sdp);
void gfs2_trans_add_gl(struct gfs2_glock *gl); void gfs2_trans_add_gl(struct gfs2_glock *gl);
void gfs2_trans_add_bh(struct gfs2_glock *gl, struct buffer_head *bh, int meta); void gfs2_trans_add_bh(struct gfs2_glock *gl, struct buffer_head *bh, int meta);
void gfs2_trans_add_revoke(struct gfs2_sbd *sdp, u64 blkno); void gfs2_trans_add_revoke(struct gfs2_sbd *sdp, struct gfs2_bufdata *bd);
void gfs2_trans_add_unrevoke(struct gfs2_sbd *sdp, u64 blkno); void gfs2_trans_add_unrevoke(struct gfs2_sbd *sdp, u64 blkno);
void gfs2_trans_add_rg(struct gfs2_rgrpd *rgd); void gfs2_trans_add_rg(struct gfs2_rgrpd *rgd);
......
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