diff options
author | Tsutomu Itoh <t-itoh@jp.fujitsu.com> | 2012-05-29 05:10:13 -0400 |
---|---|---|
committer | Josef Bacik <josef@redhat.com> | 2012-05-30 10:23:41 -0400 |
commit | 018642a1f197887058e97291460b890d296e8953 (patch) | |
tree | 5fc77a516728d0281873dc19f66ef9ca9e92ae34 | |
parent | 733f4fbbc1083aa343da739f46ee839705d6cfe3 (diff) |
Btrfs: return value of btrfs_read_buffer is checked correctly
btrfs_read_buffer() has the possibility of returning the error.
Therefore, I add the code in which the return value of btrfs_read_buffer()
is checked.
Signed-off-by: Tsutomu Itoh <t-itoh@jp.fujitsu.com>
-rw-r--r-- | fs/btrfs/ctree.c | 6 | ||||
-rw-r--r-- | fs/btrfs/tree-log.c | 16 |
2 files changed, 18 insertions, 4 deletions
diff --git a/fs/btrfs/ctree.c b/fs/btrfs/ctree.c index 26847999c64..99fcad631a2 100644 --- a/fs/btrfs/ctree.c +++ b/fs/btrfs/ctree.c | |||
@@ -739,7 +739,11 @@ int btrfs_realloc_node(struct btrfs_trans_handle *trans, | |||
739 | if (!cur) | 739 | if (!cur) |
740 | return -EIO; | 740 | return -EIO; |
741 | } else if (!uptodate) { | 741 | } else if (!uptodate) { |
742 | btrfs_read_buffer(cur, gen); | 742 | err = btrfs_read_buffer(cur, gen); |
743 | if (err) { | ||
744 | free_extent_buffer(cur); | ||
745 | return err; | ||
746 | } | ||
743 | } | 747 | } |
744 | } | 748 | } |
745 | if (search_start == 0) | 749 | if (search_start == 0) |
diff --git a/fs/btrfs/tree-log.c b/fs/btrfs/tree-log.c index eb1ae908582..6f22a4fca8d 100644 --- a/fs/btrfs/tree-log.c +++ b/fs/btrfs/tree-log.c | |||
@@ -1628,7 +1628,9 @@ static int replay_one_buffer(struct btrfs_root *log, struct extent_buffer *eb, | |||
1628 | int i; | 1628 | int i; |
1629 | int ret; | 1629 | int ret; |
1630 | 1630 | ||
1631 | btrfs_read_buffer(eb, gen); | 1631 | ret = btrfs_read_buffer(eb, gen); |
1632 | if (ret) | ||
1633 | return ret; | ||
1632 | 1634 | ||
1633 | level = btrfs_header_level(eb); | 1635 | level = btrfs_header_level(eb); |
1634 | 1636 | ||
@@ -1749,7 +1751,11 @@ static noinline int walk_down_log_tree(struct btrfs_trans_handle *trans, | |||
1749 | 1751 | ||
1750 | path->slots[*level]++; | 1752 | path->slots[*level]++; |
1751 | if (wc->free) { | 1753 | if (wc->free) { |
1752 | btrfs_read_buffer(next, ptr_gen); | 1754 | ret = btrfs_read_buffer(next, ptr_gen); |
1755 | if (ret) { | ||
1756 | free_extent_buffer(next); | ||
1757 | return ret; | ||
1758 | } | ||
1753 | 1759 | ||
1754 | btrfs_tree_lock(next); | 1760 | btrfs_tree_lock(next); |
1755 | btrfs_set_lock_blocking(next); | 1761 | btrfs_set_lock_blocking(next); |
@@ -1766,7 +1772,11 @@ static noinline int walk_down_log_tree(struct btrfs_trans_handle *trans, | |||
1766 | free_extent_buffer(next); | 1772 | free_extent_buffer(next); |
1767 | continue; | 1773 | continue; |
1768 | } | 1774 | } |
1769 | btrfs_read_buffer(next, ptr_gen); | 1775 | ret = btrfs_read_buffer(next, ptr_gen); |
1776 | if (ret) { | ||
1777 | free_extent_buffer(next); | ||
1778 | return ret; | ||
1779 | } | ||
1770 | 1780 | ||
1771 | WARN_ON(*level <= 0); | 1781 | WARN_ON(*level <= 0); |
1772 | if (path->nodes[*level-1]) | 1782 | if (path->nodes[*level-1]) |