]> git.karo-electronics.de Git - linux-beck.git/commitdiff
GFS2: Use cached rgrp in gfs2_rlist_add()
authorSteven Whitehouse <swhiteho@redhat.com>
Fri, 2 Sep 2011 15:08:09 +0000 (16:08 +0100)
committerSteven Whitehouse <swhiteho@redhat.com>
Fri, 21 Oct 2011 11:39:39 +0000 (12:39 +0100)
Each block which is deallocated, requires a call to gfs2_rlist_add()
and each of those calls was calling gfs2_blk2rgrpd() in order to
figure out which rgrp the block belonged in. This can be speeded up
by making use of the rgrp cached in the inode. We also reset this
cached rgrp in case the block has changed rgrp. This should provide
a big reduction in gfs2_blk2rgrpd() calls during deallocation.

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

index 9d3a0c26df286b19fe069afebab173369fc4c11f..22ad413213ca5b64d91d7fff64063c6fdd93028d 100644 (file)
@@ -724,7 +724,7 @@ static int do_strip(struct gfs2_inode *ip, struct buffer_head *dibh,
                        blen++;
                else {
                        if (bstart)
-                               gfs2_rlist_add(sdp, &rlist, bstart);
+                               gfs2_rlist_add(ip, &rlist, bstart);
 
                        bstart = bn;
                        blen = 1;
@@ -732,7 +732,7 @@ static int do_strip(struct gfs2_inode *ip, struct buffer_head *dibh,
        }
 
        if (bstart)
-               gfs2_rlist_add(sdp, &rlist, bstart);
+               gfs2_rlist_add(ip, &rlist, bstart);
        else
                goto out; /* Nothing to do */
 
index 90b877b464ca1438ea4686e07215ab69ab9e98ac..8ccad2467cb64fe5afbaec07db4e97ad2a75206f 100644 (file)
@@ -1821,7 +1821,7 @@ static int leaf_dealloc(struct gfs2_inode *dip, u32 index, u32 len,
                if (blk != leaf_no)
                        brelse(bh);
 
-               gfs2_rlist_add(sdp, &rlist, blk);
+               gfs2_rlist_add(dip, &rlist, blk);
                l_blocks++;
        }
 
index 08b3a8002acaadc07d48106e9451828da0bd7df4..3088fb25656d64fd113b7550c1ce95eab8a6cb10 100644 (file)
@@ -1560,7 +1560,7 @@ fail:
 
 /**
  * gfs2_rlist_add - add a RG to a list of RGs
- * @sdp: the filesystem
+ * @ip: the inode
  * @rlist: the list of resource groups
  * @block: the block
  *
@@ -1570,9 +1570,10 @@ fail:
  *
  */
 
-void gfs2_rlist_add(struct gfs2_sbd *sdp, struct gfs2_rgrp_list *rlist,
+void gfs2_rlist_add(struct gfs2_inode *ip, struct gfs2_rgrp_list *rlist,
                    u64 block)
 {
+       struct gfs2_sbd *sdp = GFS2_SB(&ip->i_inode);
        struct gfs2_rgrpd *rgd;
        struct gfs2_rgrpd **tmp;
        unsigned int new_space;
@@ -1581,12 +1582,15 @@ void gfs2_rlist_add(struct gfs2_sbd *sdp, struct gfs2_rgrp_list *rlist,
        if (gfs2_assert_warn(sdp, !rlist->rl_ghs))
                return;
 
-       rgd = gfs2_blk2rgrpd(sdp, block);
+       if (ip->i_rgd && rgrp_contains_block(ip->i_rgd, block))
+               rgd = ip->i_rgd;
+       else
+               rgd = gfs2_blk2rgrpd(sdp, block);
        if (!rgd) {
-               if (gfs2_consist(sdp))
-                       fs_err(sdp, "block = %llu\n", (unsigned long long)block);
+               fs_err(sdp, "rlist_add: no rgrp for block %llu\n", (unsigned long long)block);
                return;
        }
+       ip->i_rgd = rgd;
 
        for (x = 0; x < rlist->rl_rgrps; x++)
                if (rlist->rl_rgd[x] == rgd)
index 0439fca18f0864959ef5950c8d98d7e7bac4152e..0e886d830784d3f20f2c0410d66a82dc272b0ef5 100644 (file)
@@ -60,7 +60,7 @@ struct gfs2_rgrp_list {
        struct gfs2_holder *rl_ghs;
 };
 
-extern void gfs2_rlist_add(struct gfs2_sbd *sdp, struct gfs2_rgrp_list *rlist,
+extern void gfs2_rlist_add(struct gfs2_inode *ip, struct gfs2_rgrp_list *rlist,
                           u64 block);
 extern void gfs2_rlist_alloc(struct gfs2_rgrp_list *rlist, unsigned int state);
 extern void gfs2_rlist_free(struct gfs2_rgrp_list *rlist);
index e7bf0ea1c3cc82ca177b710020b95b202e850262..71d7bf830c09a44ed22884c75c5ae3f77ec1824d 100644 (file)
@@ -1356,14 +1356,14 @@ static int ea_dealloc_indirect(struct gfs2_inode *ip)
                        blen++;
                else {
                        if (bstart)
-                               gfs2_rlist_add(sdp, &rlist, bstart);
+                               gfs2_rlist_add(ip, &rlist, bstart);
                        bstart = bn;
                        blen = 1;
                }
                blks++;
        }
        if (bstart)
-               gfs2_rlist_add(sdp, &rlist, bstart);
+               gfs2_rlist_add(ip, &rlist, bstart);
        else
                goto out;