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/reiserfs/xattr_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/reiserfs/xattr_acl.c')
-rw-r--r-- | fs/reiserfs/xattr_acl.c | 49 |
1 files changed, 10 insertions, 39 deletions
diff --git a/fs/reiserfs/xattr_acl.c b/fs/reiserfs/xattr_acl.c index b6e473faa8b8..35d6e672a279 100644 --- a/fs/reiserfs/xattr_acl.c +++ b/fs/reiserfs/xattr_acl.c | |||
@@ -188,29 +188,6 @@ static void *posix_acl_to_disk(const struct posix_acl *acl, size_t * size) | |||
188 | return ERR_PTR(-EINVAL); | 188 | return ERR_PTR(-EINVAL); |
189 | } | 189 | } |
190 | 190 | ||
191 | static inline void iset_acl(struct inode *inode, struct posix_acl **i_acl, | ||
192 | struct posix_acl *acl) | ||
193 | { | ||
194 | spin_lock(&inode->i_lock); | ||
195 | if (*i_acl != ACL_NOT_CACHED) | ||
196 | posix_acl_release(*i_acl); | ||
197 | *i_acl = posix_acl_dup(acl); | ||
198 | spin_unlock(&inode->i_lock); | ||
199 | } | ||
200 | |||
201 | static inline struct posix_acl *iget_acl(struct inode *inode, | ||
202 | struct posix_acl **i_acl) | ||
203 | { | ||
204 | struct posix_acl *acl = ACL_NOT_CACHED; | ||
205 | |||
206 | spin_lock(&inode->i_lock); | ||
207 | if (*i_acl != ACL_NOT_CACHED) | ||
208 | acl = posix_acl_dup(*i_acl); | ||
209 | spin_unlock(&inode->i_lock); | ||
210 | |||
211 | return acl; | ||
212 | } | ||
213 | |||
214 | /* | 191 | /* |
215 | * Inode operation get_posix_acl(). | 192 | * Inode operation get_posix_acl(). |
216 | * | 193 | * |
@@ -220,31 +197,29 @@ static inline struct posix_acl *iget_acl(struct inode *inode, | |||
220 | struct posix_acl *reiserfs_get_acl(struct inode *inode, int type) | 197 | struct posix_acl *reiserfs_get_acl(struct inode *inode, int type) |
221 | { | 198 | { |
222 | char *name, *value; | 199 | char *name, *value; |
223 | struct posix_acl *acl, **p_acl; | 200 | struct posix_acl *acl; |
224 | int size; | 201 | int size; |
225 | int retval; | 202 | int retval; |
226 | 203 | ||
204 | acl = get_cached_acl(inode, type); | ||
205 | if (acl != ACL_NOT_CACHED) | ||
206 | return acl; | ||
207 | |||
227 | switch (type) { | 208 | switch (type) { |
228 | case ACL_TYPE_ACCESS: | 209 | case ACL_TYPE_ACCESS: |
229 | name = POSIX_ACL_XATTR_ACCESS; | 210 | name = POSIX_ACL_XATTR_ACCESS; |
230 | p_acl = &inode->i_acl; | ||
231 | break; | 211 | break; |
232 | case ACL_TYPE_DEFAULT: | 212 | case ACL_TYPE_DEFAULT: |
233 | name = POSIX_ACL_XATTR_DEFAULT; | 213 | name = POSIX_ACL_XATTR_DEFAULT; |
234 | p_acl = &inode->i_default_acl; | ||
235 | break; | 214 | break; |
236 | default: | 215 | default: |
237 | return ERR_PTR(-EINVAL); | 216 | BUG(); |
238 | } | 217 | } |
239 | 218 | ||
240 | acl = iget_acl(inode, p_acl); | ||
241 | if (acl != ACL_NOT_CACHED) | ||
242 | return acl; | ||
243 | |||
244 | size = reiserfs_xattr_get(inode, name, NULL, 0); | 219 | size = reiserfs_xattr_get(inode, name, NULL, 0); |
245 | if (size < 0) { | 220 | if (size < 0) { |
246 | if (size == -ENODATA || size == -ENOSYS) { | 221 | if (size == -ENODATA || size == -ENOSYS) { |
247 | *p_acl = NULL; | 222 | set_cached_acl(inode, type, NULL); |
248 | return NULL; | 223 | return NULL; |
249 | } | 224 | } |
250 | return ERR_PTR(size); | 225 | return ERR_PTR(size); |
@@ -259,14 +234,13 @@ struct posix_acl *reiserfs_get_acl(struct inode *inode, int type) | |||
259 | /* This shouldn't actually happen as it should have | 234 | /* This shouldn't actually happen as it should have |
260 | been caught above.. but just in case */ | 235 | been caught above.. but just in case */ |
261 | acl = NULL; | 236 | acl = NULL; |
262 | *p_acl = acl; | ||
263 | } else if (retval < 0) { | 237 | } else if (retval < 0) { |
264 | acl = ERR_PTR(retval); | 238 | acl = ERR_PTR(retval); |
265 | } else { | 239 | } else { |
266 | acl = posix_acl_from_disk(value, retval); | 240 | acl = posix_acl_from_disk(value, retval); |
267 | if (!IS_ERR(acl)) | ||
268 | iset_acl(inode, p_acl, acl); | ||
269 | } | 241 | } |
242 | if (!IS_ERR(acl)) | ||
243 | set_cached_acl(inode, type, acl); | ||
270 | 244 | ||
271 | kfree(value); | 245 | kfree(value); |
272 | return acl; | 246 | return acl; |
@@ -284,7 +258,6 @@ reiserfs_set_acl(struct reiserfs_transaction_handle *th, struct inode *inode, | |||
284 | { | 258 | { |
285 | char *name; | 259 | char *name; |
286 | void *value = NULL; | 260 | void *value = NULL; |
287 | struct posix_acl **p_acl; | ||
288 | size_t size = 0; | 261 | size_t size = 0; |
289 | int error; | 262 | int error; |
290 | 263 | ||
@@ -294,7 +267,6 @@ reiserfs_set_acl(struct reiserfs_transaction_handle *th, struct inode *inode, | |||
294 | switch (type) { | 267 | switch (type) { |
295 | case ACL_TYPE_ACCESS: | 268 | case ACL_TYPE_ACCESS: |
296 | name = POSIX_ACL_XATTR_ACCESS; | 269 | name = POSIX_ACL_XATTR_ACCESS; |
297 | p_acl = &inode->i_acl; | ||
298 | if (acl) { | 270 | if (acl) { |
299 | mode_t mode = inode->i_mode; | 271 | mode_t mode = inode->i_mode; |
300 | error = posix_acl_equiv_mode(acl, &mode); | 272 | error = posix_acl_equiv_mode(acl, &mode); |
@@ -309,7 +281,6 @@ reiserfs_set_acl(struct reiserfs_transaction_handle *th, struct inode *inode, | |||
309 | break; | 281 | break; |
310 | case ACL_TYPE_DEFAULT: | 282 | case ACL_TYPE_DEFAULT: |
311 | name = POSIX_ACL_XATTR_DEFAULT; | 283 | name = POSIX_ACL_XATTR_DEFAULT; |
312 | p_acl = &inode->i_default_acl; | ||
313 | if (!S_ISDIR(inode->i_mode)) | 284 | if (!S_ISDIR(inode->i_mode)) |
314 | return acl ? -EACCES : 0; | 285 | return acl ? -EACCES : 0; |
315 | break; | 286 | break; |
@@ -342,7 +313,7 @@ reiserfs_set_acl(struct reiserfs_transaction_handle *th, struct inode *inode, | |||
342 | kfree(value); | 313 | kfree(value); |
343 | 314 | ||
344 | if (!error) | 315 | if (!error) |
345 | iset_acl(inode, p_acl, acl); | 316 | set_cached_acl(inode, type, acl); |
346 | 317 | ||
347 | return error; | 318 | return error; |
348 | } | 319 | } |