From 1ad38c437fa33f85ba4b6a85ea8c5478ee72d5bd Mon Sep 17 00:00:00 2001 From: Steven Whitehouse Date: Mon, 3 Sep 2007 11:01:33 +0100 Subject: [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: Steven Whitehouse --- fs/gfs2/trans.c | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) (limited to 'fs/gfs2/trans.c') diff --git a/fs/gfs2/trans.c b/fs/gfs2/trans.c index 01cc27f..717983e 100644 --- a/fs/gfs2/trans.c +++ b/fs/gfs2/trans.c @@ -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); } -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, - GFP_NOFS | __GFP_NOFAIL); + BUG_ON(!list_empty(&bd->bd_le.le_list)); + 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); - bd->bd_blkno = blkno; lops_add(sdp, &bd->bd_le); } @@ -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) { 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); sdp->sd_log_num_revoke--; found = 1; -- cgit v1.1