]> git.ipfire.org Git - thirdparty/kernel/linux.git/commitdiff
btrfs: set search_commit_root to false in iterate_inodes_from_logical()
authorFilipe Manana <fdmanana@suse.com>
Tue, 1 Jul 2025 21:45:47 +0000 (22:45 +0100)
committerDavid Sterba <dsterba@suse.com>
Mon, 21 Jul 2025 22:09:20 +0000 (00:09 +0200)
There's no point in checking at iterate_inodes_from_logical() if the path
has search_commit_root set, the only caller never sets search_commit_root
to true and it doesn't make sense for it ever to be true for the current
use case (logical_to_ino ioctl). So stop checking for that and since the
only caller allocates the path just for it to be used by
iterate_inodes_from_logical(), move the path allocation into that function.

Reviewed-by: Boris Burkov <boris@bur.io>
Signed-off-by: Filipe Manana <fdmanana@suse.com>
Reviewed-by: David Sterba <dsterba@suse.com>
Signed-off-by: David Sterba <dsterba@suse.com>
fs/btrfs/backref.c
fs/btrfs/backref.h
fs/btrfs/ioctl.c

index 2e0d959092f5b1d660997b52940ddc0ca9e4395e..6a450be293b1cd3eee0d572b75e0305a5d3ba652 100644 (file)
@@ -2546,17 +2546,20 @@ static int build_ino_list(u64 inum, u64 offset, u64 num_bytes, u64 root, void *c
 }
 
 int iterate_inodes_from_logical(u64 logical, struct btrfs_fs_info *fs_info,
-                               struct btrfs_path *path,
                                void *ctx, bool ignore_offset)
 {
        struct btrfs_backref_walk_ctx walk_ctx = { 0 };
        int ret;
        u64 flags = 0;
        struct btrfs_key found_key;
-       int search_commit_root = path->search_commit_root;
+       struct btrfs_path *path;
+
+       path = btrfs_alloc_path();
+       if (!path)
+               return -ENOMEM;
 
        ret = extent_from_logical(fs_info, logical, path, &found_key, &flags);
-       btrfs_release_path(path);
+       btrfs_free_path(path);
        if (ret < 0)
                return ret;
        if (flags & BTRFS_EXTENT_FLAG_TREE_BLOCK)
@@ -2569,8 +2572,7 @@ int iterate_inodes_from_logical(u64 logical, struct btrfs_fs_info *fs_info,
                walk_ctx.extent_item_pos = logical - found_key.objectid;
        walk_ctx.fs_info = fs_info;
 
-       return iterate_extent_inodes(&walk_ctx, search_commit_root,
-                                    build_ino_list, ctx);
+       return iterate_extent_inodes(&walk_ctx, false, build_ino_list, ctx);
 }
 
 static int inode_to_path(u64 inum, u32 name_len, unsigned long name_off,
index 61f53825226d546ab8fb1a34908bf04e43d3b74d..34b0193a181c885877ce574d2a8cde354b446751 100644 (file)
@@ -226,8 +226,7 @@ int iterate_extent_inodes(struct btrfs_backref_walk_ctx *ctx,
                          iterate_extent_inodes_t *iterate, void *user_ctx);
 
 int iterate_inodes_from_logical(u64 logical, struct btrfs_fs_info *fs_info,
-                               struct btrfs_path *path, void *ctx,
-                               bool ignore_offset);
+                               void *ctx, bool ignore_offset);
 
 int paths_from_inode(u64 inum, struct inode_fs_paths *ipath);
 
index 503c469249e5e5020484f4442111427a93690b51..680c4e794e676ebfbdff8c8c205afad6cc03f768 100644 (file)
@@ -3353,7 +3353,6 @@ static long btrfs_ioctl_logical_to_ino(struct btrfs_fs_info *fs_info,
        int size;
        struct btrfs_ioctl_logical_ino_args *loi;
        struct btrfs_data_container *inodes = NULL;
-       struct btrfs_path *path = NULL;
        bool ignore_offset;
 
        if (!capable(CAP_SYS_ADMIN))
@@ -3387,14 +3386,7 @@ static long btrfs_ioctl_logical_to_ino(struct btrfs_fs_info *fs_info,
                goto out_loi;
        }
 
-       path = btrfs_alloc_path();
-       if (!path) {
-               ret = -ENOMEM;
-               goto out;
-       }
-       ret = iterate_inodes_from_logical(loi->logical, fs_info, path,
-                                         inodes, ignore_offset);
-       btrfs_free_path(path);
+       ret = iterate_inodes_from_logical(loi->logical, fs_info, inodes, ignore_offset);
        if (ret == -EINVAL)
                ret = -ENOENT;
        if (ret < 0)