ocfs2: Don't check for NULL before brelse()

This is pointless as brelse() already does the check.

Signed-off-by: Mark Fasheh
This commit is contained in:
Mark Fasheh 2008-10-07 14:25:16 -07:00
parent fd8351f83d
commit a81cb88b64
12 changed files with 74 additions and 147 deletions

View File

@ -719,7 +719,6 @@ 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);
mlog_exit(retval);
@ -806,7 +805,6 @@ 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]);
bhs[i] = NULL;
}
@ -1017,7 +1015,6 @@ 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]);
kfree(new_eb_bhs);
}
@ -1116,7 +1113,6 @@ 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);
mlog_exit(status);
@ -1177,10 +1173,8 @@ static int ocfs2_find_branch_target(struct ocfs2_super *osb,
goto bail;
}
if (bh) {
brelse(bh);
bh = NULL;
}
status = ocfs2_read_block(osb, blkno, &bh, OCFS2_BH_CACHED,
inode);
@ -1199,7 +1193,6 @@ 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);
lowest_bh = bh;
get_bh(lowest_bh);
@ -1214,7 +1207,6 @@ static int ocfs2_find_branch_target(struct ocfs2_super *osb,
*target_bh = lowest_bh;
bail:
if (bh)
brelse(bh);
mlog_exit(status);
@ -4471,7 +4463,6 @@ int ocfs2_insert_extent(struct ocfs2_super *osb,
ocfs2_extent_map_insert_rec(inode, &rec);
bail:
if (last_eb_bh)
brelse(last_eb_bh);
mlog_exit(status);
@ -5677,7 +5668,6 @@ int ocfs2_begin_truncate_log_recovery(struct ocfs2_super *osb,
bail:
if (tl_inode)
iput(tl_inode);
if (tl_bh)
brelse(tl_bh);
if (status < 0 && (*tl_copy)) {
@ -7115,7 +7105,6 @@ 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);
kfree(tc);

View File

@ -128,7 +128,6 @@ static int ocfs2_symlink_get_block(struct inode *inode, sector_t iblock,
err = 0;
bail:
if (bh)
brelse(bh);
mlog_exit(err);

View File

@ -716,7 +716,6 @@ 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);
}
last_ra_blk = blk;
@ -899,11 +898,9 @@ int ocfs2_find_files_on_disk(const char *name,
leave:
if (status < 0) {
*dirent = NULL;
if (*dirent_bh) {
brelse(*dirent_bh);
*dirent_bh = NULL;
}
}
mlog_exit(status);
return status;
@ -951,7 +948,6 @@ int ocfs2_check_dir_for_entry(struct inode *dir,
ret = 0;
bail:
if (dirent_bh)
brelse(dirent_bh);
mlog_exit(ret);
@ -1127,7 +1123,6 @@ static int ocfs2_fill_new_dir_el(struct ocfs2_super *osb,
status = 0;
bail:
if (new_bh)
brelse(new_bh);
mlog_exit(status);
@ -1574,7 +1569,6 @@ bail:
if (meta_ac)
ocfs2_free_alloc_context(meta_ac);
if (new_bh)
brelse(new_bh);
mlog_exit(status);
@ -1702,7 +1696,6 @@ static int ocfs2_find_dir_space_el(struct inode *dir, const char *name,
status = 0;
bail:
if (bh)
brelse(bh);
mlog_exit(status);
@ -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);
return ret;
}

View File

@ -671,10 +671,8 @@ leave:
restart_func = 0;
goto restart_all;
}
if (bh) {
brelse(bh);
bh = NULL;
}
mlog_exit(status);
return status;
@ -991,7 +989,6 @@ bail_unlock_rw:
if (size_change)
ocfs2_rw_unlock(inode, 1);
bail:
if (bh)
brelse(bh);
mlog_exit(status);

View File

@ -1174,10 +1174,9 @@ struct buffer_head *ocfs2_bread(struct inode *inode,
return bh;
fail:
if (bh) {
brelse(bh);
bh = NULL;
}
*err = -EIO;
return NULL;
}

View File

@ -102,7 +102,6 @@ bail_unlock:
bail:
mutex_unlock(&inode->i_mutex);
if (bh)
brelse(bh);
mlog_exit(status);

View File

@ -554,7 +554,6 @@ done:
if (status < 0) {
if (inode_lock)
ocfs2_inode_unlock(inode, 1);
if (bh != NULL)
brelse(bh);
if (inode) {
OCFS2_I(inode)->ip_open_count--;
@ -869,7 +868,6 @@ static int ocfs2_force_read_journal(struct inode *inode)
bail:
for(i = 0; i < CONCURRENT_JOURNAL_FILL; i++)
if (bhs[i])
brelse(bhs[i]);
mlog_exit(status);
return status;
@ -1286,7 +1284,6 @@ done:
if (inode)
iput(inode);
if (bh)
brelse(bh);
mlog_exit(status);

View File

@ -294,7 +294,6 @@ int ocfs2_load_local_alloc(struct ocfs2_super *osb)
bail:
if (status < 0)
if (alloc_bh)
brelse(alloc_bh);
if (inode)
iput(inode);
@ -411,7 +410,6 @@ out_commit:
ocfs2_commit_trans(osb, handle);
out_unlock:
if (main_bm_bh)
brelse(main_bm_bh);
ocfs2_inode_unlock(main_bm_inode, 1);
@ -488,7 +486,6 @@ bail:
*alloc_copy = NULL;
}
if (alloc_bh)
brelse(alloc_bh);
if (inode) {
@ -557,7 +554,6 @@ out_unlock:
out_mutex:
mutex_unlock(&main_bm_inode->i_mutex);
if (main_bm_bh)
brelse(main_bm_bh);
iput(main_bm_inode);
@ -1281,7 +1277,6 @@ bail:
if (handle)
ocfs2_commit_trans(osb, handle);
if (main_bm_bh)
brelse(main_bm_bh);
if (main_bm_inode)

View File

@ -328,13 +328,8 @@ leave:
if (status == -ENOSPC)
mlog(0, "Disk is full\n");
if (new_fe_bh)
brelse(new_fe_bh);
if (de_bh)
brelse(de_bh);
if (parent_fe_bh)
brelse(parent_fe_bh);
if ((status < 0) && inode)
@ -648,11 +643,8 @@ out_unlock_inode:
out:
ocfs2_inode_unlock(dir, 1);
if (de_bh)
brelse(de_bh);
if (fe_bh)
brelse(fe_bh);
if (parent_fe_bh)
brelse(parent_fe_bh);
mlog_exit(err);
@ -852,16 +844,9 @@ leave:
iput(orphan_dir);
}
if (fe_bh)
brelse(fe_bh);
if (dirent_bh)
brelse(dirent_bh);
if (parent_node_bh)
brelse(parent_node_bh);
if (orphan_entry_bh)
brelse(orphan_entry_bh);
mlog_exit(status);
@ -1373,23 +1358,14 @@ bail:
if (new_inode)
iput(new_inode);
if (newfe_bh)
brelse(newfe_bh);
if (old_inode_bh)
brelse(old_inode_bh);
if (old_dir_bh)
brelse(old_dir_bh);
if (new_dir_bh)
brelse(new_dir_bh);
if (new_de_bh)
brelse(new_de_bh);
if (old_de_bh)
brelse(old_de_bh);
if (old_inode_de_bh)
brelse(old_inode_de_bh);
if (orphan_entry_bh)
brelse(orphan_entry_bh);
if (insert_entry_bh)
brelse(insert_entry_bh);
mlog_exit(status);
@ -1493,7 +1469,6 @@ bail:
if (bhs) {
for(i = 0; i < blocks; i++)
if (bhs[i])
brelse(bhs[i]);
kfree(bhs);
}
@ -1660,11 +1635,8 @@ bail:
ocfs2_inode_unlock(dir, 1);
if (new_fe_bh)
brelse(new_fe_bh);
if (parent_fe_bh)
brelse(parent_fe_bh);
if (de_bh)
brelse(de_bh);
if (inode_ac)
ocfs2_free_alloc_context(inode_ac);
@ -1760,7 +1732,6 @@ leave:
iput(orphan_dir_inode);
}
if (orphan_dir_bh)
brelse(orphan_dir_bh);
mlog_exit(status);
@ -1830,7 +1801,6 @@ static int ocfs2_orphan_add(struct ocfs2_super *osb,
(unsigned long long)OCFS2_I(inode)->ip_blkno, osb->slot_num);
leave:
if (orphan_dir_bh)
brelse(orphan_dir_bh);
mlog_exit(status);
@ -1899,7 +1869,6 @@ int ocfs2_orphan_del(struct ocfs2_super *osb,
}
leave:
if (target_de_bh)
brelse(target_de_bh);
mlog_exit(status);

View File

@ -130,11 +130,9 @@ void ocfs2_free_ac_resource(struct ocfs2_alloc_context *ac)
iput(inode);
ac->ac_inode = NULL;
}
if (ac->ac_bh) {
brelse(ac->ac_bh);
ac->ac_bh = NULL;
}
}
void ocfs2_free_alloc_context(struct ocfs2_alloc_context *ac)
{
@ -401,7 +399,6 @@ bail:
if (ac)
ocfs2_free_alloc_context(ac);
if (bg_bh)
brelse(bg_bh);
mlog_exit(status);
@ -494,7 +491,6 @@ static int ocfs2_reserve_suballoc_bits(struct ocfs2_super *osb,
get_bh(bh);
ac->ac_bh = bh;
bail:
if (bh)
brelse(bh);
mlog_exit(status);
@ -1269,10 +1265,10 @@ static int ocfs2_search_chain(struct ocfs2_alloc_context *ac,
&tmp_bits)) == -ENOSPC) {
if (!bg->bg_next_group)
break;
if (prev_group_bh) {
brelse(prev_group_bh);
prev_group_bh = NULL;
}
next_group = le64_to_cpu(bg->bg_next_group);
prev_group_bh = group_bh;
group_bh = NULL;
@ -1367,9 +1363,7 @@ static int ocfs2_search_chain(struct ocfs2_alloc_context *ac,
*bg_blkno = le64_to_cpu(bg->bg_blkno);
*bits_left = le16_to_cpu(bg->bg_free_bits_count);
bail:
if (group_bh)
brelse(group_bh);
if (prev_group_bh)
brelse(prev_group_bh);
mlog_exit(status);
@ -1844,7 +1838,6 @@ int ocfs2_free_suballoc_bits(handle_t *handle,
}
bail:
if (group_bh)
brelse(group_bh);
mlog_exit(status);

View File

@ -762,7 +762,6 @@ static int ocfs2_fill_super(struct super_block *sb, void *data, int silent)
return status;
read_super_error:
if (bh != NULL)
brelse(bh);
if (inode)

View File

@ -158,7 +158,6 @@ bail:
kunmap(page);
page_cache_release(page);
}
if (bh)
brelse(bh);
return ERR_PTR(status);