Skip to content

Commit

Permalink
ocfs2: Don't check for NULL before brelse()
Browse files Browse the repository at this point in the history
This is pointless as brelse() already does the check.

Signed-off-by: Mark Fasheh
  • Loading branch information
Mark Fasheh committed Oct 14, 2008
1 parent fd8351f commit a81cb88
Show file tree
Hide file tree
Showing 12 changed files with 74 additions and 147 deletions.
33 changes: 11 additions & 22 deletions fs/ocfs2/alloc.c
Original file line number Diff line number Diff line change
Expand Up @@ -719,8 +719,7 @@ int ocfs2_num_free_extents(struct ocfs2_super *osb,

retval = le16_to_cpu(el->l_count) - le16_to_cpu(el->l_next_free_rec);
bail:
if (eb_bh)
brelse(eb_bh);
brelse(eb_bh);

mlog_exit(retval);
return retval;
Expand Down Expand Up @@ -806,8 +805,7 @@ static int ocfs2_create_new_meta_bhs(struct ocfs2_super *osb,
bail:
if (status < 0) {
for(i = 0; i < wanted; i++) {
if (bhs[i])
brelse(bhs[i]);
brelse(bhs[i]);
bhs[i] = NULL;
}
}
Expand Down Expand Up @@ -1017,8 +1015,7 @@ static int ocfs2_add_branch(struct ocfs2_super *osb,
bail:
if (new_eb_bhs) {
for (i = 0; i < new_blocks; i++)
if (new_eb_bhs[i])
brelse(new_eb_bhs[i]);
brelse(new_eb_bhs[i]);
kfree(new_eb_bhs);
}

Expand Down Expand Up @@ -1116,8 +1113,7 @@ static int ocfs2_shift_tree_depth(struct ocfs2_super *osb,
new_eb_bh = NULL;
status = 0;
bail:
if (new_eb_bh)
brelse(new_eb_bh);
brelse(new_eb_bh);

mlog_exit(status);
return status;
Expand Down Expand Up @@ -1177,10 +1173,8 @@ static int ocfs2_find_branch_target(struct ocfs2_super *osb,
goto bail;
}

if (bh) {
brelse(bh);
bh = NULL;
}
brelse(bh);
bh = NULL;

status = ocfs2_read_block(osb, blkno, &bh, OCFS2_BH_CACHED,
inode);
Expand All @@ -1199,8 +1193,7 @@ static int ocfs2_find_branch_target(struct ocfs2_super *osb,

if (le16_to_cpu(el->l_next_free_rec) <
le16_to_cpu(el->l_count)) {
if (lowest_bh)
brelse(lowest_bh);
brelse(lowest_bh);
lowest_bh = bh;
get_bh(lowest_bh);
}
Expand All @@ -1214,8 +1207,7 @@ static int ocfs2_find_branch_target(struct ocfs2_super *osb,

*target_bh = lowest_bh;
bail:
if (bh)
brelse(bh);
brelse(bh);

mlog_exit(status);
return status;
Expand Down Expand Up @@ -4471,8 +4463,7 @@ int ocfs2_insert_extent(struct ocfs2_super *osb,
ocfs2_extent_map_insert_rec(inode, &rec);

bail:
if (last_eb_bh)
brelse(last_eb_bh);
brelse(last_eb_bh);

mlog_exit(status);
return status;
Expand Down Expand Up @@ -5677,8 +5668,7 @@ int ocfs2_begin_truncate_log_recovery(struct ocfs2_super *osb,
bail:
if (tl_inode)
iput(tl_inode);
if (tl_bh)
brelse(tl_bh);
brelse(tl_bh);

if (status < 0 && (*tl_copy)) {
kfree(*tl_copy);
Expand Down Expand Up @@ -7115,8 +7105,7 @@ static void ocfs2_free_truncate_context(struct ocfs2_truncate_context *tc)
mlog(ML_NOTICE,
"Truncate completion has non-empty dealloc context\n");

if (tc->tc_last_eb_bh)
brelse(tc->tc_last_eb_bh);
brelse(tc->tc_last_eb_bh);

kfree(tc);
}
3 changes: 1 addition & 2 deletions fs/ocfs2/aops.c
Original file line number Diff line number Diff line change
Expand Up @@ -128,8 +128,7 @@ static int ocfs2_symlink_get_block(struct inode *inode, sector_t iblock,
err = 0;

bail:
if (bh)
brelse(bh);
brelse(bh);

mlog_exit(err);
return err;
Expand Down
24 changes: 8 additions & 16 deletions fs/ocfs2/dir.c
Original file line number Diff line number Diff line change
Expand Up @@ -716,8 +716,7 @@ static int ocfs2_dir_foreach_blk_el(struct inode *inode,
for (i = ra_sectors >> (sb->s_blocksize_bits - 9);
i > 0; i--) {
tmp = ocfs2_bread(inode, ++blk, &err, 1);
if (tmp)
brelse(tmp);
brelse(tmp);
}
last_ra_blk = blk;
ra_sectors = 8;
Expand Down Expand Up @@ -899,10 +898,8 @@ int ocfs2_find_files_on_disk(const char *name,
leave:
if (status < 0) {
*dirent = NULL;
if (*dirent_bh) {
brelse(*dirent_bh);
*dirent_bh = NULL;
}
brelse(*dirent_bh);
*dirent_bh = NULL;
}

mlog_exit(status);
Expand Down Expand Up @@ -951,8 +948,7 @@ int ocfs2_check_dir_for_entry(struct inode *dir,

ret = 0;
bail:
if (dirent_bh)
brelse(dirent_bh);
brelse(dirent_bh);

mlog_exit(ret);
return ret;
Expand Down Expand Up @@ -1127,8 +1123,7 @@ static int ocfs2_fill_new_dir_el(struct ocfs2_super *osb,

status = 0;
bail:
if (new_bh)
brelse(new_bh);
brelse(new_bh);

mlog_exit(status);
return status;
Expand Down Expand Up @@ -1574,8 +1569,7 @@ static int ocfs2_extend_dir(struct ocfs2_super *osb,
if (meta_ac)
ocfs2_free_alloc_context(meta_ac);

if (new_bh)
brelse(new_bh);
brelse(new_bh);

mlog_exit(status);
return status;
Expand Down Expand Up @@ -1702,8 +1696,7 @@ static int ocfs2_find_dir_space_el(struct inode *dir, const char *name,

status = 0;
bail:
if (bh)
brelse(bh);
brelse(bh);

mlog_exit(status);
return status;
Expand Down Expand Up @@ -1762,7 +1755,6 @@ int ocfs2_prepare_dir_for_insert(struct ocfs2_super *osb,
*ret_de_bh = bh;
bh = NULL;
out:
if (bh)
brelse(bh);
brelse(bh);
return ret;
}
9 changes: 3 additions & 6 deletions fs/ocfs2/file.c
Original file line number Diff line number Diff line change
Expand Up @@ -671,10 +671,8 @@ static int __ocfs2_extend_allocation(struct inode *inode, u32 logical_start,
restart_func = 0;
goto restart_all;
}
if (bh) {
brelse(bh);
bh = NULL;
}
brelse(bh);
bh = NULL;

mlog_exit(status);
return status;
Expand Down Expand Up @@ -991,8 +989,7 @@ int ocfs2_setattr(struct dentry *dentry, struct iattr *attr)
if (size_change)
ocfs2_rw_unlock(inode, 1);
bail:
if (bh)
brelse(bh);
brelse(bh);

mlog_exit(status);
return status;
Expand Down
7 changes: 3 additions & 4 deletions fs/ocfs2/inode.c
Original file line number Diff line number Diff line change
Expand Up @@ -1174,10 +1174,9 @@ struct buffer_head *ocfs2_bread(struct inode *inode,
return bh;

fail:
if (bh) {
brelse(bh);
bh = NULL;
}
brelse(bh);
bh = NULL;

*err = -EIO;
return NULL;
}
Expand Down
3 changes: 1 addition & 2 deletions fs/ocfs2/ioctl.c
Original file line number Diff line number Diff line change
Expand Up @@ -102,8 +102,7 @@ static int ocfs2_set_inode_attr(struct inode *inode, unsigned flags,
bail:
mutex_unlock(&inode->i_mutex);

if (bh)
brelse(bh);
brelse(bh);

mlog_exit(status);
return status;
Expand Down
9 changes: 3 additions & 6 deletions fs/ocfs2/journal.c
Original file line number Diff line number Diff line change
Expand Up @@ -554,8 +554,7 @@ int ocfs2_journal_init(struct ocfs2_journal *journal, int *dirty)
if (status < 0) {
if (inode_lock)
ocfs2_inode_unlock(inode, 1);
if (bh != NULL)
brelse(bh);
brelse(bh);
if (inode) {
OCFS2_I(inode)->ip_open_count--;
iput(inode);
Expand Down Expand Up @@ -869,8 +868,7 @@ static int ocfs2_force_read_journal(struct inode *inode)

bail:
for(i = 0; i < CONCURRENT_JOURNAL_FILL; i++)
if (bhs[i])
brelse(bhs[i]);
brelse(bhs[i]);
mlog_exit(status);
return status;
}
Expand Down Expand Up @@ -1286,8 +1284,7 @@ static int ocfs2_replay_journal(struct ocfs2_super *osb,
if (inode)
iput(inode);

if (bh)
brelse(bh);
brelse(bh);

mlog_exit(status);
return status;
Expand Down
15 changes: 5 additions & 10 deletions fs/ocfs2/localalloc.c
Original file line number Diff line number Diff line change
Expand Up @@ -294,8 +294,7 @@ int ocfs2_load_local_alloc(struct ocfs2_super *osb)

bail:
if (status < 0)
if (alloc_bh)
brelse(alloc_bh);
brelse(alloc_bh);
if (inode)
iput(inode);

Expand Down Expand Up @@ -411,8 +410,7 @@ void ocfs2_shutdown_local_alloc(struct ocfs2_super *osb)
ocfs2_commit_trans(osb, handle);

out_unlock:
if (main_bm_bh)
brelse(main_bm_bh);
brelse(main_bm_bh);

ocfs2_inode_unlock(main_bm_inode, 1);

Expand Down Expand Up @@ -488,8 +486,7 @@ int ocfs2_begin_local_alloc_recovery(struct ocfs2_super *osb,
*alloc_copy = NULL;
}

if (alloc_bh)
brelse(alloc_bh);
brelse(alloc_bh);

if (inode) {
mutex_unlock(&inode->i_mutex);
Expand Down Expand Up @@ -557,8 +554,7 @@ int ocfs2_complete_local_alloc_recovery(struct ocfs2_super *osb,
out_mutex:
mutex_unlock(&main_bm_inode->i_mutex);

if (main_bm_bh)
brelse(main_bm_bh);
brelse(main_bm_bh);

iput(main_bm_inode);

Expand Down Expand Up @@ -1281,8 +1277,7 @@ static int ocfs2_local_alloc_slide_window(struct ocfs2_super *osb,
if (handle)
ocfs2_commit_trans(osb, handle);

if (main_bm_bh)
brelse(main_bm_bh);
brelse(main_bm_bh);

if (main_bm_inode)
iput(main_bm_inode);
Expand Down
Loading

0 comments on commit a81cb88

Please sign in to comment.