diff options
author | Mark Fasheh <mfasheh@suse.com> | 2011-08-08 16:20:18 -0400 |
---|---|---|
committer | David Sterba <dsterba@suse.cz> | 2012-03-21 20:45:36 -0400 |
commit | be1a5564fd39fa2ca6adbb41c75fb08f96a1ffcb (patch) | |
tree | de88d181ecbdcb130343116d7a6f71bbbc4a7e1a /fs/btrfs/ctree.c | |
parent | ce598979be6f83549c90f42ba522a19a33727611 (diff) |
btrfs: Don't BUG_ON() errors in update_ref_for_cow()
The only caller of update_ref_for_cow() is __btrfs_cow_block() which was
originally ignoring any return values. update_ref_for_cow() however doesn't
look like a candidate to become a void function - there are a few places
where errors can occur.
So instead I changed update_ref_for_cow() to bubble all errors up (instead
of BUG_ON). __btrfs_cow_block() was then updated to catch and BUG_ON() any
errors from update_ref_for_cow(). The end effect is that we have no change
in behavior, but about 8 different places where a BUG_ON(ret) was removed.
Obviously a future patch will have to address the BUG_ON() in
__btrfs_cow_block().
Signed-off-by: Mark Fasheh <mfasheh@suse.de>
Diffstat (limited to 'fs/btrfs/ctree.c')
-rw-r--r-- | fs/btrfs/ctree.c | 11 |
1 files changed, 7 insertions, 4 deletions
diff --git a/fs/btrfs/ctree.c b/fs/btrfs/ctree.c index 9d472c2a8de8..e2e43c07f6b1 100644 --- a/fs/btrfs/ctree.c +++ b/fs/btrfs/ctree.c | |||
@@ -331,7 +331,8 @@ static noinline int update_ref_for_cow(struct btrfs_trans_handle *trans, | |||
331 | if (btrfs_block_can_be_shared(root, buf)) { | 331 | if (btrfs_block_can_be_shared(root, buf)) { |
332 | ret = btrfs_lookup_extent_info(trans, root, buf->start, | 332 | ret = btrfs_lookup_extent_info(trans, root, buf->start, |
333 | buf->len, &refs, &flags); | 333 | buf->len, &refs, &flags); |
334 | BUG_ON(ret); | 334 | if (ret) |
335 | return ret; | ||
335 | BUG_ON(refs == 0); | 336 | BUG_ON(refs == 0); |
336 | } else { | 337 | } else { |
337 | refs = 1; | 338 | refs = 1; |
@@ -375,7 +376,8 @@ static noinline int update_ref_for_cow(struct btrfs_trans_handle *trans, | |||
375 | buf->start, | 376 | buf->start, |
376 | buf->len, | 377 | buf->len, |
377 | new_flags, 0); | 378 | new_flags, 0); |
378 | BUG_ON(ret); | 379 | if (ret) |
380 | return ret; | ||
379 | } | 381 | } |
380 | } else { | 382 | } else { |
381 | if (flags & BTRFS_BLOCK_FLAG_FULL_BACKREF) { | 383 | if (flags & BTRFS_BLOCK_FLAG_FULL_BACKREF) { |
@@ -415,7 +417,7 @@ static noinline int __btrfs_cow_block(struct btrfs_trans_handle *trans, | |||
415 | { | 417 | { |
416 | struct btrfs_disk_key disk_key; | 418 | struct btrfs_disk_key disk_key; |
417 | struct extent_buffer *cow; | 419 | struct extent_buffer *cow; |
418 | int level; | 420 | int level, ret; |
419 | int last_ref = 0; | 421 | int last_ref = 0; |
420 | int unlock_orig = 0; | 422 | int unlock_orig = 0; |
421 | u64 parent_start; | 423 | u64 parent_start; |
@@ -467,7 +469,8 @@ static noinline int __btrfs_cow_block(struct btrfs_trans_handle *trans, | |||
467 | (unsigned long)btrfs_header_fsid(cow), | 469 | (unsigned long)btrfs_header_fsid(cow), |
468 | BTRFS_FSID_SIZE); | 470 | BTRFS_FSID_SIZE); |
469 | 471 | ||
470 | update_ref_for_cow(trans, root, buf, cow, &last_ref); | 472 | ret = update_ref_for_cow(trans, root, buf, cow, &last_ref); |
473 | BUG_ON(ret); | ||
471 | 474 | ||
472 | if (root->ref_cows) | 475 | if (root->ref_cows) |
473 | btrfs_reloc_cow_block(trans, root, buf, cow); | 476 | btrfs_reloc_cow_block(trans, root, buf, cow); |