aboutsummaryrefslogtreecommitdiffstats
path: root/fs/jffs2/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/jffs2/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/jffs2/acl.c')
-rw-r--r--fs/jffs2/acl.c60
1 files changed, 11 insertions, 49 deletions
diff --git a/fs/jffs2/acl.c b/fs/jffs2/acl.c
index ac16589ebbd1..edd2ad6416d8 100644
--- a/fs/jffs2/acl.c
+++ b/fs/jffs2/acl.c
@@ -156,47 +156,25 @@ static void *jffs2_acl_to_medium(const struct posix_acl *acl, size_t *size)
156 return ERR_PTR(-EINVAL); 156 return ERR_PTR(-EINVAL);
157} 157}
158 158
159static struct posix_acl *jffs2_iget_acl(struct inode *inode, struct posix_acl **i_acl)
160{
161 struct posix_acl *acl = ACL_NOT_CACHED;
162
163 spin_lock(&inode->i_lock);
164 if (*i_acl != ACL_NOT_CACHED)
165 acl = posix_acl_dup(*i_acl);
166 spin_unlock(&inode->i_lock);
167 return acl;
168}
169
170static void jffs2_iset_acl(struct inode *inode, struct posix_acl **i_acl, struct posix_acl *acl)
171{
172 spin_lock(&inode->i_lock);
173 if (*i_acl != ACL_NOT_CACHED)
174 posix_acl_release(*i_acl);
175 *i_acl = posix_acl_dup(acl);
176 spin_unlock(&inode->i_lock);
177}
178
179static struct posix_acl *jffs2_get_acl(struct inode *inode, int type) 159static struct posix_acl *jffs2_get_acl(struct inode *inode, int type)
180{ 160{
181 struct posix_acl *acl; 161 struct posix_acl *acl;
182 char *value = NULL; 162 char *value = NULL;
183 int rc, xprefix; 163 int rc, xprefix;
184 164
165 acl = get_cached_acl(inode, type);
166 if (acl != ACL_NOT_CACHED)
167 return acl;
168
185 switch (type) { 169 switch (type) {
186 case ACL_TYPE_ACCESS: 170 case ACL_TYPE_ACCESS:
187 acl = jffs2_iget_acl(inode, &inode->i_acl);
188 if (acl != ACL_NOT_CACHED)
189 return acl;
190 xprefix = JFFS2_XPREFIX_ACL_ACCESS; 171 xprefix = JFFS2_XPREFIX_ACL_ACCESS;
191 break; 172 break;
192 case ACL_TYPE_DEFAULT: 173 case ACL_TYPE_DEFAULT:
193 acl = jffs2_iget_acl(inode, &inode->i_default_acl);
194 if (acl != ACL_NOT_CACHED)
195 return acl;
196 xprefix = JFFS2_XPREFIX_ACL_DEFAULT; 174 xprefix = JFFS2_XPREFIX_ACL_DEFAULT;
197 break; 175 break;
198 default: 176 default:
199 return ERR_PTR(-EINVAL); 177 BUG();
200 } 178 }
201 rc = do_jffs2_getxattr(inode, xprefix, "", NULL, 0); 179 rc = do_jffs2_getxattr(inode, xprefix, "", NULL, 0);
202 if (rc > 0) { 180 if (rc > 0) {
@@ -214,16 +192,8 @@ static struct posix_acl *jffs2_get_acl(struct inode *inode, int type)
214 } 192 }
215 if (value) 193 if (value)
216 kfree(value); 194 kfree(value);
217 if (!IS_ERR(acl)) { 195 if (!IS_ERR(acl))
218 switch (type) { 196 set_cached_acl(inode, type, acl);
219 case ACL_TYPE_ACCESS:
220 jffs2_iset_acl(inode, &inode->i_acl, acl);
221 break;
222 case ACL_TYPE_DEFAULT:
223 jffs2_iset_acl(inode, &inode->i_default_acl, acl);
224 break;
225 }
226 }
227 return acl; 197 return acl;
228} 198}
229 199
@@ -283,16 +253,8 @@ static int jffs2_set_acl(struct inode *inode, int type, struct posix_acl *acl)
283 return -EINVAL; 253 return -EINVAL;
284 } 254 }
285 rc = __jffs2_set_acl(inode, xprefix, acl); 255 rc = __jffs2_set_acl(inode, xprefix, acl);
286 if (!rc) { 256 if (!rc)
287 switch(type) { 257 set_cached_acl(inode, type, acl);
288 case ACL_TYPE_ACCESS:
289 jffs2_iset_acl(inode, &inode->i_acl, acl);
290 break;
291 case ACL_TYPE_DEFAULT:
292 jffs2_iset_acl(inode, &inode->i_default_acl, acl);
293 break;
294 }
295 }
296 return rc; 258 return rc;
297} 259}
298 260
@@ -336,7 +298,7 @@ int jffs2_init_acl_pre(struct inode *dir_i, struct inode *inode, int *i_mode)
336 *i_mode &= ~current_umask(); 298 *i_mode &= ~current_umask();
337 } else { 299 } else {
338 if (S_ISDIR(*i_mode)) 300 if (S_ISDIR(*i_mode))
339 jffs2_iset_acl(inode, &inode->i_default_acl, acl); 301 set_cached_acl(inode, ACL_TYPE_DEFAULT, acl);
340 302
341 clone = posix_acl_clone(acl, GFP_KERNEL); 303 clone = posix_acl_clone(acl, GFP_KERNEL);
342 if (!clone) 304 if (!clone)
@@ -347,7 +309,7 @@ int jffs2_init_acl_pre(struct inode *dir_i, struct inode *inode, int *i_mode)
347 return rc; 309 return rc;
348 } 310 }
349 if (rc > 0) 311 if (rc > 0)
350 jffs2_iset_acl(inode, &inode->i_acl, clone); 312 set_cached_acl(inode, ACL_TYPE_ACCESS, clone);
351 313
352 posix_acl_release(clone); 314 posix_acl_release(clone);
353 } 315 }