aboutsummaryrefslogtreecommitdiffstats
path: root/fs/ext2/acl.c
diff options
context:
space:
mode:
authorAl Viro <viro@zeniv.linux.org.uk>2009-06-09 12:11:54 -0400
committerAl Viro <viro@zeniv.linux.org.uk>2009-06-24 08:17:07 -0400
commit073aaa1b142461d91f83da66db1184d7c1b1edea (patch)
tree2b54d185d78f1229418fca521a93e6b55c57248b /fs/ext2/acl.c
parent06b16e9f68edaa1e71aee943d3c030bcf7380af1 (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/ext2/acl.c')
-rw-r--r--fs/ext2/acl.c79
1 files changed, 17 insertions, 62 deletions
diff --git a/fs/ext2/acl.c b/fs/ext2/acl.c
index d2ffddc1211..d636e1297ca 100644
--- a/fs/ext2/acl.c
+++ b/fs/ext2/acl.c
@@ -125,30 +125,6 @@ fail:
125 return ERR_PTR(-EINVAL); 125 return ERR_PTR(-EINVAL);
126} 126}
127 127
128static inline struct posix_acl *
129ext2_iget_acl(struct inode *inode, struct posix_acl **i_acl)
130{
131 struct posix_acl *acl = ACL_NOT_CACHED;
132
133 spin_lock(&inode->i_lock);
134 if (*i_acl != ACL_NOT_CACHED)
135 acl = posix_acl_dup(*i_acl);
136 spin_unlock(&inode->i_lock);
137
138 return acl;
139}
140
141static inline void
142ext2_iset_acl(struct inode *inode, struct posix_acl **i_acl,
143 struct posix_acl *acl)
144{
145 spin_lock(&inode->i_lock);
146 if (*i_acl != ACL_NOT_CACHED)
147 posix_acl_release(*i_acl);
148 *i_acl = posix_acl_dup(acl);
149 spin_unlock(&inode->i_lock);
150}
151
152/* 128/*
153 * inode->i_mutex: don't care 129 * inode->i_mutex: don't care
154 */ 130 */
@@ -163,23 +139,19 @@ ext2_get_acl(struct inode *inode, int type)
163 if (!test_opt(inode->i_sb, POSIX_ACL)) 139 if (!test_opt(inode->i_sb, POSIX_ACL))
164 return NULL; 140 return NULL;
165 141
166 switch(type) { 142 acl = get_cached_acl(inode, type);
167 case ACL_TYPE_ACCESS: 143 if (acl != ACL_NOT_CACHED)
168 acl = ext2_iget_acl(inode, &inode->i_acl); 144 return acl;
169 if (acl != ACL_NOT_CACHED) 145
170 return acl; 146 switch (type) {
171 name_index = EXT2_XATTR_INDEX_POSIX_ACL_ACCESS; 147 case ACL_TYPE_ACCESS:
172 break; 148 name_index = EXT2_XATTR_INDEX_POSIX_ACL_ACCESS;
173 149 break;
174 case ACL_TYPE_DEFAULT: 150 case ACL_TYPE_DEFAULT:
175 acl = ext2_iget_acl(inode, &inode->i_default_acl); 151 name_index = EXT2_XATTR_INDEX_POSIX_ACL_DEFAULT;
176 if (acl != ACL_NOT_CACHED) 152 break;
177 return acl; 153 default:
178 name_index = EXT2_XATTR_INDEX_POSIX_ACL_DEFAULT; 154 BUG();
179 break;
180
181 default:
182 return ERR_PTR(-EINVAL);
183 } 155 }
184 retval = ext2_xattr_get(inode, name_index, "", NULL, 0); 156 retval = ext2_xattr_get(inode, name_index, "", NULL, 0);
185 if (retval > 0) { 157 if (retval > 0) {
@@ -196,17 +168,9 @@ ext2_get_acl(struct inode *inode, int type)
196 acl = ERR_PTR(retval); 168 acl = ERR_PTR(retval);
197 kfree(value); 169 kfree(value);
198 170
199 if (!IS_ERR(acl)) { 171 if (!IS_ERR(acl))
200 switch(type) { 172 set_cached_acl(inode, type, acl);
201 case ACL_TYPE_ACCESS:
202 ext2_iset_acl(inode, &inode->i_acl, acl);
203 break;
204 173
205 case ACL_TYPE_DEFAULT:
206 ext2_iset_acl(inode, &inode->i_default_acl, acl);
207 break;
208 }
209 }
210 return acl; 174 return acl;
211} 175}
212 176
@@ -261,17 +225,8 @@ ext2_set_acl(struct inode *inode, int type, struct posix_acl *acl)
261 error = ext2_xattr_set(inode, name_index, "", value, size, 0); 225 error = ext2_xattr_set(inode, name_index, "", value, size, 0);
262 226
263 kfree(value); 227 kfree(value);
264 if (!error) { 228 if (!error)
265 switch(type) { 229 set_cached_acl(inode, type, acl);
266 case ACL_TYPE_ACCESS:
267 ext2_iset_acl(inode, &inode->i_acl, acl);
268 break;
269
270 case ACL_TYPE_DEFAULT:
271 ext2_iset_acl(inode, &inode->i_default_acl, acl);
272 break;
273 }
274 }
275 return error; 230 return error;
276} 231}
277 232