Commit 23c24ef8 authored by Omar Sandoval's avatar Omar Sandoval Committed by David Sterba

btrfs: don't pass parent objectid to btrfs_new_inode() explicitly

For everything other than a subvolume root inode, we get the parent
objectid from the parent directory. For the subvolume root inode, the
parent objectid is the same as the inode's objectid. We can find this
within btrfs_new_inode() instead of passing it.
Reviewed-by: default avatarSweet Tea Dorminy <sweettea-kernel@dorminy.me>
Signed-off-by: default avatarOmar Sandoval <osandov@fb.com>
Reviewed-by: default avatarDavid Sterba <dsterba@suse.com>
Signed-off-by: default avatarDavid Sterba <dsterba@suse.com>
parent 70dc55f4
...@@ -6090,8 +6090,7 @@ static struct inode *btrfs_new_inode(struct btrfs_trans_handle *trans, ...@@ -6090,8 +6090,7 @@ static struct inode *btrfs_new_inode(struct btrfs_trans_handle *trans,
struct user_namespace *mnt_userns, struct user_namespace *mnt_userns,
struct inode *dir, struct inode *dir,
const char *name, int name_len, const char *name, int name_len,
u64 ref_objectid, u64 objectid, u64 objectid, umode_t mode, u64 *index)
umode_t mode, u64 *index)
{ {
struct btrfs_fs_info *fs_info = root->fs_info; struct btrfs_fs_info *fs_info = root->fs_info;
struct inode *inode; struct inode *inode;
...@@ -6177,7 +6176,10 @@ static struct inode *btrfs_new_inode(struct btrfs_trans_handle *trans, ...@@ -6177,7 +6176,10 @@ static struct inode *btrfs_new_inode(struct btrfs_trans_handle *trans,
*/ */
key[1].objectid = objectid; key[1].objectid = objectid;
key[1].type = BTRFS_INODE_REF_KEY; key[1].type = BTRFS_INODE_REF_KEY;
key[1].offset = ref_objectid; if (dir)
key[1].offset = btrfs_ino(BTRFS_I(dir));
else
key[1].offset = objectid;
sizes[1] = name_len + sizeof(*ref); sizes[1] = name_len + sizeof(*ref);
} }
...@@ -6375,7 +6377,7 @@ static int btrfs_mknod(struct user_namespace *mnt_userns, struct inode *dir, ...@@ -6375,7 +6377,7 @@ static int btrfs_mknod(struct user_namespace *mnt_userns, struct inode *dir,
inode = btrfs_new_inode(trans, root, mnt_userns, dir, inode = btrfs_new_inode(trans, root, mnt_userns, dir,
dentry->d_name.name, dentry->d_name.len, dentry->d_name.name, dentry->d_name.len,
btrfs_ino(BTRFS_I(dir)), objectid, mode, &index); objectid, mode, &index);
if (IS_ERR(inode)) { if (IS_ERR(inode)) {
err = PTR_ERR(inode); err = PTR_ERR(inode);
inode = NULL; inode = NULL;
...@@ -6439,7 +6441,7 @@ static int btrfs_create(struct user_namespace *mnt_userns, struct inode *dir, ...@@ -6439,7 +6441,7 @@ static int btrfs_create(struct user_namespace *mnt_userns, struct inode *dir,
inode = btrfs_new_inode(trans, root, mnt_userns, dir, inode = btrfs_new_inode(trans, root, mnt_userns, dir,
dentry->d_name.name, dentry->d_name.len, dentry->d_name.name, dentry->d_name.len,
btrfs_ino(BTRFS_I(dir)), objectid, mode, &index); objectid, mode, &index);
if (IS_ERR(inode)) { if (IS_ERR(inode)) {
err = PTR_ERR(inode); err = PTR_ERR(inode);
inode = NULL; inode = NULL;
...@@ -6584,7 +6586,7 @@ static int btrfs_mkdir(struct user_namespace *mnt_userns, struct inode *dir, ...@@ -6584,7 +6586,7 @@ static int btrfs_mkdir(struct user_namespace *mnt_userns, struct inode *dir,
inode = btrfs_new_inode(trans, root, mnt_userns, dir, inode = btrfs_new_inode(trans, root, mnt_userns, dir,
dentry->d_name.name, dentry->d_name.len, dentry->d_name.name, dentry->d_name.len,
btrfs_ino(BTRFS_I(dir)), objectid, objectid,
S_IFDIR | mode, &index); S_IFDIR | mode, &index);
if (IS_ERR(inode)) { if (IS_ERR(inode)) {
err = PTR_ERR(inode); err = PTR_ERR(inode);
...@@ -8769,7 +8771,7 @@ int btrfs_create_subvol_root(struct btrfs_trans_handle *trans, ...@@ -8769,7 +8771,7 @@ int btrfs_create_subvol_root(struct btrfs_trans_handle *trans,
return err; return err;
inode = btrfs_new_inode(trans, new_root, mnt_userns, NULL, "..", 2, inode = btrfs_new_inode(trans, new_root, mnt_userns, NULL, "..", 2,
ino, ino, ino,
S_IFDIR | (~current_umask() & S_IRWXUGO), S_IFDIR | (~current_umask() & S_IRWXUGO),
&index); &index);
if (IS_ERR(inode)) if (IS_ERR(inode))
...@@ -9282,7 +9284,6 @@ static int btrfs_whiteout_for_rename(struct btrfs_trans_handle *trans, ...@@ -9282,7 +9284,6 @@ static int btrfs_whiteout_for_rename(struct btrfs_trans_handle *trans,
inode = btrfs_new_inode(trans, root, mnt_userns, dir, inode = btrfs_new_inode(trans, root, mnt_userns, dir,
dentry->d_name.name, dentry->d_name.name,
dentry->d_name.len, dentry->d_name.len,
btrfs_ino(BTRFS_I(dir)),
objectid, objectid,
S_IFCHR | WHITEOUT_MODE, S_IFCHR | WHITEOUT_MODE,
&index); &index);
...@@ -9776,7 +9777,7 @@ static int btrfs_symlink(struct user_namespace *mnt_userns, struct inode *dir, ...@@ -9776,7 +9777,7 @@ static int btrfs_symlink(struct user_namespace *mnt_userns, struct inode *dir,
inode = btrfs_new_inode(trans, root, mnt_userns, dir, inode = btrfs_new_inode(trans, root, mnt_userns, dir,
dentry->d_name.name, dentry->d_name.len, dentry->d_name.name, dentry->d_name.len,
btrfs_ino(BTRFS_I(dir)), objectid, objectid,
S_IFLNK | S_IRWXUGO, &index); S_IFLNK | S_IRWXUGO, &index);
if (IS_ERR(inode)) { if (IS_ERR(inode)) {
err = PTR_ERR(inode); err = PTR_ERR(inode);
...@@ -10122,7 +10123,7 @@ static int btrfs_tmpfile(struct user_namespace *mnt_userns, struct inode *dir, ...@@ -10122,7 +10123,7 @@ static int btrfs_tmpfile(struct user_namespace *mnt_userns, struct inode *dir,
goto out; goto out;
inode = btrfs_new_inode(trans, root, mnt_userns, dir, NULL, 0, inode = btrfs_new_inode(trans, root, mnt_userns, dir, NULL, 0,
btrfs_ino(BTRFS_I(dir)), objectid, mode, &index); objectid, mode, &index);
if (IS_ERR(inode)) { if (IS_ERR(inode)) {
ret = PTR_ERR(inode); ret = PTR_ERR(inode);
inode = NULL; inode = NULL;
......
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