diff options
author | Al Viro <viro@zeniv.linux.org.uk> | 2009-06-09 12:11:54 -0400 |
---|---|---|
committer | Al Viro <viro@zeniv.linux.org.uk> | 2009-06-24 08:17:07 -0400 |
commit | 073aaa1b142461d91f83da66db1184d7c1b1edea (patch) | |
tree | 2b54d185d78f1229418fca521a93e6b55c57248b /fs/ext4/acl.c | |
parent | 06b16e9f68edaa1e71aee943d3c030bcf7380af1 (diff) |
helpers for acl caching + switch to those
helpers: get_cached_acl(inode, type), set_cached_acl(inode, type, acl),
forget_cached_acl(inode, type).
ubifs/xattr.c needed includes reordered, the rest is a plain switchover.
Signed-off-by: Al Viro <viro@zeniv.linux.org.uk>
Diffstat (limited to 'fs/ext4/acl.c')
-rw-r--r-- | fs/ext4/acl.c | 65 |
1 files changed, 9 insertions, 56 deletions
diff --git a/fs/ext4/acl.c b/fs/ext4/acl.c index 0084e3a19d8..f6d8967149c 100644 --- a/fs/ext4/acl.c +++ b/fs/ext4/acl.c | |||
@@ -126,33 +126,6 @@ fail: | |||
126 | return ERR_PTR(-EINVAL); | 126 | return ERR_PTR(-EINVAL); |
127 | } | 127 | } |
128 | 128 | ||
129 | static inline struct posix_acl * | ||
130 | ext4_iget_acl(struct inode *inode, struct posix_acl **i_acl) | ||
131 | { | ||
132 | struct posix_acl *acl = ACCESS_ONCE(*i_acl); | ||
133 | |||
134 | if (acl) { | ||
135 | spin_lock(&inode->i_lock); | ||
136 | acl = *i_acl; | ||
137 | if (acl != ACL_NOT_CACHED) | ||
138 | acl = posix_acl_dup(acl); | ||
139 | spin_unlock(&inode->i_lock); | ||
140 | } | ||
141 | |||
142 | return acl; | ||
143 | } | ||
144 | |||
145 | static inline void | ||
146 | ext4_iset_acl(struct inode *inode, struct posix_acl **i_acl, | ||
147 | struct posix_acl *acl) | ||
148 | { | ||
149 | spin_lock(&inode->i_lock); | ||
150 | if (*i_acl != ACL_NOT_CACHED) | ||
151 | posix_acl_release(*i_acl); | ||
152 | *i_acl = posix_acl_dup(acl); | ||
153 | spin_unlock(&inode->i_lock); | ||
154 | } | ||
155 | |||
156 | /* | 129 | /* |
157 | * Inode operation get_posix_acl(). | 130 | * Inode operation get_posix_acl(). |
158 | * | 131 | * |
@@ -169,23 +142,19 @@ ext4_get_acl(struct inode *inode, int type) | |||
169 | if (!test_opt(inode->i_sb, POSIX_ACL)) | 142 | if (!test_opt(inode->i_sb, POSIX_ACL)) |
170 | return NULL; | 143 | return NULL; |
171 | 144 | ||
145 | acl = get_cached_acl(inode, type); | ||
146 | if (acl != ACL_NOT_CACHED) | ||
147 | return acl; | ||
148 | |||
172 | switch (type) { | 149 | switch (type) { |
173 | case ACL_TYPE_ACCESS: | 150 | case ACL_TYPE_ACCESS: |
174 | acl = ext4_iget_acl(inode, &inode->i_acl); | ||
175 | if (acl != ACL_NOT_CACHED) | ||
176 | return acl; | ||
177 | name_index = EXT4_XATTR_INDEX_POSIX_ACL_ACCESS; | 151 | name_index = EXT4_XATTR_INDEX_POSIX_ACL_ACCESS; |
178 | break; | 152 | break; |
179 | |||
180 | case ACL_TYPE_DEFAULT: | 153 | case ACL_TYPE_DEFAULT: |
181 | acl = ext4_iget_acl(inode, &inode->i_default_acl); | ||
182 | if (acl != ACL_NOT_CACHED) | ||
183 | return acl; | ||
184 | name_index = EXT4_XATTR_INDEX_POSIX_ACL_DEFAULT; | 154 | name_index = EXT4_XATTR_INDEX_POSIX_ACL_DEFAULT; |
185 | break; | 155 | break; |
186 | |||
187 | default: | 156 | default: |
188 | return ERR_PTR(-EINVAL); | 157 | BUG(); |
189 | } | 158 | } |
190 | retval = ext4_xattr_get(inode, name_index, "", NULL, 0); | 159 | retval = ext4_xattr_get(inode, name_index, "", NULL, 0); |
191 | if (retval > 0) { | 160 | if (retval > 0) { |
@@ -202,17 +171,9 @@ ext4_get_acl(struct inode *inode, int type) | |||
202 | acl = ERR_PTR(retval); | 171 | acl = ERR_PTR(retval); |
203 | kfree(value); | 172 | kfree(value); |
204 | 173 | ||
205 | if (!IS_ERR(acl)) { | 174 | if (!IS_ERR(acl)) |
206 | switch (type) { | 175 | set_cached_acl(inode, type, acl); |
207 | case ACL_TYPE_ACCESS: | ||
208 | ext4_iset_acl(inode, &inode->i_acl, acl); | ||
209 | break; | ||
210 | 176 | ||
211 | case ACL_TYPE_DEFAULT: | ||
212 | ext4_iset_acl(inode, &inode->i_default_acl, acl); | ||
213 | break; | ||
214 | } | ||
215 | } | ||
216 | return acl; | 177 | return acl; |
217 | } | 178 | } |
218 | 179 | ||
@@ -269,17 +230,9 @@ ext4_set_acl(handle_t *handle, struct inode *inode, int type, | |||
269 | value, size, 0); | 230 | value, size, 0); |
270 | 231 | ||
271 | kfree(value); | 232 | kfree(value); |
272 | if (!error) { | 233 | if (!error) |
273 | switch (type) { | 234 | set_cached_acl(inode, type, acl); |
274 | case ACL_TYPE_ACCESS: | ||
275 | ext4_iset_acl(inode, &inode->i_acl, acl); | ||
276 | break; | ||
277 | 235 | ||
278 | case ACL_TYPE_DEFAULT: | ||
279 | ext4_iset_acl(inode, &inode->i_default_acl, acl); | ||
280 | break; | ||
281 | } | ||
282 | } | ||
283 | return error; | 236 | return error; |
284 | } | 237 | } |
285 | 238 | ||