diff options
author | Gabriel Niebler <gniebler@suse.com> | 2022-03-09 14:50:45 +0100 |
---|---|---|
committer | David Sterba <dsterba@suse.com> | 2022-05-16 17:03:08 +0200 |
commit | 35a68080ff86c74f9921b5048e444eff3b92e84e (patch) | |
tree | d7fd8880f21c107e9b9b7fdb3fbebea2d65ddfc5 /fs/btrfs/send.c | |
parent | btrfs: use btrfs_for_each_slot in can_rmdir (diff) | |
download | linux-35a68080ff86c74f9921b5048e444eff3b92e84e.tar.xz linux-35a68080ff86c74f9921b5048e444eff3b92e84e.zip |
btrfs: use btrfs_for_each_slot in is_ancestor
This function can be simplified by refactoring to use the new iterator
macro. No functional changes.
Signed-off-by: Marcos Paulo de Souza <mpdesouza@suse.com>
Signed-off-by: Gabriel Niebler <gniebler@suse.com>
Reviewed-by: David Sterba <dsterba@suse.com>
Signed-off-by: David Sterba <dsterba@suse.com>
Diffstat (limited to 'fs/btrfs/send.c')
-rw-r--r-- | fs/btrfs/send.c | 25 |
1 files changed, 7 insertions, 18 deletions
diff --git a/fs/btrfs/send.c b/fs/btrfs/send.c index 9239f6124568..31aa303ddfd8 100644 --- a/fs/btrfs/send.c +++ b/fs/btrfs/send.c @@ -3550,7 +3550,7 @@ static int check_ino_in_path(struct btrfs_root *root, } /* - * Check if ino ino1 is an ancestor of inode ino2 in the given root for any + * Check if inode ino1 is an ancestor of inode ino2 in the given root for any * possible path (in case ino2 is not a directory and has multiple hard links). * Return 1 if true, 0 if false and < 0 on error. */ @@ -3562,6 +3562,7 @@ static int is_ancestor(struct btrfs_root *root, { bool free_fs_path = false; int ret = 0; + int iter_ret = 0; struct btrfs_path *path = NULL; struct btrfs_key key; @@ -3582,26 +3583,12 @@ static int is_ancestor(struct btrfs_root *root, key.type = BTRFS_INODE_REF_KEY; key.offset = 0; - ret = btrfs_search_slot(NULL, root, &key, path, 0, 0); - if (ret < 0) - goto out; - - while (true) { + btrfs_for_each_slot(root, &key, &key, path, iter_ret) { struct extent_buffer *leaf = path->nodes[0]; int slot = path->slots[0]; u32 cur_offset = 0; u32 item_size; - if (slot >= btrfs_header_nritems(leaf)) { - ret = btrfs_next_leaf(root, path); - if (ret < 0) - goto out; - if (ret > 0) - break; - continue; - } - - btrfs_item_key_to_cpu(leaf, &key, slot); if (key.objectid != ino2) break; if (key.type != BTRFS_INODE_REF_KEY && @@ -3639,10 +3626,12 @@ static int is_ancestor(struct btrfs_root *root, if (ret) goto out; } - path->slots[0]++; } ret = 0; - out: + if (iter_ret < 0) + ret = iter_ret; + +out: btrfs_free_path(path); if (free_fs_path) fs_path_free(fs_path); |