[GFS2] Replace revoke structure with bufdata structure
authorSteven Whitehouse <swhiteho@redhat.com>
Sun, 2 Sep 2007 14:39:43 +0000 (15:39 +0100)
committerSteven Whitehouse <swhiteho@redhat.com>
Wed, 10 Oct 2007 07:56:07 +0000 (08:56 +0100)
Both the revoke structure and the bufdata structure are quite similar.
They are basically small tags which are put on lists. In addition to
which the revoke structure is always allocated when there is a bufdata
structure which is (or can be) freed. As such it should be possible to
reduce the number of frees and allocations by using the same structure
for both purposes.

This patch is the first step along that path. It replaces existing uses
of the revoke structure with the bufdata structure.

Signed-off-by: Steven Whitehouse <swhiteho@redhat.com>
fs/gfs2/incore.h
fs/gfs2/lops.c
fs/gfs2/trans.c

index 388dc1bd736f9b91324b330240d14f1bdad476cb..8aa5780862beae45128e6abfa33dfcd5b34ce2d7 100644 (file)
@@ -114,7 +114,13 @@ struct gfs2_bufdata {
        struct buffer_head *bd_bh;
        struct gfs2_glock *bd_gl;
 
-       struct list_head bd_list_tr;
+       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_ail *bd_ail;
@@ -298,11 +304,6 @@ struct gfs2_file {
        struct gfs2_holder f_fl_gh;
 };
 
-struct gfs2_revoke {
-       struct gfs2_log_element rv_le;
-       u64 rv_blkno;
-};
-
 struct gfs2_revoke_replay {
        struct list_head rr_list;
        u64 rr_blkno;
index 7e2d4e692b50624cf99c094fb4cfaafc387fcbcb..cf6fe3631554129f500eeb0e9db3bc505fc46042 100644 (file)
@@ -357,7 +357,7 @@ static void revoke_lo_before_commit(struct gfs2_sbd *sdp)
        struct buffer_head *bh;
        unsigned int offset;
        struct list_head *head = &sdp->sd_log_le_revoke;
-       struct gfs2_revoke *rv;
+       struct gfs2_bufdata *bd;
 
        if (!sdp->sd_log_num_revoke)
                return;
@@ -376,8 +376,8 @@ static void revoke_lo_before_commit(struct gfs2_sbd *sdp)
        offset = sizeof(struct gfs2_log_descriptor);
 
        while (!list_empty(head)) {
-               rv = list_entry(head->next, struct gfs2_revoke, rv_le.le_list);
-               list_del_init(&rv->rv_le.le_list);
+               bd = list_entry(head->next, struct gfs2_bufdata, bd_le.le_list);
+               list_del_init(&bd->bd_le.le_list);
                sdp->sd_log_num_revoke--;
 
                if (offset + sizeof(u64) > sdp->sd_sb.sb_bsize) {
@@ -392,8 +392,8 @@ static void revoke_lo_before_commit(struct gfs2_sbd *sdp)
                        offset = sizeof(struct gfs2_meta_header);
                }
 
-               *(__be64 *)(bh->b_data + offset) = cpu_to_be64(rv->rv_blkno);
-               kfree(rv);
+               *(__be64 *)(bh->b_data + offset) = cpu_to_be64(bd->bd_blkno);
+               kfree(bd);
 
                offset += sizeof(u64);
        }
index f8dabf8446bb417000b556b53d5f29b7fc74e8fd..eadf96e00510b91c82b9deabff82faac75a717db 100644 (file)
@@ -144,23 +144,23 @@ 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)
 {
-       struct gfs2_revoke *rv = kmalloc(sizeof(struct gfs2_revoke),
-                                        GFP_NOFS | __GFP_NOFAIL);
-       lops_init_le(&rv->rv_le, &gfs2_revoke_lops);
-       rv->rv_blkno = blkno;
-       lops_add(sdp, &rv->rv_le);
+       struct gfs2_bufdata *bd = kmalloc(sizeof(struct gfs2_bufdata),
+                                         GFP_NOFS | __GFP_NOFAIL);
+       lops_init_le(&bd->bd_le, &gfs2_revoke_lops);
+       bd->bd_blkno = blkno;
+       lops_add(sdp, &bd->bd_le);
 }
 
 void gfs2_trans_add_unrevoke(struct gfs2_sbd *sdp, u64 blkno)
 {
-       struct gfs2_revoke *rv;
+       struct gfs2_bufdata *bd;
        int found = 0;
 
        gfs2_log_lock(sdp);
 
-       list_for_each_entry(rv, &sdp->sd_log_le_revoke, rv_le.le_list) {
-               if (rv->rv_blkno == blkno) {
-                       list_del(&rv->rv_le.le_list);
+       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);
                        gfs2_assert_withdraw(sdp, sdp->sd_log_num_revoke);
                        sdp->sd_log_num_revoke--;
                        found = 1;
@@ -172,7 +172,7 @@ void gfs2_trans_add_unrevoke(struct gfs2_sbd *sdp, u64 blkno)
 
        if (found) {
                struct gfs2_trans *tr = current->journal_info;
-               kfree(rv);
+               kfree(bd);
                tr->tr_num_revoke_rm++;
        }
 }