diff options
Diffstat (limited to 'fs/reiserfs/xattr_acl.c')
-rw-r--r-- | fs/reiserfs/xattr_acl.c | 58 |
1 files changed, 11 insertions, 47 deletions
diff --git a/fs/reiserfs/xattr_acl.c b/fs/reiserfs/xattr_acl.c index c303c426fe2b..35d6e672a279 100644 --- a/fs/reiserfs/xattr_acl.c +++ b/fs/reiserfs/xattr_acl.c | |||
@@ -188,29 +188,6 @@ static void *posix_acl_to_disk(const struct posix_acl *acl, size_t * size) | |||
188 | return ERR_PTR(-EINVAL); | 188 | return ERR_PTR(-EINVAL); |
189 | } | 189 | } |
190 | 190 | ||
191 | static inline void iset_acl(struct inode *inode, struct posix_acl **i_acl, | ||
192 | struct posix_acl *acl) | ||
193 | { | ||
194 | spin_lock(&inode->i_lock); | ||
195 | if (*i_acl != ERR_PTR(-ENODATA)) | ||
196 | posix_acl_release(*i_acl); | ||
197 | *i_acl = posix_acl_dup(acl); | ||
198 | spin_unlock(&inode->i_lock); | ||
199 | } | ||
200 | |||
201 | static inline struct posix_acl *iget_acl(struct inode *inode, | ||
202 | struct posix_acl **i_acl) | ||
203 | { | ||
204 | struct posix_acl *acl = ERR_PTR(-ENODATA); | ||
205 | |||
206 | spin_lock(&inode->i_lock); | ||
207 | if (*i_acl != ERR_PTR(-ENODATA)) | ||
208 | acl = posix_acl_dup(*i_acl); | ||
209 | spin_unlock(&inode->i_lock); | ||
210 | |||
211 | return acl; | ||
212 | } | ||
213 | |||
214 | /* | 191 | /* |
215 | * Inode operation get_posix_acl(). | 192 | * Inode operation get_posix_acl(). |
216 | * | 193 | * |
@@ -220,34 +197,29 @@ static inline struct posix_acl *iget_acl(struct inode *inode, | |||
220 | struct posix_acl *reiserfs_get_acl(struct inode *inode, int type) | 197 | struct posix_acl *reiserfs_get_acl(struct inode *inode, int type) |
221 | { | 198 | { |
222 | char *name, *value; | 199 | char *name, *value; |
223 | struct posix_acl *acl, **p_acl; | 200 | struct posix_acl *acl; |
224 | int size; | 201 | int size; |
225 | int retval; | 202 | int retval; |
226 | struct reiserfs_inode_info *reiserfs_i = REISERFS_I(inode); | 203 | |
204 | acl = get_cached_acl(inode, type); | ||
205 | if (acl != ACL_NOT_CACHED) | ||
206 | return acl; | ||
227 | 207 | ||
228 | switch (type) { | 208 | switch (type) { |
229 | case ACL_TYPE_ACCESS: | 209 | case ACL_TYPE_ACCESS: |
230 | name = POSIX_ACL_XATTR_ACCESS; | 210 | name = POSIX_ACL_XATTR_ACCESS; |
231 | p_acl = &reiserfs_i->i_acl_access; | ||
232 | break; | 211 | break; |
233 | case ACL_TYPE_DEFAULT: | 212 | case ACL_TYPE_DEFAULT: |
234 | name = POSIX_ACL_XATTR_DEFAULT; | 213 | name = POSIX_ACL_XATTR_DEFAULT; |
235 | p_acl = &reiserfs_i->i_acl_default; | ||
236 | break; | 214 | break; |
237 | default: | 215 | default: |
238 | return ERR_PTR(-EINVAL); | 216 | BUG(); |
239 | } | 217 | } |
240 | 218 | ||
241 | acl = iget_acl(inode, p_acl); | ||
242 | if (acl && !IS_ERR(acl)) | ||
243 | return acl; | ||
244 | else if (PTR_ERR(acl) == -ENODATA) | ||
245 | return NULL; | ||
246 | |||
247 | size = reiserfs_xattr_get(inode, name, NULL, 0); | 219 | size = reiserfs_xattr_get(inode, name, NULL, 0); |
248 | if (size < 0) { | 220 | if (size < 0) { |
249 | if (size == -ENODATA || size == -ENOSYS) { | 221 | if (size == -ENODATA || size == -ENOSYS) { |
250 | *p_acl = ERR_PTR(-ENODATA); | 222 | set_cached_acl(inode, type, NULL); |
251 | return NULL; | 223 | return NULL; |
252 | } | 224 | } |
253 | return ERR_PTR(size); | 225 | return ERR_PTR(size); |
@@ -262,14 +234,13 @@ struct posix_acl *reiserfs_get_acl(struct inode *inode, int type) | |||
262 | /* This shouldn't actually happen as it should have | 234 | /* This shouldn't actually happen as it should have |
263 | been caught above.. but just in case */ | 235 | been caught above.. but just in case */ |
264 | acl = NULL; | 236 | acl = NULL; |
265 | *p_acl = ERR_PTR(-ENODATA); | ||
266 | } else if (retval < 0) { | 237 | } else if (retval < 0) { |
267 | acl = ERR_PTR(retval); | 238 | acl = ERR_PTR(retval); |
268 | } else { | 239 | } else { |
269 | acl = posix_acl_from_disk(value, retval); | 240 | acl = posix_acl_from_disk(value, retval); |
270 | if (!IS_ERR(acl)) | ||
271 | iset_acl(inode, p_acl, acl); | ||
272 | } | 241 | } |
242 | if (!IS_ERR(acl)) | ||
243 | set_cached_acl(inode, type, acl); | ||
273 | 244 | ||
274 | kfree(value); | 245 | kfree(value); |
275 | return acl; | 246 | return acl; |
@@ -287,10 +258,8 @@ reiserfs_set_acl(struct reiserfs_transaction_handle *th, struct inode *inode, | |||
287 | { | 258 | { |
288 | char *name; | 259 | char *name; |
289 | void *value = NULL; | 260 | void *value = NULL; |
290 | struct posix_acl **p_acl; | ||
291 | size_t size = 0; | 261 | size_t size = 0; |
292 | int error; | 262 | int error; |
293 | struct reiserfs_inode_info *reiserfs_i = REISERFS_I(inode); | ||
294 | 263 | ||
295 | if (S_ISLNK(inode->i_mode)) | 264 | if (S_ISLNK(inode->i_mode)) |
296 | return -EOPNOTSUPP; | 265 | return -EOPNOTSUPP; |
@@ -298,7 +267,6 @@ reiserfs_set_acl(struct reiserfs_transaction_handle *th, struct inode *inode, | |||
298 | switch (type) { | 267 | switch (type) { |
299 | case ACL_TYPE_ACCESS: | 268 | case ACL_TYPE_ACCESS: |
300 | name = POSIX_ACL_XATTR_ACCESS; | 269 | name = POSIX_ACL_XATTR_ACCESS; |
301 | p_acl = &reiserfs_i->i_acl_access; | ||
302 | if (acl) { | 270 | if (acl) { |
303 | mode_t mode = inode->i_mode; | 271 | mode_t mode = inode->i_mode; |
304 | error = posix_acl_equiv_mode(acl, &mode); | 272 | error = posix_acl_equiv_mode(acl, &mode); |
@@ -313,7 +281,6 @@ reiserfs_set_acl(struct reiserfs_transaction_handle *th, struct inode *inode, | |||
313 | break; | 281 | break; |
314 | case ACL_TYPE_DEFAULT: | 282 | case ACL_TYPE_DEFAULT: |
315 | name = POSIX_ACL_XATTR_DEFAULT; | 283 | name = POSIX_ACL_XATTR_DEFAULT; |
316 | p_acl = &reiserfs_i->i_acl_default; | ||
317 | if (!S_ISDIR(inode->i_mode)) | 284 | if (!S_ISDIR(inode->i_mode)) |
318 | return acl ? -EACCES : 0; | 285 | return acl ? -EACCES : 0; |
319 | break; | 286 | break; |
@@ -346,7 +313,7 @@ reiserfs_set_acl(struct reiserfs_transaction_handle *th, struct inode *inode, | |||
346 | kfree(value); | 313 | kfree(value); |
347 | 314 | ||
348 | if (!error) | 315 | if (!error) |
349 | iset_acl(inode, p_acl, acl); | 316 | set_cached_acl(inode, type, acl); |
350 | 317 | ||
351 | return error; | 318 | return error; |
352 | } | 319 | } |
@@ -379,11 +346,8 @@ reiserfs_inherit_default_acl(struct reiserfs_transaction_handle *th, | |||
379 | } | 346 | } |
380 | 347 | ||
381 | acl = reiserfs_get_acl(dir, ACL_TYPE_DEFAULT); | 348 | acl = reiserfs_get_acl(dir, ACL_TYPE_DEFAULT); |
382 | if (IS_ERR(acl)) { | 349 | if (IS_ERR(acl)) |
383 | if (PTR_ERR(acl) == -ENODATA) | ||
384 | goto apply_umask; | ||
385 | return PTR_ERR(acl); | 350 | return PTR_ERR(acl); |
386 | } | ||
387 | 351 | ||
388 | if (acl) { | 352 | if (acl) { |
389 | struct posix_acl *acl_copy; | 353 | struct posix_acl *acl_copy; |