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.c159
1 files changed, 89 insertions, 70 deletions
diff --git a/fs/btrfs/inode.c b/fs/btrfs/inode.c
index 1c8b0190d031..5b68330f8585 100644
--- a/fs/btrfs/inode.c
+++ b/fs/btrfs/inode.c
@@ -48,7 +48,6 @@
48#include "ordered-data.h" 48#include "ordered-data.h"
49#include "xattr.h" 49#include "xattr.h"
50#include "tree-log.h" 50#include "tree-log.h"
51#include "ref-cache.h"
52#include "compression.h" 51#include "compression.h"
53#include "locking.h" 52#include "locking.h"
54 53
@@ -369,7 +368,7 @@ again:
369 * inode has not been flagged as nocompress. This flag can 368 * inode has not been flagged as nocompress. This flag can
370 * change at any time if we discover bad compression ratios. 369 * change at any time if we discover bad compression ratios.
371 */ 370 */
372 if (!btrfs_test_flag(inode, NOCOMPRESS) && 371 if (!(BTRFS_I(inode)->flags & BTRFS_INODE_NOCOMPRESS) &&
373 btrfs_test_opt(root, COMPRESS)) { 372 btrfs_test_opt(root, COMPRESS)) {
374 WARN_ON(pages); 373 WARN_ON(pages);
375 pages = kzalloc(sizeof(struct page *) * nr_pages, GFP_NOFS); 374 pages = kzalloc(sizeof(struct page *) * nr_pages, GFP_NOFS);
@@ -470,7 +469,7 @@ again:
470 nr_pages_ret = 0; 469 nr_pages_ret = 0;
471 470
472 /* flag the file so we don't compress in the future */ 471 /* flag the file so we don't compress in the future */
473 btrfs_set_flag(inode, NOCOMPRESS); 472 BTRFS_I(inode)->flags |= BTRFS_INODE_NOCOMPRESS;
474 } 473 }
475 if (will_compress) { 474 if (will_compress) {
476 *num_added += 1; 475 *num_added += 1;
@@ -863,7 +862,7 @@ static int cow_file_range_async(struct inode *inode, struct page *locked_page,
863 async_cow->locked_page = locked_page; 862 async_cow->locked_page = locked_page;
864 async_cow->start = start; 863 async_cow->start = start;
865 864
866 if (btrfs_test_flag(inode, NOCOMPRESS)) 865 if (BTRFS_I(inode)->flags & BTRFS_INODE_NOCOMPRESS)
867 cur_end = end; 866 cur_end = end;
868 else 867 else
869 cur_end = min(end, start + 512 * 1024 - 1); 868 cur_end = min(end, start + 512 * 1024 - 1);
@@ -944,6 +943,7 @@ static noinline int run_delalloc_nocow(struct inode *inode,
944 u64 cow_start; 943 u64 cow_start;
945 u64 cur_offset; 944 u64 cur_offset;
946 u64 extent_end; 945 u64 extent_end;
946 u64 extent_offset;
947 u64 disk_bytenr; 947 u64 disk_bytenr;
948 u64 num_bytes; 948 u64 num_bytes;
949 int extent_type; 949 int extent_type;
@@ -1005,6 +1005,7 @@ next_slot:
1005 if (extent_type == BTRFS_FILE_EXTENT_REG || 1005 if (extent_type == BTRFS_FILE_EXTENT_REG ||
1006 extent_type == BTRFS_FILE_EXTENT_PREALLOC) { 1006 extent_type == BTRFS_FILE_EXTENT_PREALLOC) {
1007 disk_bytenr = btrfs_file_extent_disk_bytenr(leaf, fi); 1007 disk_bytenr = btrfs_file_extent_disk_bytenr(leaf, fi);
1008 extent_offset = btrfs_file_extent_offset(leaf, fi);
1008 extent_end = found_key.offset + 1009 extent_end = found_key.offset +
1009 btrfs_file_extent_num_bytes(leaf, fi); 1010 btrfs_file_extent_num_bytes(leaf, fi);
1010 if (extent_end <= start) { 1011 if (extent_end <= start) {
@@ -1022,9 +1023,10 @@ next_slot:
1022 if (btrfs_extent_readonly(root, disk_bytenr)) 1023 if (btrfs_extent_readonly(root, disk_bytenr))
1023 goto out_check; 1024 goto out_check;
1024 if (btrfs_cross_ref_exist(trans, root, inode->i_ino, 1025 if (btrfs_cross_ref_exist(trans, root, inode->i_ino,
1025 disk_bytenr)) 1026 found_key.offset -
1027 extent_offset, disk_bytenr))
1026 goto out_check; 1028 goto out_check;
1027 disk_bytenr += btrfs_file_extent_offset(leaf, fi); 1029 disk_bytenr += extent_offset;
1028 disk_bytenr += cur_offset - found_key.offset; 1030 disk_bytenr += cur_offset - found_key.offset;
1029 num_bytes = min(end + 1, extent_end) - cur_offset; 1031 num_bytes = min(end + 1, extent_end) - cur_offset;
1030 /* 1032 /*
@@ -1131,10 +1133,10 @@ static int run_delalloc_range(struct inode *inode, struct page *locked_page,
1131 int ret; 1133 int ret;
1132 struct btrfs_root *root = BTRFS_I(inode)->root; 1134 struct btrfs_root *root = BTRFS_I(inode)->root;
1133 1135
1134 if (btrfs_test_flag(inode, NODATACOW)) 1136 if (BTRFS_I(inode)->flags & BTRFS_INODE_NODATACOW)
1135 ret = run_delalloc_nocow(inode, locked_page, start, end, 1137 ret = run_delalloc_nocow(inode, locked_page, start, end,
1136 page_started, 1, nr_written); 1138 page_started, 1, nr_written);
1137 else if (btrfs_test_flag(inode, PREALLOC)) 1139 else if (BTRFS_I(inode)->flags & BTRFS_INODE_PREALLOC)
1138 ret = run_delalloc_nocow(inode, locked_page, start, end, 1140 ret = run_delalloc_nocow(inode, locked_page, start, end,
1139 page_started, 0, nr_written); 1141 page_started, 0, nr_written);
1140 else if (!btrfs_test_opt(root, COMPRESS)) 1142 else if (!btrfs_test_opt(root, COMPRESS))
@@ -1288,7 +1290,7 @@ static int btrfs_submit_bio_hook(struct inode *inode, int rw, struct bio *bio,
1288 int ret = 0; 1290 int ret = 0;
1289 int skip_sum; 1291 int skip_sum;
1290 1292
1291 skip_sum = btrfs_test_flag(inode, NODATASUM); 1293 skip_sum = BTRFS_I(inode)->flags & BTRFS_INODE_NODATASUM;
1292 1294
1293 ret = btrfs_bio_wq_end_io(root->fs_info, bio, 0); 1295 ret = btrfs_bio_wq_end_io(root->fs_info, bio, 0);
1294 BUG_ON(ret); 1296 BUG_ON(ret);
@@ -1489,9 +1491,9 @@ static int insert_reserved_file_extent(struct btrfs_trans_handle *trans,
1489 ins.objectid = disk_bytenr; 1491 ins.objectid = disk_bytenr;
1490 ins.offset = disk_num_bytes; 1492 ins.offset = disk_num_bytes;
1491 ins.type = BTRFS_EXTENT_ITEM_KEY; 1493 ins.type = BTRFS_EXTENT_ITEM_KEY;
1492 ret = btrfs_alloc_reserved_extent(trans, root, leaf->start, 1494 ret = btrfs_alloc_reserved_file_extent(trans, root,
1493 root->root_key.objectid, 1495 root->root_key.objectid,
1494 trans->transid, inode->i_ino, &ins); 1496 inode->i_ino, file_pos, &ins);
1495 BUG_ON(ret); 1497 BUG_ON(ret);
1496 btrfs_free_path(path); 1498 btrfs_free_path(path);
1497 1499
@@ -1788,7 +1790,8 @@ static int btrfs_readpage_end_io_hook(struct page *page, u64 start, u64 end,
1788 ClearPageChecked(page); 1790 ClearPageChecked(page);
1789 goto good; 1791 goto good;
1790 } 1792 }
1791 if (btrfs_test_flag(inode, NODATASUM)) 1793
1794 if (BTRFS_I(inode)->flags & BTRFS_INODE_NODATASUM)
1792 return 0; 1795 return 0;
1793 1796
1794 if (root->root_key.objectid == BTRFS_DATA_RELOC_TREE_OBJECTID && 1797 if (root->root_key.objectid == BTRFS_DATA_RELOC_TREE_OBJECTID &&
@@ -1956,23 +1959,13 @@ void btrfs_orphan_cleanup(struct btrfs_root *root)
1956 * crossing root thing. we store the inode number in the 1959 * crossing root thing. we store the inode number in the
1957 * offset of the orphan item. 1960 * offset of the orphan item.
1958 */ 1961 */
1959 inode = btrfs_iget_locked(root->fs_info->sb, 1962 found_key.objectid = found_key.offset;
1960 found_key.offset, root); 1963 found_key.type = BTRFS_INODE_ITEM_KEY;
1961 if (!inode) 1964 found_key.offset = 0;
1965 inode = btrfs_iget(root->fs_info->sb, &found_key, root);
1966 if (IS_ERR(inode))
1962 break; 1967 break;
1963 1968
1964 if (inode->i_state & I_NEW) {
1965 BTRFS_I(inode)->root = root;
1966
1967 /* have to set the location manually */
1968 BTRFS_I(inode)->location.objectid = inode->i_ino;
1969 BTRFS_I(inode)->location.type = BTRFS_INODE_ITEM_KEY;
1970 BTRFS_I(inode)->location.offset = 0;
1971
1972 btrfs_read_locked_inode(inode);
1973 unlock_new_inode(inode);
1974 }
1975
1976 /* 1969 /*
1977 * add this inode to the orphan list so btrfs_orphan_del does 1970 * add this inode to the orphan list so btrfs_orphan_del does
1978 * the proper thing when we hit it 1971 * the proper thing when we hit it
@@ -2069,7 +2062,7 @@ static noinline int acls_after_inode_item(struct extent_buffer *leaf,
2069/* 2062/*
2070 * read an inode from the btree into the in-memory inode 2063 * read an inode from the btree into the in-memory inode
2071 */ 2064 */
2072void btrfs_read_locked_inode(struct inode *inode) 2065static void btrfs_read_locked_inode(struct inode *inode)
2073{ 2066{
2074 struct btrfs_path *path; 2067 struct btrfs_path *path;
2075 struct extent_buffer *leaf; 2068 struct extent_buffer *leaf;
@@ -2164,6 +2157,8 @@ void btrfs_read_locked_inode(struct inode *inode)
2164 init_special_inode(inode, inode->i_mode, rdev); 2157 init_special_inode(inode, inode->i_mode, rdev);
2165 break; 2158 break;
2166 } 2159 }
2160
2161 btrfs_update_iflags(inode);
2167 return; 2162 return;
2168 2163
2169make_bad: 2164make_bad:
@@ -2599,9 +2594,8 @@ noinline int btrfs_truncate_inode_items(struct btrfs_trans_handle *trans,
2599 struct btrfs_file_extent_item *fi; 2594 struct btrfs_file_extent_item *fi;
2600 u64 extent_start = 0; 2595 u64 extent_start = 0;
2601 u64 extent_num_bytes = 0; 2596 u64 extent_num_bytes = 0;
2597 u64 extent_offset = 0;
2602 u64 item_end = 0; 2598 u64 item_end = 0;
2603 u64 root_gen = 0;
2604 u64 root_owner = 0;
2605 int found_extent; 2599 int found_extent;
2606 int del_item; 2600 int del_item;
2607 int pending_del_nr = 0; 2601 int pending_del_nr = 0;
@@ -2716,6 +2710,9 @@ search_again:
2716 extent_num_bytes = 2710 extent_num_bytes =
2717 btrfs_file_extent_disk_num_bytes(leaf, 2711 btrfs_file_extent_disk_num_bytes(leaf,
2718 fi); 2712 fi);
2713 extent_offset = found_key.offset -
2714 btrfs_file_extent_offset(leaf, fi);
2715
2719 /* FIXME blocksize != 4096 */ 2716 /* FIXME blocksize != 4096 */
2720 num_dec = btrfs_file_extent_num_bytes(leaf, fi); 2717 num_dec = btrfs_file_extent_num_bytes(leaf, fi);
2721 if (extent_start != 0) { 2718 if (extent_start != 0) {
@@ -2723,8 +2720,6 @@ search_again:
2723 if (root->ref_cows) 2720 if (root->ref_cows)
2724 inode_sub_bytes(inode, num_dec); 2721 inode_sub_bytes(inode, num_dec);
2725 } 2722 }
2726 root_gen = btrfs_header_generation(leaf);
2727 root_owner = btrfs_header_owner(leaf);
2728 } 2723 }
2729 } else if (extent_type == BTRFS_FILE_EXTENT_INLINE) { 2724 } else if (extent_type == BTRFS_FILE_EXTENT_INLINE) {
2730 /* 2725 /*
@@ -2768,12 +2763,12 @@ delete:
2768 } else { 2763 } else {
2769 break; 2764 break;
2770 } 2765 }
2771 if (found_extent) { 2766 if (found_extent && root->ref_cows) {
2772 btrfs_set_path_blocking(path); 2767 btrfs_set_path_blocking(path);
2773 ret = btrfs_free_extent(trans, root, extent_start, 2768 ret = btrfs_free_extent(trans, root, extent_start,
2774 extent_num_bytes, 2769 extent_num_bytes, 0,
2775 leaf->start, root_owner, 2770 btrfs_header_owner(leaf),
2776 root_gen, inode->i_ino, 0); 2771 inode->i_ino, extent_offset);
2777 BUG_ON(ret); 2772 BUG_ON(ret);
2778 } 2773 }
2779next: 2774next:
@@ -3105,6 +3100,45 @@ static int fixup_tree_root_location(struct btrfs_root *root,
3105 return 0; 3100 return 0;
3106} 3101}
3107 3102
3103static void inode_tree_add(struct inode *inode)
3104{
3105 struct btrfs_root *root = BTRFS_I(inode)->root;
3106 struct btrfs_inode *entry;
3107 struct rb_node **p = &root->inode_tree.rb_node;
3108 struct rb_node *parent = NULL;
3109
3110 spin_lock(&root->inode_lock);
3111 while (*p) {
3112 parent = *p;
3113 entry = rb_entry(parent, struct btrfs_inode, rb_node);
3114
3115 if (inode->i_ino < entry->vfs_inode.i_ino)
3116 p = &(*p)->rb_left;
3117 else if (inode->i_ino > entry->vfs_inode.i_ino)
3118 p = &(*p)->rb_right;
3119 else {
3120 WARN_ON(!(entry->vfs_inode.i_state &
3121 (I_WILL_FREE | I_FREEING | I_CLEAR)));
3122 break;
3123 }
3124 }
3125 rb_link_node(&BTRFS_I(inode)->rb_node, parent, p);
3126 rb_insert_color(&BTRFS_I(inode)->rb_node, &root->inode_tree);
3127 spin_unlock(&root->inode_lock);
3128}
3129
3130static void inode_tree_del(struct inode *inode)
3131{
3132 struct btrfs_root *root = BTRFS_I(inode)->root;
3133
3134 if (!RB_EMPTY_NODE(&BTRFS_I(inode)->rb_node)) {
3135 spin_lock(&root->inode_lock);
3136 rb_erase(&BTRFS_I(inode)->rb_node, &root->inode_tree);
3137 spin_unlock(&root->inode_lock);
3138 RB_CLEAR_NODE(&BTRFS_I(inode)->rb_node);
3139 }
3140}
3141
3108static noinline void init_btrfs_i(struct inode *inode) 3142static noinline void init_btrfs_i(struct inode *inode)
3109{ 3143{
3110 struct btrfs_inode *bi = BTRFS_I(inode); 3144 struct btrfs_inode *bi = BTRFS_I(inode);
@@ -3130,6 +3164,7 @@ static noinline void init_btrfs_i(struct inode *inode)
3130 inode->i_mapping, GFP_NOFS); 3164 inode->i_mapping, GFP_NOFS);
3131 INIT_LIST_HEAD(&BTRFS_I(inode)->delalloc_inodes); 3165 INIT_LIST_HEAD(&BTRFS_I(inode)->delalloc_inodes);
3132 INIT_LIST_HEAD(&BTRFS_I(inode)->ordered_operations); 3166 INIT_LIST_HEAD(&BTRFS_I(inode)->ordered_operations);
3167 RB_CLEAR_NODE(&BTRFS_I(inode)->rb_node);
3133 btrfs_ordered_inode_tree_init(&BTRFS_I(inode)->ordered_tree); 3168 btrfs_ordered_inode_tree_init(&BTRFS_I(inode)->ordered_tree);
3134 mutex_init(&BTRFS_I(inode)->extent_mutex); 3169 mutex_init(&BTRFS_I(inode)->extent_mutex);
3135 mutex_init(&BTRFS_I(inode)->log_mutex); 3170 mutex_init(&BTRFS_I(inode)->log_mutex);
@@ -3152,26 +3187,9 @@ static int btrfs_find_actor(struct inode *inode, void *opaque)
3152 args->root == BTRFS_I(inode)->root; 3187 args->root == BTRFS_I(inode)->root;
3153} 3188}
3154 3189
3155struct inode *btrfs_ilookup(struct super_block *s, u64 objectid, 3190static struct inode *btrfs_iget_locked(struct super_block *s,
3156 struct btrfs_root *root, int wait) 3191 u64 objectid,
3157{ 3192 struct btrfs_root *root)
3158 struct inode *inode;
3159 struct btrfs_iget_args args;
3160 args.ino = objectid;
3161 args.root = root;
3162
3163 if (wait) {
3164 inode = ilookup5(s, objectid, btrfs_find_actor,
3165 (void *)&args);
3166 } else {
3167 inode = ilookup5_nowait(s, objectid, btrfs_find_actor,
3168 (void *)&args);
3169 }
3170 return inode;
3171}
3172
3173struct inode *btrfs_iget_locked(struct super_block *s, u64 objectid,
3174 struct btrfs_root *root)
3175{ 3193{
3176 struct inode *inode; 3194 struct inode *inode;
3177 struct btrfs_iget_args args; 3195 struct btrfs_iget_args args;
@@ -3188,24 +3206,21 @@ struct inode *btrfs_iget_locked(struct super_block *s, u64 objectid,
3188 * Returns in *is_new if the inode was read from disk 3206 * Returns in *is_new if the inode was read from disk
3189 */ 3207 */
3190struct inode *btrfs_iget(struct super_block *s, struct btrfs_key *location, 3208struct inode *btrfs_iget(struct super_block *s, struct btrfs_key *location,
3191 struct btrfs_root *root, int *is_new) 3209 struct btrfs_root *root)
3192{ 3210{
3193 struct inode *inode; 3211 struct inode *inode;
3194 3212
3195 inode = btrfs_iget_locked(s, location->objectid, root); 3213 inode = btrfs_iget_locked(s, location->objectid, root);
3196 if (!inode) 3214 if (!inode)
3197 return ERR_PTR(-EACCES); 3215 return ERR_PTR(-ENOMEM);
3198 3216
3199 if (inode->i_state & I_NEW) { 3217 if (inode->i_state & I_NEW) {
3200 BTRFS_I(inode)->root = root; 3218 BTRFS_I(inode)->root = root;
3201 memcpy(&BTRFS_I(inode)->location, location, sizeof(*location)); 3219 memcpy(&BTRFS_I(inode)->location, location, sizeof(*location));
3202 btrfs_read_locked_inode(inode); 3220 btrfs_read_locked_inode(inode);
3221
3222 inode_tree_add(inode);
3203 unlock_new_inode(inode); 3223 unlock_new_inode(inode);
3204 if (is_new)
3205 *is_new = 1;
3206 } else {
3207 if (is_new)
3208 *is_new = 0;
3209 } 3224 }
3210 3225
3211 return inode; 3226 return inode;
@@ -3218,7 +3233,7 @@ struct inode *btrfs_lookup_dentry(struct inode *dir, struct dentry *dentry)
3218 struct btrfs_root *root = bi->root; 3233 struct btrfs_root *root = bi->root;
3219 struct btrfs_root *sub_root = root; 3234 struct btrfs_root *sub_root = root;
3220 struct btrfs_key location; 3235 struct btrfs_key location;
3221 int ret, new; 3236 int ret;
3222 3237
3223 if (dentry->d_name.len > BTRFS_NAME_LEN) 3238 if (dentry->d_name.len > BTRFS_NAME_LEN)
3224 return ERR_PTR(-ENAMETOOLONG); 3239 return ERR_PTR(-ENAMETOOLONG);
@@ -3236,7 +3251,7 @@ struct inode *btrfs_lookup_dentry(struct inode *dir, struct dentry *dentry)
3236 return ERR_PTR(ret); 3251 return ERR_PTR(ret);
3237 if (ret > 0) 3252 if (ret > 0)
3238 return ERR_PTR(-ENOENT); 3253 return ERR_PTR(-ENOENT);
3239 inode = btrfs_iget(dir->i_sb, &location, sub_root, &new); 3254 inode = btrfs_iget(dir->i_sb, &location, sub_root);
3240 if (IS_ERR(inode)) 3255 if (IS_ERR(inode))
3241 return ERR_CAST(inode); 3256 return ERR_CAST(inode);
3242 } 3257 }
@@ -3574,9 +3589,9 @@ static struct inode *btrfs_new_inode(struct btrfs_trans_handle *trans,
3574 btrfs_find_block_group(root, 0, alloc_hint, owner); 3589 btrfs_find_block_group(root, 0, alloc_hint, owner);
3575 if ((mode & S_IFREG)) { 3590 if ((mode & S_IFREG)) {
3576 if (btrfs_test_opt(root, NODATASUM)) 3591 if (btrfs_test_opt(root, NODATASUM))
3577 btrfs_set_flag(inode, NODATASUM); 3592 BTRFS_I(inode)->flags |= BTRFS_INODE_NODATASUM;
3578 if (btrfs_test_opt(root, NODATACOW)) 3593 if (btrfs_test_opt(root, NODATACOW))
3579 btrfs_set_flag(inode, NODATACOW); 3594 BTRFS_I(inode)->flags |= BTRFS_INODE_NODATACOW;
3580 } 3595 }
3581 3596
3582 key[0].objectid = objectid; 3597 key[0].objectid = objectid;
@@ -3630,7 +3645,10 @@ static struct inode *btrfs_new_inode(struct btrfs_trans_handle *trans,
3630 location->offset = 0; 3645 location->offset = 0;
3631 btrfs_set_key_type(location, BTRFS_INODE_ITEM_KEY); 3646 btrfs_set_key_type(location, BTRFS_INODE_ITEM_KEY);
3632 3647
3648 btrfs_inherit_iflags(inode, dir);
3649
3633 insert_inode_hash(inode); 3650 insert_inode_hash(inode);
3651 inode_tree_add(inode);
3634 return inode; 3652 return inode;
3635fail: 3653fail:
3636 if (dir) 3654 if (dir)
@@ -4683,6 +4701,7 @@ void btrfs_destroy_inode(struct inode *inode)
4683 btrfs_put_ordered_extent(ordered); 4701 btrfs_put_ordered_extent(ordered);
4684 } 4702 }
4685 } 4703 }
4704 inode_tree_del(inode);
4686 btrfs_drop_extent_cache(inode, 0, (u64)-1, 0); 4705 btrfs_drop_extent_cache(inode, 0, (u64)-1, 0);
4687 kmem_cache_free(btrfs_inode_cachep, BTRFS_I(inode)); 4706 kmem_cache_free(btrfs_inode_cachep, BTRFS_I(inode));
4688} 4707}
@@ -5061,7 +5080,7 @@ static int prealloc_file_range(struct btrfs_trans_handle *trans,
5061out: 5080out:
5062 if (cur_offset > start) { 5081 if (cur_offset > start) {
5063 inode->i_ctime = CURRENT_TIME; 5082 inode->i_ctime = CURRENT_TIME;
5064 btrfs_set_flag(inode, PREALLOC); 5083 BTRFS_I(inode)->flags |= BTRFS_INODE_PREALLOC;
5065 if (!(mode & FALLOC_FL_KEEP_SIZE) && 5084 if (!(mode & FALLOC_FL_KEEP_SIZE) &&
5066 cur_offset > i_size_read(inode)) 5085 cur_offset > i_size_read(inode))
5067 btrfs_i_size_write(inode, cur_offset); 5086 btrfs_i_size_write(inode, cur_offset);
@@ -5182,7 +5201,7 @@ static int btrfs_set_page_dirty(struct page *page)
5182 5201
5183static int btrfs_permission(struct inode *inode, int mask) 5202static int btrfs_permission(struct inode *inode, int mask)
5184{ 5203{
5185 if (btrfs_test_flag(inode, READONLY) && (mask & MAY_WRITE)) 5204 if ((BTRFS_I(inode)->flags & BTRFS_INODE_READONLY) && (mask & MAY_WRITE))
5186 return -EACCES; 5205 return -EACCES;
5187 return generic_permission(inode, mask, btrfs_check_acl); 5206 return generic_permission(inode, mask, btrfs_check_acl);
5188} 5207}