Commit 2fe5c1d7 authored by Mark Fasheh's avatar Mark Fasheh

ocfs2: clean up bh null checks

If we know a buffer_head is non-null, then brelse() is unnecessary and
put_bh() can be used instead. Also, an explicit check for NULL is
unnecessary when using brelse(). This patch only covers buffer_head_io.c and
resize.c, which have recently added code which exhibits this problem.
Signed-off-by: default avatarMark Fasheh <mark.fasheh@oracle.com>
parent 7ec373cf
...@@ -79,7 +79,7 @@ int ocfs2_write_block(struct ocfs2_super *osb, struct buffer_head *bh, ...@@ -79,7 +79,7 @@ int ocfs2_write_block(struct ocfs2_super *osb, struct buffer_head *bh,
* information for this bh as it's not marked locally * information for this bh as it's not marked locally
* uptodate. */ * uptodate. */
ret = -EIO; ret = -EIO;
brelse(bh); put_bh(bh);
} }
mutex_unlock(&OCFS2_I(inode)->ip_io_mutex); mutex_unlock(&OCFS2_I(inode)->ip_io_mutex);
...@@ -256,7 +256,7 @@ int ocfs2_read_blocks(struct ocfs2_super *osb, u64 block, int nr, ...@@ -256,7 +256,7 @@ int ocfs2_read_blocks(struct ocfs2_super *osb, u64 block, int nr,
* for this bh as it's not marked locally * for this bh as it's not marked locally
* uptodate. */ * uptodate. */
status = -EIO; status = -EIO;
brelse(bh); put_bh(bh);
bhs[i] = NULL; bhs[i] = NULL;
continue; continue;
} }
...@@ -334,7 +334,7 @@ int ocfs2_write_super_or_backup(struct ocfs2_super *osb, ...@@ -334,7 +334,7 @@ int ocfs2_write_super_or_backup(struct ocfs2_super *osb,
if (!buffer_uptodate(bh)) { if (!buffer_uptodate(bh)) {
ret = -EIO; ret = -EIO;
brelse(bh); put_bh(bh);
} }
out: out:
......
...@@ -257,7 +257,6 @@ static void ocfs2_update_super_and_backups(struct inode *inode, ...@@ -257,7 +257,6 @@ static void ocfs2_update_super_and_backups(struct inode *inode,
ret = update_backups(inode, clusters, super_bh->b_data); ret = update_backups(inode, clusters, super_bh->b_data);
out: out:
if (super_bh)
brelse(super_bh); brelse(super_bh);
if (ret) if (ret)
printk(KERN_WARNING "ocfs2: Failed to update super blocks on %s" printk(KERN_WARNING "ocfs2: Failed to update super blocks on %s"
...@@ -380,10 +379,7 @@ int ocfs2_group_extend(struct inode * inode, int new_clusters) ...@@ -380,10 +379,7 @@ int ocfs2_group_extend(struct inode * inode, int new_clusters)
out_commit: out_commit:
ocfs2_commit_trans(osb, handle); ocfs2_commit_trans(osb, handle);
out_unlock: out_unlock:
if (group_bh)
brelse(group_bh); brelse(group_bh);
if (main_bm_bh)
brelse(main_bm_bh); brelse(main_bm_bh);
ocfs2_inode_unlock(main_bm_inode, 1); ocfs2_inode_unlock(main_bm_inode, 1);
...@@ -623,10 +619,7 @@ int ocfs2_group_add(struct inode *inode, struct ocfs2_new_group_input *input) ...@@ -623,10 +619,7 @@ int ocfs2_group_add(struct inode *inode, struct ocfs2_new_group_input *input)
out_commit: out_commit:
ocfs2_commit_trans(osb, handle); ocfs2_commit_trans(osb, handle);
out_unlock: out_unlock:
if (group_bh)
brelse(group_bh); brelse(group_bh);
if (main_bm_bh)
brelse(main_bm_bh); brelse(main_bm_bh);
ocfs2_inode_unlock(main_bm_inode, 1); ocfs2_inode_unlock(main_bm_inode, 1);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment