aboutsummaryrefslogtreecommitdiffstats
path: root/include/linux/posix_acl.h
diff options
context:
space:
mode:
authorAl Viro <viro@zeniv.linux.org.uk>2011-08-03 00:47:21 -0400
committerAl Viro <viro@zeniv.linux.org.uk>2011-08-03 00:47:21 -0400
commit951c0d660a7c35286e401ca6d6ef38c9d49643c7 (patch)
tree3d642b16e966a5f000c288bfbcac868cf994559c /include/linux/posix_acl.h
parentda5aa861bea09197e6ae4d7c46618616064891e4 (diff)
get rid of boilerplate switches in posix_acl.h
the only potentially subtle thing here: get_cached_acl() is never called with the second argument other than ACL_TYPE_{ACCESS,DEFAULT}. IOW, that return ERR_PTR(-EINVAL) in there might as well be BUG(). Signed-off-by: Al Viro <viro@zeniv.linux.org.uk>
Diffstat (limited to 'include/linux/posix_acl.h')
-rw-r--r--include/linux/posix_acl.h62
1 files changed, 20 insertions, 42 deletions
diff --git a/include/linux/posix_acl.h b/include/linux/posix_acl.h
index 951bba82d50d..a9c2fb29be96 100644
--- a/include/linux/posix_acl.h
+++ b/include/linux/posix_acl.h
@@ -84,20 +84,22 @@ extern struct posix_acl *get_posix_acl(struct inode *, int);
84extern int set_posix_acl(struct inode *, int, struct posix_acl *); 84extern int set_posix_acl(struct inode *, int, struct posix_acl *);
85 85
86#ifdef CONFIG_FS_POSIX_ACL 86#ifdef CONFIG_FS_POSIX_ACL
87static inline struct posix_acl *get_cached_acl(struct inode *inode, int type) 87static inline struct posix_acl **acl_by_type(struct inode *inode, int type)
88{ 88{
89 struct posix_acl **p, *acl;
90 switch (type) { 89 switch (type) {
91 case ACL_TYPE_ACCESS: 90 case ACL_TYPE_ACCESS:
92 p = &inode->i_acl; 91 return &inode->i_acl;
93 break;
94 case ACL_TYPE_DEFAULT: 92 case ACL_TYPE_DEFAULT:
95 p = &inode->i_default_acl; 93 return &inode->i_default_acl;
96 break;
97 default: 94 default:
98 return ERR_PTR(-EINVAL); 95 BUG();
99 } 96 }
100 acl = ACCESS_ONCE(*p); 97}
98
99static inline struct posix_acl *get_cached_acl(struct inode *inode, int type)
100{
101 struct posix_acl **p = acl_by_type(inode, type);
102 struct posix_acl *acl = ACCESS_ONCE(*p);
101 if (acl) { 103 if (acl) {
102 spin_lock(&inode->i_lock); 104 spin_lock(&inode->i_lock);
103 acl = *p; 105 acl = *p;
@@ -110,18 +112,8 @@ static inline struct posix_acl *get_cached_acl(struct inode *inode, int type)
110 112
111static inline int negative_cached_acl(struct inode *inode, int type) 113static inline int negative_cached_acl(struct inode *inode, int type)
112{ 114{
113 struct posix_acl **p, *acl; 115 struct posix_acl **p = acl_by_type(inode, type);
114 switch (type) { 116 struct posix_acl *acl = ACCESS_ONCE(*p);
115 case ACL_TYPE_ACCESS:
116 p = &inode->i_acl;
117 break;
118 case ACL_TYPE_DEFAULT:
119 p = &inode->i_default_acl;
120 break;
121 default:
122 BUG();
123 }
124 acl = ACCESS_ONCE(*p);
125 if (acl) 117 if (acl)
126 return 0; 118 return 0;
127 return 1; 119 return 1;
@@ -131,18 +123,11 @@ static inline void set_cached_acl(struct inode *inode,
131 int type, 123 int type,
132 struct posix_acl *acl) 124 struct posix_acl *acl)
133{ 125{
134 struct posix_acl *old = NULL; 126 struct posix_acl **p = acl_by_type(inode, type);
127 struct posix_acl *old;
135 spin_lock(&inode->i_lock); 128 spin_lock(&inode->i_lock);
136 switch (type) { 129 old = *p;
137 case ACL_TYPE_ACCESS: 130 *p = posix_dup_acl(acl);
138 old = inode->i_acl;
139 inode->i_acl = posix_acl_dup(acl);
140 break;
141 case ACL_TYPE_DEFAULT:
142 old = inode->i_default_acl;
143 inode->i_default_acl = posix_acl_dup(acl);
144 break;
145 }
146 spin_unlock(&inode->i_lock); 131 spin_unlock(&inode->i_lock);
147 if (old != ACL_NOT_CACHED) 132 if (old != ACL_NOT_CACHED)
148 posix_acl_release(old); 133 posix_acl_release(old);
@@ -150,18 +135,11 @@ static inline void set_cached_acl(struct inode *inode,
150 135
151static inline void forget_cached_acl(struct inode *inode, int type) 136static inline void forget_cached_acl(struct inode *inode, int type)
152{ 137{
153 struct posix_acl *old = NULL; 138 struct posix_acl **p = acl_by_type(inode, type);
139 struct posix_acl *old;
154 spin_lock(&inode->i_lock); 140 spin_lock(&inode->i_lock);
155 switch (type) { 141 old = *p;
156 case ACL_TYPE_ACCESS: 142 *p = ACL_NOT_CACHED;
157 old = inode->i_acl;
158 inode->i_acl = ACL_NOT_CACHED;
159 break;
160 case ACL_TYPE_DEFAULT:
161 old = inode->i_default_acl;
162 inode->i_default_acl = ACL_NOT_CACHED;
163 break;
164 }
165 spin_unlock(&inode->i_lock); 143 spin_unlock(&inode->i_lock);
166 if (old != ACL_NOT_CACHED) 144 if (old != ACL_NOT_CACHED)
167 posix_acl_release(old); 145 posix_acl_release(old);