diff options
Diffstat (limited to 'fs/btrfs')
| -rw-r--r-- | fs/btrfs/acl.c | 44 | ||||
| -rw-r--r-- | fs/btrfs/btrfs_inode.h | 4 | ||||
| -rw-r--r-- | fs/btrfs/ctree.h | 2 | ||||
| -rw-r--r-- | fs/btrfs/inode.c | 16 |
4 files changed, 11 insertions, 55 deletions
diff --git a/fs/btrfs/acl.c b/fs/btrfs/acl.c index 603972576f0f..f128427b995b 100644 --- a/fs/btrfs/acl.c +++ b/fs/btrfs/acl.c | |||
| @@ -29,51 +29,28 @@ | |||
| 29 | 29 | ||
| 30 | #ifdef CONFIG_FS_POSIX_ACL | 30 | #ifdef CONFIG_FS_POSIX_ACL |
| 31 | 31 | ||
| 32 | static void btrfs_update_cached_acl(struct inode *inode, | ||
| 33 | struct posix_acl **p_acl, | ||
| 34 | struct posix_acl *acl) | ||
| 35 | { | ||
| 36 | spin_lock(&inode->i_lock); | ||
| 37 | if (*p_acl && *p_acl != BTRFS_ACL_NOT_CACHED) | ||
| 38 | posix_acl_release(*p_acl); | ||
| 39 | *p_acl = posix_acl_dup(acl); | ||
| 40 | spin_unlock(&inode->i_lock); | ||
| 41 | } | ||
| 42 | |||
| 43 | static struct posix_acl *btrfs_get_acl(struct inode *inode, int type) | 32 | static struct posix_acl *btrfs_get_acl(struct inode *inode, int type) |
| 44 | { | 33 | { |
| 45 | int size; | 34 | int size; |
| 46 | const char *name; | 35 | const char *name; |
| 47 | char *value = NULL; | 36 | char *value = NULL; |
| 48 | struct posix_acl *acl = NULL, **p_acl; | 37 | struct posix_acl *acl; |
| 38 | |||
| 39 | acl = get_cached_acl(inode, type); | ||
| 40 | if (acl != ACL_NOT_CACHED) | ||
| 41 | return acl; | ||
| 49 | 42 | ||
| 50 | switch (type) { | 43 | switch (type) { |
| 51 | case ACL_TYPE_ACCESS: | 44 | case ACL_TYPE_ACCESS: |
| 52 | name = POSIX_ACL_XATTR_ACCESS; | 45 | name = POSIX_ACL_XATTR_ACCESS; |
| 53 | p_acl = &BTRFS_I(inode)->i_acl; | ||
| 54 | break; | 46 | break; |
| 55 | case ACL_TYPE_DEFAULT: | 47 | case ACL_TYPE_DEFAULT: |
| 56 | name = POSIX_ACL_XATTR_DEFAULT; | 48 | name = POSIX_ACL_XATTR_DEFAULT; |
| 57 | p_acl = &BTRFS_I(inode)->i_default_acl; | ||
| 58 | break; | 49 | break; |
| 59 | default: | 50 | default: |
| 60 | return ERR_PTR(-EINVAL); | 51 | BUG(); |
| 61 | } | 52 | } |
| 62 | 53 | ||
| 63 | /* Handle the cached NULL acl case without locking */ | ||
| 64 | acl = ACCESS_ONCE(*p_acl); | ||
| 65 | if (!acl) | ||
| 66 | return acl; | ||
| 67 | |||
| 68 | spin_lock(&inode->i_lock); | ||
| 69 | acl = *p_acl; | ||
| 70 | if (acl != BTRFS_ACL_NOT_CACHED) | ||
| 71 | acl = posix_acl_dup(acl); | ||
| 72 | spin_unlock(&inode->i_lock); | ||
| 73 | |||
| 74 | if (acl != BTRFS_ACL_NOT_CACHED) | ||
| 75 | return acl; | ||
| 76 | |||
| 77 | size = __btrfs_getxattr(inode, name, "", 0); | 54 | size = __btrfs_getxattr(inode, name, "", 0); |
| 78 | if (size > 0) { | 55 | if (size > 0) { |
| 79 | value = kzalloc(size, GFP_NOFS); | 56 | value = kzalloc(size, GFP_NOFS); |
| @@ -82,13 +59,13 @@ static struct posix_acl *btrfs_get_acl(struct inode *inode, int type) | |||
| 82 | size = __btrfs_getxattr(inode, name, value, size); | 59 | size = __btrfs_getxattr(inode, name, value, size); |
| 83 | if (size > 0) { | 60 | if (size > 0) { |
| 84 | acl = posix_acl_from_xattr(value, size); | 61 | acl = posix_acl_from_xattr(value, size); |
| 85 | btrfs_update_cached_acl(inode, p_acl, acl); | 62 | set_cached_acl(inode, type, acl); |
| 86 | } | 63 | } |
| 87 | kfree(value); | 64 | kfree(value); |
| 88 | } else if (size == -ENOENT || size == -ENODATA || size == 0) { | 65 | } else if (size == -ENOENT || size == -ENODATA || size == 0) { |
| 89 | /* FIXME, who returns -ENOENT? I think nobody */ | 66 | /* FIXME, who returns -ENOENT? I think nobody */ |
| 90 | acl = NULL; | 67 | acl = NULL; |
| 91 | btrfs_update_cached_acl(inode, p_acl, acl); | 68 | set_cached_acl(inode, type, acl); |
| 92 | } else { | 69 | } else { |
| 93 | acl = ERR_PTR(-EIO); | 70 | acl = ERR_PTR(-EIO); |
| 94 | } | 71 | } |
| @@ -121,7 +98,6 @@ static int btrfs_set_acl(struct inode *inode, struct posix_acl *acl, int type) | |||
| 121 | { | 98 | { |
| 122 | int ret, size = 0; | 99 | int ret, size = 0; |
| 123 | const char *name; | 100 | const char *name; |
| 124 | struct posix_acl **p_acl; | ||
| 125 | char *value = NULL; | 101 | char *value = NULL; |
| 126 | mode_t mode; | 102 | mode_t mode; |
| 127 | 103 | ||
| @@ -141,13 +117,11 @@ static int btrfs_set_acl(struct inode *inode, struct posix_acl *acl, int type) | |||
| 141 | ret = 0; | 117 | ret = 0; |
| 142 | inode->i_mode = mode; | 118 | inode->i_mode = mode; |
| 143 | name = POSIX_ACL_XATTR_ACCESS; | 119 | name = POSIX_ACL_XATTR_ACCESS; |
| 144 | p_acl = &BTRFS_I(inode)->i_acl; | ||
| 145 | break; | 120 | break; |
| 146 | case ACL_TYPE_DEFAULT: | 121 | case ACL_TYPE_DEFAULT: |
| 147 | if (!S_ISDIR(inode->i_mode)) | 122 | if (!S_ISDIR(inode->i_mode)) |
| 148 | return acl ? -EINVAL : 0; | 123 | return acl ? -EINVAL : 0; |
| 149 | name = POSIX_ACL_XATTR_DEFAULT; | 124 | name = POSIX_ACL_XATTR_DEFAULT; |
| 150 | p_acl = &BTRFS_I(inode)->i_default_acl; | ||
| 151 | break; | 125 | break; |
| 152 | default: | 126 | default: |
| 153 | return -EINVAL; | 127 | return -EINVAL; |
| @@ -172,7 +146,7 @@ out: | |||
| 172 | kfree(value); | 146 | kfree(value); |
| 173 | 147 | ||
| 174 | if (!ret) | 148 | if (!ret) |
| 175 | btrfs_update_cached_acl(inode, p_acl, acl); | 149 | set_cached_acl(inode, type, acl); |
| 176 | 150 | ||
| 177 | return ret; | 151 | return ret; |
| 178 | } | 152 | } |
diff --git a/fs/btrfs/btrfs_inode.h b/fs/btrfs/btrfs_inode.h index acb4f3517582..ea1ea0af8c0e 100644 --- a/fs/btrfs/btrfs_inode.h +++ b/fs/btrfs/btrfs_inode.h | |||
| @@ -53,10 +53,6 @@ struct btrfs_inode { | |||
| 53 | /* used to order data wrt metadata */ | 53 | /* used to order data wrt metadata */ |
| 54 | struct btrfs_ordered_inode_tree ordered_tree; | 54 | struct btrfs_ordered_inode_tree ordered_tree; |
| 55 | 55 | ||
| 56 | /* standard acl pointers */ | ||
| 57 | struct posix_acl *i_acl; | ||
| 58 | struct posix_acl *i_default_acl; | ||
| 59 | |||
| 60 | /* for keeping track of orphaned inodes */ | 56 | /* for keeping track of orphaned inodes */ |
| 61 | struct list_head i_orphan; | 57 | struct list_head i_orphan; |
| 62 | 58 | ||
diff --git a/fs/btrfs/ctree.h b/fs/btrfs/ctree.h index 03441a99ea38..2779c2f5360a 100644 --- a/fs/btrfs/ctree.h +++ b/fs/btrfs/ctree.h | |||
| @@ -41,8 +41,6 @@ struct btrfs_ordered_sum; | |||
| 41 | 41 | ||
| 42 | #define BTRFS_MAGIC "_BHRfS_M" | 42 | #define BTRFS_MAGIC "_BHRfS_M" |
| 43 | 43 | ||
| 44 | #define BTRFS_ACL_NOT_CACHED ((void *)-1) | ||
| 45 | |||
| 46 | #define BTRFS_MAX_LEVEL 8 | 44 | #define BTRFS_MAX_LEVEL 8 |
| 47 | 45 | ||
| 48 | #define BTRFS_COMPAT_EXTENT_TREE_V0 | 46 | #define BTRFS_COMPAT_EXTENT_TREE_V0 |
diff --git a/fs/btrfs/inode.c b/fs/btrfs/inode.c index 8612b3a09811..78ad38ddd01f 100644 --- a/fs/btrfs/inode.c +++ b/fs/btrfs/inode.c | |||
| @@ -2123,8 +2123,8 @@ static void btrfs_read_locked_inode(struct inode *inode) | |||
| 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 | inode->i_acl = NULL; |
| 2127 | BTRFS_I(inode)->i_default_acl = NULL; | 2127 | inode->i_default_acl = NULL; |
| 2128 | } | 2128 | } |
| 2129 | 2129 | ||
| 2130 | BTRFS_I(inode)->block_group = btrfs_find_block_group(root, 0, | 2130 | BTRFS_I(inode)->block_group = btrfs_find_block_group(root, 0, |
| @@ -3141,9 +3141,6 @@ static noinline void init_btrfs_i(struct inode *inode) | |||
| 3141 | { | 3141 | { |
| 3142 | struct btrfs_inode *bi = BTRFS_I(inode); | 3142 | struct btrfs_inode *bi = BTRFS_I(inode); |
| 3143 | 3143 | ||
| 3144 | bi->i_acl = BTRFS_ACL_NOT_CACHED; | ||
| 3145 | bi->i_default_acl = BTRFS_ACL_NOT_CACHED; | ||
| 3146 | |||
| 3147 | bi->generation = 0; | 3144 | bi->generation = 0; |
| 3148 | bi->sequence = 0; | 3145 | bi->sequence = 0; |
| 3149 | bi->last_trans = 0; | 3146 | bi->last_trans = 0; |
| @@ -4640,8 +4637,6 @@ struct inode *btrfs_alloc_inode(struct super_block *sb) | |||
| 4640 | ei->last_trans = 0; | 4637 | ei->last_trans = 0; |
| 4641 | ei->logged_trans = 0; | 4638 | ei->logged_trans = 0; |
| 4642 | btrfs_ordered_inode_tree_init(&ei->ordered_tree); | 4639 | 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); | 4640 | INIT_LIST_HEAD(&ei->i_orphan); |
| 4646 | INIT_LIST_HEAD(&ei->ordered_operations); | 4641 | INIT_LIST_HEAD(&ei->ordered_operations); |
| 4647 | return &ei->vfs_inode; | 4642 | return &ei->vfs_inode; |
| @@ -4655,13 +4650,6 @@ void btrfs_destroy_inode(struct inode *inode) | |||
| 4655 | WARN_ON(!list_empty(&inode->i_dentry)); | 4650 | WARN_ON(!list_empty(&inode->i_dentry)); |
| 4656 | WARN_ON(inode->i_data.nrpages); | 4651 | WARN_ON(inode->i_data.nrpages); |
| 4657 | 4652 | ||
| 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 | /* | 4653 | /* |
| 4666 | * Make sure we're properly removed from the ordered operation | 4654 | * Make sure we're properly removed from the ordered operation |
| 4667 | * lists. | 4655 | * lists. |
