Skip to content

Commit 29d9c5e

Browse files
fdmananakdave
authored andcommitted
btrfs: avoid unnecessary path allocation at fixup_inode_link_count()
There's no need to allocate a path as our single caller already has a path that we can use. So pass the caller's path and use it. Signed-off-by: Filipe Manana <fdmanana@suse.com> Reviewed-by: David Sterba <dsterba@suse.com> Signed-off-by: David Sterba <dsterba@suse.com>
1 parent 2ac7094 commit 29d9c5e

1 file changed

Lines changed: 3 additions & 7 deletions

File tree

fs/btrfs/tree-log.c

Lines changed: 3 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1728,19 +1728,15 @@ static int count_inode_refs(struct btrfs_inode *inode, struct btrfs_path *path)
17281728
* will free the inode.
17291729
*/
17301730
static noinline int fixup_inode_link_count(struct walk_control *wc,
1731+
struct btrfs_path *path,
17311732
struct btrfs_inode *inode)
17321733
{
17331734
struct btrfs_trans_handle *trans = wc->trans;
17341735
struct btrfs_root *root = inode->root;
1735-
struct btrfs_path *path;
17361736
int ret;
17371737
u64 nlink = 0;
17381738
const u64 ino = btrfs_ino(inode);
17391739

1740-
path = btrfs_alloc_path();
1741-
if (!path)
1742-
return -ENOMEM;
1743-
17441740
ret = count_inode_refs(inode, path);
17451741
if (ret < 0)
17461742
goto out;
@@ -1776,7 +1772,7 @@ static noinline int fixup_inode_link_count(struct walk_control *wc,
17761772
}
17771773

17781774
out:
1779-
btrfs_free_path(path);
1775+
btrfs_release_path(path);
17801776
return ret;
17811777
}
17821778

@@ -1821,7 +1817,7 @@ static noinline int fixup_inode_link_counts(struct walk_control *wc,
18211817
break;
18221818
}
18231819

1824-
ret = fixup_inode_link_count(wc, inode);
1820+
ret = fixup_inode_link_count(wc, path, inode);
18251821
iput(&inode->vfs_inode);
18261822
if (ret)
18271823
break;

0 commit comments

Comments
 (0)