summaryrefslogtreecommitdiffstats
path: root/fs/jfs
diff options
context:
space:
mode:
authorAl Viro <viro@zeniv.linux.org.uk>2009-06-09 18:11:54 +0200
committerAl Viro <viro@zeniv.linux.org.uk>2009-06-24 14:17:07 +0200
commit073aaa1b142461d91f83da66db1184d7c1b1edea (patch)
tree2b54d185d78f1229418fca521a93e6b55c57248b /fs/jfs
parentswitch shmem to inode->i_acl (diff)
downloadlinux-073aaa1b142461d91f83da66db1184d7c1b1edea.tar.xz
linux-073aaa1b142461d91f83da66db1184d7c1b1edea.zip
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')
-rw-r--r--fs/jfs/acl.c32
-rw-r--r--fs/jfs/xattr.c10
2 files changed, 15 insertions, 27 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)
{
struct posix_acl *acl;
char *ea_name;
- struct posix_acl **p_acl;
int size;
char *value = NULL;
+ acl = get_cached_acl(inode, type);
+ if (acl != ACL_NOT_CACHED)
+ return acl;
+
switch(type) {
case ACL_TYPE_ACCESS:
ea_name = POSIX_ACL_XATTR_ACCESS;
- p_acl = &inode->i_acl;
break;
case ACL_TYPE_DEFAULT:
ea_name = POSIX_ACL_XATTR_DEFAULT;
- p_acl = &inode->i_default_acl;
break;
default:
return ERR_PTR(-EINVAL);
}
- if (*p_acl != ACL_NOT_CACHED)
- return posix_acl_dup(*p_acl);
-
size = __jfs_getxattr(inode, ea_name, NULL, 0);
if (size > 0) {
@@ -61,17 +59,18 @@ static struct posix_acl *jfs_get_acl(struct inode *inode, int type)
}
if (size < 0) {
- if (size == -ENODATA) {
- *p_acl = NULL;
+ if (size == -ENODATA)
acl = NULL;
- } else
+ else
acl = ERR_PTR(size);
} else {
acl = posix_acl_from_xattr(value, size);
- if (!IS_ERR(acl))
- *p_acl = posix_acl_dup(acl);
}
kfree(value);
+ if (!IS_ERR(acl)) {
+ set_cached_acl(inode, type, acl);
+ posix_acl_release(acl);
+ }
return acl;
}
@@ -79,7 +78,6 @@ static int jfs_set_acl(tid_t tid, struct inode *inode, int type,
struct posix_acl *acl)
{
char *ea_name;
- struct posix_acl **p_acl;
int rc;
int size = 0;
char *value = NULL;
@@ -90,11 +88,9 @@ static int jfs_set_acl(tid_t tid, struct inode *inode, int type,
switch(type) {
case ACL_TYPE_ACCESS:
ea_name = POSIX_ACL_XATTR_ACCESS;
- p_acl = &inode->i_acl;
break;
case ACL_TYPE_DEFAULT:
ea_name = POSIX_ACL_XATTR_DEFAULT;
- p_acl = &inode->i_default_acl;
if (!S_ISDIR(inode->i_mode))
return acl ? -EACCES : 0;
break;
@@ -114,11 +110,9 @@ static int jfs_set_acl(tid_t tid, struct inode *inode, int type,
out:
kfree(value);
- if (!rc) {
- if (*p_acl && (*p_acl != ACL_NOT_CACHED))
- posix_acl_release(*p_acl);
- *p_acl = posix_acl_dup(acl);
- }
+ if (!rc)
+ set_cached_acl(inode, type, acl);
+
return rc;
}
diff --git a/fs/jfs/xattr.c b/fs/jfs/xattr.c
index f6e90e343593..fad364548bc9 100644
--- a/fs/jfs/xattr.c
+++ b/fs/jfs/xattr.c
@@ -727,10 +727,7 @@ static int can_set_system_xattr(struct inode *inode, const char *name,
/*
* We're changing the ACL. Get rid of the cached one
*/
- acl =inode->i_acl;
- if (acl != ACL_NOT_CACHED)
- posix_acl_release(acl);
- inode->i_acl = ACL_NOT_CACHED;
+ forget_cached_acl(inode, ACL_TYPE_ACCESS);
return 0;
} else if (strcmp(name, POSIX_ACL_XATTR_DEFAULT) == 0) {
@@ -746,10 +743,7 @@ static int can_set_system_xattr(struct inode *inode, const char *name,
/*
* We're changing the default ACL. Get rid of the cached one
*/
- acl = inode->i_default_acl;
- if (acl && (acl != ACL_NOT_CACHED))
- posix_acl_release(acl);
- inode->i_default_acl = ACL_NOT_CACHED;
+ forget_cached_acl(inode, ACL_TYPE_DEFAULT);
return 0;
}