diff options
author | Takashi Iwai <tiwai@suse.de> | 2014-10-06 08:01:11 -0400 |
---|---|---|
committer | Takashi Iwai <tiwai@suse.de> | 2014-10-06 08:01:11 -0400 |
commit | 8df22a4d6f5b81c9c1703579d4907b57002689ed (patch) | |
tree | 064e9662d427a82076e1151fcd9aa78a1066f9f4 /fs/btrfs/inode.c | |
parent | 0cae90a96c15f2fd3bd139ba5505755c9c9ef2eb (diff) | |
parent | a5448c88b812390a3622e76d774e10c0da1fb970 (diff) |
Merge tag 'asoc-v3.18' of git://git.kernel.org/pub/scm/linux/kernel/git/broonie/sound into for-next
ASoC: Updates for v3.18
- More componentisation work from Lars-Peter, this time mainly
cleaning up the suspend and bias level transition callbacks.
- Real system support for the Intel drivers and a bunch of fixes and
enhancements for the associated CODEC drivers, this is going to need
a lot quirks over time due to the lack of any firmware description of
the boards.
- Jack detect support for simple card from Dylan Reid.
- A bunch of small fixes and enhancements for the Freescale drivers.
- New drivers for Analog Devices SSM4567, Cirrus Logic CS35L32, Everest
Semiconductor ES8328 and Freescale cards using the ASRC in newer i.MX
processors.
Diffstat (limited to 'fs/btrfs/inode.c')
-rw-r--r-- | fs/btrfs/inode.c | 191 |
1 files changed, 120 insertions, 71 deletions
diff --git a/fs/btrfs/inode.c b/fs/btrfs/inode.c index 9c194bd74d6e..016c403bfe7e 100644 --- a/fs/btrfs/inode.c +++ b/fs/btrfs/inode.c | |||
@@ -778,8 +778,12 @@ retry: | |||
778 | ins.offset, | 778 | ins.offset, |
779 | BTRFS_ORDERED_COMPRESSED, | 779 | BTRFS_ORDERED_COMPRESSED, |
780 | async_extent->compress_type); | 780 | async_extent->compress_type); |
781 | if (ret) | 781 | if (ret) { |
782 | btrfs_drop_extent_cache(inode, async_extent->start, | ||
783 | async_extent->start + | ||
784 | async_extent->ram_size - 1, 0); | ||
782 | goto out_free_reserve; | 785 | goto out_free_reserve; |
786 | } | ||
783 | 787 | ||
784 | /* | 788 | /* |
785 | * clear dirty, set writeback and unlock the pages. | 789 | * clear dirty, set writeback and unlock the pages. |
@@ -971,14 +975,14 @@ static noinline int cow_file_range(struct inode *inode, | |||
971 | ret = btrfs_add_ordered_extent(inode, start, ins.objectid, | 975 | ret = btrfs_add_ordered_extent(inode, start, ins.objectid, |
972 | ram_size, cur_alloc_size, 0); | 976 | ram_size, cur_alloc_size, 0); |
973 | if (ret) | 977 | if (ret) |
974 | goto out_reserve; | 978 | goto out_drop_extent_cache; |
975 | 979 | ||
976 | if (root->root_key.objectid == | 980 | if (root->root_key.objectid == |
977 | BTRFS_DATA_RELOC_TREE_OBJECTID) { | 981 | BTRFS_DATA_RELOC_TREE_OBJECTID) { |
978 | ret = btrfs_reloc_clone_csums(inode, start, | 982 | ret = btrfs_reloc_clone_csums(inode, start, |
979 | cur_alloc_size); | 983 | cur_alloc_size); |
980 | if (ret) | 984 | if (ret) |
981 | goto out_reserve; | 985 | goto out_drop_extent_cache; |
982 | } | 986 | } |
983 | 987 | ||
984 | if (disk_num_bytes < cur_alloc_size) | 988 | if (disk_num_bytes < cur_alloc_size) |
@@ -1006,6 +1010,8 @@ static noinline int cow_file_range(struct inode *inode, | |||
1006 | out: | 1010 | out: |
1007 | return ret; | 1011 | return ret; |
1008 | 1012 | ||
1013 | out_drop_extent_cache: | ||
1014 | btrfs_drop_extent_cache(inode, start, start + ram_size - 1, 0); | ||
1009 | out_reserve: | 1015 | out_reserve: |
1010 | btrfs_free_reserved_extent(root, ins.objectid, ins.offset, 1); | 1016 | btrfs_free_reserved_extent(root, ins.objectid, ins.offset, 1); |
1011 | out_unlock: | 1017 | out_unlock: |
@@ -4242,7 +4248,8 @@ out: | |||
4242 | btrfs_abort_transaction(trans, root, ret); | 4248 | btrfs_abort_transaction(trans, root, ret); |
4243 | } | 4249 | } |
4244 | error: | 4250 | error: |
4245 | if (last_size != (u64)-1) | 4251 | if (last_size != (u64)-1 && |
4252 | root->root_key.objectid != BTRFS_TREE_LOG_OBJECTID) | ||
4246 | btrfs_ordered_update_i_size(inode, last_size, NULL); | 4253 | btrfs_ordered_update_i_size(inode, last_size, NULL); |
4247 | btrfs_free_path(path); | 4254 | btrfs_free_path(path); |
4248 | return err; | 4255 | return err; |
@@ -5627,6 +5634,17 @@ int btrfs_set_inode_index(struct inode *dir, u64 *index) | |||
5627 | return ret; | 5634 | return ret; |
5628 | } | 5635 | } |
5629 | 5636 | ||
5637 | static int btrfs_insert_inode_locked(struct inode *inode) | ||
5638 | { | ||
5639 | struct btrfs_iget_args args; | ||
5640 | args.location = &BTRFS_I(inode)->location; | ||
5641 | args.root = BTRFS_I(inode)->root; | ||
5642 | |||
5643 | return insert_inode_locked4(inode, | ||
5644 | btrfs_inode_hash(inode->i_ino, BTRFS_I(inode)->root), | ||
5645 | btrfs_find_actor, &args); | ||
5646 | } | ||
5647 | |||
5630 | static struct inode *btrfs_new_inode(struct btrfs_trans_handle *trans, | 5648 | static struct inode *btrfs_new_inode(struct btrfs_trans_handle *trans, |
5631 | struct btrfs_root *root, | 5649 | struct btrfs_root *root, |
5632 | struct inode *dir, | 5650 | struct inode *dir, |
@@ -5719,10 +5737,19 @@ static struct inode *btrfs_new_inode(struct btrfs_trans_handle *trans, | |||
5719 | sizes[1] = name_len + sizeof(*ref); | 5737 | sizes[1] = name_len + sizeof(*ref); |
5720 | } | 5738 | } |
5721 | 5739 | ||
5740 | location = &BTRFS_I(inode)->location; | ||
5741 | location->objectid = objectid; | ||
5742 | location->offset = 0; | ||
5743 | btrfs_set_key_type(location, BTRFS_INODE_ITEM_KEY); | ||
5744 | |||
5745 | ret = btrfs_insert_inode_locked(inode); | ||
5746 | if (ret < 0) | ||
5747 | goto fail; | ||
5748 | |||
5722 | path->leave_spinning = 1; | 5749 | path->leave_spinning = 1; |
5723 | ret = btrfs_insert_empty_items(trans, root, path, key, sizes, nitems); | 5750 | ret = btrfs_insert_empty_items(trans, root, path, key, sizes, nitems); |
5724 | if (ret != 0) | 5751 | if (ret != 0) |
5725 | goto fail; | 5752 | goto fail_unlock; |
5726 | 5753 | ||
5727 | inode_init_owner(inode, dir, mode); | 5754 | inode_init_owner(inode, dir, mode); |
5728 | inode_set_bytes(inode, 0); | 5755 | inode_set_bytes(inode, 0); |
@@ -5745,11 +5772,6 @@ static struct inode *btrfs_new_inode(struct btrfs_trans_handle *trans, | |||
5745 | btrfs_mark_buffer_dirty(path->nodes[0]); | 5772 | btrfs_mark_buffer_dirty(path->nodes[0]); |
5746 | btrfs_free_path(path); | 5773 | btrfs_free_path(path); |
5747 | 5774 | ||
5748 | location = &BTRFS_I(inode)->location; | ||
5749 | location->objectid = objectid; | ||
5750 | location->offset = 0; | ||
5751 | btrfs_set_key_type(location, BTRFS_INODE_ITEM_KEY); | ||
5752 | |||
5753 | btrfs_inherit_iflags(inode, dir); | 5775 | btrfs_inherit_iflags(inode, dir); |
5754 | 5776 | ||
5755 | if (S_ISREG(mode)) { | 5777 | if (S_ISREG(mode)) { |
@@ -5760,7 +5782,6 @@ static struct inode *btrfs_new_inode(struct btrfs_trans_handle *trans, | |||
5760 | BTRFS_INODE_NODATASUM; | 5782 | BTRFS_INODE_NODATASUM; |
5761 | } | 5783 | } |
5762 | 5784 | ||
5763 | btrfs_insert_inode_hash(inode); | ||
5764 | inode_tree_add(inode); | 5785 | inode_tree_add(inode); |
5765 | 5786 | ||
5766 | trace_btrfs_inode_new(inode); | 5787 | trace_btrfs_inode_new(inode); |
@@ -5775,6 +5796,9 @@ static struct inode *btrfs_new_inode(struct btrfs_trans_handle *trans, | |||
5775 | btrfs_ino(inode), root->root_key.objectid, ret); | 5796 | btrfs_ino(inode), root->root_key.objectid, ret); |
5776 | 5797 | ||
5777 | return inode; | 5798 | return inode; |
5799 | |||
5800 | fail_unlock: | ||
5801 | unlock_new_inode(inode); | ||
5778 | fail: | 5802 | fail: |
5779 | if (dir && name) | 5803 | if (dir && name) |
5780 | BTRFS_I(dir)->index_cnt--; | 5804 | BTRFS_I(dir)->index_cnt--; |
@@ -5909,28 +5933,28 @@ static int btrfs_mknod(struct inode *dir, struct dentry *dentry, | |||
5909 | goto out_unlock; | 5933 | goto out_unlock; |
5910 | } | 5934 | } |
5911 | 5935 | ||
5912 | err = btrfs_init_inode_security(trans, inode, dir, &dentry->d_name); | ||
5913 | if (err) { | ||
5914 | drop_inode = 1; | ||
5915 | goto out_unlock; | ||
5916 | } | ||
5917 | |||
5918 | /* | 5936 | /* |
5919 | * If the active LSM wants to access the inode during | 5937 | * If the active LSM wants to access the inode during |
5920 | * d_instantiate it needs these. Smack checks to see | 5938 | * d_instantiate it needs these. Smack checks to see |
5921 | * if the filesystem supports xattrs by looking at the | 5939 | * if the filesystem supports xattrs by looking at the |
5922 | * ops vector. | 5940 | * ops vector. |
5923 | */ | 5941 | */ |
5924 | |||
5925 | inode->i_op = &btrfs_special_inode_operations; | 5942 | inode->i_op = &btrfs_special_inode_operations; |
5926 | err = btrfs_add_nondir(trans, dir, dentry, inode, 0, index); | 5943 | init_special_inode(inode, inode->i_mode, rdev); |
5944 | |||
5945 | err = btrfs_init_inode_security(trans, inode, dir, &dentry->d_name); | ||
5927 | if (err) | 5946 | if (err) |
5928 | drop_inode = 1; | 5947 | goto out_unlock_inode; |
5929 | else { | 5948 | |
5930 | init_special_inode(inode, inode->i_mode, rdev); | 5949 | err = btrfs_add_nondir(trans, dir, dentry, inode, 0, index); |
5950 | if (err) { | ||
5951 | goto out_unlock_inode; | ||
5952 | } else { | ||
5931 | btrfs_update_inode(trans, root, inode); | 5953 | btrfs_update_inode(trans, root, inode); |
5954 | unlock_new_inode(inode); | ||
5932 | d_instantiate(dentry, inode); | 5955 | d_instantiate(dentry, inode); |
5933 | } | 5956 | } |
5957 | |||
5934 | out_unlock: | 5958 | out_unlock: |
5935 | btrfs_end_transaction(trans, root); | 5959 | btrfs_end_transaction(trans, root); |
5936 | btrfs_balance_delayed_items(root); | 5960 | btrfs_balance_delayed_items(root); |
@@ -5940,6 +5964,12 @@ out_unlock: | |||
5940 | iput(inode); | 5964 | iput(inode); |
5941 | } | 5965 | } |
5942 | return err; | 5966 | return err; |
5967 | |||
5968 | out_unlock_inode: | ||
5969 | drop_inode = 1; | ||
5970 | unlock_new_inode(inode); | ||
5971 | goto out_unlock; | ||
5972 | |||
5943 | } | 5973 | } |
5944 | 5974 | ||
5945 | static int btrfs_create(struct inode *dir, struct dentry *dentry, | 5975 | static int btrfs_create(struct inode *dir, struct dentry *dentry, |
@@ -5974,15 +6004,6 @@ static int btrfs_create(struct inode *dir, struct dentry *dentry, | |||
5974 | goto out_unlock; | 6004 | goto out_unlock; |
5975 | } | 6005 | } |
5976 | drop_inode_on_err = 1; | 6006 | drop_inode_on_err = 1; |
5977 | |||
5978 | err = btrfs_init_inode_security(trans, inode, dir, &dentry->d_name); | ||
5979 | if (err) | ||
5980 | goto out_unlock; | ||
5981 | |||
5982 | err = btrfs_update_inode(trans, root, inode); | ||
5983 | if (err) | ||
5984 | goto out_unlock; | ||
5985 | |||
5986 | /* | 6007 | /* |
5987 | * If the active LSM wants to access the inode during | 6008 | * If the active LSM wants to access the inode during |
5988 | * d_instantiate it needs these. Smack checks to see | 6009 | * d_instantiate it needs these. Smack checks to see |
@@ -5991,14 +6012,23 @@ static int btrfs_create(struct inode *dir, struct dentry *dentry, | |||
5991 | */ | 6012 | */ |
5992 | inode->i_fop = &btrfs_file_operations; | 6013 | inode->i_fop = &btrfs_file_operations; |
5993 | inode->i_op = &btrfs_file_inode_operations; | 6014 | inode->i_op = &btrfs_file_inode_operations; |
6015 | inode->i_mapping->a_ops = &btrfs_aops; | ||
6016 | inode->i_mapping->backing_dev_info = &root->fs_info->bdi; | ||
6017 | |||
6018 | err = btrfs_init_inode_security(trans, inode, dir, &dentry->d_name); | ||
6019 | if (err) | ||
6020 | goto out_unlock_inode; | ||
6021 | |||
6022 | err = btrfs_update_inode(trans, root, inode); | ||
6023 | if (err) | ||
6024 | goto out_unlock_inode; | ||
5994 | 6025 | ||
5995 | err = btrfs_add_nondir(trans, dir, dentry, inode, 0, index); | 6026 | err = btrfs_add_nondir(trans, dir, dentry, inode, 0, index); |
5996 | if (err) | 6027 | if (err) |
5997 | goto out_unlock; | 6028 | goto out_unlock_inode; |
5998 | 6029 | ||
5999 | inode->i_mapping->a_ops = &btrfs_aops; | ||
6000 | inode->i_mapping->backing_dev_info = &root->fs_info->bdi; | ||
6001 | BTRFS_I(inode)->io_tree.ops = &btrfs_extent_io_ops; | 6030 | BTRFS_I(inode)->io_tree.ops = &btrfs_extent_io_ops; |
6031 | unlock_new_inode(inode); | ||
6002 | d_instantiate(dentry, inode); | 6032 | d_instantiate(dentry, inode); |
6003 | 6033 | ||
6004 | out_unlock: | 6034 | out_unlock: |
@@ -6010,6 +6040,11 @@ out_unlock: | |||
6010 | btrfs_balance_delayed_items(root); | 6040 | btrfs_balance_delayed_items(root); |
6011 | btrfs_btree_balance_dirty(root); | 6041 | btrfs_btree_balance_dirty(root); |
6012 | return err; | 6042 | return err; |
6043 | |||
6044 | out_unlock_inode: | ||
6045 | unlock_new_inode(inode); | ||
6046 | goto out_unlock; | ||
6047 | |||
6013 | } | 6048 | } |
6014 | 6049 | ||
6015 | static int btrfs_link(struct dentry *old_dentry, struct inode *dir, | 6050 | static int btrfs_link(struct dentry *old_dentry, struct inode *dir, |
@@ -6117,25 +6152,30 @@ static int btrfs_mkdir(struct inode *dir, struct dentry *dentry, umode_t mode) | |||
6117 | } | 6152 | } |
6118 | 6153 | ||
6119 | drop_on_err = 1; | 6154 | drop_on_err = 1; |
6155 | /* these must be set before we unlock the inode */ | ||
6156 | inode->i_op = &btrfs_dir_inode_operations; | ||
6157 | inode->i_fop = &btrfs_dir_file_operations; | ||
6120 | 6158 | ||
6121 | err = btrfs_init_inode_security(trans, inode, dir, &dentry->d_name); | 6159 | err = btrfs_init_inode_security(trans, inode, dir, &dentry->d_name); |
6122 | if (err) | 6160 | if (err) |
6123 | goto out_fail; | 6161 | goto out_fail_inode; |
6124 | |||
6125 | inode->i_op = &btrfs_dir_inode_operations; | ||
6126 | inode->i_fop = &btrfs_dir_file_operations; | ||
6127 | 6162 | ||
6128 | btrfs_i_size_write(inode, 0); | 6163 | btrfs_i_size_write(inode, 0); |
6129 | err = btrfs_update_inode(trans, root, inode); | 6164 | err = btrfs_update_inode(trans, root, inode); |
6130 | if (err) | 6165 | if (err) |
6131 | goto out_fail; | 6166 | goto out_fail_inode; |
6132 | 6167 | ||
6133 | err = btrfs_add_link(trans, dir, inode, dentry->d_name.name, | 6168 | err = btrfs_add_link(trans, dir, inode, dentry->d_name.name, |
6134 | dentry->d_name.len, 0, index); | 6169 | dentry->d_name.len, 0, index); |
6135 | if (err) | 6170 | if (err) |
6136 | goto out_fail; | 6171 | goto out_fail_inode; |
6137 | 6172 | ||
6138 | d_instantiate(dentry, inode); | 6173 | d_instantiate(dentry, inode); |
6174 | /* | ||
6175 | * mkdir is special. We're unlocking after we call d_instantiate | ||
6176 | * to avoid a race with nfsd calling d_instantiate. | ||
6177 | */ | ||
6178 | unlock_new_inode(inode); | ||
6139 | drop_on_err = 0; | 6179 | drop_on_err = 0; |
6140 | 6180 | ||
6141 | out_fail: | 6181 | out_fail: |
@@ -6145,6 +6185,10 @@ out_fail: | |||
6145 | btrfs_balance_delayed_items(root); | 6185 | btrfs_balance_delayed_items(root); |
6146 | btrfs_btree_balance_dirty(root); | 6186 | btrfs_btree_balance_dirty(root); |
6147 | return err; | 6187 | return err; |
6188 | |||
6189 | out_fail_inode: | ||
6190 | unlock_new_inode(inode); | ||
6191 | goto out_fail; | ||
6148 | } | 6192 | } |
6149 | 6193 | ||
6150 | /* helper for btfs_get_extent. Given an existing extent in the tree, | 6194 | /* helper for btfs_get_extent. Given an existing extent in the tree, |
@@ -8100,6 +8144,7 @@ int btrfs_create_subvol_root(struct btrfs_trans_handle *trans, | |||
8100 | 8144 | ||
8101 | set_nlink(inode, 1); | 8145 | set_nlink(inode, 1); |
8102 | btrfs_i_size_write(inode, 0); | 8146 | btrfs_i_size_write(inode, 0); |
8147 | unlock_new_inode(inode); | ||
8103 | 8148 | ||
8104 | err = btrfs_subvol_inherit_props(trans, new_root, parent_root); | 8149 | err = btrfs_subvol_inherit_props(trans, new_root, parent_root); |
8105 | if (err) | 8150 | if (err) |
@@ -8760,12 +8805,6 @@ static int btrfs_symlink(struct inode *dir, struct dentry *dentry, | |||
8760 | goto out_unlock; | 8805 | goto out_unlock; |
8761 | } | 8806 | } |
8762 | 8807 | ||
8763 | err = btrfs_init_inode_security(trans, inode, dir, &dentry->d_name); | ||
8764 | if (err) { | ||
8765 | drop_inode = 1; | ||
8766 | goto out_unlock; | ||
8767 | } | ||
8768 | |||
8769 | /* | 8808 | /* |
8770 | * If the active LSM wants to access the inode during | 8809 | * If the active LSM wants to access the inode during |
8771 | * d_instantiate it needs these. Smack checks to see | 8810 | * d_instantiate it needs these. Smack checks to see |
@@ -8774,23 +8813,22 @@ static int btrfs_symlink(struct inode *dir, struct dentry *dentry, | |||
8774 | */ | 8813 | */ |
8775 | inode->i_fop = &btrfs_file_operations; | 8814 | inode->i_fop = &btrfs_file_operations; |
8776 | inode->i_op = &btrfs_file_inode_operations; | 8815 | inode->i_op = &btrfs_file_inode_operations; |
8816 | inode->i_mapping->a_ops = &btrfs_aops; | ||
8817 | inode->i_mapping->backing_dev_info = &root->fs_info->bdi; | ||
8818 | BTRFS_I(inode)->io_tree.ops = &btrfs_extent_io_ops; | ||
8819 | |||
8820 | err = btrfs_init_inode_security(trans, inode, dir, &dentry->d_name); | ||
8821 | if (err) | ||
8822 | goto out_unlock_inode; | ||
8777 | 8823 | ||
8778 | err = btrfs_add_nondir(trans, dir, dentry, inode, 0, index); | 8824 | err = btrfs_add_nondir(trans, dir, dentry, inode, 0, index); |
8779 | if (err) | 8825 | if (err) |
8780 | drop_inode = 1; | 8826 | goto out_unlock_inode; |
8781 | else { | ||
8782 | inode->i_mapping->a_ops = &btrfs_aops; | ||
8783 | inode->i_mapping->backing_dev_info = &root->fs_info->bdi; | ||
8784 | BTRFS_I(inode)->io_tree.ops = &btrfs_extent_io_ops; | ||
8785 | } | ||
8786 | if (drop_inode) | ||
8787 | goto out_unlock; | ||
8788 | 8827 | ||
8789 | path = btrfs_alloc_path(); | 8828 | path = btrfs_alloc_path(); |
8790 | if (!path) { | 8829 | if (!path) { |
8791 | err = -ENOMEM; | 8830 | err = -ENOMEM; |
8792 | drop_inode = 1; | 8831 | goto out_unlock_inode; |
8793 | goto out_unlock; | ||
8794 | } | 8832 | } |
8795 | key.objectid = btrfs_ino(inode); | 8833 | key.objectid = btrfs_ino(inode); |
8796 | key.offset = 0; | 8834 | key.offset = 0; |
@@ -8799,9 +8837,8 @@ static int btrfs_symlink(struct inode *dir, struct dentry *dentry, | |||
8799 | err = btrfs_insert_empty_item(trans, root, path, &key, | 8837 | err = btrfs_insert_empty_item(trans, root, path, &key, |
8800 | datasize); | 8838 | datasize); |
8801 | if (err) { | 8839 | if (err) { |
8802 | drop_inode = 1; | ||
8803 | btrfs_free_path(path); | 8840 | btrfs_free_path(path); |
8804 | goto out_unlock; | 8841 | goto out_unlock_inode; |
8805 | } | 8842 | } |
8806 | leaf = path->nodes[0]; | 8843 | leaf = path->nodes[0]; |
8807 | ei = btrfs_item_ptr(leaf, path->slots[0], | 8844 | ei = btrfs_item_ptr(leaf, path->slots[0], |
@@ -8825,12 +8862,15 @@ static int btrfs_symlink(struct inode *dir, struct dentry *dentry, | |||
8825 | inode_set_bytes(inode, name_len); | 8862 | inode_set_bytes(inode, name_len); |
8826 | btrfs_i_size_write(inode, name_len); | 8863 | btrfs_i_size_write(inode, name_len); |
8827 | err = btrfs_update_inode(trans, root, inode); | 8864 | err = btrfs_update_inode(trans, root, inode); |
8828 | if (err) | 8865 | if (err) { |
8829 | drop_inode = 1; | 8866 | drop_inode = 1; |
8867 | goto out_unlock_inode; | ||
8868 | } | ||
8869 | |||
8870 | unlock_new_inode(inode); | ||
8871 | d_instantiate(dentry, inode); | ||
8830 | 8872 | ||
8831 | out_unlock: | 8873 | out_unlock: |
8832 | if (!err) | ||
8833 | d_instantiate(dentry, inode); | ||
8834 | btrfs_end_transaction(trans, root); | 8874 | btrfs_end_transaction(trans, root); |
8835 | if (drop_inode) { | 8875 | if (drop_inode) { |
8836 | inode_dec_link_count(inode); | 8876 | inode_dec_link_count(inode); |
@@ -8838,6 +8878,11 @@ out_unlock: | |||
8838 | } | 8878 | } |
8839 | btrfs_btree_balance_dirty(root); | 8879 | btrfs_btree_balance_dirty(root); |
8840 | return err; | 8880 | return err; |
8881 | |||
8882 | out_unlock_inode: | ||
8883 | drop_inode = 1; | ||
8884 | unlock_new_inode(inode); | ||
8885 | goto out_unlock; | ||
8841 | } | 8886 | } |
8842 | 8887 | ||
8843 | static int __btrfs_prealloc_file_range(struct inode *inode, int mode, | 8888 | static int __btrfs_prealloc_file_range(struct inode *inode, int mode, |
@@ -9021,14 +9066,6 @@ static int btrfs_tmpfile(struct inode *dir, struct dentry *dentry, umode_t mode) | |||
9021 | goto out; | 9066 | goto out; |
9022 | } | 9067 | } |
9023 | 9068 | ||
9024 | ret = btrfs_init_inode_security(trans, inode, dir, NULL); | ||
9025 | if (ret) | ||
9026 | goto out; | ||
9027 | |||
9028 | ret = btrfs_update_inode(trans, root, inode); | ||
9029 | if (ret) | ||
9030 | goto out; | ||
9031 | |||
9032 | inode->i_fop = &btrfs_file_operations; | 9069 | inode->i_fop = &btrfs_file_operations; |
9033 | inode->i_op = &btrfs_file_inode_operations; | 9070 | inode->i_op = &btrfs_file_inode_operations; |
9034 | 9071 | ||
@@ -9036,9 +9073,16 @@ static int btrfs_tmpfile(struct inode *dir, struct dentry *dentry, umode_t mode) | |||
9036 | inode->i_mapping->backing_dev_info = &root->fs_info->bdi; | 9073 | inode->i_mapping->backing_dev_info = &root->fs_info->bdi; |
9037 | BTRFS_I(inode)->io_tree.ops = &btrfs_extent_io_ops; | 9074 | BTRFS_I(inode)->io_tree.ops = &btrfs_extent_io_ops; |
9038 | 9075 | ||
9076 | ret = btrfs_init_inode_security(trans, inode, dir, NULL); | ||
9077 | if (ret) | ||
9078 | goto out_inode; | ||
9079 | |||
9080 | ret = btrfs_update_inode(trans, root, inode); | ||
9081 | if (ret) | ||
9082 | goto out_inode; | ||
9039 | ret = btrfs_orphan_add(trans, inode); | 9083 | ret = btrfs_orphan_add(trans, inode); |
9040 | if (ret) | 9084 | if (ret) |
9041 | goto out; | 9085 | goto out_inode; |
9042 | 9086 | ||
9043 | /* | 9087 | /* |
9044 | * We set number of links to 0 in btrfs_new_inode(), and here we set | 9088 | * We set number of links to 0 in btrfs_new_inode(), and here we set |
@@ -9048,6 +9092,7 @@ static int btrfs_tmpfile(struct inode *dir, struct dentry *dentry, umode_t mode) | |||
9048 | * d_tmpfile() -> inode_dec_link_count() -> drop_nlink() | 9092 | * d_tmpfile() -> inode_dec_link_count() -> drop_nlink() |
9049 | */ | 9093 | */ |
9050 | set_nlink(inode, 1); | 9094 | set_nlink(inode, 1); |
9095 | unlock_new_inode(inode); | ||
9051 | d_tmpfile(dentry, inode); | 9096 | d_tmpfile(dentry, inode); |
9052 | mark_inode_dirty(inode); | 9097 | mark_inode_dirty(inode); |
9053 | 9098 | ||
@@ -9057,8 +9102,12 @@ out: | |||
9057 | iput(inode); | 9102 | iput(inode); |
9058 | btrfs_balance_delayed_items(root); | 9103 | btrfs_balance_delayed_items(root); |
9059 | btrfs_btree_balance_dirty(root); | 9104 | btrfs_btree_balance_dirty(root); |
9060 | |||
9061 | return ret; | 9105 | return ret; |
9106 | |||
9107 | out_inode: | ||
9108 | unlock_new_inode(inode); | ||
9109 | goto out; | ||
9110 | |||
9062 | } | 9111 | } |
9063 | 9112 | ||
9064 | static const struct inode_operations btrfs_dir_inode_operations = { | 9113 | static const struct inode_operations btrfs_dir_inode_operations = { |