Commit a1b075d2 authored by Josef Bacik's avatar Josef Bacik Committed by Chris Mason

Btrfs: make btrfs_add_nondir take parent inode as an argument

Everybody who calls btrfs_add_nondir just passes in the dentry of the new file
and then dereference dentry->d_parent->d_inode, but everybody who calls
btrfs_add_nondir() are already passed the parent's inode.  So instead of
dereferencing dentry->d_parent, just make btrfs_add_nondir take the dir inode as
an argument and pass that along so we don't have to worry about d_parent.
Thanks,
Signed-off-by: default avatarJosef Bacik <josef@redhat.com>
Signed-off-by: default avatarChris Mason <chris.mason@oracle.com>
parent 495e8677
...@@ -4623,12 +4623,12 @@ int btrfs_add_link(struct btrfs_trans_handle *trans, ...@@ -4623,12 +4623,12 @@ int btrfs_add_link(struct btrfs_trans_handle *trans,
} }
static int btrfs_add_nondir(struct btrfs_trans_handle *trans, static int btrfs_add_nondir(struct btrfs_trans_handle *trans,
struct dentry *dentry, struct inode *inode, struct inode *dir, struct dentry *dentry,
int backref, u64 index) struct inode *inode, int backref, u64 index)
{ {
int err = btrfs_add_link(trans, dentry->d_parent->d_inode, int err = btrfs_add_link(trans, dir, inode,
inode, dentry->d_name.name, dentry->d_name.name, dentry->d_name.len,
dentry->d_name.len, backref, index); backref, index);
if (!err) { if (!err) {
d_instantiate(dentry, inode); d_instantiate(dentry, inode);
return 0; return 0;
...@@ -4669,8 +4669,7 @@ static int btrfs_mknod(struct inode *dir, struct dentry *dentry, ...@@ -4669,8 +4669,7 @@ static int btrfs_mknod(struct inode *dir, struct dentry *dentry,
btrfs_set_trans_block_group(trans, dir); btrfs_set_trans_block_group(trans, dir);
inode = btrfs_new_inode(trans, root, dir, dentry->d_name.name, inode = btrfs_new_inode(trans, root, dir, dentry->d_name.name,
dentry->d_name.len, dentry->d_name.len, dir->i_ino, objectid,
dentry->d_parent->d_inode->i_ino, objectid,
BTRFS_I(dir)->block_group, mode, &index); BTRFS_I(dir)->block_group, mode, &index);
err = PTR_ERR(inode); err = PTR_ERR(inode);
if (IS_ERR(inode)) if (IS_ERR(inode))
...@@ -4683,7 +4682,7 @@ static int btrfs_mknod(struct inode *dir, struct dentry *dentry, ...@@ -4683,7 +4682,7 @@ static int btrfs_mknod(struct inode *dir, struct dentry *dentry,
} }
btrfs_set_trans_block_group(trans, inode); btrfs_set_trans_block_group(trans, inode);
err = btrfs_add_nondir(trans, dentry, inode, 0, index); err = btrfs_add_nondir(trans, dir, dentry, inode, 0, index);
if (err) if (err)
drop_inode = 1; drop_inode = 1;
else { else {
...@@ -4731,10 +4730,8 @@ static int btrfs_create(struct inode *dir, struct dentry *dentry, ...@@ -4731,10 +4730,8 @@ static int btrfs_create(struct inode *dir, struct dentry *dentry,
btrfs_set_trans_block_group(trans, dir); btrfs_set_trans_block_group(trans, dir);
inode = btrfs_new_inode(trans, root, dir, dentry->d_name.name, inode = btrfs_new_inode(trans, root, dir, dentry->d_name.name,
dentry->d_name.len, dentry->d_name.len, dir->i_ino, objectid,
dentry->d_parent->d_inode->i_ino, BTRFS_I(dir)->block_group, mode, &index);
objectid, BTRFS_I(dir)->block_group, mode,
&index);
err = PTR_ERR(inode); err = PTR_ERR(inode);
if (IS_ERR(inode)) if (IS_ERR(inode))
goto out_unlock; goto out_unlock;
...@@ -4746,7 +4743,7 @@ static int btrfs_create(struct inode *dir, struct dentry *dentry, ...@@ -4746,7 +4743,7 @@ static int btrfs_create(struct inode *dir, struct dentry *dentry,
} }
btrfs_set_trans_block_group(trans, inode); btrfs_set_trans_block_group(trans, inode);
err = btrfs_add_nondir(trans, dentry, inode, 0, index); err = btrfs_add_nondir(trans, dir, dentry, inode, 0, index);
if (err) if (err)
drop_inode = 1; drop_inode = 1;
else { else {
...@@ -4806,7 +4803,7 @@ static int btrfs_link(struct dentry *old_dentry, struct inode *dir, ...@@ -4806,7 +4803,7 @@ static int btrfs_link(struct dentry *old_dentry, struct inode *dir,
btrfs_set_trans_block_group(trans, dir); btrfs_set_trans_block_group(trans, dir);
atomic_inc(&inode->i_count); atomic_inc(&inode->i_count);
err = btrfs_add_nondir(trans, dentry, inode, 1, index); err = btrfs_add_nondir(trans, dir, dentry, inode, 1, index);
if (err) { if (err) {
drop_inode = 1; drop_inode = 1;
...@@ -4856,8 +4853,7 @@ static int btrfs_mkdir(struct inode *dir, struct dentry *dentry, int mode) ...@@ -4856,8 +4853,7 @@ static int btrfs_mkdir(struct inode *dir, struct dentry *dentry, int mode)
btrfs_set_trans_block_group(trans, dir); btrfs_set_trans_block_group(trans, dir);
inode = btrfs_new_inode(trans, root, dir, dentry->d_name.name, inode = btrfs_new_inode(trans, root, dir, dentry->d_name.name,
dentry->d_name.len, dentry->d_name.len, dir->i_ino, objectid,
dentry->d_parent->d_inode->i_ino, objectid,
BTRFS_I(dir)->block_group, S_IFDIR | mode, BTRFS_I(dir)->block_group, S_IFDIR | mode,
&index); &index);
if (IS_ERR(inode)) { if (IS_ERR(inode)) {
...@@ -4880,9 +4876,8 @@ static int btrfs_mkdir(struct inode *dir, struct dentry *dentry, int mode) ...@@ -4880,9 +4876,8 @@ static int btrfs_mkdir(struct inode *dir, struct dentry *dentry, int mode)
if (err) if (err)
goto out_fail; goto out_fail;
err = btrfs_add_link(trans, dentry->d_parent->d_inode, err = btrfs_add_link(trans, dir, inode, dentry->d_name.name,
inode, dentry->d_name.name, dentry->d_name.len, 0, index);
dentry->d_name.len, 0, index);
if (err) if (err)
goto out_fail; goto out_fail;
...@@ -6922,8 +6917,7 @@ static int btrfs_symlink(struct inode *dir, struct dentry *dentry, ...@@ -6922,8 +6917,7 @@ static int btrfs_symlink(struct inode *dir, struct dentry *dentry,
btrfs_set_trans_block_group(trans, dir); btrfs_set_trans_block_group(trans, dir);
inode = btrfs_new_inode(trans, root, dir, dentry->d_name.name, inode = btrfs_new_inode(trans, root, dir, dentry->d_name.name,
dentry->d_name.len, dentry->d_name.len, dir->i_ino, objectid,
dentry->d_parent->d_inode->i_ino, objectid,
BTRFS_I(dir)->block_group, S_IFLNK|S_IRWXUGO, BTRFS_I(dir)->block_group, S_IFLNK|S_IRWXUGO,
&index); &index);
err = PTR_ERR(inode); err = PTR_ERR(inode);
...@@ -6937,7 +6931,7 @@ static int btrfs_symlink(struct inode *dir, struct dentry *dentry, ...@@ -6937,7 +6931,7 @@ static int btrfs_symlink(struct inode *dir, struct dentry *dentry,
} }
btrfs_set_trans_block_group(trans, inode); btrfs_set_trans_block_group(trans, inode);
err = btrfs_add_nondir(trans, dentry, inode, 0, index); err = btrfs_add_nondir(trans, dir, dentry, inode, 0, index);
if (err) if (err)
drop_inode = 1; drop_inode = 1;
else { else {
......
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