aboutsummaryrefslogtreecommitdiffstats
path: root/fs/gfs2
diff options
context:
space:
mode:
authorSteven Whitehouse <swhiteho@redhat.com>2011-09-02 11:08:09 -0400
committerSteven Whitehouse <swhiteho@redhat.com>2011-10-21 07:39:39 -0400
commit70b0c3656f12964a6dac104214c904c66e626058 (patch)
treef58b4b67d6343d5b48c6335fb93ccbe6ed61e1c0 /fs/gfs2
parentd56fa8a1c17b68274349fc852f634af99c0c4671 (diff)
GFS2: Use cached rgrp in gfs2_rlist_add()
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>
Diffstat (limited to 'fs/gfs2')
-rw-r--r--fs/gfs2/bmap.c4
-rw-r--r--fs/gfs2/dir.c2
-rw-r--r--fs/gfs2/rgrp.c14
-rw-r--r--fs/gfs2/rgrp.h2
-rw-r--r--fs/gfs2/xattr.c4
5 files changed, 15 insertions, 11 deletions
diff --git a/fs/gfs2/bmap.c b/fs/gfs2/bmap.c
index 9d3a0c26df28..22ad413213ca 100644
--- a/fs/gfs2/bmap.c
+++ b/fs/gfs2/bmap.c
@@ -724,7 +724,7 @@ static int do_strip(struct gfs2_inode *ip, struct buffer_head *dibh,
724 blen++; 724 blen++;
725 else { 725 else {
726 if (bstart) 726 if (bstart)
727 gfs2_rlist_add(sdp, &rlist, bstart); 727 gfs2_rlist_add(ip, &rlist, bstart);
728 728
729 bstart = bn; 729 bstart = bn;
730 blen = 1; 730 blen = 1;
@@ -732,7 +732,7 @@ static int do_strip(struct gfs2_inode *ip, struct buffer_head *dibh,
732 } 732 }
733 733
734 if (bstart) 734 if (bstart)
735 gfs2_rlist_add(sdp, &rlist, bstart); 735 gfs2_rlist_add(ip, &rlist, bstart);
736 else 736 else
737 goto out; /* Nothing to do */ 737 goto out; /* Nothing to do */
738 738
diff --git a/fs/gfs2/dir.c b/fs/gfs2/dir.c
index 90b877b464ca..8ccad2467cb6 100644
--- a/fs/gfs2/dir.c
+++ b/fs/gfs2/dir.c
@@ -1821,7 +1821,7 @@ static int leaf_dealloc(struct gfs2_inode *dip, u32 index, u32 len,
1821 if (blk != leaf_no) 1821 if (blk != leaf_no)
1822 brelse(bh); 1822 brelse(bh);
1823 1823
1824 gfs2_rlist_add(sdp, &rlist, blk); 1824 gfs2_rlist_add(dip, &rlist, blk);
1825 l_blocks++; 1825 l_blocks++;
1826 } 1826 }
1827 1827
diff --git a/fs/gfs2/rgrp.c b/fs/gfs2/rgrp.c
index 08b3a8002aca..3088fb25656d 100644
--- a/fs/gfs2/rgrp.c
+++ b/fs/gfs2/rgrp.c
@@ -1560,7 +1560,7 @@ fail:
1560 1560
1561/** 1561/**
1562 * gfs2_rlist_add - add a RG to a list of RGs 1562 * gfs2_rlist_add - add a RG to a list of RGs
1563 * @sdp: the filesystem 1563 * @ip: the inode
1564 * @rlist: the list of resource groups 1564 * @rlist: the list of resource groups
1565 * @block: the block 1565 * @block: the block
1566 * 1566 *
@@ -1570,9 +1570,10 @@ fail:
1570 * 1570 *
1571 */ 1571 */
1572 1572
1573void gfs2_rlist_add(struct gfs2_sbd *sdp, struct gfs2_rgrp_list *rlist, 1573void gfs2_rlist_add(struct gfs2_inode *ip, struct gfs2_rgrp_list *rlist,
1574 u64 block) 1574 u64 block)
1575{ 1575{
1576 struct gfs2_sbd *sdp = GFS2_SB(&ip->i_inode);
1576 struct gfs2_rgrpd *rgd; 1577 struct gfs2_rgrpd *rgd;
1577 struct gfs2_rgrpd **tmp; 1578 struct gfs2_rgrpd **tmp;
1578 unsigned int new_space; 1579 unsigned int new_space;
@@ -1581,12 +1582,15 @@ void gfs2_rlist_add(struct gfs2_sbd *sdp, struct gfs2_rgrp_list *rlist,
1581 if (gfs2_assert_warn(sdp, !rlist->rl_ghs)) 1582 if (gfs2_assert_warn(sdp, !rlist->rl_ghs))
1582 return; 1583 return;
1583 1584
1584 rgd = gfs2_blk2rgrpd(sdp, block); 1585 if (ip->i_rgd && rgrp_contains_block(ip->i_rgd, block))
1586 rgd = ip->i_rgd;
1587 else
1588 rgd = gfs2_blk2rgrpd(sdp, block);
1585 if (!rgd) { 1589 if (!rgd) {
1586 if (gfs2_consist(sdp)) 1590 fs_err(sdp, "rlist_add: no rgrp for block %llu\n", (unsigned long long)block);
1587 fs_err(sdp, "block = %llu\n", (unsigned long long)block);
1588 return; 1591 return;
1589 } 1592 }
1593 ip->i_rgd = rgd;
1590 1594
1591 for (x = 0; x < rlist->rl_rgrps; x++) 1595 for (x = 0; x < rlist->rl_rgrps; x++)
1592 if (rlist->rl_rgd[x] == rgd) 1596 if (rlist->rl_rgd[x] == rgd)
diff --git a/fs/gfs2/rgrp.h b/fs/gfs2/rgrp.h
index 0439fca18f08..0e886d830784 100644
--- a/fs/gfs2/rgrp.h
+++ b/fs/gfs2/rgrp.h
@@ -60,7 +60,7 @@ struct gfs2_rgrp_list {
60 struct gfs2_holder *rl_ghs; 60 struct gfs2_holder *rl_ghs;
61}; 61};
62 62
63extern void gfs2_rlist_add(struct gfs2_sbd *sdp, struct gfs2_rgrp_list *rlist, 63extern void gfs2_rlist_add(struct gfs2_inode *ip, struct gfs2_rgrp_list *rlist,
64 u64 block); 64 u64 block);
65extern void gfs2_rlist_alloc(struct gfs2_rgrp_list *rlist, unsigned int state); 65extern void gfs2_rlist_alloc(struct gfs2_rgrp_list *rlist, unsigned int state);
66extern void gfs2_rlist_free(struct gfs2_rgrp_list *rlist); 66extern void gfs2_rlist_free(struct gfs2_rgrp_list *rlist);
diff --git a/fs/gfs2/xattr.c b/fs/gfs2/xattr.c
index e7bf0ea1c3cc..71d7bf830c09 100644
--- a/fs/gfs2/xattr.c
+++ b/fs/gfs2/xattr.c
@@ -1356,14 +1356,14 @@ static int ea_dealloc_indirect(struct gfs2_inode *ip)
1356 blen++; 1356 blen++;
1357 else { 1357 else {
1358 if (bstart) 1358 if (bstart)
1359 gfs2_rlist_add(sdp, &rlist, bstart); 1359 gfs2_rlist_add(ip, &rlist, bstart);
1360 bstart = bn; 1360 bstart = bn;
1361 blen = 1; 1361 blen = 1;
1362 } 1362 }
1363 blks++; 1363 blks++;
1364 } 1364 }
1365 if (bstart) 1365 if (bstart)
1366 gfs2_rlist_add(sdp, &rlist, bstart); 1366 gfs2_rlist_add(ip, &rlist, bstart);
1367 else 1367 else
1368 goto out; 1368 goto out;
1369 1369