aboutsummaryrefslogtreecommitdiffstats
path: root/fs/gfs2/rgrp.c
diff options
context:
space:
mode:
authorEric Sandeen <sandeen@redhat.com>2011-06-23 11:39:34 -0400
committerSteven Whitehouse <swhiteho@redhat.com>2011-07-15 04:32:52 -0400
commit46fcb2ed29ff7a9ec34c4ae67b631743eb7e756f (patch)
treef28487201dd8fe815192b75d1b29426a7882a01b /fs/gfs2/rgrp.c
parent9964afbb797329e4c6e5d05ebc199c39af618c5f (diff)
GFS2: combine duplicated block freeing routines
__gfs2_free_data and __gfs2_free_meta are almost identical, and can be trivially combined. [This is as per Eric's original patch minus gfs2_free_data() which had no callers left and plus the conversion of the bmap.c calls to these functions. All in all, a nice clean up] Signed-off-by: Eric Sandeen <sandeen@redhat.com> Signed-off-by: Steven Whitehouse <swhiteho@redhat.com>
Diffstat (limited to 'fs/gfs2/rgrp.c')
-rw-r--r--fs/gfs2/rgrp.c52
1 files changed, 5 insertions, 47 deletions
diff --git a/fs/gfs2/rgrp.c b/fs/gfs2/rgrp.c
index 9b780df3fd5..7f8af1eb02d 100644
--- a/fs/gfs2/rgrp.c
+++ b/fs/gfs2/rgrp.c
@@ -1607,14 +1607,15 @@ rgrp_error:
1607} 1607}
1608 1608
1609/** 1609/**
1610 * gfs2_free_data - free a contiguous run of data block(s) 1610 * __gfs2_free_blocks - free a contiguous run of block(s)
1611 * @ip: the inode these blocks are being freed from 1611 * @ip: the inode these blocks are being freed from
1612 * @bstart: first block of a run of contiguous blocks 1612 * @bstart: first block of a run of contiguous blocks
1613 * @blen: the length of the block run 1613 * @blen: the length of the block run
1614 * @meta: 1 if the blocks represent metadata
1614 * 1615 *
1615 */ 1616 */
1616 1617
1617void __gfs2_free_data(struct gfs2_inode *ip, u64 bstart, u32 blen) 1618void __gfs2_free_blocks(struct gfs2_inode *ip, u64 bstart, u32 blen, int meta)
1618{ 1619{
1619 struct gfs2_sbd *sdp = GFS2_SB(&ip->i_inode); 1620 struct gfs2_sbd *sdp = GFS2_SB(&ip->i_inode);
1620 struct gfs2_rgrpd *rgd; 1621 struct gfs2_rgrpd *rgd;
@@ -1631,54 +1632,11 @@ void __gfs2_free_data(struct gfs2_inode *ip, u64 bstart, u32 blen)
1631 gfs2_trans_add_rg(rgd); 1632 gfs2_trans_add_rg(rgd);
1632 1633
1633 /* Directories keep their data in the metadata address space */ 1634 /* Directories keep their data in the metadata address space */
1634 if (ip->i_depth) 1635 if (meta || ip->i_depth)
1635 gfs2_meta_wipe(ip, bstart, blen); 1636 gfs2_meta_wipe(ip, bstart, blen);
1636} 1637}
1637 1638
1638/** 1639/**
1639 * gfs2_free_data - free a contiguous run of data block(s)
1640 * @ip: the inode these blocks are being freed from
1641 * @bstart: first block of a run of contiguous blocks
1642 * @blen: the length of the block run
1643 *
1644 */
1645
1646void gfs2_free_data(struct gfs2_inode *ip, u64 bstart, u32 blen)
1647{
1648 struct gfs2_sbd *sdp = GFS2_SB(&ip->i_inode);
1649
1650 __gfs2_free_data(ip, bstart, blen);
1651 gfs2_statfs_change(sdp, 0, +blen, 0);
1652 gfs2_quota_change(ip, -(s64)blen, ip->i_inode.i_uid, ip->i_inode.i_gid);
1653}
1654
1655/**
1656 * gfs2_free_meta - free a contiguous run of data block(s)
1657 * @ip: the inode these blocks are being freed from
1658 * @bstart: first block of a run of contiguous blocks
1659 * @blen: the length of the block run
1660 *
1661 */
1662
1663void __gfs2_free_meta(struct gfs2_inode *ip, u64 bstart, u32 blen)
1664{
1665 struct gfs2_sbd *sdp = GFS2_SB(&ip->i_inode);
1666 struct gfs2_rgrpd *rgd;
1667
1668 rgd = rgblk_free(sdp, bstart, blen, GFS2_BLKST_FREE);
1669 if (!rgd)
1670 return;
1671 trace_gfs2_block_alloc(ip, bstart, blen, GFS2_BLKST_FREE);
1672 rgd->rd_free += blen;
1673
1674 gfs2_trans_add_bh(rgd->rd_gl, rgd->rd_bits[0].bi_bh, 1);
1675 gfs2_rgrp_out(rgd, rgd->rd_bits[0].bi_bh->b_data);
1676
1677 gfs2_trans_add_rg(rgd);
1678 gfs2_meta_wipe(ip, bstart, blen);
1679}
1680
1681/**
1682 * gfs2_free_meta - free a contiguous run of data block(s) 1640 * gfs2_free_meta - free a contiguous run of data block(s)
1683 * @ip: the inode these blocks are being freed from 1641 * @ip: the inode these blocks are being freed from
1684 * @bstart: first block of a run of contiguous blocks 1642 * @bstart: first block of a run of contiguous blocks
@@ -1690,7 +1648,7 @@ void gfs2_free_meta(struct gfs2_inode *ip, u64 bstart, u32 blen)
1690{ 1648{
1691 struct gfs2_sbd *sdp = GFS2_SB(&ip->i_inode); 1649 struct gfs2_sbd *sdp = GFS2_SB(&ip->i_inode);
1692 1650
1693 __gfs2_free_meta(ip, bstart, blen); 1651 __gfs2_free_blocks(ip, bstart, blen, 1);
1694 gfs2_statfs_change(sdp, 0, +blen, 0); 1652 gfs2_statfs_change(sdp, 0, +blen, 0);
1695 gfs2_quota_change(ip, -(s64)blen, ip->i_inode.i_uid, ip->i_inode.i_gid); 1653 gfs2_quota_change(ip, -(s64)blen, ip->i_inode.i_uid, ip->i_inode.i_gid);
1696} 1654}