diff options
author | Christoph Hellwig <hch@lst.de> | 2008-08-28 06:21:17 -0400 |
---|---|---|
committer | Chris Mason <chris.mason@oracle.com> | 2008-09-25 11:04:07 -0400 |
commit | 95819c05732c511338b43c115ffbcee978c02888 (patch) | |
tree | 4622f326207c53e42e7c9e8e8d14960e17190a30 /fs/btrfs/acl.c | |
parent | eaa47d8612783807ef9703ebc9bf0d0f0455bf62 (diff) |
Btrfs: optimize btrget/set/removexattr
btrfs actually stores the whole xattr name, including the prefix ondisk,
so using the generic resolver that strips off the prefix is not very
helpful. Instead do the real ondisk xattrs manually and only use the
generic resolver for synthetic xattrs like ACLs.
(Sorry Josef for guiding you towards the wrong direction here intially)
Signed-off-by: Christoph Hellwig <hch@lst.de>
Signed-off-by: Chris Mason <chris.mason@oracle.com>
Diffstat (limited to 'fs/btrfs/acl.c')
-rw-r--r-- | fs/btrfs/acl.c | 20 |
1 files changed, 11 insertions, 9 deletions
diff --git a/fs/btrfs/acl.c b/fs/btrfs/acl.c index 2f865311460c..867eaf1f8efb 100644 --- a/fs/btrfs/acl.c +++ b/fs/btrfs/acl.c | |||
@@ -42,17 +42,18 @@ static void btrfs_update_cached_acl(struct inode *inode, | |||
42 | 42 | ||
43 | static struct posix_acl *btrfs_get_acl(struct inode *inode, int type) | 43 | static struct posix_acl *btrfs_get_acl(struct inode *inode, int type) |
44 | { | 44 | { |
45 | int size, name_index; | 45 | int size; |
46 | const char *name; | ||
46 | char *value = NULL; | 47 | char *value = NULL; |
47 | struct posix_acl *acl = NULL, **p_acl; | 48 | struct posix_acl *acl = NULL, **p_acl; |
48 | 49 | ||
49 | switch (type) { | 50 | switch (type) { |
50 | case ACL_TYPE_ACCESS: | 51 | case ACL_TYPE_ACCESS: |
51 | name_index = BTRFS_XATTR_INDEX_POSIX_ACL_ACCESS; | 52 | name = POSIX_ACL_XATTR_ACCESS; |
52 | p_acl = &BTRFS_I(inode)->i_acl; | 53 | p_acl = &BTRFS_I(inode)->i_acl; |
53 | break; | 54 | break; |
54 | case ACL_TYPE_DEFAULT: | 55 | case ACL_TYPE_DEFAULT: |
55 | name_index = BTRFS_XATTR_INDEX_POSIX_ACL_DEFAULT; | 56 | name = POSIX_ACL_XATTR_DEFAULT; |
56 | p_acl = &BTRFS_I(inode)->i_default_acl; | 57 | p_acl = &BTRFS_I(inode)->i_default_acl; |
57 | break; | 58 | break; |
58 | default: | 59 | default: |
@@ -68,12 +69,12 @@ static struct posix_acl *btrfs_get_acl(struct inode *inode, int type) | |||
68 | return acl; | 69 | return acl; |
69 | 70 | ||
70 | 71 | ||
71 | size = btrfs_xattr_get(inode, name_index, "", NULL, 0); | 72 | size = __btrfs_getxattr(inode, name, "", 0); |
72 | if (size > 0) { | 73 | if (size > 0) { |
73 | value = kzalloc(size, GFP_NOFS); | 74 | value = kzalloc(size, GFP_NOFS); |
74 | if (!value) | 75 | if (!value) |
75 | return ERR_PTR(-ENOMEM); | 76 | return ERR_PTR(-ENOMEM); |
76 | size = btrfs_xattr_get(inode, name_index, "", value, size); | 77 | size = __btrfs_getxattr(inode, name, value, size); |
77 | if (size > 0) { | 78 | if (size > 0) { |
78 | acl = posix_acl_from_xattr(value, size); | 79 | acl = posix_acl_from_xattr(value, size); |
79 | btrfs_update_cached_acl(inode, p_acl, acl); | 80 | btrfs_update_cached_acl(inode, p_acl, acl); |
@@ -110,7 +111,8 @@ static int btrfs_xattr_get_acl(struct inode *inode, int type, | |||
110 | */ | 111 | */ |
111 | static int btrfs_set_acl(struct inode *inode, struct posix_acl *acl, int type) | 112 | static int btrfs_set_acl(struct inode *inode, struct posix_acl *acl, int type) |
112 | { | 113 | { |
113 | int ret, name_index = 0, size = 0; | 114 | int ret, size = 0; |
115 | const char *name; | ||
114 | struct posix_acl **p_acl; | 116 | struct posix_acl **p_acl; |
115 | char *value = NULL; | 117 | char *value = NULL; |
116 | mode_t mode; | 118 | mode_t mode; |
@@ -130,13 +132,13 @@ static int btrfs_set_acl(struct inode *inode, struct posix_acl *acl, int type) | |||
130 | return ret; | 132 | return ret; |
131 | ret = 0; | 133 | ret = 0; |
132 | inode->i_mode = mode; | 134 | inode->i_mode = mode; |
133 | name_index = BTRFS_XATTR_INDEX_POSIX_ACL_ACCESS; | 135 | name = POSIX_ACL_XATTR_ACCESS; |
134 | p_acl = &BTRFS_I(inode)->i_acl; | 136 | p_acl = &BTRFS_I(inode)->i_acl; |
135 | break; | 137 | break; |
136 | case ACL_TYPE_DEFAULT: | 138 | case ACL_TYPE_DEFAULT: |
137 | if (!S_ISDIR(inode->i_mode)) | 139 | if (!S_ISDIR(inode->i_mode)) |
138 | return acl ? -EINVAL : 0; | 140 | return acl ? -EINVAL : 0; |
139 | name_index = BTRFS_XATTR_INDEX_POSIX_ACL_DEFAULT; | 141 | name = POSIX_ACL_XATTR_DEFAULT; |
140 | p_acl = &BTRFS_I(inode)->i_default_acl; | 142 | p_acl = &BTRFS_I(inode)->i_default_acl; |
141 | break; | 143 | break; |
142 | default: | 144 | default: |
@@ -156,7 +158,7 @@ static int btrfs_set_acl(struct inode *inode, struct posix_acl *acl, int type) | |||
156 | goto out; | 158 | goto out; |
157 | } | 159 | } |
158 | 160 | ||
159 | ret = btrfs_xattr_set(inode, name_index, "", value, size, 0); | 161 | ret = __btrfs_setxattr(inode, name, value, size, 0); |
160 | 162 | ||
161 | out: | 163 | out: |
162 | if (value) | 164 | if (value) |