aboutsummaryrefslogtreecommitdiffstats
path: root/fs/ext3
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/ext3
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/ext3')
-rw-r--r--fs/ext3/acl.c83
1 files changed, 19 insertions, 64 deletions
diff --git a/fs/ext3/acl.c b/fs/ext3/acl.c
index a9707689d9e1..e167bae37ef0 100644
--- a/fs/ext3/acl.c
+++ b/fs/ext3/acl.c
@@ -126,33 +126,6 @@ fail:
126 return ERR_PTR(-EINVAL); 126 return ERR_PTR(-EINVAL);
127} 127}
128 128
129static inline struct posix_acl *
130ext3_iget_acl(struct inode *inode, struct posix_acl **i_acl)
131{
132 struct posix_acl *acl = ACCESS_ONCE(*i_acl);
133
134 if (acl) {
135 spin_lock(&inode->i_lock);
136 acl = *i_acl;
137 if (acl != ACL_NOT_CACHED)
138 acl = posix_acl_dup(acl);
139 spin_unlock(&inode->i_lock);
140 }
141
142 return acl;
143}
144
145static inline void
146ext3_iset_acl(struct inode *inode, struct posix_acl **i_acl,
147 struct posix_acl *acl)
148{
149 spin_lock(&inode->i_lock);
150 if (*i_acl != ACL_NOT_CACHED)
151 posix_acl_release(*i_acl);
152 *i_acl = posix_acl_dup(acl);
153 spin_unlock(&inode->i_lock);
154}
155
156/* 129/*
157 * Inode operation get_posix_acl(). 130 * Inode operation get_posix_acl().
158 * 131 *
@@ -169,24 +142,21 @@ ext3_get_acl(struct inode *inode, int type)
169 if (!test_opt(inode->i_sb, POSIX_ACL)) 142 if (!test_opt(inode->i_sb, POSIX_ACL))
170 return NULL; 143 return NULL;
171 144
172 switch(type) { 145 acl = get_cached_acl(inode, type);
173 case ACL_TYPE_ACCESS: 146 if (acl != ACL_NOT_CACHED)
174 acl = ext3_iget_acl(inode, &inode->i_acl); 147 return acl;
175 if (acl != ACL_NOT_CACHED) 148
176 return acl; 149 switch (type) {
177 name_index = EXT3_XATTR_INDEX_POSIX_ACL_ACCESS; 150 case ACL_TYPE_ACCESS:
178 break; 151 name_index = EXT3_XATTR_INDEX_POSIX_ACL_ACCESS;
179 152 break;
180 case ACL_TYPE_DEFAULT: 153 case ACL_TYPE_DEFAULT:
181 acl = ext3_iget_acl(inode, &inode->i_default_acl); 154 name_index = EXT3_XATTR_INDEX_POSIX_ACL_DEFAULT;
182 if (acl != ACL_NOT_CACHED) 155 break;
183 return acl; 156 default:
184 name_index = EXT3_XATTR_INDEX_POSIX_ACL_DEFAULT; 157 BUG();
185 break;
186
187 default:
188 return ERR_PTR(-EINVAL);
189 } 158 }
159
190 retval = ext3_xattr_get(inode, name_index, "", NULL, 0); 160 retval = ext3_xattr_get(inode, name_index, "", NULL, 0);
191 if (retval > 0) { 161 if (retval > 0) {
192 value = kmalloc(retval, GFP_NOFS); 162 value = kmalloc(retval, GFP_NOFS);
@@ -202,17 +172,9 @@ ext3_get_acl(struct inode *inode, int type)
202 acl = ERR_PTR(retval); 172 acl = ERR_PTR(retval);
203 kfree(value); 173 kfree(value);
204 174
205 if (!IS_ERR(acl)) { 175 if (!IS_ERR(acl))
206 switch(type) { 176 set_cached_acl(inode, type, acl);
207 case ACL_TYPE_ACCESS:
208 ext3_iset_acl(inode, &inode->i_acl, acl);
209 break;
210 177
211 case ACL_TYPE_DEFAULT:
212 ext3_iset_acl(inode, &inode->i_default_acl, acl);
213 break;
214 }
215 }
216 return acl; 178 return acl;
217} 179}
218 180
@@ -269,17 +231,10 @@ ext3_set_acl(handle_t *handle, struct inode *inode, int type,
269 value, size, 0); 231 value, size, 0);
270 232
271 kfree(value); 233 kfree(value);
272 if (!error) {
273 switch(type) {
274 case ACL_TYPE_ACCESS:
275 ext3_iset_acl(inode, &inode->i_acl, acl);
276 break;
277 234
278 case ACL_TYPE_DEFAULT: 235 if (!error)
279 ext3_iset_acl(inode, &inode->i_default_acl, acl); 236 set_cached_acl(inode, type, acl);
280 break; 237
281 }
282 }
283 return error; 238 return error;
284} 239}
285 240