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: Nikolay Borisov <nborisov@suse.com> Reviewed-by: David Sterba <dsterba@suse.com> [ add changelog ] Signed-off-by: David Sterba <dsterba@suse.com>
This commit is contained in:
committed by
David Sterba
parent
3296bf5624
commit
89cbf5f6b6
@@ -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) {
|
||||||
|
ret = 0;
|
||||||
goto out;
|
goto out;
|
||||||
|
}
|
||||||
|
|
||||||
ptr = btrfs_item_ptr_offset(path->nodes[0], path->slots[0]);
|
if (key->type == BTRFS_INODE_EXTREF_KEY)
|
||||||
|
ret = !!btrfs_find_name_in_ext_backref(path->nodes[0],
|
||||||
if (key->type == BTRFS_INODE_EXTREF_KEY) {
|
|
||||||
if (btrfs_find_name_in_ext_backref(path->nodes[0],
|
|
||||||
path->slots[0],
|
path->slots[0],
|
||||||
ref_objectid,
|
ref_objectid,
|
||||||
name, namelen))
|
name, namelen);
|
||||||
match = 1;
|
else
|
||||||
|
ret = !!btrfs_find_name_in_backref(path->nodes[0],
|
||||||
goto out;
|
path->slots[0],
|
||||||
}
|
name, namelen);
|
||||||
|
|
||||||
item_size = btrfs_item_size_nr(path->nodes[0], path->slots[0]);
|
|
||||||
ptr_end = ptr + item_size;
|
|
||||||
while (ptr < ptr_end) {
|
|
||||||
ref = (struct btrfs_inode_ref *)ptr;
|
|
||||||
found_name_len = btrfs_inode_ref_name_len(path->nodes[0], ref);
|
|
||||||
if (found_name_len == namelen) {
|
|
||||||
name_ptr = (unsigned long)(ref + 1);
|
|
||||||
ret = memcmp_extent_buffer(path->nodes[0], name,
|
|
||||||
name_ptr, 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,
|
||||||
|
|||||||
Reference in New Issue
Block a user