diff options
author | Josef Bacik <josef@redhat.com> | 2010-11-19 15:36:11 -0500 |
---|---|---|
committer | Chris Mason <chris.mason@oracle.com> | 2010-11-21 22:26:10 -0500 |
commit | a1b075d28da563c5e2325577f282c042494254ba (patch) | |
tree | 0699a0490e11efb6fc2b1a2e99fa6419e9e568fa /fs/btrfs | |
parent | 495e86779f4f319828bc10dfc0c9ac2161868077 (diff) |
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: Josef Bacik <josef@redhat.com>
Signed-off-by: Chris Mason <chris.mason@oracle.com>
Diffstat (limited to 'fs/btrfs')
-rw-r--r-- | fs/btrfs/inode.c | 38 |
1 files changed, 16 insertions, 22 deletions
diff --git a/fs/btrfs/inode.c b/fs/btrfs/inode.c index c0faf47d0cd9..37cc1776a5d7 100644 --- a/fs/btrfs/inode.c +++ b/fs/btrfs/inode.c | |||
@@ -4623,12 +4623,12 @@ int btrfs_add_link(struct btrfs_trans_handle *trans, | |||
4623 | } | 4623 | } |
4624 | 4624 | ||
4625 | static int btrfs_add_nondir(struct btrfs_trans_handle *trans, | 4625 | static int btrfs_add_nondir(struct btrfs_trans_handle *trans, |
4626 | struct dentry *dentry, struct inode *inode, | 4626 | struct inode *dir, struct dentry *dentry, |
4627 | int backref, u64 index) | 4627 | struct inode *inode, int backref, u64 index) |
4628 | { | 4628 | { |
4629 | int err = btrfs_add_link(trans, dentry->d_parent->d_inode, | 4629 | int err = btrfs_add_link(trans, dir, inode, |
4630 | inode, dentry->d_name.name, | 4630 | dentry->d_name.name, dentry->d_name.len, |
4631 | dentry->d_name.len, backref, index); | 4631 | backref, index); |
4632 | if (!err) { | 4632 | if (!err) { |
4633 | d_instantiate(dentry, inode); | 4633 | d_instantiate(dentry, inode); |
4634 | return 0; | 4634 | return 0; |
@@ -4669,8 +4669,7 @@ static int btrfs_mknod(struct inode *dir, struct dentry *dentry, | |||
4669 | btrfs_set_trans_block_group(trans, dir); | 4669 | btrfs_set_trans_block_group(trans, dir); |
4670 | 4670 | ||
4671 | inode = btrfs_new_inode(trans, root, dir, dentry->d_name.name, | 4671 | inode = btrfs_new_inode(trans, root, dir, dentry->d_name.name, |
4672 | dentry->d_name.len, | 4672 | dentry->d_name.len, dir->i_ino, objectid, |
4673 | dentry->d_parent->d_inode->i_ino, objectid, | ||
4674 | BTRFS_I(dir)->block_group, mode, &index); | 4673 | BTRFS_I(dir)->block_group, mode, &index); |
4675 | err = PTR_ERR(inode); | 4674 | err = PTR_ERR(inode); |
4676 | if (IS_ERR(inode)) | 4675 | if (IS_ERR(inode)) |
@@ -4683,7 +4682,7 @@ static int btrfs_mknod(struct inode *dir, struct dentry *dentry, | |||
4683 | } | 4682 | } |
4684 | 4683 | ||
4685 | btrfs_set_trans_block_group(trans, inode); | 4684 | btrfs_set_trans_block_group(trans, inode); |
4686 | err = btrfs_add_nondir(trans, dentry, inode, 0, index); | 4685 | err = btrfs_add_nondir(trans, dir, dentry, inode, 0, index); |
4687 | if (err) | 4686 | if (err) |
4688 | drop_inode = 1; | 4687 | drop_inode = 1; |
4689 | else { | 4688 | else { |
@@ -4731,10 +4730,8 @@ static int btrfs_create(struct inode *dir, struct dentry *dentry, | |||
4731 | btrfs_set_trans_block_group(trans, dir); | 4730 | btrfs_set_trans_block_group(trans, dir); |
4732 | 4731 | ||
4733 | inode = btrfs_new_inode(trans, root, dir, dentry->d_name.name, | 4732 | inode = btrfs_new_inode(trans, root, dir, dentry->d_name.name, |
4734 | dentry->d_name.len, | 4733 | dentry->d_name.len, dir->i_ino, objectid, |
4735 | dentry->d_parent->d_inode->i_ino, | 4734 | BTRFS_I(dir)->block_group, mode, &index); |
4736 | objectid, BTRFS_I(dir)->block_group, mode, | ||
4737 | &index); | ||
4738 | err = PTR_ERR(inode); | 4735 | err = PTR_ERR(inode); |
4739 | if (IS_ERR(inode)) | 4736 | if (IS_ERR(inode)) |
4740 | goto out_unlock; | 4737 | goto out_unlock; |
@@ -4746,7 +4743,7 @@ static int btrfs_create(struct inode *dir, struct dentry *dentry, | |||
4746 | } | 4743 | } |
4747 | 4744 | ||
4748 | btrfs_set_trans_block_group(trans, inode); | 4745 | btrfs_set_trans_block_group(trans, inode); |
4749 | err = btrfs_add_nondir(trans, dentry, inode, 0, index); | 4746 | err = btrfs_add_nondir(trans, dir, dentry, inode, 0, index); |
4750 | if (err) | 4747 | if (err) |
4751 | drop_inode = 1; | 4748 | drop_inode = 1; |
4752 | else { | 4749 | else { |
@@ -4806,7 +4803,7 @@ static int btrfs_link(struct dentry *old_dentry, struct inode *dir, | |||
4806 | btrfs_set_trans_block_group(trans, dir); | 4803 | btrfs_set_trans_block_group(trans, dir); |
4807 | atomic_inc(&inode->i_count); | 4804 | atomic_inc(&inode->i_count); |
4808 | 4805 | ||
4809 | err = btrfs_add_nondir(trans, dentry, inode, 1, index); | 4806 | err = btrfs_add_nondir(trans, dir, dentry, inode, 1, index); |
4810 | 4807 | ||
4811 | if (err) { | 4808 | if (err) { |
4812 | drop_inode = 1; | 4809 | drop_inode = 1; |
@@ -4856,8 +4853,7 @@ static int btrfs_mkdir(struct inode *dir, struct dentry *dentry, int mode) | |||
4856 | btrfs_set_trans_block_group(trans, dir); | 4853 | btrfs_set_trans_block_group(trans, dir); |
4857 | 4854 | ||
4858 | inode = btrfs_new_inode(trans, root, dir, dentry->d_name.name, | 4855 | inode = btrfs_new_inode(trans, root, dir, dentry->d_name.name, |
4859 | dentry->d_name.len, | 4856 | dentry->d_name.len, dir->i_ino, objectid, |
4860 | dentry->d_parent->d_inode->i_ino, objectid, | ||
4861 | BTRFS_I(dir)->block_group, S_IFDIR | mode, | 4857 | BTRFS_I(dir)->block_group, S_IFDIR | mode, |
4862 | &index); | 4858 | &index); |
4863 | if (IS_ERR(inode)) { | 4859 | if (IS_ERR(inode)) { |
@@ -4880,9 +4876,8 @@ static int btrfs_mkdir(struct inode *dir, struct dentry *dentry, int mode) | |||
4880 | if (err) | 4876 | if (err) |
4881 | goto out_fail; | 4877 | goto out_fail; |
4882 | 4878 | ||
4883 | err = btrfs_add_link(trans, dentry->d_parent->d_inode, | 4879 | err = btrfs_add_link(trans, dir, inode, dentry->d_name.name, |
4884 | inode, dentry->d_name.name, | 4880 | dentry->d_name.len, 0, index); |
4885 | dentry->d_name.len, 0, index); | ||
4886 | if (err) | 4881 | if (err) |
4887 | goto out_fail; | 4882 | goto out_fail; |
4888 | 4883 | ||
@@ -6922,8 +6917,7 @@ static int btrfs_symlink(struct inode *dir, struct dentry *dentry, | |||
6922 | btrfs_set_trans_block_group(trans, dir); | 6917 | btrfs_set_trans_block_group(trans, dir); |
6923 | 6918 | ||
6924 | inode = btrfs_new_inode(trans, root, dir, dentry->d_name.name, | 6919 | inode = btrfs_new_inode(trans, root, dir, dentry->d_name.name, |
6925 | dentry->d_name.len, | 6920 | dentry->d_name.len, dir->i_ino, objectid, |
6926 | dentry->d_parent->d_inode->i_ino, objectid, | ||
6927 | BTRFS_I(dir)->block_group, S_IFLNK|S_IRWXUGO, | 6921 | BTRFS_I(dir)->block_group, S_IFLNK|S_IRWXUGO, |
6928 | &index); | 6922 | &index); |
6929 | err = PTR_ERR(inode); | 6923 | err = PTR_ERR(inode); |
@@ -6937,7 +6931,7 @@ static int btrfs_symlink(struct inode *dir, struct dentry *dentry, | |||
6937 | } | 6931 | } |
6938 | 6932 | ||
6939 | btrfs_set_trans_block_group(trans, inode); | 6933 | btrfs_set_trans_block_group(trans, inode); |
6940 | err = btrfs_add_nondir(trans, dentry, inode, 0, index); | 6934 | err = btrfs_add_nondir(trans, dir, dentry, inode, 0, index); |
6941 | if (err) | 6935 | if (err) |
6942 | drop_inode = 1; | 6936 | drop_inode = 1; |
6943 | else { | 6937 | else { |