diff options
author | Tsutomu Itoh <t-itoh@jp.fujitsu.com> | 2011-04-28 05:10:23 -0400 |
---|---|---|
committer | Chris Mason <chris.mason@oracle.com> | 2011-05-23 13:24:40 -0400 |
commit | c00e9493f1412621c8665a707d63e32b0768f572 (patch) | |
tree | 60e7b26ea4e6ff0b3270edc2abecdbacc4b211dc /fs/btrfs | |
parent | 1cd307990d6e2b4965620e339a92e0d7ae853e13 (diff) |
Btrfs: return error to caller if read_one_inode() fails
When read_one_inode() fails, error code is returned to caller instead
of BUG_ON().
Signed-off-by: Tsutomu Itoh <t-itoh@jp.fujitsu.com>
Signed-off-by: Chris Mason <chris.mason@oracle.com>
Diffstat (limited to 'fs/btrfs')
-rw-r--r-- | fs/btrfs/tree-log.c | 24 |
1 files changed, 18 insertions, 6 deletions
diff --git a/fs/btrfs/tree-log.c b/fs/btrfs/tree-log.c index 0350147106d5..46b7b57650ab 100644 --- a/fs/btrfs/tree-log.c +++ b/fs/btrfs/tree-log.c | |||
@@ -677,7 +677,10 @@ static noinline int drop_one_dir_item(struct btrfs_trans_handle *trans, | |||
677 | btrfs_release_path(root, path); | 677 | btrfs_release_path(root, path); |
678 | 678 | ||
679 | inode = read_one_inode(root, location.objectid); | 679 | inode = read_one_inode(root, location.objectid); |
680 | BUG_ON(!inode); | 680 | if (!inode) { |
681 | kfree(name); | ||
682 | return -EIO; | ||
683 | } | ||
681 | 684 | ||
682 | ret = link_to_fixup_dir(trans, root, path, location.objectid); | 685 | ret = link_to_fixup_dir(trans, root, path, location.objectid); |
683 | BUG_ON(ret); | 686 | BUG_ON(ret); |
@@ -816,7 +819,10 @@ static noinline int add_inode_ref(struct btrfs_trans_handle *trans, | |||
816 | return -ENOENT; | 819 | return -ENOENT; |
817 | 820 | ||
818 | inode = read_one_inode(root, key->objectid); | 821 | inode = read_one_inode(root, key->objectid); |
819 | BUG_ON(!inode); | 822 | if (!inode) { |
823 | iput(dir); | ||
824 | return -EIO; | ||
825 | } | ||
820 | 826 | ||
821 | ref_ptr = btrfs_item_ptr_offset(eb, slot); | 827 | ref_ptr = btrfs_item_ptr_offset(eb, slot); |
822 | ref_end = ref_ptr + btrfs_item_size_nr(eb, slot); | 828 | ref_end = ref_ptr + btrfs_item_size_nr(eb, slot); |
@@ -1054,7 +1060,8 @@ static noinline int fixup_inode_link_counts(struct btrfs_trans_handle *trans, | |||
1054 | 1060 | ||
1055 | btrfs_release_path(root, path); | 1061 | btrfs_release_path(root, path); |
1056 | inode = read_one_inode(root, key.offset); | 1062 | inode = read_one_inode(root, key.offset); |
1057 | BUG_ON(!inode); | 1063 | if (!inode) |
1064 | return -EIO; | ||
1058 | 1065 | ||
1059 | ret = fixup_inode_link_count(trans, root, inode); | 1066 | ret = fixup_inode_link_count(trans, root, inode); |
1060 | BUG_ON(ret); | 1067 | BUG_ON(ret); |
@@ -1090,7 +1097,8 @@ static noinline int link_to_fixup_dir(struct btrfs_trans_handle *trans, | |||
1090 | struct inode *inode; | 1097 | struct inode *inode; |
1091 | 1098 | ||
1092 | inode = read_one_inode(root, objectid); | 1099 | inode = read_one_inode(root, objectid); |
1093 | BUG_ON(!inode); | 1100 | if (!inode) |
1101 | return -EIO; | ||
1094 | 1102 | ||
1095 | key.objectid = BTRFS_TREE_LOG_FIXUP_OBJECTID; | 1103 | key.objectid = BTRFS_TREE_LOG_FIXUP_OBJECTID; |
1096 | btrfs_set_key_type(&key, BTRFS_ORPHAN_ITEM_KEY); | 1104 | btrfs_set_key_type(&key, BTRFS_ORPHAN_ITEM_KEY); |
@@ -1177,7 +1185,8 @@ static noinline int replay_one_name(struct btrfs_trans_handle *trans, | |||
1177 | int ret; | 1185 | int ret; |
1178 | 1186 | ||
1179 | dir = read_one_inode(root, key->objectid); | 1187 | dir = read_one_inode(root, key->objectid); |
1180 | BUG_ON(!dir); | 1188 | if (!dir) |
1189 | return -EIO; | ||
1181 | 1190 | ||
1182 | name_len = btrfs_dir_name_len(eb, di); | 1191 | name_len = btrfs_dir_name_len(eb, di); |
1183 | name = kmalloc(name_len, GFP_NOFS); | 1192 | name = kmalloc(name_len, GFP_NOFS); |
@@ -1433,7 +1442,10 @@ again: | |||
1433 | btrfs_release_path(root, path); | 1442 | btrfs_release_path(root, path); |
1434 | btrfs_release_path(log, log_path); | 1443 | btrfs_release_path(log, log_path); |
1435 | inode = read_one_inode(root, location.objectid); | 1444 | inode = read_one_inode(root, location.objectid); |
1436 | BUG_ON(!inode); | 1445 | if (!inode) { |
1446 | kfree(name); | ||
1447 | return -EIO; | ||
1448 | } | ||
1437 | 1449 | ||
1438 | ret = link_to_fixup_dir(trans, root, | 1450 | ret = link_to_fixup_dir(trans, root, |
1439 | path, location.objectid); | 1451 | path, location.objectid); |