diff options
author | Steven Whitehouse <swhiteho@redhat.com> | 2006-04-07 16:28:07 -0400 |
---|---|---|
committer | Steven Whitehouse <swhiteho@redhat.com> | 2006-04-07 16:28:07 -0400 |
commit | ed3865079b573ef55dc13ab0bfb242ed5ebab4c1 (patch) | |
tree | 805051b854553a04cc6bb5082a74e3030216372b /fs/gfs2/dir.c | |
parent | b09e593d799560f1a0782c20ac5900058390a26f (diff) |
[GFS2] Finally get ref counting correct
The last patch missed some other instances of incorrect ref counting,
this fixes all of those too.
Signed-off-by: Steven Whitehouse <swhiteho@redhat.com>
Diffstat (limited to 'fs/gfs2/dir.c')
-rw-r--r-- | fs/gfs2/dir.c | 17 |
1 files changed, 12 insertions, 5 deletions
diff --git a/fs/gfs2/dir.c b/fs/gfs2/dir.c index 316eed688f8e..100672d2c6c5 100644 --- a/fs/gfs2/dir.c +++ b/fs/gfs2/dir.c | |||
@@ -776,9 +776,9 @@ static struct gfs2_dirent *gfs2_dirent_search(struct inode *inode, | |||
776 | goto got_dent; | 776 | goto got_dent; |
777 | leaf = (struct gfs2_leaf *)bh->b_data; | 777 | leaf = (struct gfs2_leaf *)bh->b_data; |
778 | ln = be64_to_cpu(leaf->lf_next); | 778 | ln = be64_to_cpu(leaf->lf_next); |
779 | brelse(bh); | ||
780 | if (!ln) | 779 | if (!ln) |
781 | break; | 780 | break; |
781 | brelse(bh); | ||
782 | error = get_leaf(ip, ln, &bh); | 782 | error = get_leaf(ip, ln, &bh); |
783 | } while(!error); | 783 | } while(!error); |
784 | 784 | ||
@@ -789,9 +789,11 @@ static struct gfs2_dirent *gfs2_dirent_search(struct inode *inode, | |||
789 | if (error) | 789 | if (error) |
790 | return ERR_PTR(error); | 790 | return ERR_PTR(error); |
791 | dent = gfs2_dirent_scan(inode, bh->b_data, bh->b_size, scan, name, NULL); | 791 | dent = gfs2_dirent_scan(inode, bh->b_data, bh->b_size, scan, name, NULL); |
792 | brelse(bh); | ||
793 | |||
794 | got_dent: | 792 | got_dent: |
793 | if (unlikely(IS_ERR(dent))) { | ||
794 | brelse(bh); | ||
795 | bh = NULL; | ||
796 | } | ||
795 | *pbh = bh; | 797 | *pbh = bh; |
796 | return dent; | 798 | return dent; |
797 | } | 799 | } |
@@ -1475,6 +1477,7 @@ int gfs2_dir_search(struct inode *dir, const struct qstr *name, | |||
1475 | brelse(bh); | 1477 | brelse(bh); |
1476 | return 0; | 1478 | return 0; |
1477 | } | 1479 | } |
1480 | brelse(bh); | ||
1478 | return -ENOENT; | 1481 | return -ENOENT; |
1479 | } | 1482 | } |
1480 | 1483 | ||
@@ -1616,6 +1619,7 @@ int gfs2_dir_del(struct gfs2_inode *dip, const struct qstr *name) | |||
1616 | previous entry otherwise */ | 1619 | previous entry otherwise */ |
1617 | dent = gfs2_dirent_search(dip->i_vnode, name, gfs2_dirent_prev, &bh); | 1620 | dent = gfs2_dirent_search(dip->i_vnode, name, gfs2_dirent_prev, &bh); |
1618 | if (!dent) { | 1621 | if (!dent) { |
1622 | brelse(bh); | ||
1619 | gfs2_consist_inode(dip); | 1623 | gfs2_consist_inode(dip); |
1620 | return -EIO; | 1624 | return -EIO; |
1621 | } | 1625 | } |
@@ -1636,8 +1640,8 @@ int gfs2_dir_del(struct gfs2_inode *dip, const struct qstr *name) | |||
1636 | if (!entries) | 1640 | if (!entries) |
1637 | gfs2_consist_inode(dip); | 1641 | gfs2_consist_inode(dip); |
1638 | leaf->lf_entries = cpu_to_be16(--entries); | 1642 | leaf->lf_entries = cpu_to_be16(--entries); |
1639 | brelse(bh); | ||
1640 | } | 1643 | } |
1644 | brelse(bh); | ||
1641 | 1645 | ||
1642 | error = gfs2_meta_inode_buffer(dip, &bh); | 1646 | error = gfs2_meta_inode_buffer(dip, &bh); |
1643 | if (error) | 1647 | if (error) |
@@ -1676,6 +1680,7 @@ int gfs2_dir_mvino(struct gfs2_inode *dip, const struct qstr *filename, | |||
1676 | 1680 | ||
1677 | dent = gfs2_dirent_search(dip->i_vnode, filename, gfs2_dirent_find, &bh); | 1681 | dent = gfs2_dirent_search(dip->i_vnode, filename, gfs2_dirent_find, &bh); |
1678 | if (!dent) { | 1682 | if (!dent) { |
1683 | brelse(bh); | ||
1679 | gfs2_consist_inode(dip); | 1684 | gfs2_consist_inode(dip); |
1680 | return -EIO; | 1685 | return -EIO; |
1681 | } | 1686 | } |
@@ -1955,8 +1960,10 @@ int gfs2_diradd_alloc_required(struct inode *inode, | |||
1955 | struct buffer_head *bh; | 1960 | struct buffer_head *bh; |
1956 | 1961 | ||
1957 | dent = gfs2_dirent_search(inode, name, gfs2_dirent_find_space, &bh); | 1962 | dent = gfs2_dirent_search(inode, name, gfs2_dirent_find_space, &bh); |
1958 | if (!dent) | 1963 | if (!dent) { |
1964 | brelse(bh); | ||
1959 | return 1; | 1965 | return 1; |
1966 | } | ||
1960 | if (IS_ERR(dent)) | 1967 | if (IS_ERR(dent)) |
1961 | return PTR_ERR(dent); | 1968 | return PTR_ERR(dent); |
1962 | brelse(bh); | 1969 | brelse(bh); |