]> www.pilppa.org Git - linux-2.6-omap-h63xx.git/commitdiff
[GFS2] Update gfs2_trans_add_unrevoke to accept extents
authorSteven Whitehouse <swhiteho@redhat.com>
Fri, 1 Feb 2008 13:16:55 +0000 (13:16 +0000)
committerSteven Whitehouse <swhiteho@redhat.com>
Mon, 31 Mar 2008 09:40:42 +0000 (10:40 +0100)
By adding an extra argument to gfs2_trans_add_unrevoke we can now
specify an extent length of blocks to unrevoke. This means that
we only need to make one pass through the list for each extent
rather than each block. Currently the only extent length which
is used is 1, but that will change in the future.

Also gfs2_trans_add_unrevoke is removed from gfs2_alloc_meta
since its the only difference between this and gfs2_alloc_data
which is left. This will allow a future patch to merge these
two functions into one (i.e. one call to allocate both data
and metadata in a single extent in the future).

Signed-off-by: Steven Whitehouse <swhiteho@redhat.com>
fs/gfs2/bmap.c
fs/gfs2/dir.c
fs/gfs2/eattr.c
fs/gfs2/rgrp.c
fs/gfs2/trans.c
fs/gfs2/trans.h

index 30d718b3438f3daf85e29905db2b08880bc5452f..651e5320bb4f9112f87dcc2681df86131f85471f 100644 (file)
@@ -138,7 +138,7 @@ int gfs2_unstuff_dinode(struct gfs2_inode *ip, struct page *page)
 
                if (isdir) {
                        block = gfs2_alloc_meta(ip);
-
+                       gfs2_trans_add_unrevoke(GFS2_SB(&ip->i_inode), block, 1);
                        error = gfs2_dir_get_new_buffer(ip, block, &bh);
                        if (error)
                                goto out_brelse;
@@ -206,6 +206,7 @@ static int build_height(struct inode *inode, struct metapath *mp, unsigned heigh
 
        for(n = 0; n < new_height; n++) {
                bn = gfs2_alloc_meta(ip);
+               gfs2_trans_add_unrevoke(GFS2_SB(inode), bn, 1);
                mp->mp_bh[n] = gfs2_meta_new(ip->i_gl, bn);
                gfs2_trans_add_bh(ip->i_gl, mp->mp_bh[n], 1);
        }
@@ -370,8 +371,10 @@ static int lookup_block(struct gfs2_inode *ip, unsigned int height,
 
        if (height == ip->i_height - 1 && !gfs2_is_dir(ip))
                *block = gfs2_alloc_data(ip);
-       else
+       else {
                *block = gfs2_alloc_meta(ip);
+               gfs2_trans_add_unrevoke(GFS2_SB(&ip->i_inode), *block, 1);
+       }
 
        gfs2_trans_add_bh(ip->i_gl, mp->mp_bh[height], 1);
 
index 081daa96a9d9a1b9f3c9363cb05f2decd367d60f..55514ee06dd86c4b8a0dcaf6fc7d8b11a21e748d 100644 (file)
@@ -810,7 +810,7 @@ static struct gfs2_leaf *new_leaf(struct inode *inode, struct buffer_head **pbh,
        struct qstr name = { .name = "", .len = 0, .hash = 0 };
        if (!bh)
                return NULL;
-
+       gfs2_trans_add_unrevoke(GFS2_SB(inode), bn, 1);
        gfs2_trans_add_bh(ip->i_gl, bh, 1);
        gfs2_metatype_set(bh, GFS2_METATYPE_LF, GFS2_FORMAT_LF);
        leaf = (struct gfs2_leaf *)bh->b_data;
index 04febbc17a1631a33ffbd6ecc70f2973a5546597..c7fa0a8b1648bd0823960464798f37d76f5052be 100644 (file)
@@ -585,7 +585,7 @@ static int ea_alloc_blk(struct gfs2_inode *ip, struct buffer_head **bhp)
        u64 block;
 
        block = gfs2_alloc_meta(ip);
-
+       gfs2_trans_add_unrevoke(sdp, block, 1);
        *bhp = gfs2_meta_new(ip->i_gl, block);
        gfs2_trans_add_bh(ip->i_gl, *bhp, 1);
        gfs2_metatype_set(*bhp, GFS2_METATYPE_EA, GFS2_FORMAT_EA);
@@ -644,7 +644,7 @@ static int ea_write(struct gfs2_inode *ip, struct gfs2_ea_header *ea,
                        int mh_size = sizeof(struct gfs2_meta_header);
 
                        block = gfs2_alloc_meta(ip);
-
+                       gfs2_trans_add_unrevoke(sdp, block, 1);
                        bh = gfs2_meta_new(ip->i_gl, block);
                        gfs2_trans_add_bh(ip->i_gl, bh, 1);
                        gfs2_metatype_set(bh, GFS2_METATYPE_ED, GFS2_FORMAT_ED);
@@ -968,7 +968,7 @@ static int ea_set_block(struct gfs2_inode *ip, struct gfs2_ea_request *er,
                u64 blk;
 
                blk = gfs2_alloc_meta(ip);
-
+               gfs2_trans_add_unrevoke(sdp, blk, 1);
                indbh = gfs2_meta_new(ip->i_gl, blk);
                gfs2_trans_add_bh(ip->i_gl, indbh, 1);
                gfs2_metatype_set(indbh, GFS2_METATYPE_IN, GFS2_FORMAT_IN);
index cc28845ba6fdc131666dba56efa6f4ee8d389dba..9f28463e62e526296a7f03e5b1c7967d16d67af1 100644 (file)
@@ -1486,7 +1486,6 @@ u64 gfs2_alloc_meta(struct gfs2_inode *ip)
 
        gfs2_statfs_change(sdp, 0, -1, 0);
        gfs2_quota_change(ip, +1, ip->i_inode.i_uid, ip->i_inode.i_gid);
-       gfs2_trans_add_unrevoke(sdp, block);
 
        spin_lock(&sdp->sd_rindex_spin);
        rgd->rd_free_clone--;
@@ -1528,7 +1527,7 @@ u64 gfs2_alloc_di(struct gfs2_inode *dip, u64 *generation)
        al->al_alloced++;
 
        gfs2_statfs_change(sdp, 0, -1, +1);
-       gfs2_trans_add_unrevoke(sdp, block);
+       gfs2_trans_add_unrevoke(sdp, block, 1);
 
        spin_lock(&sdp->sd_rindex_spin);
        rgd->rd_free_clone--;
index 73e5d92a657ca4aa119afb3658814d648ac4486a..f677b8a83f0cc2d0d3cb7c1ebbee47908620a440 100644 (file)
@@ -146,30 +146,25 @@ void gfs2_trans_add_revoke(struct gfs2_sbd *sdp, struct gfs2_bufdata *bd)
        lops_add(sdp, &bd->bd_le);
 }
 
-void gfs2_trans_add_unrevoke(struct gfs2_sbd *sdp, u64 blkno)
+void gfs2_trans_add_unrevoke(struct gfs2_sbd *sdp, u64 blkno, unsigned int len)
 {
-       struct gfs2_bufdata *bd;
-       int found = 0;
+       struct gfs2_bufdata *bd, *tmp;
+       struct gfs2_trans *tr = current->journal_info;
+       unsigned int n = len;
 
        gfs2_log_lock(sdp);
-
-       list_for_each_entry(bd, &sdp->sd_log_le_revoke, bd_le.le_list) {
-               if (bd->bd_blkno == blkno) {
+       list_for_each_entry_safe(bd, tmp, &sdp->sd_log_le_revoke, bd_le.le_list) {
+               if ((bd->bd_blkno >= blkno) && (bd->bd_blkno < (blkno + len))) {
                        list_del_init(&bd->bd_le.le_list);
                        gfs2_assert_withdraw(sdp, sdp->sd_log_num_revoke);
                        sdp->sd_log_num_revoke--;
-                       found = 1;
-                       break;
+                       kmem_cache_free(gfs2_bufdata_cachep, bd);
+                       tr->tr_num_revoke_rm++;
+                       if (--n == 0)
+                               break;
                }
        }
-
        gfs2_log_unlock(sdp);
-
-       if (found) {
-               struct gfs2_trans *tr = current->journal_info;
-               kmem_cache_free(gfs2_bufdata_cachep, bd);
-               tr->tr_num_revoke_rm++;
-       }
 }
 
 void gfs2_trans_add_rg(struct gfs2_rgrpd *rgd)
index e826f0dab80a841834d19336e59f9590eed8017f..edf9d4bd908ee2726991f12ac869bfeb60971381 100644 (file)
@@ -32,7 +32,7 @@ void gfs2_trans_end(struct gfs2_sbd *sdp);
 
 void gfs2_trans_add_bh(struct gfs2_glock *gl, struct buffer_head *bh, int meta);
 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, unsigned int len);
 void gfs2_trans_add_rg(struct gfs2_rgrpd *rgd);
 
 #endif /* __TRANS_DOT_H__ */