summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorZygo Blaxell <ce3g8jdj@umail.furryterror.org>2017-09-22 13:58:45 -0400
committerDavid Sterba <dsterba@suse.com>2017-11-01 15:45:34 -0400
commitc995ab3cda3f4178c1f1a47926bea5f8372880cb (patch)
treee4515551164dd625ab7d279aaa27386e5bf2e395
parenteb7b9d6a467409cc0b6c369b0a72489bf3be6801 (diff)
btrfs: add a flag to iterate_inodes_from_logical to find all extent refs for uncompressed extents
The LOGICAL_INO ioctl provides a backward mapping from extent bytenr and offset (encoded as a single logical address) to a list of extent refs. LOGICAL_INO complements TREE_SEARCH, which provides the forward mapping (extent ref -> extent bytenr and offset, or logical address). These are useful capabilities for programs that manipulate extents and extent references from userspace (e.g. dedup and defrag utilities). When the extents are uncompressed (and not encrypted and not other), check_extent_in_eb performs filtering of the extent refs to remove any extent refs which do not contain the same extent offset as the 'logical' parameter's extent offset. This prevents LOGICAL_INO from returning references to more than a single block. To find the set of extent references to an uncompressed extent from [a, b), userspace has to run a loop like this pseudocode: for (i = a; i < b; ++i) extent_ref_set += LOGICAL_INO(i); At each iteration of the loop (up to 32768 iterations for a 128M extent), data we are interested in is collected in the kernel, then deleted by the filter in check_extent_in_eb. When the extents are compressed (or encrypted or other), the 'logical' parameter must be an extent bytenr (the 'a' parameter in the loop). No filtering by extent offset is done (or possible?) so the result is the complete set of extent refs for the entire extent. This removes the need for the loop, since we get all the extent refs in one call. Add an 'ignore_offset' argument to iterate_inodes_from_logical, [...several levels of function call graph...], and check_extent_in_eb, so that we can disable the extent offset filtering for uncompressed extents. This flag can be set by an improved version of the LOGICAL_INO ioctl to get either behavior as desired. There is no functional change in this patch. The new flag is always false. Signed-off-by: Zygo Blaxell <ce3g8jdj@umail.furryterror.org> Reviewed-by: David Sterba <dsterba@suse.com> [ minor coding style fixes ] Signed-off-by: David Sterba <dsterba@suse.com>
-rw-r--r--fs/btrfs/backref.c63
-rw-r--r--fs/btrfs/backref.h8
-rw-r--r--fs/btrfs/inode.c2
-rw-r--r--fs/btrfs/ioctl.c2
-rw-r--r--fs/btrfs/qgroup.c8
-rw-r--r--fs/btrfs/scrub.c6
-rw-r--r--fs/btrfs/send.c2
-rw-r--r--fs/btrfs/tests/qgroup-tests.c30
8 files changed, 73 insertions, 48 deletions
diff --git a/fs/btrfs/backref.c b/fs/btrfs/backref.c
index 33cba1abf8b6..523d2dba7745 100644
--- a/fs/btrfs/backref.c
+++ b/fs/btrfs/backref.c
@@ -40,12 +40,14 @@ static int check_extent_in_eb(const struct btrfs_key *key,
40 const struct extent_buffer *eb, 40 const struct extent_buffer *eb,
41 const struct btrfs_file_extent_item *fi, 41 const struct btrfs_file_extent_item *fi,
42 u64 extent_item_pos, 42 u64 extent_item_pos,
43 struct extent_inode_elem **eie) 43 struct extent_inode_elem **eie,
44 bool ignore_offset)
44{ 45{
45 u64 offset = 0; 46 u64 offset = 0;
46 struct extent_inode_elem *e; 47 struct extent_inode_elem *e;
47 48
48 if (!btrfs_file_extent_compression(eb, fi) && 49 if (!ignore_offset &&
50 !btrfs_file_extent_compression(eb, fi) &&
49 !btrfs_file_extent_encryption(eb, fi) && 51 !btrfs_file_extent_encryption(eb, fi) &&
50 !btrfs_file_extent_other_encoding(eb, fi)) { 52 !btrfs_file_extent_other_encoding(eb, fi)) {
51 u64 data_offset; 53 u64 data_offset;
@@ -84,7 +86,8 @@ static void free_inode_elem_list(struct extent_inode_elem *eie)
84 86
85static int find_extent_in_eb(const struct extent_buffer *eb, 87static int find_extent_in_eb(const struct extent_buffer *eb,
86 u64 wanted_disk_byte, u64 extent_item_pos, 88 u64 wanted_disk_byte, u64 extent_item_pos,
87 struct extent_inode_elem **eie) 89 struct extent_inode_elem **eie,
90 bool ignore_offset)
88{ 91{
89 u64 disk_byte; 92 u64 disk_byte;
90 struct btrfs_key key; 93 struct btrfs_key key;
@@ -113,7 +116,7 @@ static int find_extent_in_eb(const struct extent_buffer *eb,
113 if (disk_byte != wanted_disk_byte) 116 if (disk_byte != wanted_disk_byte)
114 continue; 117 continue;
115 118
116 ret = check_extent_in_eb(&key, eb, fi, extent_item_pos, eie); 119 ret = check_extent_in_eb(&key, eb, fi, extent_item_pos, eie, ignore_offset);
117 if (ret < 0) 120 if (ret < 0)
118 return ret; 121 return ret;
119 } 122 }
@@ -419,7 +422,7 @@ static int add_indirect_ref(const struct btrfs_fs_info *fs_info,
419static int add_all_parents(struct btrfs_root *root, struct btrfs_path *path, 422static int add_all_parents(struct btrfs_root *root, struct btrfs_path *path,
420 struct ulist *parents, struct prelim_ref *ref, 423 struct ulist *parents, struct prelim_ref *ref,
421 int level, u64 time_seq, const u64 *extent_item_pos, 424 int level, u64 time_seq, const u64 *extent_item_pos,
422 u64 total_refs) 425 u64 total_refs, bool ignore_offset)
423{ 426{
424 int ret = 0; 427 int ret = 0;
425 int slot; 428 int slot;
@@ -472,7 +475,7 @@ static int add_all_parents(struct btrfs_root *root, struct btrfs_path *path,
472 if (extent_item_pos) { 475 if (extent_item_pos) {
473 ret = check_extent_in_eb(&key, eb, fi, 476 ret = check_extent_in_eb(&key, eb, fi,
474 *extent_item_pos, 477 *extent_item_pos,
475 &eie); 478 &eie, ignore_offset);
476 if (ret < 0) 479 if (ret < 0)
477 break; 480 break;
478 } 481 }
@@ -510,7 +513,8 @@ next:
510static int resolve_indirect_ref(struct btrfs_fs_info *fs_info, 513static int resolve_indirect_ref(struct btrfs_fs_info *fs_info,
511 struct btrfs_path *path, u64 time_seq, 514 struct btrfs_path *path, u64 time_seq,
512 struct prelim_ref *ref, struct ulist *parents, 515 struct prelim_ref *ref, struct ulist *parents,
513 const u64 *extent_item_pos, u64 total_refs) 516 const u64 *extent_item_pos, u64 total_refs,
517 bool ignore_offset)
514{ 518{
515 struct btrfs_root *root; 519 struct btrfs_root *root;
516 struct btrfs_key root_key; 520 struct btrfs_key root_key;
@@ -581,7 +585,7 @@ static int resolve_indirect_ref(struct btrfs_fs_info *fs_info,
581 } 585 }
582 586
583 ret = add_all_parents(root, path, parents, ref, level, time_seq, 587 ret = add_all_parents(root, path, parents, ref, level, time_seq,
584 extent_item_pos, total_refs); 588 extent_item_pos, total_refs, ignore_offset);
585out: 589out:
586 path->lowest_level = 0; 590 path->lowest_level = 0;
587 btrfs_release_path(path); 591 btrfs_release_path(path);
@@ -616,7 +620,7 @@ static int resolve_indirect_refs(struct btrfs_fs_info *fs_info,
616 struct btrfs_path *path, u64 time_seq, 620 struct btrfs_path *path, u64 time_seq,
617 struct preftrees *preftrees, 621 struct preftrees *preftrees,
618 const u64 *extent_item_pos, u64 total_refs, 622 const u64 *extent_item_pos, u64 total_refs,
619 struct share_check *sc) 623 struct share_check *sc, bool ignore_offset)
620{ 624{
621 int err; 625 int err;
622 int ret = 0; 626 int ret = 0;
@@ -661,7 +665,7 @@ static int resolve_indirect_refs(struct btrfs_fs_info *fs_info,
661 } 665 }
662 err = resolve_indirect_ref(fs_info, path, time_seq, ref, 666 err = resolve_indirect_ref(fs_info, path, time_seq, ref,
663 parents, extent_item_pos, 667 parents, extent_item_pos,
664 total_refs); 668 total_refs, ignore_offset);
665 /* 669 /*
666 * we can only tolerate ENOENT,otherwise,we should catch error 670 * we can only tolerate ENOENT,otherwise,we should catch error
667 * and return directly. 671 * and return directly.
@@ -1107,13 +1111,17 @@ static int add_keyed_refs(struct btrfs_fs_info *fs_info,
1107 * 1111 *
1108 * Otherwise this returns 0 for success and <0 for an error. 1112 * Otherwise this returns 0 for success and <0 for an error.
1109 * 1113 *
1114 * If ignore_offset is set to false, only extent refs whose offsets match
1115 * extent_item_pos are returned. If true, every extent ref is returned
1116 * and extent_item_pos is ignored.
1117 *
1110 * FIXME some caching might speed things up 1118 * FIXME some caching might speed things up
1111 */ 1119 */
1112static int find_parent_nodes(struct btrfs_trans_handle *trans, 1120static int find_parent_nodes(struct btrfs_trans_handle *trans,
1113 struct btrfs_fs_info *fs_info, u64 bytenr, 1121 struct btrfs_fs_info *fs_info, u64 bytenr,
1114 u64 time_seq, struct ulist *refs, 1122 u64 time_seq, struct ulist *refs,
1115 struct ulist *roots, const u64 *extent_item_pos, 1123 struct ulist *roots, const u64 *extent_item_pos,
1116 struct share_check *sc) 1124 struct share_check *sc, bool ignore_offset)
1117{ 1125{
1118 struct btrfs_key key; 1126 struct btrfs_key key;
1119 struct btrfs_path *path; 1127 struct btrfs_path *path;
@@ -1235,7 +1243,7 @@ again:
1235 WARN_ON(!RB_EMPTY_ROOT(&preftrees.indirect_missing_keys.root)); 1243 WARN_ON(!RB_EMPTY_ROOT(&preftrees.indirect_missing_keys.root));
1236 1244
1237 ret = resolve_indirect_refs(fs_info, path, time_seq, &preftrees, 1245 ret = resolve_indirect_refs(fs_info, path, time_seq, &preftrees,
1238 extent_item_pos, total_refs, sc); 1246 extent_item_pos, total_refs, sc, ignore_offset);
1239 if (ret) 1247 if (ret)
1240 goto out; 1248 goto out;
1241 1249
@@ -1282,7 +1290,7 @@ again:
1282 btrfs_tree_read_lock(eb); 1290 btrfs_tree_read_lock(eb);
1283 btrfs_set_lock_blocking_rw(eb, BTRFS_READ_LOCK); 1291 btrfs_set_lock_blocking_rw(eb, BTRFS_READ_LOCK);
1284 ret = find_extent_in_eb(eb, bytenr, 1292 ret = find_extent_in_eb(eb, bytenr,
1285 *extent_item_pos, &eie); 1293 *extent_item_pos, &eie, ignore_offset);
1286 btrfs_tree_read_unlock_blocking(eb); 1294 btrfs_tree_read_unlock_blocking(eb);
1287 free_extent_buffer(eb); 1295 free_extent_buffer(eb);
1288 if (ret < 0) 1296 if (ret < 0)
@@ -1350,7 +1358,7 @@ static void free_leaf_list(struct ulist *blocks)
1350static int btrfs_find_all_leafs(struct btrfs_trans_handle *trans, 1358static int btrfs_find_all_leafs(struct btrfs_trans_handle *trans,
1351 struct btrfs_fs_info *fs_info, u64 bytenr, 1359 struct btrfs_fs_info *fs_info, u64 bytenr,
1352 u64 time_seq, struct ulist **leafs, 1360 u64 time_seq, struct ulist **leafs,
1353 const u64 *extent_item_pos) 1361 const u64 *extent_item_pos, bool ignore_offset)
1354{ 1362{
1355 int ret; 1363 int ret;
1356 1364
@@ -1359,7 +1367,7 @@ static int btrfs_find_all_leafs(struct btrfs_trans_handle *trans,
1359 return -ENOMEM; 1367 return -ENOMEM;
1360 1368
1361 ret = find_parent_nodes(trans, fs_info, bytenr, time_seq, 1369 ret = find_parent_nodes(trans, fs_info, bytenr, time_seq,
1362 *leafs, NULL, extent_item_pos, NULL); 1370 *leafs, NULL, extent_item_pos, NULL, ignore_offset);
1363 if (ret < 0 && ret != -ENOENT) { 1371 if (ret < 0 && ret != -ENOENT) {
1364 free_leaf_list(*leafs); 1372 free_leaf_list(*leafs);
1365 return ret; 1373 return ret;
@@ -1383,7 +1391,8 @@ static int btrfs_find_all_leafs(struct btrfs_trans_handle *trans,
1383 */ 1391 */
1384static int btrfs_find_all_roots_safe(struct btrfs_trans_handle *trans, 1392static int btrfs_find_all_roots_safe(struct btrfs_trans_handle *trans,
1385 struct btrfs_fs_info *fs_info, u64 bytenr, 1393 struct btrfs_fs_info *fs_info, u64 bytenr,
1386 u64 time_seq, struct ulist **roots) 1394 u64 time_seq, struct ulist **roots,
1395 bool ignore_offset)
1387{ 1396{
1388 struct ulist *tmp; 1397 struct ulist *tmp;
1389 struct ulist_node *node = NULL; 1398 struct ulist_node *node = NULL;
@@ -1402,7 +1411,7 @@ static int btrfs_find_all_roots_safe(struct btrfs_trans_handle *trans,
1402 ULIST_ITER_INIT(&uiter); 1411 ULIST_ITER_INIT(&uiter);
1403 while (1) { 1412 while (1) {
1404 ret = find_parent_nodes(trans, fs_info, bytenr, time_seq, 1413 ret = find_parent_nodes(trans, fs_info, bytenr, time_seq,
1405 tmp, *roots, NULL, NULL); 1414 tmp, *roots, NULL, NULL, ignore_offset);
1406 if (ret < 0 && ret != -ENOENT) { 1415 if (ret < 0 && ret != -ENOENT) {
1407 ulist_free(tmp); 1416 ulist_free(tmp);
1408 ulist_free(*roots); 1417 ulist_free(*roots);
@@ -1421,14 +1430,15 @@ static int btrfs_find_all_roots_safe(struct btrfs_trans_handle *trans,
1421 1430
1422int btrfs_find_all_roots(struct btrfs_trans_handle *trans, 1431int btrfs_find_all_roots(struct btrfs_trans_handle *trans,
1423 struct btrfs_fs_info *fs_info, u64 bytenr, 1432 struct btrfs_fs_info *fs_info, u64 bytenr,
1424 u64 time_seq, struct ulist **roots) 1433 u64 time_seq, struct ulist **roots,
1434 bool ignore_offset)
1425{ 1435{
1426 int ret; 1436 int ret;
1427 1437
1428 if (!trans) 1438 if (!trans)
1429 down_read(&fs_info->commit_root_sem); 1439 down_read(&fs_info->commit_root_sem);
1430 ret = btrfs_find_all_roots_safe(trans, fs_info, bytenr, 1440 ret = btrfs_find_all_roots_safe(trans, fs_info, bytenr,
1431 time_seq, roots); 1441 time_seq, roots, ignore_offset);
1432 if (!trans) 1442 if (!trans)
1433 up_read(&fs_info->commit_root_sem); 1443 up_read(&fs_info->commit_root_sem);
1434 return ret; 1444 return ret;
@@ -1483,7 +1493,7 @@ int btrfs_check_shared(struct btrfs_root *root, u64 inum, u64 bytenr)
1483 ULIST_ITER_INIT(&uiter); 1493 ULIST_ITER_INIT(&uiter);
1484 while (1) { 1494 while (1) {
1485 ret = find_parent_nodes(trans, fs_info, bytenr, elem.seq, tmp, 1495 ret = find_parent_nodes(trans, fs_info, bytenr, elem.seq, tmp,
1486 roots, NULL, &shared); 1496 roots, NULL, &shared, false);
1487 if (ret == BACKREF_FOUND_SHARED) { 1497 if (ret == BACKREF_FOUND_SHARED) {
1488 /* this is the only condition under which we return 1 */ 1498 /* this is the only condition under which we return 1 */
1489 ret = 1; 1499 ret = 1;
@@ -1877,7 +1887,8 @@ static int iterate_leaf_refs(struct btrfs_fs_info *fs_info,
1877int iterate_extent_inodes(struct btrfs_fs_info *fs_info, 1887int iterate_extent_inodes(struct btrfs_fs_info *fs_info,
1878 u64 extent_item_objectid, u64 extent_item_pos, 1888 u64 extent_item_objectid, u64 extent_item_pos,
1879 int search_commit_root, 1889 int search_commit_root,
1880 iterate_extent_inodes_t *iterate, void *ctx) 1890 iterate_extent_inodes_t *iterate, void *ctx,
1891 bool ignore_offset)
1881{ 1892{
1882 int ret; 1893 int ret;
1883 struct btrfs_trans_handle *trans = NULL; 1894 struct btrfs_trans_handle *trans = NULL;
@@ -1903,14 +1914,15 @@ int iterate_extent_inodes(struct btrfs_fs_info *fs_info,
1903 1914
1904 ret = btrfs_find_all_leafs(trans, fs_info, extent_item_objectid, 1915 ret = btrfs_find_all_leafs(trans, fs_info, extent_item_objectid,
1905 tree_mod_seq_elem.seq, &refs, 1916 tree_mod_seq_elem.seq, &refs,
1906 &extent_item_pos); 1917 &extent_item_pos, ignore_offset);
1907 if (ret) 1918 if (ret)
1908 goto out; 1919 goto out;
1909 1920
1910 ULIST_ITER_INIT(&ref_uiter); 1921 ULIST_ITER_INIT(&ref_uiter);
1911 while (!ret && (ref_node = ulist_next(refs, &ref_uiter))) { 1922 while (!ret && (ref_node = ulist_next(refs, &ref_uiter))) {
1912 ret = btrfs_find_all_roots_safe(trans, fs_info, ref_node->val, 1923 ret = btrfs_find_all_roots_safe(trans, fs_info, ref_node->val,
1913 tree_mod_seq_elem.seq, &roots); 1924 tree_mod_seq_elem.seq, &roots,
1925 ignore_offset);
1914 if (ret) 1926 if (ret)
1915 break; 1927 break;
1916 ULIST_ITER_INIT(&root_uiter); 1928 ULIST_ITER_INIT(&root_uiter);
@@ -1943,7 +1955,8 @@ out:
1943 1955
1944int iterate_inodes_from_logical(u64 logical, struct btrfs_fs_info *fs_info, 1956int iterate_inodes_from_logical(u64 logical, struct btrfs_fs_info *fs_info,
1945 struct btrfs_path *path, 1957 struct btrfs_path *path,
1946 iterate_extent_inodes_t *iterate, void *ctx) 1958 iterate_extent_inodes_t *iterate, void *ctx,
1959 bool ignore_offset)
1947{ 1960{
1948 int ret; 1961 int ret;
1949 u64 extent_item_pos; 1962 u64 extent_item_pos;
@@ -1961,7 +1974,7 @@ int iterate_inodes_from_logical(u64 logical, struct btrfs_fs_info *fs_info,
1961 extent_item_pos = logical - found_key.objectid; 1974 extent_item_pos = logical - found_key.objectid;
1962 ret = iterate_extent_inodes(fs_info, found_key.objectid, 1975 ret = iterate_extent_inodes(fs_info, found_key.objectid,
1963 extent_item_pos, search_commit_root, 1976 extent_item_pos, search_commit_root,
1964 iterate, ctx); 1977 iterate, ctx, ignore_offset);
1965 1978
1966 return ret; 1979 return ret;
1967} 1980}
diff --git a/fs/btrfs/backref.h b/fs/btrfs/backref.h
index e410335841aa..0c2fab8514ff 100644
--- a/fs/btrfs/backref.h
+++ b/fs/btrfs/backref.h
@@ -43,17 +43,19 @@ int tree_backref_for_extent(unsigned long *ptr, struct extent_buffer *eb,
43int iterate_extent_inodes(struct btrfs_fs_info *fs_info, 43int iterate_extent_inodes(struct btrfs_fs_info *fs_info,
44 u64 extent_item_objectid, 44 u64 extent_item_objectid,
45 u64 extent_offset, int search_commit_root, 45 u64 extent_offset, int search_commit_root,
46 iterate_extent_inodes_t *iterate, void *ctx); 46 iterate_extent_inodes_t *iterate, void *ctx,
47 bool ignore_offset);
47 48
48int iterate_inodes_from_logical(u64 logical, struct btrfs_fs_info *fs_info, 49int iterate_inodes_from_logical(u64 logical, struct btrfs_fs_info *fs_info,
49 struct btrfs_path *path, 50 struct btrfs_path *path,
50 iterate_extent_inodes_t *iterate, void *ctx); 51 iterate_extent_inodes_t *iterate, void *ctx,
52 bool ignore_offset);
51 53
52int paths_from_inode(u64 inum, struct inode_fs_paths *ipath); 54int paths_from_inode(u64 inum, struct inode_fs_paths *ipath);
53 55
54int btrfs_find_all_roots(struct btrfs_trans_handle *trans, 56int btrfs_find_all_roots(struct btrfs_trans_handle *trans,
55 struct btrfs_fs_info *fs_info, u64 bytenr, 57 struct btrfs_fs_info *fs_info, u64 bytenr,
56 u64 time_seq, struct ulist **roots); 58 u64 time_seq, struct ulist **roots, bool ignore_offset);
57char *btrfs_ref_to_path(struct btrfs_root *fs_root, struct btrfs_path *path, 59char *btrfs_ref_to_path(struct btrfs_root *fs_root, struct btrfs_path *path,
58 u32 name_len, unsigned long name_off, 60 u32 name_len, unsigned long name_off,
59 struct extent_buffer *eb_in, u64 parent, 61 struct extent_buffer *eb_in, u64 parent,
diff --git a/fs/btrfs/inode.c b/fs/btrfs/inode.c
index 3f1b53f85735..eb20239284a2 100644
--- a/fs/btrfs/inode.c
+++ b/fs/btrfs/inode.c
@@ -2457,7 +2457,7 @@ static noinline bool record_extent_backrefs(struct btrfs_path *path,
2457 ret = iterate_inodes_from_logical(old->bytenr + 2457 ret = iterate_inodes_from_logical(old->bytenr +
2458 old->extent_offset, fs_info, 2458 old->extent_offset, fs_info,
2459 path, record_one_backref, 2459 path, record_one_backref,
2460 old); 2460 old, false);
2461 if (ret < 0 && ret != -ENOENT) 2461 if (ret < 0 && ret != -ENOENT)
2462 return false; 2462 return false;
2463 2463
diff --git a/fs/btrfs/ioctl.c b/fs/btrfs/ioctl.c
index 847d318756d4..2497a5d45d9c 100644
--- a/fs/btrfs/ioctl.c
+++ b/fs/btrfs/ioctl.c
@@ -4560,7 +4560,7 @@ static long btrfs_ioctl_logical_to_ino(struct btrfs_fs_info *fs_info,
4560 } 4560 }
4561 4561
4562 ret = iterate_inodes_from_logical(loi->logical, fs_info, path, 4562 ret = iterate_inodes_from_logical(loi->logical, fs_info, path,
4563 build_ino_list, inodes); 4563 build_ino_list, inodes, false);
4564 if (ret == -EINVAL) 4564 if (ret == -EINVAL)
4565 ret = -ENOENT; 4565 ret = -ENOENT;
4566 if (ret < 0) 4566 if (ret < 0)
diff --git a/fs/btrfs/qgroup.c b/fs/btrfs/qgroup.c
index e172d4843eae..168fd03ca3ac 100644
--- a/fs/btrfs/qgroup.c
+++ b/fs/btrfs/qgroup.c
@@ -1441,7 +1441,7 @@ int btrfs_qgroup_trace_extent_post(struct btrfs_fs_info *fs_info,
1441 u64 bytenr = qrecord->bytenr; 1441 u64 bytenr = qrecord->bytenr;
1442 int ret; 1442 int ret;
1443 1443
1444 ret = btrfs_find_all_roots(NULL, fs_info, bytenr, 0, &old_root); 1444 ret = btrfs_find_all_roots(NULL, fs_info, bytenr, 0, &old_root, false);
1445 if (ret < 0) 1445 if (ret < 0)
1446 return ret; 1446 return ret;
1447 1447
@@ -2031,7 +2031,7 @@ int btrfs_qgroup_account_extents(struct btrfs_trans_handle *trans,
2031 /* Search commit root to find old_roots */ 2031 /* Search commit root to find old_roots */
2032 ret = btrfs_find_all_roots(NULL, fs_info, 2032 ret = btrfs_find_all_roots(NULL, fs_info,
2033 record->bytenr, 0, 2033 record->bytenr, 0,
2034 &record->old_roots); 2034 &record->old_roots, false);
2035 if (ret < 0) 2035 if (ret < 0)
2036 goto cleanup; 2036 goto cleanup;
2037 } 2037 }
@@ -2042,7 +2042,7 @@ int btrfs_qgroup_account_extents(struct btrfs_trans_handle *trans,
2042 * root. It's safe inside commit_transaction(). 2042 * root. It's safe inside commit_transaction().
2043 */ 2043 */
2044 ret = btrfs_find_all_roots(trans, fs_info, 2044 ret = btrfs_find_all_roots(trans, fs_info,
2045 record->bytenr, SEQ_LAST, &new_roots); 2045 record->bytenr, SEQ_LAST, &new_roots, false);
2046 if (ret < 0) 2046 if (ret < 0)
2047 goto cleanup; 2047 goto cleanup;
2048 if (qgroup_to_skip) { 2048 if (qgroup_to_skip) {
@@ -2570,7 +2570,7 @@ qgroup_rescan_leaf(struct btrfs_fs_info *fs_info, struct btrfs_path *path,
2570 num_bytes = found.offset; 2570 num_bytes = found.offset;
2571 2571
2572 ret = btrfs_find_all_roots(NULL, fs_info, found.objectid, 0, 2572 ret = btrfs_find_all_roots(NULL, fs_info, found.objectid, 0,
2573 &roots); 2573 &roots, false);
2574 if (ret < 0) 2574 if (ret < 0)
2575 goto out; 2575 goto out;
2576 /* For rescan, just pass old_roots as NULL */ 2576 /* For rescan, just pass old_roots as NULL */
diff --git a/fs/btrfs/scrub.c b/fs/btrfs/scrub.c
index cd1b791d9706..b2f871d80982 100644
--- a/fs/btrfs/scrub.c
+++ b/fs/btrfs/scrub.c
@@ -883,7 +883,7 @@ static void scrub_print_warning(const char *errstr, struct scrub_block *sblock)
883 swarn.dev = dev; 883 swarn.dev = dev;
884 iterate_extent_inodes(fs_info, found_key.objectid, 884 iterate_extent_inodes(fs_info, found_key.objectid,
885 extent_item_pos, 1, 885 extent_item_pos, 1,
886 scrub_print_warning_inode, &swarn); 886 scrub_print_warning_inode, &swarn, false);
887 } 887 }
888 888
889out: 889out:
@@ -1047,7 +1047,7 @@ static void scrub_fixup_nodatasum(struct btrfs_work *work)
1047 * can be found. 1047 * can be found.
1048 */ 1048 */
1049 ret = iterate_inodes_from_logical(fixup->logical, fs_info, path, 1049 ret = iterate_inodes_from_logical(fixup->logical, fs_info, path,
1050 scrub_fixup_readpage, fixup); 1050 scrub_fixup_readpage, fixup, false);
1051 if (ret < 0) { 1051 if (ret < 0) {
1052 uncorrectable = 1; 1052 uncorrectable = 1;
1053 goto out; 1053 goto out;
@@ -4390,7 +4390,7 @@ static void copy_nocow_pages_worker(struct btrfs_work *work)
4390 } 4390 }
4391 4391
4392 ret = iterate_inodes_from_logical(logical, fs_info, path, 4392 ret = iterate_inodes_from_logical(logical, fs_info, path,
4393 record_inode_for_nocow, nocow_ctx); 4393 record_inode_for_nocow, nocow_ctx, false);
4394 if (ret != 0 && ret != -ENOENT) { 4394 if (ret != 0 && ret != -ENOENT) {
4395 btrfs_warn(fs_info, 4395 btrfs_warn(fs_info,
4396 "iterate_inodes_from_logical() failed: log %llu, phys %llu, len %llu, mir %u, ret %d", 4396 "iterate_inodes_from_logical() failed: log %llu, phys %llu, len %llu, mir %u, ret %d",
diff --git a/fs/btrfs/send.c b/fs/btrfs/send.c
index 13b98a554aab..c10e4c70f02d 100644
--- a/fs/btrfs/send.c
+++ b/fs/btrfs/send.c
@@ -1423,7 +1423,7 @@ static int find_extent_clone(struct send_ctx *sctx,
1423 extent_item_pos = 0; 1423 extent_item_pos = 0;
1424 ret = iterate_extent_inodes(fs_info, found_key.objectid, 1424 ret = iterate_extent_inodes(fs_info, found_key.objectid,
1425 extent_item_pos, 1, __iterate_backrefs, 1425 extent_item_pos, 1, __iterate_backrefs,
1426 backref_ctx); 1426 backref_ctx, false);
1427 1427
1428 if (ret < 0) 1428 if (ret < 0)
1429 goto out; 1429 goto out;
diff --git a/fs/btrfs/tests/qgroup-tests.c b/fs/btrfs/tests/qgroup-tests.c
index 0f4ce970d195..90204b166643 100644
--- a/fs/btrfs/tests/qgroup-tests.c
+++ b/fs/btrfs/tests/qgroup-tests.c
@@ -240,7 +240,8 @@ static int test_no_shared_qgroup(struct btrfs_root *root,
240 * we can only call btrfs_qgroup_account_extent() directly to test 240 * we can only call btrfs_qgroup_account_extent() directly to test
241 * quota. 241 * quota.
242 */ 242 */
243 ret = btrfs_find_all_roots(&trans, fs_info, nodesize, 0, &old_roots); 243 ret = btrfs_find_all_roots(&trans, fs_info, nodesize, 0, &old_roots,
244 false);
244 if (ret) { 245 if (ret) {
245 ulist_free(old_roots); 246 ulist_free(old_roots);
246 test_msg("Couldn't find old roots: %d\n", ret); 247 test_msg("Couldn't find old roots: %d\n", ret);
@@ -252,7 +253,8 @@ static int test_no_shared_qgroup(struct btrfs_root *root,
252 if (ret) 253 if (ret)
253 return ret; 254 return ret;
254 255
255 ret = btrfs_find_all_roots(&trans, fs_info, nodesize, 0, &new_roots); 256 ret = btrfs_find_all_roots(&trans, fs_info, nodesize, 0, &new_roots,
257 false);
256 if (ret) { 258 if (ret) {
257 ulist_free(old_roots); 259 ulist_free(old_roots);
258 ulist_free(new_roots); 260 ulist_free(new_roots);
@@ -275,7 +277,8 @@ static int test_no_shared_qgroup(struct btrfs_root *root,
275 old_roots = NULL; 277 old_roots = NULL;
276 new_roots = NULL; 278 new_roots = NULL;
277 279
278 ret = btrfs_find_all_roots(&trans, fs_info, nodesize, 0, &old_roots); 280 ret = btrfs_find_all_roots(&trans, fs_info, nodesize, 0, &old_roots,
281 false);
279 if (ret) { 282 if (ret) {
280 ulist_free(old_roots); 283 ulist_free(old_roots);
281 test_msg("Couldn't find old roots: %d\n", ret); 284 test_msg("Couldn't find old roots: %d\n", ret);
@@ -286,7 +289,8 @@ static int test_no_shared_qgroup(struct btrfs_root *root,
286 if (ret) 289 if (ret)
287 return -EINVAL; 290 return -EINVAL;
288 291
289 ret = btrfs_find_all_roots(&trans, fs_info, nodesize, 0, &new_roots); 292 ret = btrfs_find_all_roots(&trans, fs_info, nodesize, 0, &new_roots,
293 false);
290 if (ret) { 294 if (ret) {
291 ulist_free(old_roots); 295 ulist_free(old_roots);
292 ulist_free(new_roots); 296 ulist_free(new_roots);
@@ -337,7 +341,8 @@ static int test_multiple_refs(struct btrfs_root *root,
337 return ret; 341 return ret;
338 } 342 }
339 343
340 ret = btrfs_find_all_roots(&trans, fs_info, nodesize, 0, &old_roots); 344 ret = btrfs_find_all_roots(&trans, fs_info, nodesize, 0, &old_roots,
345 false);
341 if (ret) { 346 if (ret) {
342 ulist_free(old_roots); 347 ulist_free(old_roots);
343 test_msg("Couldn't find old roots: %d\n", ret); 348 test_msg("Couldn't find old roots: %d\n", ret);
@@ -349,7 +354,8 @@ static int test_multiple_refs(struct btrfs_root *root,
349 if (ret) 354 if (ret)
350 return ret; 355 return ret;
351 356
352 ret = btrfs_find_all_roots(&trans, fs_info, nodesize, 0, &new_roots); 357 ret = btrfs_find_all_roots(&trans, fs_info, nodesize, 0, &new_roots,
358 false);
353 if (ret) { 359 if (ret) {
354 ulist_free(old_roots); 360 ulist_free(old_roots);
355 ulist_free(new_roots); 361 ulist_free(new_roots);
@@ -370,7 +376,8 @@ static int test_multiple_refs(struct btrfs_root *root,
370 return -EINVAL; 376 return -EINVAL;
371 } 377 }
372 378
373 ret = btrfs_find_all_roots(&trans, fs_info, nodesize, 0, &old_roots); 379 ret = btrfs_find_all_roots(&trans, fs_info, nodesize, 0, &old_roots,
380 false);
374 if (ret) { 381 if (ret) {
375 ulist_free(old_roots); 382 ulist_free(old_roots);
376 test_msg("Couldn't find old roots: %d\n", ret); 383 test_msg("Couldn't find old roots: %d\n", ret);
@@ -382,7 +389,8 @@ static int test_multiple_refs(struct btrfs_root *root,
382 if (ret) 389 if (ret)
383 return ret; 390 return ret;
384 391
385 ret = btrfs_find_all_roots(&trans, fs_info, nodesize, 0, &new_roots); 392 ret = btrfs_find_all_roots(&trans, fs_info, nodesize, 0, &new_roots,
393 false);
386 if (ret) { 394 if (ret) {
387 ulist_free(old_roots); 395 ulist_free(old_roots);
388 ulist_free(new_roots); 396 ulist_free(new_roots);
@@ -409,7 +417,8 @@ static int test_multiple_refs(struct btrfs_root *root,
409 return -EINVAL; 417 return -EINVAL;
410 } 418 }
411 419
412 ret = btrfs_find_all_roots(&trans, fs_info, nodesize, 0, &old_roots); 420 ret = btrfs_find_all_roots(&trans, fs_info, nodesize, 0, &old_roots,
421 false);
413 if (ret) { 422 if (ret) {
414 ulist_free(old_roots); 423 ulist_free(old_roots);
415 test_msg("Couldn't find old roots: %d\n", ret); 424 test_msg("Couldn't find old roots: %d\n", ret);
@@ -421,7 +430,8 @@ static int test_multiple_refs(struct btrfs_root *root,
421 if (ret) 430 if (ret)
422 return ret; 431 return ret;
423 432
424 ret = btrfs_find_all_roots(&trans, fs_info, nodesize, 0, &new_roots); 433 ret = btrfs_find_all_roots(&trans, fs_info, nodesize, 0, &new_roots,
434 false);
425 if (ret) { 435 if (ret) {
426 ulist_free(old_roots); 436 ulist_free(old_roots);
427 ulist_free(new_roots); 437 ulist_free(new_roots);