summaryrefslogtreecommitdiff
path: root/fs/jffs2/acl.c
diff options
context:
space:
mode:
authorAl Viro <viro@zeniv.linux.org.uk>2009-06-09 20:11:54 +0400
committerAl Viro <viro@zeniv.linux.org.uk>2009-06-24 16:17:07 +0400
commit073aaa1b142461d91f83da66db1184d7c1b1edea (patch)
tree2b54d185d78f1229418fca521a93e6b55c57248b /fs/jffs2/acl.c
parent06b16e9f68edaa1e71aee943d3c030bcf7380af1 (diff)
downloadlinux-073aaa1b142461d91f83da66db1184d7c1b1edea.tar.xz
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)
return ERR_PTR(-EINVAL);
}
-static struct posix_acl *jffs2_iget_acl(struct inode *inode, struct posix_acl **i_acl)
-{
- struct posix_acl *acl = ACL_NOT_CACHED;
-
- spin_lock(&inode->i_lock);
- if (*i_acl != ACL_NOT_CACHED)
- acl = posix_acl_dup(*i_acl);
- spin_unlock(&inode->i_lock);
- return acl;
-}
-
-static void jffs2_iset_acl(struct inode *inode, struct posix_acl **i_acl, struct posix_acl *acl)
-{
- spin_lock(&inode->i_lock);
- if (*i_acl != ACL_NOT_CACHED)
- posix_acl_release(*i_acl);
- *i_acl = posix_acl_dup(acl);
- spin_unlock(&inode->i_lock);
-}
-
static struct posix_acl *jffs2_get_acl(struct inode *inode, int type)
{
struct posix_acl *acl;
char *value = NULL;
int rc, xprefix;
+ acl = get_cached_acl(inode, type);
+ if (acl != ACL_NOT_CACHED)
+ return acl;
+
switch (type) {
case ACL_TYPE_ACCESS:
- acl = jffs2_iget_acl(inode, &inode->i_acl);
- if (acl != ACL_NOT_CACHED)
- return acl;
xprefix = JFFS2_XPREFIX_ACL_ACCESS;
break;
case ACL_TYPE_DEFAULT:
- acl = jffs2_iget_acl(inode, &inode->i_default_acl);
- if (acl != ACL_NOT_CACHED)
- return acl;
xprefix = JFFS2_XPREFIX_ACL_DEFAULT;
break;
default:
- return ERR_PTR(-EINVAL);
+ BUG();
}
rc = do_jffs2_getxattr(inode, xprefix, "", NULL, 0);
if (rc > 0) {
@@ -214,16 +192,8 @@ static struct posix_acl *jffs2_get_acl(struct inode *inode, int type)
}
if (value)
kfree(value);
- if (!IS_ERR(acl)) {
- switch (type) {
- case ACL_TYPE_ACCESS:
- jffs2_iset_acl(inode, &inode->i_acl, acl);
- break;
- case ACL_TYPE_DEFAULT:
- jffs2_iset_acl(inode, &inode->i_default_acl, acl);
- break;
- }
- }
+ if (!IS_ERR(acl))
+ set_cached_acl(inode, type, acl);
return acl;
}
@@ -283,16 +253,8 @@ static int jffs2_set_acl(struct inode *inode, int type, struct posix_acl *acl)
return -EINVAL;
}
rc = __jffs2_set_acl(inode, xprefix, acl);
- if (!rc) {
- switch(type) {
- case ACL_TYPE_ACCESS:
- jffs2_iset_acl(inode, &inode->i_acl, acl);
- break;
- case ACL_TYPE_DEFAULT:
- jffs2_iset_acl(inode, &inode->i_default_acl, acl);
- break;
- }
- }
+ if (!rc)
+ set_cached_acl(inode, type, acl);
return rc;
}
@@ -336,7 +298,7 @@ int jffs2_init_acl_pre(struct inode *dir_i, struct inode *inode, int *i_mode)
*i_mode &= ~current_umask();
} else {
if (S_ISDIR(*i_mode))
- jffs2_iset_acl(inode, &inode->i_default_acl, acl);
+ set_cached_acl(inode, ACL_TYPE_DEFAULT, acl);
clone = posix_acl_clone(acl, GFP_KERNEL);
if (!clone)
@@ -347,7 +309,7 @@ int jffs2_init_acl_pre(struct inode *dir_i, struct inode *inode, int *i_mode)
return rc;
}
if (rc > 0)
- jffs2_iset_acl(inode, &inode->i_acl, clone);
+ set_cached_acl(inode, ACL_TYPE_ACCESS, clone);
posix_acl_release(clone);
}