aboutsummaryrefslogtreecommitdiffstats
path: root/fs/btrfs/inode.c
diff options
context:
space:
mode:
Diffstat (limited to 'fs/btrfs/inode.c')
-rw-r--r--fs/btrfs/inode.c43
1 files changed, 20 insertions, 23 deletions
diff --git a/fs/btrfs/inode.c b/fs/btrfs/inode.c
index 8612b3a09811..7ffa3d34ea19 100644
--- a/fs/btrfs/inode.c
+++ b/fs/btrfs/inode.c
@@ -2122,10 +2122,8 @@ static void btrfs_read_locked_inode(struct inode *inode)
2122 * any xattrs or acls 2122 * any xattrs or acls
2123 */ 2123 */
2124 maybe_acls = acls_after_inode_item(leaf, path->slots[0], inode->i_ino); 2124 maybe_acls = acls_after_inode_item(leaf, path->slots[0], inode->i_ino);
2125 if (!maybe_acls) { 2125 if (!maybe_acls)
2126 BTRFS_I(inode)->i_acl = NULL; 2126 cache_no_acl(inode);
2127 BTRFS_I(inode)->i_default_acl = NULL;
2128 }
2129 2127
2130 BTRFS_I(inode)->block_group = btrfs_find_block_group(root, 0, 2128 BTRFS_I(inode)->block_group = btrfs_find_block_group(root, 0,
2131 alloc_group_block, 0); 2129 alloc_group_block, 0);
@@ -3141,9 +3139,6 @@ static noinline void init_btrfs_i(struct inode *inode)
3141{ 3139{
3142 struct btrfs_inode *bi = BTRFS_I(inode); 3140 struct btrfs_inode *bi = BTRFS_I(inode);
3143 3141
3144 bi->i_acl = BTRFS_ACL_NOT_CACHED;
3145 bi->i_default_acl = BTRFS_ACL_NOT_CACHED;
3146
3147 bi->generation = 0; 3142 bi->generation = 0;
3148 bi->sequence = 0; 3143 bi->sequence = 0;
3149 bi->last_trans = 0; 3144 bi->last_trans = 0;
@@ -3585,12 +3580,6 @@ static struct inode *btrfs_new_inode(struct btrfs_trans_handle *trans,
3585 owner = 1; 3580 owner = 1;
3586 BTRFS_I(inode)->block_group = 3581 BTRFS_I(inode)->block_group =
3587 btrfs_find_block_group(root, 0, alloc_hint, owner); 3582 btrfs_find_block_group(root, 0, alloc_hint, owner);
3588 if ((mode & S_IFREG)) {
3589 if (btrfs_test_opt(root, NODATASUM))
3590 BTRFS_I(inode)->flags |= BTRFS_INODE_NODATASUM;
3591 if (btrfs_test_opt(root, NODATACOW))
3592 BTRFS_I(inode)->flags |= BTRFS_INODE_NODATACOW;
3593 }
3594 3583
3595 key[0].objectid = objectid; 3584 key[0].objectid = objectid;
3596 btrfs_set_key_type(&key[0], BTRFS_INODE_ITEM_KEY); 3585 btrfs_set_key_type(&key[0], BTRFS_INODE_ITEM_KEY);
@@ -3645,6 +3634,13 @@ static struct inode *btrfs_new_inode(struct btrfs_trans_handle *trans,
3645 3634
3646 btrfs_inherit_iflags(inode, dir); 3635 btrfs_inherit_iflags(inode, dir);
3647 3636
3637 if ((mode & S_IFREG)) {
3638 if (btrfs_test_opt(root, NODATASUM))
3639 BTRFS_I(inode)->flags |= BTRFS_INODE_NODATASUM;
3640 if (btrfs_test_opt(root, NODATACOW))
3641 BTRFS_I(inode)->flags |= BTRFS_INODE_NODATACOW;
3642 }
3643
3648 insert_inode_hash(inode); 3644 insert_inode_hash(inode);
3649 inode_tree_add(inode); 3645 inode_tree_add(inode);
3650 return inode; 3646 return inode;
@@ -4640,8 +4636,6 @@ struct inode *btrfs_alloc_inode(struct super_block *sb)
4640 ei->last_trans = 0; 4636 ei->last_trans = 0;
4641 ei->logged_trans = 0; 4637 ei->logged_trans = 0;
4642 btrfs_ordered_inode_tree_init(&ei->ordered_tree); 4638 btrfs_ordered_inode_tree_init(&ei->ordered_tree);
4643 ei->i_acl = BTRFS_ACL_NOT_CACHED;
4644 ei->i_default_acl = BTRFS_ACL_NOT_CACHED;
4645 INIT_LIST_HEAD(&ei->i_orphan); 4639 INIT_LIST_HEAD(&ei->i_orphan);
4646 INIT_LIST_HEAD(&ei->ordered_operations); 4640 INIT_LIST_HEAD(&ei->ordered_operations);
4647 return &ei->vfs_inode; 4641 return &ei->vfs_inode;
@@ -4655,13 +4649,6 @@ void btrfs_destroy_inode(struct inode *inode)
4655 WARN_ON(!list_empty(&inode->i_dentry)); 4649 WARN_ON(!list_empty(&inode->i_dentry));
4656 WARN_ON(inode->i_data.nrpages); 4650 WARN_ON(inode->i_data.nrpages);
4657 4651
4658 if (BTRFS_I(inode)->i_acl &&
4659 BTRFS_I(inode)->i_acl != BTRFS_ACL_NOT_CACHED)
4660 posix_acl_release(BTRFS_I(inode)->i_acl);
4661 if (BTRFS_I(inode)->i_default_acl &&
4662 BTRFS_I(inode)->i_default_acl != BTRFS_ACL_NOT_CACHED)
4663 posix_acl_release(BTRFS_I(inode)->i_default_acl);
4664
4665 /* 4652 /*
4666 * Make sure we're properly removed from the ordered operation 4653 * Make sure we're properly removed from the ordered operation
4667 * lists. 4654 * lists.
@@ -5096,6 +5083,7 @@ static long btrfs_fallocate(struct inode *inode, int mode,
5096 u64 mask = BTRFS_I(inode)->root->sectorsize - 1; 5083 u64 mask = BTRFS_I(inode)->root->sectorsize - 1;
5097 struct extent_map *em; 5084 struct extent_map *em;
5098 struct btrfs_trans_handle *trans; 5085 struct btrfs_trans_handle *trans;
5086 struct btrfs_root *root;
5099 int ret; 5087 int ret;
5100 5088
5101 alloc_start = offset & ~mask; 5089 alloc_start = offset & ~mask;
@@ -5114,6 +5102,13 @@ static long btrfs_fallocate(struct inode *inode, int mode,
5114 goto out; 5102 goto out;
5115 } 5103 }
5116 5104
5105 root = BTRFS_I(inode)->root;
5106
5107 ret = btrfs_check_data_free_space(root, inode,
5108 alloc_end - alloc_start);
5109 if (ret)
5110 goto out;
5111
5117 locked_end = alloc_end - 1; 5112 locked_end = alloc_end - 1;
5118 while (1) { 5113 while (1) {
5119 struct btrfs_ordered_extent *ordered; 5114 struct btrfs_ordered_extent *ordered;
@@ -5121,7 +5116,7 @@ static long btrfs_fallocate(struct inode *inode, int mode,
5121 trans = btrfs_start_transaction(BTRFS_I(inode)->root, 1); 5116 trans = btrfs_start_transaction(BTRFS_I(inode)->root, 1);
5122 if (!trans) { 5117 if (!trans) {
5123 ret = -EIO; 5118 ret = -EIO;
5124 goto out; 5119 goto out_free;
5125 } 5120 }
5126 5121
5127 /* the extent lock is ordered inside the running 5122 /* the extent lock is ordered inside the running
@@ -5182,6 +5177,8 @@ static long btrfs_fallocate(struct inode *inode, int mode,
5182 GFP_NOFS); 5177 GFP_NOFS);
5183 5178
5184 btrfs_end_transaction(trans, BTRFS_I(inode)->root); 5179 btrfs_end_transaction(trans, BTRFS_I(inode)->root);
5180out_free:
5181 btrfs_free_reserved_data_space(root, inode, alloc_end - alloc_start);
5185out: 5182out:
5186 mutex_unlock(&inode->i_mutex); 5183 mutex_unlock(&inode->i_mutex);
5187 return ret; 5184 return ret;