diff options
author | Bob Peterson <rpeterso@redhat.com> | 2011-03-22 13:55:23 -0400 |
---|---|---|
committer | Steven Whitehouse <swhiteho@redhat.com> | 2011-04-20 03:54:26 -0400 |
commit | ec038c826b5c3c163ad1673390f10e869020c28c (patch) | |
tree | 11d97ed7a40033e1bf113e3ca7fa28e4f22bfe0d /fs/gfs2 | |
parent | d24a7a439a329b60f8e168c03e80566519e09be2 (diff) |
GFS2: pass leaf_bh into leaf_dealloc
Function foreach_leaf used to look up the leaf block address and get
a buffer_head. Then it would call leaf_dealloc which did the same
lookup. This patch combines the two operations by making foreach_leaf
pass the leaf bh to leaf_dealloc.
Signed-off-by: Bob Peterson <rpeterso@redhat.com>
Signed-off-by: Steven Whitehouse <swhiteho@redhat.com>
Diffstat (limited to 'fs/gfs2')
-rw-r--r-- | fs/gfs2/dir.c | 35 |
1 files changed, 24 insertions, 11 deletions
diff --git a/fs/gfs2/dir.c b/fs/gfs2/dir.c index bd575871f0f2..1f5a7ac97f7d 100644 --- a/fs/gfs2/dir.c +++ b/fs/gfs2/dir.c | |||
@@ -86,7 +86,8 @@ typedef int (*gfs2_dscan_t)(const struct gfs2_dirent *dent, | |||
86 | const struct qstr *name, void *opaque); | 86 | const struct qstr *name, void *opaque); |
87 | 87 | ||
88 | static int leaf_dealloc(struct gfs2_inode *dip, u32 index, u32 len, | 88 | static int leaf_dealloc(struct gfs2_inode *dip, u32 index, u32 len, |
89 | u64 leaf_no, int last_dealloc); | 89 | u64 leaf_no, struct buffer_head *leaf_bh, |
90 | int last_dealloc); | ||
90 | 91 | ||
91 | int gfs2_dir_get_new_buffer(struct gfs2_inode *ip, u64 block, | 92 | int gfs2_dir_get_new_buffer(struct gfs2_inode *ip, u64 block, |
92 | struct buffer_head **bhp) | 93 | struct buffer_head **bhp) |
@@ -1821,8 +1822,9 @@ static int foreach_leaf(struct gfs2_inode *dip) | |||
1821 | len = 1 << (dip->i_depth - be16_to_cpu(leaf->lf_depth)); | 1822 | len = 1 << (dip->i_depth - be16_to_cpu(leaf->lf_depth)); |
1822 | next_index = (index & ~(len - 1)) + len; | 1823 | next_index = (index & ~(len - 1)) + len; |
1823 | last = ((next_index >= hsize) ? 1 : 0); | 1824 | last = ((next_index >= hsize) ? 1 : 0); |
1825 | error = leaf_dealloc(dip, index, len, leaf_no, bh, | ||
1826 | last); | ||
1824 | brelse(bh); | 1827 | brelse(bh); |
1825 | error = leaf_dealloc(dip, index, len, leaf_no, last); | ||
1826 | if (error) | 1828 | if (error) |
1827 | goto out; | 1829 | goto out; |
1828 | index = next_index; | 1830 | index = next_index; |
@@ -1847,13 +1849,15 @@ out: | |||
1847 | * @index: the hash table offset in the directory | 1849 | * @index: the hash table offset in the directory |
1848 | * @len: the number of pointers to this leaf | 1850 | * @len: the number of pointers to this leaf |
1849 | * @leaf_no: the leaf number | 1851 | * @leaf_no: the leaf number |
1852 | * @leaf_bh: buffer_head for the starting leaf | ||
1850 | * last_dealloc: 1 if this is the final dealloc for the leaf, else 0 | 1853 | * last_dealloc: 1 if this is the final dealloc for the leaf, else 0 |
1851 | * | 1854 | * |
1852 | * Returns: errno | 1855 | * Returns: errno |
1853 | */ | 1856 | */ |
1854 | 1857 | ||
1855 | static int leaf_dealloc(struct gfs2_inode *dip, u32 index, u32 len, | 1858 | static int leaf_dealloc(struct gfs2_inode *dip, u32 index, u32 len, |
1856 | u64 leaf_no, int last_dealloc) | 1859 | u64 leaf_no, struct buffer_head *leaf_bh, |
1860 | int last_dealloc) | ||
1857 | { | 1861 | { |
1858 | struct gfs2_sbd *sdp = GFS2_SB(&dip->i_inode); | 1862 | struct gfs2_sbd *sdp = GFS2_SB(&dip->i_inode); |
1859 | struct gfs2_leaf *tmp_leaf; | 1863 | struct gfs2_leaf *tmp_leaf; |
@@ -1885,14 +1889,18 @@ static int leaf_dealloc(struct gfs2_inode *dip, u32 index, u32 len, | |||
1885 | goto out_qs; | 1889 | goto out_qs; |
1886 | 1890 | ||
1887 | /* Count the number of leaves */ | 1891 | /* Count the number of leaves */ |
1892 | bh = leaf_bh; | ||
1888 | 1893 | ||
1889 | for (blk = leaf_no; blk; blk = nblk) { | 1894 | for (blk = leaf_no; blk; blk = nblk) { |
1890 | error = get_leaf(dip, blk, &bh); | 1895 | if (blk != leaf_no) { |
1891 | if (error) | 1896 | error = get_leaf(dip, blk, &bh); |
1892 | goto out_rlist; | 1897 | if (error) |
1898 | goto out_rlist; | ||
1899 | } | ||
1893 | tmp_leaf = (struct gfs2_leaf *)bh->b_data; | 1900 | tmp_leaf = (struct gfs2_leaf *)bh->b_data; |
1894 | nblk = be64_to_cpu(tmp_leaf->lf_next); | 1901 | nblk = be64_to_cpu(tmp_leaf->lf_next); |
1895 | brelse(bh); | 1902 | if (blk != leaf_no) |
1903 | brelse(bh); | ||
1896 | 1904 | ||
1897 | gfs2_rlist_add(sdp, &rlist, blk); | 1905 | gfs2_rlist_add(sdp, &rlist, blk); |
1898 | l_blocks++; | 1906 | l_blocks++; |
@@ -1916,13 +1924,18 @@ static int leaf_dealloc(struct gfs2_inode *dip, u32 index, u32 len, | |||
1916 | if (error) | 1924 | if (error) |
1917 | goto out_rg_gunlock; | 1925 | goto out_rg_gunlock; |
1918 | 1926 | ||
1927 | bh = leaf_bh; | ||
1928 | |||
1919 | for (blk = leaf_no; blk; blk = nblk) { | 1929 | for (blk = leaf_no; blk; blk = nblk) { |
1920 | error = get_leaf(dip, blk, &bh); | 1930 | if (blk != leaf_no) { |
1921 | if (error) | 1931 | error = get_leaf(dip, blk, &bh); |
1922 | goto out_end_trans; | 1932 | if (error) |
1933 | goto out_end_trans; | ||
1934 | } | ||
1923 | tmp_leaf = (struct gfs2_leaf *)bh->b_data; | 1935 | tmp_leaf = (struct gfs2_leaf *)bh->b_data; |
1924 | nblk = be64_to_cpu(tmp_leaf->lf_next); | 1936 | nblk = be64_to_cpu(tmp_leaf->lf_next); |
1925 | brelse(bh); | 1937 | if (blk != leaf_no) |
1938 | brelse(bh); | ||
1926 | 1939 | ||
1927 | gfs2_free_meta(dip, blk, 1); | 1940 | gfs2_free_meta(dip, blk, 1); |
1928 | gfs2_add_inode_blocks(&dip->i_inode, -1); | 1941 | gfs2_add_inode_blocks(&dip->i_inode, -1); |