diff options
author | Mark Fasheh <mark.fasheh@oracle.com> | 2008-01-23 21:35:31 -0500 |
---|---|---|
committer | Mark Fasheh <mark.fasheh@oracle.com> | 2008-01-25 18:05:48 -0500 |
commit | 2fe5c1d7eb88830b09c863a4b5b3279dc120f3af (patch) | |
tree | c04e3249e3ae14f935ae1d090cd88833c96e6e3b /fs | |
parent | 7ec373cf33533af6c50828a62f6b305c2d7fa931 (diff) |
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 <mark.fasheh@oracle.com>
Diffstat (limited to 'fs')
-rw-r--r-- | fs/ocfs2/buffer_head_io.c | 6 | ||||
-rw-r--r-- | fs/ocfs2/resize.c | 17 |
2 files changed, 8 insertions, 15 deletions
diff --git a/fs/ocfs2/buffer_head_io.c b/fs/ocfs2/buffer_head_io.c index 31aa61dc777b..f136639f5b41 100644 --- a/fs/ocfs2/buffer_head_io.c +++ b/fs/ocfs2/buffer_head_io.c | |||
@@ -79,7 +79,7 @@ int ocfs2_write_block(struct ocfs2_super *osb, struct buffer_head *bh, | |||
79 | * information for this bh as it's not marked locally | 79 | * information for this bh as it's not marked locally |
80 | * uptodate. */ | 80 | * uptodate. */ |
81 | ret = -EIO; | 81 | ret = -EIO; |
82 | brelse(bh); | 82 | put_bh(bh); |
83 | } | 83 | } |
84 | 84 | ||
85 | mutex_unlock(&OCFS2_I(inode)->ip_io_mutex); | 85 | 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 | * for this bh as it's not marked locally | 256 | * for this bh as it's not marked locally |
257 | * uptodate. */ | 257 | * uptodate. */ |
258 | status = -EIO; | 258 | status = -EIO; |
259 | brelse(bh); | 259 | put_bh(bh); |
260 | bhs[i] = NULL; | 260 | bhs[i] = NULL; |
261 | continue; | 261 | continue; |
262 | } | 262 | } |
@@ -334,7 +334,7 @@ int ocfs2_write_super_or_backup(struct ocfs2_super *osb, | |||
334 | 334 | ||
335 | if (!buffer_uptodate(bh)) { | 335 | if (!buffer_uptodate(bh)) { |
336 | ret = -EIO; | 336 | ret = -EIO; |
337 | brelse(bh); | 337 | put_bh(bh); |
338 | } | 338 | } |
339 | 339 | ||
340 | out: | 340 | out: |
diff --git a/fs/ocfs2/resize.c b/fs/ocfs2/resize.c index 7791309bb258..37835ffcb039 100644 --- a/fs/ocfs2/resize.c +++ b/fs/ocfs2/resize.c | |||
@@ -257,8 +257,7 @@ static void ocfs2_update_super_and_backups(struct inode *inode, | |||
257 | ret = update_backups(inode, clusters, super_bh->b_data); | 257 | ret = update_backups(inode, clusters, super_bh->b_data); |
258 | 258 | ||
259 | out: | 259 | out: |
260 | if (super_bh) | 260 | brelse(super_bh); |
261 | brelse(super_bh); | ||
262 | if (ret) | 261 | if (ret) |
263 | printk(KERN_WARNING "ocfs2: Failed to update super blocks on %s" | 262 | printk(KERN_WARNING "ocfs2: Failed to update super blocks on %s" |
264 | " during fs resize. This condition is not fatal," | 263 | " during fs resize. This condition is not fatal," |
@@ -380,11 +379,8 @@ int ocfs2_group_extend(struct inode * inode, int new_clusters) | |||
380 | out_commit: | 379 | out_commit: |
381 | ocfs2_commit_trans(osb, handle); | 380 | ocfs2_commit_trans(osb, handle); |
382 | out_unlock: | 381 | out_unlock: |
383 | if (group_bh) | 382 | brelse(group_bh); |
384 | brelse(group_bh); | 383 | brelse(main_bm_bh); |
385 | |||
386 | if (main_bm_bh) | ||
387 | brelse(main_bm_bh); | ||
388 | 384 | ||
389 | ocfs2_inode_unlock(main_bm_inode, 1); | 385 | ocfs2_inode_unlock(main_bm_inode, 1); |
390 | 386 | ||
@@ -623,11 +619,8 @@ int ocfs2_group_add(struct inode *inode, struct ocfs2_new_group_input *input) | |||
623 | out_commit: | 619 | out_commit: |
624 | ocfs2_commit_trans(osb, handle); | 620 | ocfs2_commit_trans(osb, handle); |
625 | out_unlock: | 621 | out_unlock: |
626 | if (group_bh) | 622 | brelse(group_bh); |
627 | brelse(group_bh); | 623 | brelse(main_bm_bh); |
628 | |||
629 | if (main_bm_bh) | ||
630 | brelse(main_bm_bh); | ||
631 | 624 | ||
632 | ocfs2_inode_unlock(main_bm_inode, 1); | 625 | ocfs2_inode_unlock(main_bm_inode, 1); |
633 | 626 | ||