Commit 89cbf5f6 authored by Nikolay Borisov's avatar Nikolay Borisov Committed by David Sterba

btrfs: Don't opencode btrfs_find_name_in_backref in backref_in_log

Direct replacement, though note that the inside of the loop in
btrfs_find_name_in_backref is organized in a slightly different way but
is equvalent.
Signed-off-by: default avatarNikolay Borisov <nborisov@suse.com>
Reviewed-by: default avatarDavid Sterba <dsterba@suse.com>
[ add changelog ]
Signed-off-by: default avatarDavid Sterba <dsterba@suse.com>
parent 3296bf56
...@@ -945,54 +945,30 @@ static noinline int backref_in_log(struct btrfs_root *log, ...@@ -945,54 +945,30 @@ static noinline int backref_in_log(struct btrfs_root *log,
const char *name, int namelen) const char *name, int namelen)
{ {
struct btrfs_path *path; struct btrfs_path *path;
struct btrfs_inode_ref *ref;
unsigned long ptr;
unsigned long ptr_end;
unsigned long name_ptr;
int found_name_len;
int item_size;
int ret; int ret;
int match = 0;
path = btrfs_alloc_path(); path = btrfs_alloc_path();
if (!path) if (!path)
return -ENOMEM; return -ENOMEM;
ret = btrfs_search_slot(NULL, log, key, path, 0, 0); ret = btrfs_search_slot(NULL, log, key, path, 0, 0);
if (ret != 0) if (ret != 0) {
goto out; ret = 0;
ptr = btrfs_item_ptr_offset(path->nodes[0], path->slots[0]);
if (key->type == BTRFS_INODE_EXTREF_KEY) {
if (btrfs_find_name_in_ext_backref(path->nodes[0],
path->slots[0],
ref_objectid,
name, namelen))
match = 1;
goto out; goto out;
} }
item_size = btrfs_item_size_nr(path->nodes[0], path->slots[0]); if (key->type == BTRFS_INODE_EXTREF_KEY)
ptr_end = ptr + item_size; ret = !!btrfs_find_name_in_ext_backref(path->nodes[0],
while (ptr < ptr_end) { path->slots[0],
ref = (struct btrfs_inode_ref *)ptr; ref_objectid,
found_name_len = btrfs_inode_ref_name_len(path->nodes[0], ref); name, namelen);
if (found_name_len == namelen) { else
name_ptr = (unsigned long)(ref + 1); ret = !!btrfs_find_name_in_backref(path->nodes[0],
ret = memcmp_extent_buffer(path->nodes[0], name, path->slots[0],
name_ptr, namelen); name, namelen);
if (ret == 0) {
match = 1;
goto out;
}
}
ptr = (unsigned long)(ref + 1) + found_name_len;
}
out: out:
btrfs_free_path(path); btrfs_free_path(path);
return match; return ret;
} }
static inline int __add_inode_ref(struct btrfs_trans_handle *trans, static inline int __add_inode_ref(struct btrfs_trans_handle *trans,
......
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