aboutsummaryrefslogtreecommitdiffstats
path: root/fs/jfs
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/jfs
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/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)
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,
114out: 110out:
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
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,
727 /* 727 /*
728 * We're changing the ACL. Get rid of the cached one 728 * We're changing the ACL. Get rid of the cached one
729 */ 729 */
730 acl =inode->i_acl; 730 forget_cached_acl(inode, ACL_TYPE_ACCESS);
731 if (acl != ACL_NOT_CACHED)
732 posix_acl_release(acl);
733 inode->i_acl = ACL_NOT_CACHED;
734 731
735 return 0; 732 return 0;
736 } else if (strcmp(name, POSIX_ACL_XATTR_DEFAULT) == 0) { 733 } 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,
746 /* 743 /*
747 * We're changing the default ACL. Get rid of the cached one 744 * We're changing the default ACL. Get rid of the cached one
748 */ 745 */
749 acl = inode->i_default_acl; 746 forget_cached_acl(inode, ACL_TYPE_DEFAULT);
750 if (acl && (acl != ACL_NOT_CACHED))
751 posix_acl_release(acl);
752 inode->i_default_acl = ACL_NOT_CACHED;
753 747
754 return 0; 748 return 0;
755 } 749 }