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/jfs/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/jfs/acl.c')
-rw-r--r-- | fs/jfs/acl.c | 32 |
1 files changed, 13 insertions, 19 deletions
diff --git a/fs/jfs/acl.c b/fs/jfs/acl.c index 5fcfc9857c11..f272bf032e1e 100644 --- a/fs/jfs/acl.c +++ b/fs/jfs/acl.c | |||
@@ -31,26 +31,24 @@ static struct posix_acl *jfs_get_acl(struct inode *inode, int type) | |||
31 | { | 31 | { |
32 | struct posix_acl *acl; | 32 | struct posix_acl *acl; |
33 | char *ea_name; | 33 | char *ea_name; |
34 | struct posix_acl **p_acl; | ||
35 | int size; | 34 | int size; |
36 | char *value = NULL; | 35 | char *value = NULL; |
37 | 36 | ||
37 | acl = get_cached_acl(inode, type); | ||
38 | if (acl != ACL_NOT_CACHED) | ||
39 | return acl; | ||
40 | |||
38 | switch(type) { | 41 | switch(type) { |
39 | case ACL_TYPE_ACCESS: | 42 | case ACL_TYPE_ACCESS: |
40 | ea_name = POSIX_ACL_XATTR_ACCESS; | 43 | ea_name = POSIX_ACL_XATTR_ACCESS; |
41 | p_acl = &inode->i_acl; | ||
42 | break; | 44 | break; |
43 | case ACL_TYPE_DEFAULT: | 45 | case ACL_TYPE_DEFAULT: |
44 | ea_name = POSIX_ACL_XATTR_DEFAULT; | 46 | ea_name = POSIX_ACL_XATTR_DEFAULT; |
45 | p_acl = &inode->i_default_acl; | ||
46 | break; | 47 | break; |
47 | default: | 48 | default: |
48 | return ERR_PTR(-EINVAL); | 49 | return ERR_PTR(-EINVAL); |
49 | } | 50 | } |
50 | 51 | ||
51 | if (*p_acl != ACL_NOT_CACHED) | ||
52 | return posix_acl_dup(*p_acl); | ||
53 | |||
54 | size = __jfs_getxattr(inode, ea_name, NULL, 0); | 52 | size = __jfs_getxattr(inode, ea_name, NULL, 0); |
55 | 53 | ||
56 | if (size > 0) { | 54 | if (size > 0) { |
@@ -61,17 +59,18 @@ static struct posix_acl *jfs_get_acl(struct inode *inode, int type) | |||
61 | } | 59 | } |
62 | 60 | ||
63 | if (size < 0) { | 61 | if (size < 0) { |
64 | if (size == -ENODATA) { | 62 | if (size == -ENODATA) |
65 | *p_acl = NULL; | ||
66 | acl = NULL; | 63 | acl = NULL; |
67 | } else | 64 | else |
68 | acl = ERR_PTR(size); | 65 | acl = ERR_PTR(size); |
69 | } else { | 66 | } else { |
70 | acl = posix_acl_from_xattr(value, size); | 67 | acl = posix_acl_from_xattr(value, size); |
71 | if (!IS_ERR(acl)) | ||
72 | *p_acl = posix_acl_dup(acl); | ||
73 | } | 68 | } |
74 | kfree(value); | 69 | kfree(value); |
70 | if (!IS_ERR(acl)) { | ||
71 | set_cached_acl(inode, type, acl); | ||
72 | posix_acl_release(acl); | ||
73 | } | ||
75 | return acl; | 74 | return acl; |
76 | } | 75 | } |
77 | 76 | ||
@@ -79,7 +78,6 @@ static int jfs_set_acl(tid_t tid, struct inode *inode, int type, | |||
79 | struct posix_acl *acl) | 78 | struct posix_acl *acl) |
80 | { | 79 | { |
81 | char *ea_name; | 80 | char *ea_name; |
82 | struct posix_acl **p_acl; | ||
83 | int rc; | 81 | int rc; |
84 | int size = 0; | 82 | int size = 0; |
85 | char *value = NULL; | 83 | char *value = NULL; |
@@ -90,11 +88,9 @@ static int jfs_set_acl(tid_t tid, struct inode *inode, int type, | |||
90 | switch(type) { | 88 | switch(type) { |
91 | case ACL_TYPE_ACCESS: | 89 | case ACL_TYPE_ACCESS: |
92 | ea_name = POSIX_ACL_XATTR_ACCESS; | 90 | ea_name = POSIX_ACL_XATTR_ACCESS; |
93 | p_acl = &inode->i_acl; | ||
94 | break; | 91 | break; |
95 | case ACL_TYPE_DEFAULT: | 92 | case ACL_TYPE_DEFAULT: |
96 | ea_name = POSIX_ACL_XATTR_DEFAULT; | 93 | ea_name = POSIX_ACL_XATTR_DEFAULT; |
97 | p_acl = &inode->i_default_acl; | ||
98 | if (!S_ISDIR(inode->i_mode)) | 94 | if (!S_ISDIR(inode->i_mode)) |
99 | return acl ? -EACCES : 0; | 95 | return acl ? -EACCES : 0; |
100 | break; | 96 | break; |
@@ -114,11 +110,9 @@ static int jfs_set_acl(tid_t tid, struct inode *inode, int type, | |||
114 | out: | 110 | out: |
115 | kfree(value); | 111 | kfree(value); |
116 | 112 | ||
117 | if (!rc) { | 113 | if (!rc) |
118 | if (*p_acl && (*p_acl != ACL_NOT_CACHED)) | 114 | set_cached_acl(inode, type, acl); |
119 | posix_acl_release(*p_acl); | 115 | |
120 | *p_acl = posix_acl_dup(acl); | ||
121 | } | ||
122 | return rc; | 116 | return rc; |
123 | } | 117 | } |
124 | 118 | ||