Skip to content

Commit f007ad1

Browse files
fdmananakdave
authored andcommitted
btrfs: set search_commit_root to false in iterate_inodes_from_logical()
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> Signed-off-by: David Sterba <dsterba@suse.com>
1 parent 6383f23 commit f007ad1

File tree

3 files changed

+9
-16
lines changed

3 files changed

+9
-16
lines changed

fs/btrfs/backref.c

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2546,17 +2546,20 @@ static int build_ino_list(u64 inum, u64 offset, u64 num_bytes, u64 root, void *c
25462546
}
25472547

25482548
int iterate_inodes_from_logical(u64 logical, struct btrfs_fs_info *fs_info,
2549-
struct btrfs_path *path,
25502549
void *ctx, bool ignore_offset)
25512550
{
25522551
struct btrfs_backref_walk_ctx walk_ctx = { 0 };
25532552
int ret;
25542553
u64 flags = 0;
25552554
struct btrfs_key found_key;
2556-
int search_commit_root = path->search_commit_root;
2555+
struct btrfs_path *path;
2556+
2557+
path = btrfs_alloc_path();
2558+
if (!path)
2559+
return -ENOMEM;
25572560

25582561
ret = extent_from_logical(fs_info, logical, path, &found_key, &flags);
2559-
btrfs_release_path(path);
2562+
btrfs_free_path(path);
25602563
if (ret < 0)
25612564
return ret;
25622565
if (flags & BTRFS_EXTENT_FLAG_TREE_BLOCK)
@@ -2569,8 +2572,7 @@ int iterate_inodes_from_logical(u64 logical, struct btrfs_fs_info *fs_info,
25692572
walk_ctx.extent_item_pos = logical - found_key.objectid;
25702573
walk_ctx.fs_info = fs_info;
25712574

2572-
return iterate_extent_inodes(&walk_ctx, search_commit_root,
2573-
build_ino_list, ctx);
2575+
return iterate_extent_inodes(&walk_ctx, false, build_ino_list, ctx);
25742576
}
25752577

25762578
static int inode_to_path(u64 inum, u32 name_len, unsigned long name_off,

fs/btrfs/backref.h

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -226,8 +226,7 @@ int iterate_extent_inodes(struct btrfs_backref_walk_ctx *ctx,
226226
iterate_extent_inodes_t *iterate, void *user_ctx);
227227

228228
int iterate_inodes_from_logical(u64 logical, struct btrfs_fs_info *fs_info,
229-
struct btrfs_path *path, void *ctx,
230-
bool ignore_offset);
229+
void *ctx, bool ignore_offset);
231230

232231
int paths_from_inode(u64 inum, struct inode_fs_paths *ipath);
233232

fs/btrfs/ioctl.c

Lines changed: 1 addition & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -3353,7 +3353,6 @@ static long btrfs_ioctl_logical_to_ino(struct btrfs_fs_info *fs_info,
33533353
int size;
33543354
struct btrfs_ioctl_logical_ino_args *loi;
33553355
struct btrfs_data_container *inodes = NULL;
3356-
struct btrfs_path *path = NULL;
33573356
bool ignore_offset;
33583357

33593358
if (!capable(CAP_SYS_ADMIN))
@@ -3387,14 +3386,7 @@ static long btrfs_ioctl_logical_to_ino(struct btrfs_fs_info *fs_info,
33873386
goto out_loi;
33883387
}
33893388

3390-
path = btrfs_alloc_path();
3391-
if (!path) {
3392-
ret = -ENOMEM;
3393-
goto out;
3394-
}
3395-
ret = iterate_inodes_from_logical(loi->logical, fs_info, path,
3396-
inodes, ignore_offset);
3397-
btrfs_free_path(path);
3389+
ret = iterate_inodes_from_logical(loi->logical, fs_info, inodes, ignore_offset);
33983390
if (ret == -EINVAL)
33993391
ret = -ENOENT;
34003392
if (ret < 0)

0 commit comments

Comments
 (0)