Commit da61d31a authored by Josef Bacik's avatar Josef Bacik

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: default avatarJosef Bacik <jbacik@fusionio.com>
parent d88d46c6
...@@ -255,13 +255,11 @@ static int add_all_parents(struct btrfs_root *root, struct btrfs_path *path, ...@@ -255,13 +255,11 @@ static int add_all_parents(struct btrfs_root *root, struct btrfs_path *path,
* to a logical address * to a logical address
*/ */
static int __resolve_indirect_ref(struct btrfs_fs_info *fs_info, static int __resolve_indirect_ref(struct btrfs_fs_info *fs_info,
int search_commit_root, struct btrfs_path *path, u64 time_seq,
u64 time_seq, struct __prelim_ref *ref,
struct __prelim_ref *ref, struct ulist *parents,
struct ulist *parents, const u64 *extent_item_pos)
const u64 *extent_item_pos)
{ {
struct btrfs_path *path;
struct btrfs_root *root; struct btrfs_root *root;
struct btrfs_key root_key; struct btrfs_key root_key;
struct extent_buffer *eb; struct extent_buffer *eb;
...@@ -269,11 +267,6 @@ static int __resolve_indirect_ref(struct btrfs_fs_info *fs_info, ...@@ -269,11 +267,6 @@ static int __resolve_indirect_ref(struct btrfs_fs_info *fs_info,
int root_level; int root_level;
int level = ref->level; int level = ref->level;
path = btrfs_alloc_path();
if (!path)
return -ENOMEM;
path->search_commit_root = !!search_commit_root;
root_key.objectid = ref->root_id; root_key.objectid = ref->root_id;
root_key.type = BTRFS_ROOT_ITEM_KEY; root_key.type = BTRFS_ROOT_ITEM_KEY;
root_key.offset = (u64)-1; root_key.offset = (u64)-1;
...@@ -314,7 +307,8 @@ static int __resolve_indirect_ref(struct btrfs_fs_info *fs_info, ...@@ -314,7 +307,8 @@ static int __resolve_indirect_ref(struct btrfs_fs_info *fs_info,
time_seq, ref->wanted_disk_byte, time_seq, ref->wanted_disk_byte,
extent_item_pos); extent_item_pos);
out: out:
btrfs_free_path(path); path->lowest_level = 0;
btrfs_release_path(path);
return ret; return ret;
} }
...@@ -322,7 +316,7 @@ static int __resolve_indirect_ref(struct btrfs_fs_info *fs_info, ...@@ -322,7 +316,7 @@ static int __resolve_indirect_ref(struct btrfs_fs_info *fs_info,
* resolve all indirect backrefs from the list * resolve all indirect backrefs from the list
*/ */
static int __resolve_indirect_refs(struct btrfs_fs_info *fs_info, static int __resolve_indirect_refs(struct btrfs_fs_info *fs_info,
int search_commit_root, u64 time_seq, struct btrfs_path *path, u64 time_seq,
struct list_head *head, struct list_head *head,
const u64 *extent_item_pos) const u64 *extent_item_pos)
{ {
...@@ -349,9 +343,8 @@ static int __resolve_indirect_refs(struct btrfs_fs_info *fs_info, ...@@ -349,9 +343,8 @@ static int __resolve_indirect_refs(struct btrfs_fs_info *fs_info,
continue; continue;
if (ref->count == 0) if (ref->count == 0)
continue; continue;
err = __resolve_indirect_ref(fs_info, search_commit_root, err = __resolve_indirect_ref(fs_info, path, time_seq, ref,
time_seq, ref, parents, parents, extent_item_pos);
extent_item_pos);
if (err == -ENOMEM) if (err == -ENOMEM)
goto out; goto out;
if (err) if (err)
...@@ -795,7 +788,6 @@ static int find_parent_nodes(struct btrfs_trans_handle *trans, ...@@ -795,7 +788,6 @@ static int find_parent_nodes(struct btrfs_trans_handle *trans,
struct btrfs_delayed_ref_head *head; struct btrfs_delayed_ref_head *head;
int info_level = 0; int info_level = 0;
int ret; int ret;
int search_commit_root = (trans == BTRFS_BACKREF_SEARCH_COMMIT_ROOT);
struct list_head prefs_delayed; struct list_head prefs_delayed;
struct list_head prefs; struct list_head prefs;
struct __prelim_ref *ref; struct __prelim_ref *ref;
...@@ -810,7 +802,8 @@ static int find_parent_nodes(struct btrfs_trans_handle *trans, ...@@ -810,7 +802,8 @@ static int find_parent_nodes(struct btrfs_trans_handle *trans,
path = btrfs_alloc_path(); path = btrfs_alloc_path();
if (!path) if (!path)
return -ENOMEM; return -ENOMEM;
path->search_commit_root = !!search_commit_root; if (!trans)
path->search_commit_root = 1;
/* /*
* grab both a lock on the path and a lock on the delayed ref head. * grab both a lock on the path and a lock on the delayed ref head.
...@@ -825,7 +818,7 @@ static int find_parent_nodes(struct btrfs_trans_handle *trans, ...@@ -825,7 +818,7 @@ static int find_parent_nodes(struct btrfs_trans_handle *trans,
goto out; goto out;
BUG_ON(ret == 0); BUG_ON(ret == 0);
if (trans != BTRFS_BACKREF_SEARCH_COMMIT_ROOT) { if (trans) {
/* /*
* look if there are updates for this ref queued and lock the * look if there are updates for this ref queued and lock the
* head * head
...@@ -890,8 +883,8 @@ static int find_parent_nodes(struct btrfs_trans_handle *trans, ...@@ -890,8 +883,8 @@ static int find_parent_nodes(struct btrfs_trans_handle *trans,
__merge_refs(&prefs, 1); __merge_refs(&prefs, 1);
ret = __resolve_indirect_refs(fs_info, search_commit_root, time_seq, ret = __resolve_indirect_refs(fs_info, path, time_seq, &prefs,
&prefs, extent_item_pos); extent_item_pos);
if (ret) if (ret)
goto out; goto out;
...@@ -1459,7 +1452,7 @@ int iterate_extent_inodes(struct btrfs_fs_info *fs_info, ...@@ -1459,7 +1452,7 @@ int iterate_extent_inodes(struct btrfs_fs_info *fs_info,
iterate_extent_inodes_t *iterate, void *ctx) iterate_extent_inodes_t *iterate, void *ctx)
{ {
int ret; int ret;
struct btrfs_trans_handle *trans; struct btrfs_trans_handle *trans = NULL;
struct ulist *refs = NULL; struct ulist *refs = NULL;
struct ulist *roots = NULL; struct ulist *roots = NULL;
struct ulist_node *ref_node = NULL; struct ulist_node *ref_node = NULL;
...@@ -1471,9 +1464,7 @@ int iterate_extent_inodes(struct btrfs_fs_info *fs_info, ...@@ -1471,9 +1464,7 @@ int iterate_extent_inodes(struct btrfs_fs_info *fs_info,
pr_debug("resolving all inodes for extent %llu\n", pr_debug("resolving all inodes for extent %llu\n",
extent_item_objectid); extent_item_objectid);
if (search_commit_root) { if (!search_commit_root) {
trans = BTRFS_BACKREF_SEARCH_COMMIT_ROOT;
} else {
trans = btrfs_join_transaction(fs_info->extent_root); trans = btrfs_join_transaction(fs_info->extent_root);
if (IS_ERR(trans)) if (IS_ERR(trans))
return PTR_ERR(trans); return PTR_ERR(trans);
......
...@@ -23,8 +23,6 @@ ...@@ -23,8 +23,6 @@
#include "ulist.h" #include "ulist.h"
#include "extent_io.h" #include "extent_io.h"
#define BTRFS_BACKREF_SEARCH_COMMIT_ROOT ((struct btrfs_trans_handle *)0)
struct inode_fs_paths { struct inode_fs_paths {
struct btrfs_path *btrfs_path; struct btrfs_path *btrfs_path;
struct btrfs_root *fs_root; struct btrfs_root *fs_root;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment