Commit 8befc61c authored by Filipe Manana's avatar Filipe Manana Committed by David Sterba

btrfs: remove redundant root argument from fixup_inode_link_count()

The root argument for fixup_inode_link_count() always matches the root of
the given inode, so remove the root argument and get it from the inode
argument. This also applies to the helpers count_inode_extrefs() and
count_inode_refs() used by fixup_inode_link_count() - they don't need the
root argument, as it always matches the root of the inode passed to them.
Reviewed-by: default avatarQu Wenruo <wqu@suse.com>
Signed-off-by: default avatarFilipe Manana <fdmanana@suse.com>
Reviewed-by: default avatarDavid Sterba <dsterba@suse.com>
Signed-off-by: default avatarDavid Sterba <dsterba@suse.com>
parent 0a325e62
...@@ -1483,8 +1483,7 @@ static noinline int add_inode_ref(struct btrfs_trans_handle *trans, ...@@ -1483,8 +1483,7 @@ static noinline int add_inode_ref(struct btrfs_trans_handle *trans,
return ret; return ret;
} }
static int count_inode_extrefs(struct btrfs_root *root, static int count_inode_extrefs(struct btrfs_inode *inode, struct btrfs_path *path)
struct btrfs_inode *inode, struct btrfs_path *path)
{ {
int ret = 0; int ret = 0;
int name_len; int name_len;
...@@ -1498,8 +1497,8 @@ static int count_inode_extrefs(struct btrfs_root *root, ...@@ -1498,8 +1497,8 @@ static int count_inode_extrefs(struct btrfs_root *root,
struct extent_buffer *leaf; struct extent_buffer *leaf;
while (1) { while (1) {
ret = btrfs_find_one_extref(root, inode_objectid, offset, path, ret = btrfs_find_one_extref(inode->root, inode_objectid, offset,
&extref, &offset); path, &extref, &offset);
if (ret) if (ret)
break; break;
...@@ -1527,8 +1526,7 @@ static int count_inode_extrefs(struct btrfs_root *root, ...@@ -1527,8 +1526,7 @@ static int count_inode_extrefs(struct btrfs_root *root,
return nlink; return nlink;
} }
static int count_inode_refs(struct btrfs_root *root, static int count_inode_refs(struct btrfs_inode *inode, struct btrfs_path *path)
struct btrfs_inode *inode, struct btrfs_path *path)
{ {
int ret; int ret;
struct btrfs_key key; struct btrfs_key key;
...@@ -1543,7 +1541,7 @@ static int count_inode_refs(struct btrfs_root *root, ...@@ -1543,7 +1541,7 @@ static int count_inode_refs(struct btrfs_root *root,
key.offset = (u64)-1; key.offset = (u64)-1;
while (1) { while (1) {
ret = btrfs_search_slot(NULL, root, &key, path, 0, 0); ret = btrfs_search_slot(NULL, inode->root, &key, path, 0, 0);
if (ret < 0) if (ret < 0)
break; break;
if (ret > 0) { if (ret > 0) {
...@@ -1595,9 +1593,9 @@ static int count_inode_refs(struct btrfs_root *root, ...@@ -1595,9 +1593,9 @@ static int count_inode_refs(struct btrfs_root *root,
* will free the inode. * will free the inode.
*/ */
static noinline int fixup_inode_link_count(struct btrfs_trans_handle *trans, static noinline int fixup_inode_link_count(struct btrfs_trans_handle *trans,
struct btrfs_root *root,
struct inode *inode) struct inode *inode)
{ {
struct btrfs_root *root = BTRFS_I(inode)->root;
struct btrfs_path *path; struct btrfs_path *path;
int ret; int ret;
u64 nlink = 0; u64 nlink = 0;
...@@ -1607,13 +1605,13 @@ static noinline int fixup_inode_link_count(struct btrfs_trans_handle *trans, ...@@ -1607,13 +1605,13 @@ static noinline int fixup_inode_link_count(struct btrfs_trans_handle *trans,
if (!path) if (!path)
return -ENOMEM; return -ENOMEM;
ret = count_inode_refs(root, BTRFS_I(inode), path); ret = count_inode_refs(BTRFS_I(inode), path);
if (ret < 0) if (ret < 0)
goto out; goto out;
nlink = ret; nlink = ret;
ret = count_inode_extrefs(root, BTRFS_I(inode), path); ret = count_inode_extrefs(BTRFS_I(inode), path);
if (ret < 0) if (ret < 0)
goto out; goto out;
...@@ -1685,7 +1683,7 @@ static noinline int fixup_inode_link_counts(struct btrfs_trans_handle *trans, ...@@ -1685,7 +1683,7 @@ static noinline int fixup_inode_link_counts(struct btrfs_trans_handle *trans,
break; break;
} }
ret = fixup_inode_link_count(trans, root, inode); ret = fixup_inode_link_count(trans, inode);
iput(inode); iput(inode);
if (ret) if (ret)
break; break;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment