aboutsummaryrefslogtreecommitdiffstats
path: root/fs/btrfs/tree-log.c
diff options
context:
space:
mode:
authorChris Mason <chris.mason@oracle.com>2011-05-23 14:37:47 -0400
committerChris Mason <chris.mason@oracle.com>2011-05-23 14:37:47 -0400
commitd6c0cb379c5198487e4ac124728cbb2346d63b1f (patch)
tree167a97ac58c7a2fbf7c4e94b6abbfe1e03af014a /fs/btrfs/tree-log.c
parent8e531cdfeb75269c6c5aae33651cca39707848da (diff)
parent1f78160ce1b1b8e657e2248118c4d91f881763f0 (diff)
Merge branch 'cleanups_and_fixes' into inode_numbers
Conflicts: fs/btrfs/tree-log.c fs/btrfs/volumes.c Signed-off-by: Chris Mason <chris.mason@oracle.com>
Diffstat (limited to 'fs/btrfs/tree-log.c')
-rw-r--r--fs/btrfs/tree-log.c36
1 files changed, 26 insertions, 10 deletions
diff --git a/fs/btrfs/tree-log.c b/fs/btrfs/tree-log.c
index 0f5537e60bb4..592396c6dc47 100644
--- a/fs/btrfs/tree-log.c
+++ b/fs/btrfs/tree-log.c
@@ -382,7 +382,6 @@ insert:
382 } else if (found_size < item_size) { 382 } else if (found_size < item_size) {
383 ret = btrfs_extend_item(trans, root, path, 383 ret = btrfs_extend_item(trans, root, path,
384 item_size - found_size); 384 item_size - found_size);
385 BUG_ON(ret);
386 } 385 }
387 } else if (ret) { 386 } else if (ret) {
388 return ret; 387 return ret;
@@ -590,6 +589,7 @@ static noinline int replay_one_extent(struct btrfs_trans_handle *trans,
590 ins.objectid, ins.offset, 589 ins.objectid, ins.offset,
591 0, root->root_key.objectid, 590 0, root->root_key.objectid,
592 key->objectid, offset); 591 key->objectid, offset);
592 BUG_ON(ret);
593 } else { 593 } else {
594 /* 594 /*
595 * insert the extent pointer in the extent 595 * insert the extent pointer in the extent
@@ -678,7 +678,10 @@ static noinline int drop_one_dir_item(struct btrfs_trans_handle *trans,
678 btrfs_release_path(path); 678 btrfs_release_path(path);
679 679
680 inode = read_one_inode(root, location.objectid); 680 inode = read_one_inode(root, location.objectid);
681 BUG_ON(!inode); 681 if (!inode) {
682 kfree(name);
683 return -EIO;
684 }
682 685
683 ret = link_to_fixup_dir(trans, root, path, location.objectid); 686 ret = link_to_fixup_dir(trans, root, path, location.objectid);
684 BUG_ON(ret); 687 BUG_ON(ret);
@@ -817,7 +820,10 @@ static noinline int add_inode_ref(struct btrfs_trans_handle *trans,
817 return -ENOENT; 820 return -ENOENT;
818 821
819 inode = read_one_inode(root, key->objectid); 822 inode = read_one_inode(root, key->objectid);
820 BUG_ON(!inode); 823 if (!inode) {
824 iput(dir);
825 return -EIO;
826 }
821 827
822 ref_ptr = btrfs_item_ptr_offset(eb, slot); 828 ref_ptr = btrfs_item_ptr_offset(eb, slot);
823 ref_end = ref_ptr + btrfs_item_size_nr(eb, slot); 829 ref_end = ref_ptr + btrfs_item_size_nr(eb, slot);
@@ -1051,11 +1057,13 @@ static noinline int fixup_inode_link_counts(struct btrfs_trans_handle *trans,
1051 break; 1057 break;
1052 1058
1053 ret = btrfs_del_item(trans, root, path); 1059 ret = btrfs_del_item(trans, root, path);
1054 BUG_ON(ret); 1060 if (ret)
1061 goto out;
1055 1062
1056 btrfs_release_path(path); 1063 btrfs_release_path(path);
1057 inode = read_one_inode(root, key.offset); 1064 inode = read_one_inode(root, key.offset);
1058 BUG_ON(!inode); 1065 if (!inode)
1066 return -EIO;
1059 1067
1060 ret = fixup_inode_link_count(trans, root, inode); 1068 ret = fixup_inode_link_count(trans, root, inode);
1061 BUG_ON(ret); 1069 BUG_ON(ret);
@@ -1069,8 +1077,10 @@ static noinline int fixup_inode_link_counts(struct btrfs_trans_handle *trans,
1069 */ 1077 */
1070 key.offset = (u64)-1; 1078 key.offset = (u64)-1;
1071 } 1079 }
1080 ret = 0;
1081out:
1072 btrfs_release_path(path); 1082 btrfs_release_path(path);
1073 return 0; 1083 return ret;
1074} 1084}
1075 1085
1076 1086
@@ -1089,7 +1099,8 @@ static noinline int link_to_fixup_dir(struct btrfs_trans_handle *trans,
1089 struct inode *inode; 1099 struct inode *inode;
1090 1100
1091 inode = read_one_inode(root, objectid); 1101 inode = read_one_inode(root, objectid);
1092 BUG_ON(!inode); 1102 if (!inode)
1103 return -EIO;
1093 1104
1094 key.objectid = BTRFS_TREE_LOG_FIXUP_OBJECTID; 1105 key.objectid = BTRFS_TREE_LOG_FIXUP_OBJECTID;
1095 btrfs_set_key_type(&key, BTRFS_ORPHAN_ITEM_KEY); 1106 btrfs_set_key_type(&key, BTRFS_ORPHAN_ITEM_KEY);
@@ -1176,7 +1187,8 @@ static noinline int replay_one_name(struct btrfs_trans_handle *trans,
1176 int ret; 1187 int ret;
1177 1188
1178 dir = read_one_inode(root, key->objectid); 1189 dir = read_one_inode(root, key->objectid);
1179 BUG_ON(!dir); 1190 if (!dir)
1191 return -EIO;
1180 1192
1181 name_len = btrfs_dir_name_len(eb, di); 1193 name_len = btrfs_dir_name_len(eb, di);
1182 name = kmalloc(name_len, GFP_NOFS); 1194 name = kmalloc(name_len, GFP_NOFS);
@@ -1432,7 +1444,10 @@ again:
1432 btrfs_release_path(path); 1444 btrfs_release_path(path);
1433 btrfs_release_path(log_path); 1445 btrfs_release_path(log_path);
1434 inode = read_one_inode(root, location.objectid); 1446 inode = read_one_inode(root, location.objectid);
1435 BUG_ON(!inode); 1447 if (!inode) {
1448 kfree(name);
1449 return -EIO;
1450 }
1436 1451
1437 ret = link_to_fixup_dir(trans, root, 1452 ret = link_to_fixup_dir(trans, root,
1438 path, location.objectid); 1453 path, location.objectid);
@@ -2589,7 +2604,8 @@ static int drop_objectid_items(struct btrfs_trans_handle *trans,
2589 break; 2604 break;
2590 2605
2591 ret = btrfs_del_item(trans, log, path); 2606 ret = btrfs_del_item(trans, log, path);
2592 BUG_ON(ret); 2607 if (ret)
2608 break;
2593 btrfs_release_path(path); 2609 btrfs_release_path(path);
2594 } 2610 }
2595 btrfs_release_path(path); 2611 btrfs_release_path(path);