提交 ed386507 编写于 作者: S Steven Whitehouse

[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: NSteven Whitehouse <swhiteho@redhat.com>
上级 b09e593d
...@@ -776,9 +776,9 @@ static struct gfs2_dirent *gfs2_dirent_search(struct inode *inode, ...@@ -776,9 +776,9 @@ static struct gfs2_dirent *gfs2_dirent_search(struct inode *inode,
goto got_dent; goto got_dent;
leaf = (struct gfs2_leaf *)bh->b_data; leaf = (struct gfs2_leaf *)bh->b_data;
ln = be64_to_cpu(leaf->lf_next); ln = be64_to_cpu(leaf->lf_next);
brelse(bh);
if (!ln) if (!ln)
break; break;
brelse(bh);
error = get_leaf(ip, ln, &bh); error = get_leaf(ip, ln, &bh);
} while(!error); } while(!error);
...@@ -789,9 +789,11 @@ static struct gfs2_dirent *gfs2_dirent_search(struct inode *inode, ...@@ -789,9 +789,11 @@ static struct gfs2_dirent *gfs2_dirent_search(struct inode *inode,
if (error) if (error)
return ERR_PTR(error); return ERR_PTR(error);
dent = gfs2_dirent_scan(inode, bh->b_data, bh->b_size, scan, name, NULL); dent = gfs2_dirent_scan(inode, bh->b_data, bh->b_size, scan, name, NULL);
brelse(bh);
got_dent: got_dent:
if (unlikely(IS_ERR(dent))) {
brelse(bh);
bh = NULL;
}
*pbh = bh; *pbh = bh;
return dent; return dent;
} }
...@@ -1475,6 +1477,7 @@ int gfs2_dir_search(struct inode *dir, const struct qstr *name, ...@@ -1475,6 +1477,7 @@ int gfs2_dir_search(struct inode *dir, const struct qstr *name,
brelse(bh); brelse(bh);
return 0; return 0;
} }
brelse(bh);
return -ENOENT; return -ENOENT;
} }
...@@ -1616,6 +1619,7 @@ int gfs2_dir_del(struct gfs2_inode *dip, const struct qstr *name) ...@@ -1616,6 +1619,7 @@ int gfs2_dir_del(struct gfs2_inode *dip, const struct qstr *name)
previous entry otherwise */ previous entry otherwise */
dent = gfs2_dirent_search(dip->i_vnode, name, gfs2_dirent_prev, &bh); dent = gfs2_dirent_search(dip->i_vnode, name, gfs2_dirent_prev, &bh);
if (!dent) { if (!dent) {
brelse(bh);
gfs2_consist_inode(dip); gfs2_consist_inode(dip);
return -EIO; return -EIO;
} }
...@@ -1636,8 +1640,8 @@ int gfs2_dir_del(struct gfs2_inode *dip, const struct qstr *name) ...@@ -1636,8 +1640,8 @@ int gfs2_dir_del(struct gfs2_inode *dip, const struct qstr *name)
if (!entries) if (!entries)
gfs2_consist_inode(dip); gfs2_consist_inode(dip);
leaf->lf_entries = cpu_to_be16(--entries); leaf->lf_entries = cpu_to_be16(--entries);
brelse(bh);
} }
brelse(bh);
error = gfs2_meta_inode_buffer(dip, &bh); error = gfs2_meta_inode_buffer(dip, &bh);
if (error) if (error)
...@@ -1676,6 +1680,7 @@ int gfs2_dir_mvino(struct gfs2_inode *dip, const struct qstr *filename, ...@@ -1676,6 +1680,7 @@ int gfs2_dir_mvino(struct gfs2_inode *dip, const struct qstr *filename,
dent = gfs2_dirent_search(dip->i_vnode, filename, gfs2_dirent_find, &bh); dent = gfs2_dirent_search(dip->i_vnode, filename, gfs2_dirent_find, &bh);
if (!dent) { if (!dent) {
brelse(bh);
gfs2_consist_inode(dip); gfs2_consist_inode(dip);
return -EIO; return -EIO;
} }
...@@ -1955,8 +1960,10 @@ int gfs2_diradd_alloc_required(struct inode *inode, ...@@ -1955,8 +1960,10 @@ int gfs2_diradd_alloc_required(struct inode *inode,
struct buffer_head *bh; struct buffer_head *bh;
dent = gfs2_dirent_search(inode, name, gfs2_dirent_find_space, &bh); dent = gfs2_dirent_search(inode, name, gfs2_dirent_find_space, &bh);
if (!dent) if (!dent) {
brelse(bh);
return 1; return 1;
}
if (IS_ERR(dent)) if (IS_ERR(dent))
return PTR_ERR(dent); return PTR_ERR(dent);
brelse(bh); brelse(bh);
......
...@@ -196,7 +196,6 @@ int gfs2_log_reserve(struct gfs2_sbd *sdp, unsigned int blks) ...@@ -196,7 +196,6 @@ int gfs2_log_reserve(struct gfs2_sbd *sdp, unsigned int blks)
void gfs2_log_release(struct gfs2_sbd *sdp, unsigned int blks) void gfs2_log_release(struct gfs2_sbd *sdp, unsigned int blks)
{ {
up_read(&sdp->sd_log_flush_lock);
gfs2_log_lock(sdp); gfs2_log_lock(sdp);
sdp->sd_log_blks_free += blks; sdp->sd_log_blks_free += blks;
...@@ -204,6 +203,7 @@ void gfs2_log_release(struct gfs2_sbd *sdp, unsigned int blks) ...@@ -204,6 +203,7 @@ void gfs2_log_release(struct gfs2_sbd *sdp, unsigned int blks)
gfs2_assert_withdraw(sdp, gfs2_assert_withdraw(sdp,
sdp->sd_log_blks_free <= sdp->sd_jdesc->jd_blocks); sdp->sd_log_blks_free <= sdp->sd_jdesc->jd_blocks);
gfs2_log_unlock(sdp); gfs2_log_unlock(sdp);
up_read(&sdp->sd_log_flush_lock);
} }
static uint64_t log_bmap(struct gfs2_sbd *sdp, unsigned int lbn) static uint64_t log_bmap(struct gfs2_sbd *sdp, unsigned int lbn)
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册