Skip to content

Commit 2fe5c1d

Browse files
author
Mark Fasheh
committed
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: Mark Fasheh <[email protected]>
1 parent 7ec373c commit 2fe5c1d

File tree

2 files changed

+8
-15
lines changed

2 files changed

+8
-15
lines changed

fs/ocfs2/buffer_head_io.c

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -79,7 +79,7 @@ int ocfs2_write_block(struct ocfs2_super *osb, struct buffer_head *bh,
7979
* information for this bh as it's not marked locally
8080
* uptodate. */
8181
ret = -EIO;
82-
brelse(bh);
82+
put_bh(bh);
8383
}
8484

8585
mutex_unlock(&OCFS2_I(inode)->ip_io_mutex);
@@ -256,7 +256,7 @@ int ocfs2_read_blocks(struct ocfs2_super *osb, u64 block, int nr,
256256
* for this bh as it's not marked locally
257257
* uptodate. */
258258
status = -EIO;
259-
brelse(bh);
259+
put_bh(bh);
260260
bhs[i] = NULL;
261261
continue;
262262
}
@@ -334,7 +334,7 @@ int ocfs2_write_super_or_backup(struct ocfs2_super *osb,
334334

335335
if (!buffer_uptodate(bh)) {
336336
ret = -EIO;
337-
brelse(bh);
337+
put_bh(bh);
338338
}
339339

340340
out:

fs/ocfs2/resize.c

Lines changed: 5 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -257,8 +257,7 @@ static void ocfs2_update_super_and_backups(struct inode *inode,
257257
ret = update_backups(inode, clusters, super_bh->b_data);
258258

259259
out:
260-
if (super_bh)
261-
brelse(super_bh);
260+
brelse(super_bh);
262261
if (ret)
263262
printk(KERN_WARNING "ocfs2: Failed to update super blocks on %s"
264263
" during fs resize. This condition is not fatal,"
@@ -380,11 +379,8 @@ int ocfs2_group_extend(struct inode * inode, int new_clusters)
380379
out_commit:
381380
ocfs2_commit_trans(osb, handle);
382381
out_unlock:
383-
if (group_bh)
384-
brelse(group_bh);
385-
386-
if (main_bm_bh)
387-
brelse(main_bm_bh);
382+
brelse(group_bh);
383+
brelse(main_bm_bh);
388384

389385
ocfs2_inode_unlock(main_bm_inode, 1);
390386

@@ -623,11 +619,8 @@ int ocfs2_group_add(struct inode *inode, struct ocfs2_new_group_input *input)
623619
out_commit:
624620
ocfs2_commit_trans(osb, handle);
625621
out_unlock:
626-
if (group_bh)
627-
brelse(group_bh);
628-
629-
if (main_bm_bh)
630-
brelse(main_bm_bh);
622+
brelse(group_bh);
623+
brelse(main_bm_bh);
631624

632625
ocfs2_inode_unlock(main_bm_inode, 1);
633626

0 commit comments

Comments
 (0)