diff options
author | Josef Bacik <jbacik@fusionio.com> | 2013-06-12 16:20:08 -0400 |
---|---|---|
committer | Josef Bacik <jbacik@fusionio.com> | 2013-07-01 08:52:29 -0400 |
commit | da61d31a78dc2116fa725c92d4eca36dfbc3da8b (patch) | |
tree | 51b3795955097ae28b695f753b7305a98f0b657d | |
parent | d88d46c6e06cb47cd3b951287ccaf414e96560d0 (diff) |
Btrfs: cleanup backref search commit root flag stuff
Looking into this backref problem I noticed we're using a macro to what turns
out to essentially be a NULL check to see if we need to search the commit root.
I'm killing this, let's just do what everybody else does and checks if trans ==
NULL. I've also made it so we pass in the path to __resolve_indirect_refs which
will have the search_commit_root flag set properly already and that way we can
avoid allocating another path when we have a perfectly good one to use. Thanks,
Signed-off-by: Josef Bacik <jbacik@fusionio.com>
-rw-r--r-- | fs/btrfs/backref.c | 41 | ||||
-rw-r--r-- | fs/btrfs/backref.h | 2 |
2 files changed, 16 insertions, 27 deletions
diff --git a/fs/btrfs/backref.c b/fs/btrfs/backref.c index 290e347b6db3..431ea9211bc1 100644 --- a/fs/btrfs/backref.c +++ b/fs/btrfs/backref.c | |||
@@ -255,13 +255,11 @@ static int add_all_parents(struct btrfs_root *root, struct btrfs_path *path, | |||
255 | * to a logical address | 255 | * to a logical address |
256 | */ | 256 | */ |
257 | static int __resolve_indirect_ref(struct btrfs_fs_info *fs_info, | 257 | static int __resolve_indirect_ref(struct btrfs_fs_info *fs_info, |
258 | int search_commit_root, | 258 | struct btrfs_path *path, u64 time_seq, |
259 | u64 time_seq, | 259 | struct __prelim_ref *ref, |
260 | struct __prelim_ref *ref, | 260 | struct ulist *parents, |
261 | struct ulist *parents, | 261 | const u64 *extent_item_pos) |
262 | const u64 *extent_item_pos) | ||
263 | { | 262 | { |
264 | struct btrfs_path *path; | ||
265 | struct btrfs_root *root; | 263 | struct btrfs_root *root; |
266 | struct btrfs_key root_key; | 264 | struct btrfs_key root_key; |
267 | struct extent_buffer *eb; | 265 | struct extent_buffer *eb; |
@@ -269,11 +267,6 @@ static int __resolve_indirect_ref(struct btrfs_fs_info *fs_info, | |||
269 | int root_level; | 267 | int root_level; |
270 | int level = ref->level; | 268 | int level = ref->level; |
271 | 269 | ||
272 | path = btrfs_alloc_path(); | ||
273 | if (!path) | ||
274 | return -ENOMEM; | ||
275 | path->search_commit_root = !!search_commit_root; | ||
276 | |||
277 | root_key.objectid = ref->root_id; | 270 | root_key.objectid = ref->root_id; |
278 | root_key.type = BTRFS_ROOT_ITEM_KEY; | 271 | root_key.type = BTRFS_ROOT_ITEM_KEY; |
279 | root_key.offset = (u64)-1; | 272 | root_key.offset = (u64)-1; |
@@ -314,7 +307,8 @@ static int __resolve_indirect_ref(struct btrfs_fs_info *fs_info, | |||
314 | time_seq, ref->wanted_disk_byte, | 307 | time_seq, ref->wanted_disk_byte, |
315 | extent_item_pos); | 308 | extent_item_pos); |
316 | out: | 309 | out: |
317 | btrfs_free_path(path); | 310 | path->lowest_level = 0; |
311 | btrfs_release_path(path); | ||
318 | return ret; | 312 | return ret; |
319 | } | 313 | } |
320 | 314 | ||
@@ -322,7 +316,7 @@ out: | |||
322 | * resolve all indirect backrefs from the list | 316 | * resolve all indirect backrefs from the list |
323 | */ | 317 | */ |
324 | static int __resolve_indirect_refs(struct btrfs_fs_info *fs_info, | 318 | static int __resolve_indirect_refs(struct btrfs_fs_info *fs_info, |
325 | int search_commit_root, u64 time_seq, | 319 | struct btrfs_path *path, u64 time_seq, |
326 | struct list_head *head, | 320 | struct list_head *head, |
327 | const u64 *extent_item_pos) | 321 | const u64 *extent_item_pos) |
328 | { | 322 | { |
@@ -349,9 +343,8 @@ static int __resolve_indirect_refs(struct btrfs_fs_info *fs_info, | |||
349 | continue; | 343 | continue; |
350 | if (ref->count == 0) | 344 | if (ref->count == 0) |
351 | continue; | 345 | continue; |
352 | err = __resolve_indirect_ref(fs_info, search_commit_root, | 346 | err = __resolve_indirect_ref(fs_info, path, time_seq, ref, |
353 | time_seq, ref, parents, | 347 | parents, extent_item_pos); |
354 | extent_item_pos); | ||
355 | if (err == -ENOMEM) | 348 | if (err == -ENOMEM) |
356 | goto out; | 349 | goto out; |
357 | if (err) | 350 | if (err) |
@@ -795,7 +788,6 @@ static int find_parent_nodes(struct btrfs_trans_handle *trans, | |||
795 | struct btrfs_delayed_ref_head *head; | 788 | struct btrfs_delayed_ref_head *head; |
796 | int info_level = 0; | 789 | int info_level = 0; |
797 | int ret; | 790 | int ret; |
798 | int search_commit_root = (trans == BTRFS_BACKREF_SEARCH_COMMIT_ROOT); | ||
799 | struct list_head prefs_delayed; | 791 | struct list_head prefs_delayed; |
800 | struct list_head prefs; | 792 | struct list_head prefs; |
801 | struct __prelim_ref *ref; | 793 | struct __prelim_ref *ref; |
@@ -810,7 +802,8 @@ static int find_parent_nodes(struct btrfs_trans_handle *trans, | |||
810 | path = btrfs_alloc_path(); | 802 | path = btrfs_alloc_path(); |
811 | if (!path) | 803 | if (!path) |
812 | return -ENOMEM; | 804 | return -ENOMEM; |
813 | path->search_commit_root = !!search_commit_root; | 805 | if (!trans) |
806 | path->search_commit_root = 1; | ||
814 | 807 | ||
815 | /* | 808 | /* |
816 | * grab both a lock on the path and a lock on the delayed ref head. | 809 | * grab both a lock on the path and a lock on the delayed ref head. |
@@ -825,7 +818,7 @@ again: | |||
825 | goto out; | 818 | goto out; |
826 | BUG_ON(ret == 0); | 819 | BUG_ON(ret == 0); |
827 | 820 | ||
828 | if (trans != BTRFS_BACKREF_SEARCH_COMMIT_ROOT) { | 821 | if (trans) { |
829 | /* | 822 | /* |
830 | * look if there are updates for this ref queued and lock the | 823 | * look if there are updates for this ref queued and lock the |
831 | * head | 824 | * head |
@@ -890,8 +883,8 @@ again: | |||
890 | 883 | ||
891 | __merge_refs(&prefs, 1); | 884 | __merge_refs(&prefs, 1); |
892 | 885 | ||
893 | ret = __resolve_indirect_refs(fs_info, search_commit_root, time_seq, | 886 | ret = __resolve_indirect_refs(fs_info, path, time_seq, &prefs, |
894 | &prefs, extent_item_pos); | 887 | extent_item_pos); |
895 | if (ret) | 888 | if (ret) |
896 | goto out; | 889 | goto out; |
897 | 890 | ||
@@ -1459,7 +1452,7 @@ int iterate_extent_inodes(struct btrfs_fs_info *fs_info, | |||
1459 | iterate_extent_inodes_t *iterate, void *ctx) | 1452 | iterate_extent_inodes_t *iterate, void *ctx) |
1460 | { | 1453 | { |
1461 | int ret; | 1454 | int ret; |
1462 | struct btrfs_trans_handle *trans; | 1455 | struct btrfs_trans_handle *trans = NULL; |
1463 | struct ulist *refs = NULL; | 1456 | struct ulist *refs = NULL; |
1464 | struct ulist *roots = NULL; | 1457 | struct ulist *roots = NULL; |
1465 | struct ulist_node *ref_node = NULL; | 1458 | struct ulist_node *ref_node = NULL; |
@@ -1471,9 +1464,7 @@ int iterate_extent_inodes(struct btrfs_fs_info *fs_info, | |||
1471 | pr_debug("resolving all inodes for extent %llu\n", | 1464 | pr_debug("resolving all inodes for extent %llu\n", |
1472 | extent_item_objectid); | 1465 | extent_item_objectid); |
1473 | 1466 | ||
1474 | if (search_commit_root) { | 1467 | if (!search_commit_root) { |
1475 | trans = BTRFS_BACKREF_SEARCH_COMMIT_ROOT; | ||
1476 | } else { | ||
1477 | trans = btrfs_join_transaction(fs_info->extent_root); | 1468 | trans = btrfs_join_transaction(fs_info->extent_root); |
1478 | if (IS_ERR(trans)) | 1469 | if (IS_ERR(trans)) |
1479 | return PTR_ERR(trans); | 1470 | return PTR_ERR(trans); |
diff --git a/fs/btrfs/backref.h b/fs/btrfs/backref.h index 0f446d7ca2c0..8f2e76702932 100644 --- a/fs/btrfs/backref.h +++ b/fs/btrfs/backref.h | |||
@@ -23,8 +23,6 @@ | |||
23 | #include "ulist.h" | 23 | #include "ulist.h" |
24 | #include "extent_io.h" | 24 | #include "extent_io.h" |
25 | 25 | ||
26 | #define BTRFS_BACKREF_SEARCH_COMMIT_ROOT ((struct btrfs_trans_handle *)0) | ||
27 | |||
28 | struct inode_fs_paths { | 26 | struct inode_fs_paths { |
29 | struct btrfs_path *btrfs_path; | 27 | struct btrfs_path *btrfs_path; |
30 | struct btrfs_root *fs_root; | 28 | struct btrfs_root *fs_root; |