Skip to content

Commit 4467af8

Browse files
fdmananakdave
authored andcommitted
btrfs: remove root argument from btrfs_unlink_inode()
The root argument passed to btrfs_unlink_inode() and its callee, __btrfs_unlink_inode(), always matches the root of the given directory and the given inode. So remove the argument and make __btrfs_unlink_inode() use the root of the directory. Signed-off-by: Filipe Manana <[email protected]> Reviewed-by: David Sterba <[email protected]> Signed-off-by: David Sterba <[email protected]>
1 parent 9798ba2 commit 4467af8

File tree

3 files changed

+18
-22
lines changed

3 files changed

+18
-22
lines changed

fs/btrfs/ctree.h

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3195,7 +3195,6 @@ void __btrfs_del_delalloc_inode(struct btrfs_root *root,
31953195
struct inode *btrfs_lookup_dentry(struct inode *dir, struct dentry *dentry);
31963196
int btrfs_set_inode_index(struct btrfs_inode *dir, u64 *index);
31973197
int btrfs_unlink_inode(struct btrfs_trans_handle *trans,
3198-
struct btrfs_root *root,
31993198
struct btrfs_inode *dir, struct btrfs_inode *inode,
32003199
const char *name, int name_len);
32013200
int btrfs_add_link(struct btrfs_trans_handle *trans,

fs/btrfs/inode.c

Lines changed: 11 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -4056,11 +4056,11 @@ int btrfs_update_inode_fallback(struct btrfs_trans_handle *trans,
40564056
* also drops the back refs in the inode to the directory
40574057
*/
40584058
static int __btrfs_unlink_inode(struct btrfs_trans_handle *trans,
4059-
struct btrfs_root *root,
40604059
struct btrfs_inode *dir,
40614060
struct btrfs_inode *inode,
40624061
const char *name, int name_len)
40634062
{
4063+
struct btrfs_root *root = dir->root;
40644064
struct btrfs_fs_info *fs_info = root->fs_info;
40654065
struct btrfs_path *path;
40664066
int ret = 0;
@@ -4150,15 +4150,14 @@ static int __btrfs_unlink_inode(struct btrfs_trans_handle *trans,
41504150
}
41514151

41524152
int btrfs_unlink_inode(struct btrfs_trans_handle *trans,
4153-
struct btrfs_root *root,
41544153
struct btrfs_inode *dir, struct btrfs_inode *inode,
41554154
const char *name, int name_len)
41564155
{
41574156
int ret;
4158-
ret = __btrfs_unlink_inode(trans, root, dir, inode, name, name_len);
4157+
ret = __btrfs_unlink_inode(trans, dir, inode, name, name_len);
41594158
if (!ret) {
41604159
drop_nlink(&inode->vfs_inode);
4161-
ret = btrfs_update_inode(trans, root, inode);
4160+
ret = btrfs_update_inode(trans, inode->root, inode);
41624161
}
41634162
return ret;
41644163
}
@@ -4187,7 +4186,6 @@ static struct btrfs_trans_handle *__unlink_start_trans(struct inode *dir)
41874186

41884187
static int btrfs_unlink(struct inode *dir, struct dentry *dentry)
41894188
{
4190-
struct btrfs_root *root = BTRFS_I(dir)->root;
41914189
struct btrfs_trans_handle *trans;
41924190
struct inode *inode = d_inode(dentry);
41934191
int ret;
@@ -4199,7 +4197,7 @@ static int btrfs_unlink(struct inode *dir, struct dentry *dentry)
41994197
btrfs_record_unlink_dir(trans, BTRFS_I(dir), BTRFS_I(d_inode(dentry)),
42004198
0);
42014199

4202-
ret = btrfs_unlink_inode(trans, root, BTRFS_I(dir),
4200+
ret = btrfs_unlink_inode(trans, BTRFS_I(dir),
42034201
BTRFS_I(d_inode(dentry)), dentry->d_name.name,
42044202
dentry->d_name.len);
42054203
if (ret)
@@ -4213,7 +4211,7 @@ static int btrfs_unlink(struct inode *dir, struct dentry *dentry)
42134211

42144212
out:
42154213
btrfs_end_transaction(trans);
4216-
btrfs_btree_balance_dirty(root->fs_info);
4214+
btrfs_btree_balance_dirty(BTRFS_I(dir)->root->fs_info);
42174215
return ret;
42184216
}
42194217

@@ -4564,7 +4562,6 @@ static int btrfs_rmdir(struct inode *dir, struct dentry *dentry)
45644562
{
45654563
struct inode *inode = d_inode(dentry);
45664564
int err = 0;
4567-
struct btrfs_root *root = BTRFS_I(dir)->root;
45684565
struct btrfs_trans_handle *trans;
45694566
u64 last_unlink_trans;
45704567

@@ -4589,7 +4586,7 @@ static int btrfs_rmdir(struct inode *dir, struct dentry *dentry)
45894586
last_unlink_trans = BTRFS_I(inode)->last_unlink_trans;
45904587

45914588
/* now the directory is empty */
4592-
err = btrfs_unlink_inode(trans, root, BTRFS_I(dir),
4589+
err = btrfs_unlink_inode(trans, BTRFS_I(dir),
45934590
BTRFS_I(d_inode(dentry)), dentry->d_name.name,
45944591
dentry->d_name.len);
45954592
if (!err) {
@@ -4610,7 +4607,7 @@ static int btrfs_rmdir(struct inode *dir, struct dentry *dentry)
46104607
}
46114608
out:
46124609
btrfs_end_transaction(trans);
4613-
btrfs_btree_balance_dirty(root->fs_info);
4610+
btrfs_btree_balance_dirty(BTRFS_I(dir)->root->fs_info);
46144611

46154612
return err;
46164613
}
@@ -9468,7 +9465,7 @@ static int btrfs_rename_exchange(struct inode *old_dir,
94689465
if (old_ino == BTRFS_FIRST_FREE_OBJECTID) {
94699466
ret = btrfs_unlink_subvol(trans, old_dir, old_dentry);
94709467
} else { /* src is an inode */
9471-
ret = __btrfs_unlink_inode(trans, root, BTRFS_I(old_dir),
9468+
ret = __btrfs_unlink_inode(trans, BTRFS_I(old_dir),
94729469
BTRFS_I(old_dentry->d_inode),
94739470
old_dentry->d_name.name,
94749471
old_dentry->d_name.len);
@@ -9484,7 +9481,7 @@ static int btrfs_rename_exchange(struct inode *old_dir,
94849481
if (new_ino == BTRFS_FIRST_FREE_OBJECTID) {
94859482
ret = btrfs_unlink_subvol(trans, new_dir, new_dentry);
94869483
} else { /* dest is an inode */
9487-
ret = __btrfs_unlink_inode(trans, dest, BTRFS_I(new_dir),
9484+
ret = __btrfs_unlink_inode(trans, BTRFS_I(new_dir),
94889485
BTRFS_I(new_dentry->d_inode),
94899486
new_dentry->d_name.name,
94909487
new_dentry->d_name.len);
@@ -9759,7 +9756,7 @@ static int btrfs_rename(struct user_namespace *mnt_userns,
97599756
*/
97609757
btrfs_pin_log_trans(root);
97619758
log_pinned = true;
9762-
ret = __btrfs_unlink_inode(trans, root, BTRFS_I(old_dir),
9759+
ret = __btrfs_unlink_inode(trans, BTRFS_I(old_dir),
97639760
BTRFS_I(d_inode(old_dentry)),
97649761
old_dentry->d_name.name,
97659762
old_dentry->d_name.len);
@@ -9779,7 +9776,7 @@ static int btrfs_rename(struct user_namespace *mnt_userns,
97799776
ret = btrfs_unlink_subvol(trans, new_dir, new_dentry);
97809777
BUG_ON(new_inode->i_nlink == 0);
97819778
} else {
9782-
ret = btrfs_unlink_inode(trans, dest, BTRFS_I(new_dir),
9779+
ret = btrfs_unlink_inode(trans, BTRFS_I(new_dir),
97839780
BTRFS_I(d_inode(new_dentry)),
97849781
new_dentry->d_name.name,
97859782
new_dentry->d_name.len);

fs/btrfs/tree-log.c

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -954,7 +954,7 @@ static noinline int drop_one_dir_item(struct btrfs_trans_handle *trans,
954954
if (ret)
955955
goto out;
956956

957-
ret = btrfs_unlink_inode(trans, root, dir, BTRFS_I(inode), name,
957+
ret = btrfs_unlink_inode(trans, dir, BTRFS_I(inode), name,
958958
name_len);
959959
if (ret)
960960
goto out;
@@ -1119,7 +1119,7 @@ static inline int __add_inode_ref(struct btrfs_trans_handle *trans,
11191119
inc_nlink(&inode->vfs_inode);
11201120
btrfs_release_path(path);
11211121

1122-
ret = btrfs_unlink_inode(trans, root, dir, inode,
1122+
ret = btrfs_unlink_inode(trans, dir, inode,
11231123
victim_name, victim_name_len);
11241124
kfree(victim_name);
11251125
if (ret)
@@ -1190,7 +1190,7 @@ static inline int __add_inode_ref(struct btrfs_trans_handle *trans,
11901190
inc_nlink(&inode->vfs_inode);
11911191
btrfs_release_path(path);
11921192

1193-
ret = btrfs_unlink_inode(trans, root,
1193+
ret = btrfs_unlink_inode(trans,
11941194
BTRFS_I(victim_parent),
11951195
inode,
11961196
victim_name,
@@ -1352,7 +1352,7 @@ static int unlink_old_inode_refs(struct btrfs_trans_handle *trans,
13521352
kfree(name);
13531353
goto out;
13541354
}
1355-
ret = btrfs_unlink_inode(trans, root, BTRFS_I(dir),
1355+
ret = btrfs_unlink_inode(trans, BTRFS_I(dir),
13561356
inode, name, namelen);
13571357
kfree(name);
13581358
iput(dir);
@@ -1450,7 +1450,7 @@ static int add_link(struct btrfs_trans_handle *trans, struct btrfs_root *root,
14501450
ret = -ENOENT;
14511451
goto out;
14521452
}
1453-
ret = btrfs_unlink_inode(trans, root, BTRFS_I(dir), BTRFS_I(other_inode),
1453+
ret = btrfs_unlink_inode(trans, BTRFS_I(dir), BTRFS_I(other_inode),
14541454
name, namelen);
14551455
if (ret)
14561456
goto out;
@@ -1596,7 +1596,7 @@ static noinline int add_inode_ref(struct btrfs_trans_handle *trans,
15961596
ret = btrfs_inode_ref_exists(inode, dir, key->type,
15971597
name, namelen);
15981598
if (ret > 0) {
1599-
ret = btrfs_unlink_inode(trans, root,
1599+
ret = btrfs_unlink_inode(trans,
16001600
BTRFS_I(dir),
16011601
BTRFS_I(inode),
16021602
name, namelen);
@@ -2346,7 +2346,7 @@ static noinline int check_item_in_log(struct btrfs_trans_handle *trans,
23462346
}
23472347

23482348
inc_nlink(inode);
2349-
ret = btrfs_unlink_inode(trans, root, BTRFS_I(dir),
2349+
ret = btrfs_unlink_inode(trans, BTRFS_I(dir),
23502350
BTRFS_I(inode), name, name_len);
23512351
if (!ret)
23522352
ret = btrfs_run_delayed_items(trans);

0 commit comments

Comments
 (0)