diff options
Diffstat (limited to 'fs/btrfs/backref.c')
-rw-r--r-- | fs/btrfs/backref.c | 33 |
1 files changed, 27 insertions, 6 deletions
diff --git a/fs/btrfs/backref.c b/fs/btrfs/backref.c index aad7201ad11b..10db21fa0926 100644 --- a/fs/btrfs/backref.c +++ b/fs/btrfs/backref.c | |||
@@ -330,7 +330,10 @@ static int __resolve_indirect_ref(struct btrfs_fs_info *fs_info, | |||
330 | goto out; | 330 | goto out; |
331 | } | 331 | } |
332 | 332 | ||
333 | root_level = btrfs_old_root_level(root, time_seq); | 333 | if (path->search_commit_root) |
334 | root_level = btrfs_header_level(root->commit_root); | ||
335 | else | ||
336 | root_level = btrfs_old_root_level(root, time_seq); | ||
334 | 337 | ||
335 | if (root_level + 1 == level) { | 338 | if (root_level + 1 == level) { |
336 | srcu_read_unlock(&fs_info->subvol_srcu, index); | 339 | srcu_read_unlock(&fs_info->subvol_srcu, index); |
@@ -1099,9 +1102,9 @@ static int btrfs_find_all_leafs(struct btrfs_trans_handle *trans, | |||
1099 | * | 1102 | * |
1100 | * returns 0 on success, < 0 on error. | 1103 | * returns 0 on success, < 0 on error. |
1101 | */ | 1104 | */ |
1102 | int btrfs_find_all_roots(struct btrfs_trans_handle *trans, | 1105 | static int __btrfs_find_all_roots(struct btrfs_trans_handle *trans, |
1103 | struct btrfs_fs_info *fs_info, u64 bytenr, | 1106 | struct btrfs_fs_info *fs_info, u64 bytenr, |
1104 | u64 time_seq, struct ulist **roots) | 1107 | u64 time_seq, struct ulist **roots) |
1105 | { | 1108 | { |
1106 | struct ulist *tmp; | 1109 | struct ulist *tmp; |
1107 | struct ulist_node *node = NULL; | 1110 | struct ulist_node *node = NULL; |
@@ -1137,6 +1140,20 @@ int btrfs_find_all_roots(struct btrfs_trans_handle *trans, | |||
1137 | return 0; | 1140 | return 0; |
1138 | } | 1141 | } |
1139 | 1142 | ||
1143 | int btrfs_find_all_roots(struct btrfs_trans_handle *trans, | ||
1144 | struct btrfs_fs_info *fs_info, u64 bytenr, | ||
1145 | u64 time_seq, struct ulist **roots) | ||
1146 | { | ||
1147 | int ret; | ||
1148 | |||
1149 | if (!trans) | ||
1150 | down_read(&fs_info->commit_root_sem); | ||
1151 | ret = __btrfs_find_all_roots(trans, fs_info, bytenr, time_seq, roots); | ||
1152 | if (!trans) | ||
1153 | up_read(&fs_info->commit_root_sem); | ||
1154 | return ret; | ||
1155 | } | ||
1156 | |||
1140 | /* | 1157 | /* |
1141 | * this makes the path point to (inum INODE_ITEM ioff) | 1158 | * this makes the path point to (inum INODE_ITEM ioff) |
1142 | */ | 1159 | */ |
@@ -1516,6 +1533,8 @@ int iterate_extent_inodes(struct btrfs_fs_info *fs_info, | |||
1516 | if (IS_ERR(trans)) | 1533 | if (IS_ERR(trans)) |
1517 | return PTR_ERR(trans); | 1534 | return PTR_ERR(trans); |
1518 | btrfs_get_tree_mod_seq(fs_info, &tree_mod_seq_elem); | 1535 | btrfs_get_tree_mod_seq(fs_info, &tree_mod_seq_elem); |
1536 | } else { | ||
1537 | down_read(&fs_info->commit_root_sem); | ||
1519 | } | 1538 | } |
1520 | 1539 | ||
1521 | ret = btrfs_find_all_leafs(trans, fs_info, extent_item_objectid, | 1540 | ret = btrfs_find_all_leafs(trans, fs_info, extent_item_objectid, |
@@ -1526,8 +1545,8 @@ int iterate_extent_inodes(struct btrfs_fs_info *fs_info, | |||
1526 | 1545 | ||
1527 | ULIST_ITER_INIT(&ref_uiter); | 1546 | ULIST_ITER_INIT(&ref_uiter); |
1528 | while (!ret && (ref_node = ulist_next(refs, &ref_uiter))) { | 1547 | while (!ret && (ref_node = ulist_next(refs, &ref_uiter))) { |
1529 | ret = btrfs_find_all_roots(trans, fs_info, ref_node->val, | 1548 | ret = __btrfs_find_all_roots(trans, fs_info, ref_node->val, |
1530 | tree_mod_seq_elem.seq, &roots); | 1549 | tree_mod_seq_elem.seq, &roots); |
1531 | if (ret) | 1550 | if (ret) |
1532 | break; | 1551 | break; |
1533 | ULIST_ITER_INIT(&root_uiter); | 1552 | ULIST_ITER_INIT(&root_uiter); |
@@ -1549,6 +1568,8 @@ out: | |||
1549 | if (!search_commit_root) { | 1568 | if (!search_commit_root) { |
1550 | btrfs_put_tree_mod_seq(fs_info, &tree_mod_seq_elem); | 1569 | btrfs_put_tree_mod_seq(fs_info, &tree_mod_seq_elem); |
1551 | btrfs_end_transaction(trans, fs_info->extent_root); | 1570 | btrfs_end_transaction(trans, fs_info->extent_root); |
1571 | } else { | ||
1572 | up_read(&fs_info->commit_root_sem); | ||
1552 | } | 1573 | } |
1553 | 1574 | ||
1554 | return ret; | 1575 | return ret; |