diff options
author | Linus Torvalds <torvalds@linux-foundation.org> | 2014-01-28 11:38:04 -0500 |
---|---|---|
committer | Linus Torvalds <torvalds@linux-foundation.org> | 2014-01-28 11:38:04 -0500 |
commit | bf3d846b783327359ddc4bd4f52627b36abb4d1d (patch) | |
tree | c6b8fddbf04a2962dfcf9f487af25033f11b10b9 /fs/ocfs2 | |
parent | 54c0a4b46150db1571d955d598cd342c9f1d9657 (diff) | |
parent | f6500801522c61782d4990fa1ad96154cb397cd4 (diff) |
Merge branch 'for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/viro/vfs
Pull vfs updates from Al Viro:
"Assorted stuff; the biggest pile here is Christoph's ACL series. Plus
assorted cleanups and fixes all over the place...
There will be another pile later this week"
* 'for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/viro/vfs: (43 commits)
__dentry_path() fixes
vfs: Remove second variable named error in __dentry_path
vfs: Is mounted should be testing mnt_ns for NULL or error.
Fix race when checking i_size on direct i/o read
hfsplus: remove can_set_xattr
nfsd: use get_acl and ->set_acl
fs: remove generic_acl
nfs: use generic posix ACL infrastructure for v3 Posix ACLs
gfs2: use generic posix ACL infrastructure
jfs: use generic posix ACL infrastructure
xfs: use generic posix ACL infrastructure
reiserfs: use generic posix ACL infrastructure
ocfs2: use generic posix ACL infrastructure
jffs2: use generic posix ACL infrastructure
hfsplus: use generic posix ACL infrastructure
f2fs: use generic posix ACL infrastructure
ext2/3/4: use generic posix ACL infrastructure
btrfs: use generic posix ACL infrastructure
fs: make posix_acl_create more useful
fs: make posix_acl_chmod more useful
...
Diffstat (limited to 'fs/ocfs2')
-rw-r--r-- | fs/ocfs2/acl.c | 234 | ||||
-rw-r--r-- | fs/ocfs2/acl.h | 13 | ||||
-rw-r--r-- | fs/ocfs2/file.c | 4 | ||||
-rw-r--r-- | fs/ocfs2/namei.c | 25 | ||||
-rw-r--r-- | fs/ocfs2/refcounttree.c | 19 | ||||
-rw-r--r-- | fs/ocfs2/xattr.c | 21 | ||||
-rw-r--r-- | fs/ocfs2/xattr.h | 6 |
7 files changed, 72 insertions, 250 deletions
diff --git a/fs/ocfs2/acl.c b/fs/ocfs2/acl.c index b4f788e0ca31..555f4cddefe3 100644 --- a/fs/ocfs2/acl.c +++ b/fs/ocfs2/acl.c | |||
@@ -160,36 +160,6 @@ static struct posix_acl *ocfs2_get_acl_nolock(struct inode *inode, | |||
160 | return acl; | 160 | return acl; |
161 | } | 161 | } |
162 | 162 | ||
163 | |||
164 | /* | ||
165 | * Get posix acl. | ||
166 | */ | ||
167 | static struct posix_acl *ocfs2_get_acl(struct inode *inode, int type) | ||
168 | { | ||
169 | struct ocfs2_super *osb = OCFS2_SB(inode->i_sb); | ||
170 | struct buffer_head *di_bh = NULL; | ||
171 | struct posix_acl *acl; | ||
172 | int ret; | ||
173 | |||
174 | if (!(osb->s_mount_opt & OCFS2_MOUNT_POSIX_ACL)) | ||
175 | return NULL; | ||
176 | |||
177 | ret = ocfs2_inode_lock(inode, &di_bh, 0); | ||
178 | if (ret < 0) { | ||
179 | mlog_errno(ret); | ||
180 | acl = ERR_PTR(ret); | ||
181 | return acl; | ||
182 | } | ||
183 | |||
184 | acl = ocfs2_get_acl_nolock(inode, type, di_bh); | ||
185 | |||
186 | ocfs2_inode_unlock(inode, 0); | ||
187 | |||
188 | brelse(di_bh); | ||
189 | |||
190 | return acl; | ||
191 | } | ||
192 | |||
193 | /* | 163 | /* |
194 | * Helper function to set i_mode in memory and disk. Some call paths | 164 | * Helper function to set i_mode in memory and disk. Some call paths |
195 | * will not have di_bh or a journal handle to pass, in which case it | 165 | * will not have di_bh or a journal handle to pass, in which case it |
@@ -250,7 +220,7 @@ out: | |||
250 | /* | 220 | /* |
251 | * Set the access or default ACL of an inode. | 221 | * Set the access or default ACL of an inode. |
252 | */ | 222 | */ |
253 | static int ocfs2_set_acl(handle_t *handle, | 223 | int ocfs2_set_acl(handle_t *handle, |
254 | struct inode *inode, | 224 | struct inode *inode, |
255 | struct buffer_head *di_bh, | 225 | struct buffer_head *di_bh, |
256 | int type, | 226 | int type, |
@@ -313,6 +283,11 @@ static int ocfs2_set_acl(handle_t *handle, | |||
313 | return ret; | 283 | return ret; |
314 | } | 284 | } |
315 | 285 | ||
286 | int ocfs2_iop_set_acl(struct inode *inode, struct posix_acl *acl, int type) | ||
287 | { | ||
288 | return ocfs2_set_acl(NULL, inode, NULL, type, acl, NULL, NULL); | ||
289 | } | ||
290 | |||
316 | struct posix_acl *ocfs2_iop_get_acl(struct inode *inode, int type) | 291 | struct posix_acl *ocfs2_iop_get_acl(struct inode *inode, int type) |
317 | { | 292 | { |
318 | struct ocfs2_super *osb; | 293 | struct ocfs2_super *osb; |
@@ -334,200 +309,3 @@ struct posix_acl *ocfs2_iop_get_acl(struct inode *inode, int type) | |||
334 | 309 | ||
335 | return acl; | 310 | return acl; |
336 | } | 311 | } |
337 | |||
338 | int ocfs2_acl_chmod(struct inode *inode) | ||
339 | { | ||
340 | struct ocfs2_super *osb = OCFS2_SB(inode->i_sb); | ||
341 | struct posix_acl *acl; | ||
342 | int ret; | ||
343 | |||
344 | if (S_ISLNK(inode->i_mode)) | ||
345 | return -EOPNOTSUPP; | ||
346 | |||
347 | if (!(osb->s_mount_opt & OCFS2_MOUNT_POSIX_ACL)) | ||
348 | return 0; | ||
349 | |||
350 | acl = ocfs2_get_acl(inode, ACL_TYPE_ACCESS); | ||
351 | if (IS_ERR(acl) || !acl) | ||
352 | return PTR_ERR(acl); | ||
353 | ret = posix_acl_chmod(&acl, GFP_KERNEL, inode->i_mode); | ||
354 | if (ret) | ||
355 | return ret; | ||
356 | ret = ocfs2_set_acl(NULL, inode, NULL, ACL_TYPE_ACCESS, | ||
357 | acl, NULL, NULL); | ||
358 | posix_acl_release(acl); | ||
359 | return ret; | ||
360 | } | ||
361 | |||
362 | /* | ||
363 | * Initialize the ACLs of a new inode. If parent directory has default ACL, | ||
364 | * then clone to new inode. Called from ocfs2_mknod. | ||
365 | */ | ||
366 | int ocfs2_init_acl(handle_t *handle, | ||
367 | struct inode *inode, | ||
368 | struct inode *dir, | ||
369 | struct buffer_head *di_bh, | ||
370 | struct buffer_head *dir_bh, | ||
371 | struct ocfs2_alloc_context *meta_ac, | ||
372 | struct ocfs2_alloc_context *data_ac) | ||
373 | { | ||
374 | struct ocfs2_super *osb = OCFS2_SB(inode->i_sb); | ||
375 | struct posix_acl *acl = NULL; | ||
376 | int ret = 0, ret2; | ||
377 | umode_t mode; | ||
378 | |||
379 | if (!S_ISLNK(inode->i_mode)) { | ||
380 | if (osb->s_mount_opt & OCFS2_MOUNT_POSIX_ACL) { | ||
381 | acl = ocfs2_get_acl_nolock(dir, ACL_TYPE_DEFAULT, | ||
382 | dir_bh); | ||
383 | if (IS_ERR(acl)) | ||
384 | return PTR_ERR(acl); | ||
385 | } | ||
386 | if (!acl) { | ||
387 | mode = inode->i_mode & ~current_umask(); | ||
388 | ret = ocfs2_acl_set_mode(inode, di_bh, handle, mode); | ||
389 | if (ret) { | ||
390 | mlog_errno(ret); | ||
391 | goto cleanup; | ||
392 | } | ||
393 | } | ||
394 | } | ||
395 | if ((osb->s_mount_opt & OCFS2_MOUNT_POSIX_ACL) && acl) { | ||
396 | if (S_ISDIR(inode->i_mode)) { | ||
397 | ret = ocfs2_set_acl(handle, inode, di_bh, | ||
398 | ACL_TYPE_DEFAULT, acl, | ||
399 | meta_ac, data_ac); | ||
400 | if (ret) | ||
401 | goto cleanup; | ||
402 | } | ||
403 | mode = inode->i_mode; | ||
404 | ret = posix_acl_create(&acl, GFP_NOFS, &mode); | ||
405 | if (ret < 0) | ||
406 | return ret; | ||
407 | |||
408 | ret2 = ocfs2_acl_set_mode(inode, di_bh, handle, mode); | ||
409 | if (ret2) { | ||
410 | mlog_errno(ret2); | ||
411 | ret = ret2; | ||
412 | goto cleanup; | ||
413 | } | ||
414 | if (ret > 0) { | ||
415 | ret = ocfs2_set_acl(handle, inode, | ||
416 | di_bh, ACL_TYPE_ACCESS, | ||
417 | acl, meta_ac, data_ac); | ||
418 | } | ||
419 | } | ||
420 | cleanup: | ||
421 | posix_acl_release(acl); | ||
422 | return ret; | ||
423 | } | ||
424 | |||
425 | static size_t ocfs2_xattr_list_acl_access(struct dentry *dentry, | ||
426 | char *list, | ||
427 | size_t list_len, | ||
428 | const char *name, | ||
429 | size_t name_len, | ||
430 | int type) | ||
431 | { | ||
432 | struct ocfs2_super *osb = OCFS2_SB(dentry->d_sb); | ||
433 | const size_t size = sizeof(POSIX_ACL_XATTR_ACCESS); | ||
434 | |||
435 | if (!(osb->s_mount_opt & OCFS2_MOUNT_POSIX_ACL)) | ||
436 | return 0; | ||
437 | |||
438 | if (list && size <= list_len) | ||
439 | memcpy(list, POSIX_ACL_XATTR_ACCESS, size); | ||
440 | return size; | ||
441 | } | ||
442 | |||
443 | static size_t ocfs2_xattr_list_acl_default(struct dentry *dentry, | ||
444 | char *list, | ||
445 | size_t list_len, | ||
446 | const char *name, | ||
447 | size_t name_len, | ||
448 | int type) | ||
449 | { | ||
450 | struct ocfs2_super *osb = OCFS2_SB(dentry->d_sb); | ||
451 | const size_t size = sizeof(POSIX_ACL_XATTR_DEFAULT); | ||
452 | |||
453 | if (!(osb->s_mount_opt & OCFS2_MOUNT_POSIX_ACL)) | ||
454 | return 0; | ||
455 | |||
456 | if (list && size <= list_len) | ||
457 | memcpy(list, POSIX_ACL_XATTR_DEFAULT, size); | ||
458 | return size; | ||
459 | } | ||
460 | |||
461 | static int ocfs2_xattr_get_acl(struct dentry *dentry, const char *name, | ||
462 | void *buffer, size_t size, int type) | ||
463 | { | ||
464 | struct ocfs2_super *osb = OCFS2_SB(dentry->d_sb); | ||
465 | struct posix_acl *acl; | ||
466 | int ret; | ||
467 | |||
468 | if (strcmp(name, "") != 0) | ||
469 | return -EINVAL; | ||
470 | if (!(osb->s_mount_opt & OCFS2_MOUNT_POSIX_ACL)) | ||
471 | return -EOPNOTSUPP; | ||
472 | |||
473 | acl = ocfs2_get_acl(dentry->d_inode, type); | ||
474 | if (IS_ERR(acl)) | ||
475 | return PTR_ERR(acl); | ||
476 | if (acl == NULL) | ||
477 | return -ENODATA; | ||
478 | ret = posix_acl_to_xattr(&init_user_ns, acl, buffer, size); | ||
479 | posix_acl_release(acl); | ||
480 | |||
481 | return ret; | ||
482 | } | ||
483 | |||
484 | static int ocfs2_xattr_set_acl(struct dentry *dentry, const char *name, | ||
485 | const void *value, size_t size, int flags, int type) | ||
486 | { | ||
487 | struct inode *inode = dentry->d_inode; | ||
488 | struct ocfs2_super *osb = OCFS2_SB(inode->i_sb); | ||
489 | struct posix_acl *acl; | ||
490 | int ret = 0; | ||
491 | |||
492 | if (strcmp(name, "") != 0) | ||
493 | return -EINVAL; | ||
494 | if (!(osb->s_mount_opt & OCFS2_MOUNT_POSIX_ACL)) | ||
495 | return -EOPNOTSUPP; | ||
496 | |||
497 | if (!inode_owner_or_capable(inode)) | ||
498 | return -EPERM; | ||
499 | |||
500 | if (value) { | ||
501 | acl = posix_acl_from_xattr(&init_user_ns, value, size); | ||
502 | if (IS_ERR(acl)) | ||
503 | return PTR_ERR(acl); | ||
504 | else if (acl) { | ||
505 | ret = posix_acl_valid(acl); | ||
506 | if (ret) | ||
507 | goto cleanup; | ||
508 | } | ||
509 | } else | ||
510 | acl = NULL; | ||
511 | |||
512 | ret = ocfs2_set_acl(NULL, inode, NULL, type, acl, NULL, NULL); | ||
513 | |||
514 | cleanup: | ||
515 | posix_acl_release(acl); | ||
516 | return ret; | ||
517 | } | ||
518 | |||
519 | const struct xattr_handler ocfs2_xattr_acl_access_handler = { | ||
520 | .prefix = POSIX_ACL_XATTR_ACCESS, | ||
521 | .flags = ACL_TYPE_ACCESS, | ||
522 | .list = ocfs2_xattr_list_acl_access, | ||
523 | .get = ocfs2_xattr_get_acl, | ||
524 | .set = ocfs2_xattr_set_acl, | ||
525 | }; | ||
526 | |||
527 | const struct xattr_handler ocfs2_xattr_acl_default_handler = { | ||
528 | .prefix = POSIX_ACL_XATTR_DEFAULT, | ||
529 | .flags = ACL_TYPE_DEFAULT, | ||
530 | .list = ocfs2_xattr_list_acl_default, | ||
531 | .get = ocfs2_xattr_get_acl, | ||
532 | .set = ocfs2_xattr_set_acl, | ||
533 | }; | ||
diff --git a/fs/ocfs2/acl.h b/fs/ocfs2/acl.h index 071fbd380f2f..3fce68d08625 100644 --- a/fs/ocfs2/acl.h +++ b/fs/ocfs2/acl.h | |||
@@ -27,10 +27,13 @@ struct ocfs2_acl_entry { | |||
27 | }; | 27 | }; |
28 | 28 | ||
29 | struct posix_acl *ocfs2_iop_get_acl(struct inode *inode, int type); | 29 | struct posix_acl *ocfs2_iop_get_acl(struct inode *inode, int type); |
30 | extern int ocfs2_acl_chmod(struct inode *); | 30 | int ocfs2_iop_set_acl(struct inode *inode, struct posix_acl *acl, int type); |
31 | extern int ocfs2_init_acl(handle_t *, struct inode *, struct inode *, | 31 | int ocfs2_set_acl(handle_t *handle, |
32 | struct buffer_head *, struct buffer_head *, | 32 | struct inode *inode, |
33 | struct ocfs2_alloc_context *, | 33 | struct buffer_head *di_bh, |
34 | struct ocfs2_alloc_context *); | 34 | int type, |
35 | struct posix_acl *acl, | ||
36 | struct ocfs2_alloc_context *meta_ac, | ||
37 | struct ocfs2_alloc_context *data_ac); | ||
35 | 38 | ||
36 | #endif /* OCFS2_ACL_H */ | 39 | #endif /* OCFS2_ACL_H */ |
diff --git a/fs/ocfs2/file.c b/fs/ocfs2/file.c index f42eecef6478..d77d71ead8d1 100644 --- a/fs/ocfs2/file.c +++ b/fs/ocfs2/file.c | |||
@@ -1236,7 +1236,7 @@ bail: | |||
1236 | dqput(transfer_to[qtype]); | 1236 | dqput(transfer_to[qtype]); |
1237 | 1237 | ||
1238 | if (!status && attr->ia_valid & ATTR_MODE) { | 1238 | if (!status && attr->ia_valid & ATTR_MODE) { |
1239 | status = ocfs2_acl_chmod(inode); | 1239 | status = posix_acl_chmod(inode, inode->i_mode); |
1240 | if (status < 0) | 1240 | if (status < 0) |
1241 | mlog_errno(status); | 1241 | mlog_errno(status); |
1242 | } | 1242 | } |
@@ -2662,6 +2662,7 @@ const struct inode_operations ocfs2_file_iops = { | |||
2662 | .removexattr = generic_removexattr, | 2662 | .removexattr = generic_removexattr, |
2663 | .fiemap = ocfs2_fiemap, | 2663 | .fiemap = ocfs2_fiemap, |
2664 | .get_acl = ocfs2_iop_get_acl, | 2664 | .get_acl = ocfs2_iop_get_acl, |
2665 | .set_acl = ocfs2_iop_set_acl, | ||
2665 | }; | 2666 | }; |
2666 | 2667 | ||
2667 | const struct inode_operations ocfs2_special_file_iops = { | 2668 | const struct inode_operations ocfs2_special_file_iops = { |
@@ -2669,6 +2670,7 @@ const struct inode_operations ocfs2_special_file_iops = { | |||
2669 | .getattr = ocfs2_getattr, | 2670 | .getattr = ocfs2_getattr, |
2670 | .permission = ocfs2_permission, | 2671 | .permission = ocfs2_permission, |
2671 | .get_acl = ocfs2_iop_get_acl, | 2672 | .get_acl = ocfs2_iop_get_acl, |
2673 | .set_acl = ocfs2_iop_set_acl, | ||
2672 | }; | 2674 | }; |
2673 | 2675 | ||
2674 | /* | 2676 | /* |
diff --git a/fs/ocfs2/namei.c b/fs/ocfs2/namei.c index 41513a4e98e4..f4d609be9400 100644 --- a/fs/ocfs2/namei.c +++ b/fs/ocfs2/namei.c | |||
@@ -230,6 +230,7 @@ static int ocfs2_mknod(struct inode *dir, | |||
230 | struct ocfs2_dir_lookup_result lookup = { NULL, }; | 230 | struct ocfs2_dir_lookup_result lookup = { NULL, }; |
231 | sigset_t oldset; | 231 | sigset_t oldset; |
232 | int did_block_signals = 0; | 232 | int did_block_signals = 0; |
233 | struct posix_acl *default_acl = NULL, *acl = NULL; | ||
233 | 234 | ||
234 | trace_ocfs2_mknod(dir, dentry, dentry->d_name.len, dentry->d_name.name, | 235 | trace_ocfs2_mknod(dir, dentry, dentry->d_name.len, dentry->d_name.name, |
235 | (unsigned long long)OCFS2_I(dir)->ip_blkno, | 236 | (unsigned long long)OCFS2_I(dir)->ip_blkno, |
@@ -331,6 +332,12 @@ static int ocfs2_mknod(struct inode *dir, | |||
331 | goto leave; | 332 | goto leave; |
332 | } | 333 | } |
333 | 334 | ||
335 | status = posix_acl_create(dir, &mode, &default_acl, &acl); | ||
336 | if (status) { | ||
337 | mlog_errno(status); | ||
338 | goto leave; | ||
339 | } | ||
340 | |||
334 | handle = ocfs2_start_trans(osb, ocfs2_mknod_credits(osb->sb, | 341 | handle = ocfs2_start_trans(osb, ocfs2_mknod_credits(osb->sb, |
335 | S_ISDIR(mode), | 342 | S_ISDIR(mode), |
336 | xattr_credits)); | 343 | xattr_credits)); |
@@ -379,8 +386,17 @@ static int ocfs2_mknod(struct inode *dir, | |||
379 | inc_nlink(dir); | 386 | inc_nlink(dir); |
380 | } | 387 | } |
381 | 388 | ||
382 | status = ocfs2_init_acl(handle, inode, dir, new_fe_bh, parent_fe_bh, | 389 | if (default_acl) { |
383 | meta_ac, data_ac); | 390 | status = ocfs2_set_acl(handle, inode, new_fe_bh, |
391 | ACL_TYPE_DEFAULT, default_acl, | ||
392 | meta_ac, data_ac); | ||
393 | } | ||
394 | if (!status && acl) { | ||
395 | status = ocfs2_set_acl(handle, inode, new_fe_bh, | ||
396 | ACL_TYPE_ACCESS, acl, | ||
397 | meta_ac, data_ac); | ||
398 | } | ||
399 | |||
384 | if (status < 0) { | 400 | if (status < 0) { |
385 | mlog_errno(status); | 401 | mlog_errno(status); |
386 | goto leave; | 402 | goto leave; |
@@ -419,6 +435,10 @@ static int ocfs2_mknod(struct inode *dir, | |||
419 | d_instantiate(dentry, inode); | 435 | d_instantiate(dentry, inode); |
420 | status = 0; | 436 | status = 0; |
421 | leave: | 437 | leave: |
438 | if (default_acl) | ||
439 | posix_acl_release(default_acl); | ||
440 | if (acl) | ||
441 | posix_acl_release(acl); | ||
422 | if (status < 0 && did_quota_inode) | 442 | if (status < 0 && did_quota_inode) |
423 | dquot_free_inode(inode); | 443 | dquot_free_inode(inode); |
424 | if (handle) | 444 | if (handle) |
@@ -2504,4 +2524,5 @@ const struct inode_operations ocfs2_dir_iops = { | |||
2504 | .removexattr = generic_removexattr, | 2524 | .removexattr = generic_removexattr, |
2505 | .fiemap = ocfs2_fiemap, | 2525 | .fiemap = ocfs2_fiemap, |
2506 | .get_acl = ocfs2_iop_get_acl, | 2526 | .get_acl = ocfs2_iop_get_acl, |
2527 | .set_acl = ocfs2_iop_set_acl, | ||
2507 | }; | 2528 | }; |
diff --git a/fs/ocfs2/refcounttree.c b/fs/ocfs2/refcounttree.c index 55767e1ba724..6ba4bcbc4796 100644 --- a/fs/ocfs2/refcounttree.c +++ b/fs/ocfs2/refcounttree.c | |||
@@ -46,6 +46,7 @@ | |||
46 | #include <linux/quotaops.h> | 46 | #include <linux/quotaops.h> |
47 | #include <linux/namei.h> | 47 | #include <linux/namei.h> |
48 | #include <linux/mount.h> | 48 | #include <linux/mount.h> |
49 | #include <linux/posix_acl.h> | ||
49 | 50 | ||
50 | struct ocfs2_cow_context { | 51 | struct ocfs2_cow_context { |
51 | struct inode *inode; | 52 | struct inode *inode; |
@@ -4268,11 +4269,20 @@ static int ocfs2_reflink(struct dentry *old_dentry, struct inode *dir, | |||
4268 | struct inode *inode = old_dentry->d_inode; | 4269 | struct inode *inode = old_dentry->d_inode; |
4269 | struct buffer_head *old_bh = NULL; | 4270 | struct buffer_head *old_bh = NULL; |
4270 | struct inode *new_orphan_inode = NULL; | 4271 | struct inode *new_orphan_inode = NULL; |
4272 | struct posix_acl *default_acl, *acl; | ||
4273 | umode_t mode; | ||
4271 | 4274 | ||
4272 | if (!ocfs2_refcount_tree(OCFS2_SB(inode->i_sb))) | 4275 | if (!ocfs2_refcount_tree(OCFS2_SB(inode->i_sb))) |
4273 | return -EOPNOTSUPP; | 4276 | return -EOPNOTSUPP; |
4274 | 4277 | ||
4275 | error = ocfs2_create_inode_in_orphan(dir, inode->i_mode, | 4278 | mode = inode->i_mode; |
4279 | error = posix_acl_create(dir, &mode, &default_acl, &acl); | ||
4280 | if (error) { | ||
4281 | mlog_errno(error); | ||
4282 | goto out; | ||
4283 | } | ||
4284 | |||
4285 | error = ocfs2_create_inode_in_orphan(dir, mode, | ||
4276 | &new_orphan_inode); | 4286 | &new_orphan_inode); |
4277 | if (error) { | 4287 | if (error) { |
4278 | mlog_errno(error); | 4288 | mlog_errno(error); |
@@ -4303,11 +4313,16 @@ static int ocfs2_reflink(struct dentry *old_dentry, struct inode *dir, | |||
4303 | /* If the security isn't preserved, we need to re-initialize them. */ | 4313 | /* If the security isn't preserved, we need to re-initialize them. */ |
4304 | if (!preserve) { | 4314 | if (!preserve) { |
4305 | error = ocfs2_init_security_and_acl(dir, new_orphan_inode, | 4315 | error = ocfs2_init_security_and_acl(dir, new_orphan_inode, |
4306 | &new_dentry->d_name); | 4316 | &new_dentry->d_name, |
4317 | default_acl, acl); | ||
4307 | if (error) | 4318 | if (error) |
4308 | mlog_errno(error); | 4319 | mlog_errno(error); |
4309 | } | 4320 | } |
4310 | out: | 4321 | out: |
4322 | if (default_acl) | ||
4323 | posix_acl_release(default_acl); | ||
4324 | if (acl) | ||
4325 | posix_acl_release(acl); | ||
4311 | if (!error) { | 4326 | if (!error) { |
4312 | error = ocfs2_mv_orphaned_inode_to_new(dir, new_orphan_inode, | 4327 | error = ocfs2_mv_orphaned_inode_to_new(dir, new_orphan_inode, |
4313 | new_dentry); | 4328 | new_dentry); |
diff --git a/fs/ocfs2/xattr.c b/fs/ocfs2/xattr.c index f0a1326d9bba..185fa3b7f962 100644 --- a/fs/ocfs2/xattr.c +++ b/fs/ocfs2/xattr.c | |||
@@ -99,8 +99,8 @@ static struct ocfs2_xattr_def_value_root def_xv = { | |||
99 | 99 | ||
100 | const struct xattr_handler *ocfs2_xattr_handlers[] = { | 100 | const struct xattr_handler *ocfs2_xattr_handlers[] = { |
101 | &ocfs2_xattr_user_handler, | 101 | &ocfs2_xattr_user_handler, |
102 | &ocfs2_xattr_acl_access_handler, | 102 | &posix_acl_access_xattr_handler, |
103 | &ocfs2_xattr_acl_default_handler, | 103 | &posix_acl_default_xattr_handler, |
104 | &ocfs2_xattr_trusted_handler, | 104 | &ocfs2_xattr_trusted_handler, |
105 | &ocfs2_xattr_security_handler, | 105 | &ocfs2_xattr_security_handler, |
106 | NULL | 106 | NULL |
@@ -109,9 +109,9 @@ const struct xattr_handler *ocfs2_xattr_handlers[] = { | |||
109 | static const struct xattr_handler *ocfs2_xattr_handler_map[OCFS2_XATTR_MAX] = { | 109 | static const struct xattr_handler *ocfs2_xattr_handler_map[OCFS2_XATTR_MAX] = { |
110 | [OCFS2_XATTR_INDEX_USER] = &ocfs2_xattr_user_handler, | 110 | [OCFS2_XATTR_INDEX_USER] = &ocfs2_xattr_user_handler, |
111 | [OCFS2_XATTR_INDEX_POSIX_ACL_ACCESS] | 111 | [OCFS2_XATTR_INDEX_POSIX_ACL_ACCESS] |
112 | = &ocfs2_xattr_acl_access_handler, | 112 | = &posix_acl_access_xattr_handler, |
113 | [OCFS2_XATTR_INDEX_POSIX_ACL_DEFAULT] | 113 | [OCFS2_XATTR_INDEX_POSIX_ACL_DEFAULT] |
114 | = &ocfs2_xattr_acl_default_handler, | 114 | = &posix_acl_default_xattr_handler, |
115 | [OCFS2_XATTR_INDEX_TRUSTED] = &ocfs2_xattr_trusted_handler, | 115 | [OCFS2_XATTR_INDEX_TRUSTED] = &ocfs2_xattr_trusted_handler, |
116 | [OCFS2_XATTR_INDEX_SECURITY] = &ocfs2_xattr_security_handler, | 116 | [OCFS2_XATTR_INDEX_SECURITY] = &ocfs2_xattr_security_handler, |
117 | }; | 117 | }; |
@@ -7190,10 +7190,12 @@ out: | |||
7190 | */ | 7190 | */ |
7191 | int ocfs2_init_security_and_acl(struct inode *dir, | 7191 | int ocfs2_init_security_and_acl(struct inode *dir, |
7192 | struct inode *inode, | 7192 | struct inode *inode, |
7193 | const struct qstr *qstr) | 7193 | const struct qstr *qstr, |
7194 | struct posix_acl *default_acl, | ||
7195 | struct posix_acl *acl) | ||
7194 | { | 7196 | { |
7195 | int ret = 0; | ||
7196 | struct buffer_head *dir_bh = NULL; | 7197 | struct buffer_head *dir_bh = NULL; |
7198 | int ret = 0; | ||
7197 | 7199 | ||
7198 | ret = ocfs2_init_security_get(inode, dir, qstr, NULL); | 7200 | ret = ocfs2_init_security_get(inode, dir, qstr, NULL); |
7199 | if (ret) { | 7201 | if (ret) { |
@@ -7207,9 +7209,10 @@ int ocfs2_init_security_and_acl(struct inode *dir, | |||
7207 | goto leave; | 7209 | goto leave; |
7208 | } | 7210 | } |
7209 | 7211 | ||
7210 | ret = ocfs2_init_acl(NULL, inode, dir, NULL, dir_bh, NULL, NULL); | 7212 | if (!ret && default_acl) |
7211 | if (ret) | 7213 | ret = ocfs2_iop_set_acl(inode, default_acl, ACL_TYPE_DEFAULT); |
7212 | mlog_errno(ret); | 7214 | if (!ret && acl) |
7215 | ret = ocfs2_iop_set_acl(inode, acl, ACL_TYPE_ACCESS); | ||
7213 | 7216 | ||
7214 | ocfs2_inode_unlock(dir, 0); | 7217 | ocfs2_inode_unlock(dir, 0); |
7215 | brelse(dir_bh); | 7218 | brelse(dir_bh); |
diff --git a/fs/ocfs2/xattr.h b/fs/ocfs2/xattr.h index 19f134e896a9..f10d5b93c366 100644 --- a/fs/ocfs2/xattr.h +++ b/fs/ocfs2/xattr.h | |||
@@ -40,8 +40,6 @@ struct ocfs2_security_xattr_info { | |||
40 | extern const struct xattr_handler ocfs2_xattr_user_handler; | 40 | extern const struct xattr_handler ocfs2_xattr_user_handler; |
41 | extern const struct xattr_handler ocfs2_xattr_trusted_handler; | 41 | extern const struct xattr_handler ocfs2_xattr_trusted_handler; |
42 | extern const struct xattr_handler ocfs2_xattr_security_handler; | 42 | extern const struct xattr_handler ocfs2_xattr_security_handler; |
43 | extern const struct xattr_handler ocfs2_xattr_acl_access_handler; | ||
44 | extern const struct xattr_handler ocfs2_xattr_acl_default_handler; | ||
45 | extern const struct xattr_handler *ocfs2_xattr_handlers[]; | 43 | extern const struct xattr_handler *ocfs2_xattr_handlers[]; |
46 | 44 | ||
47 | ssize_t ocfs2_listxattr(struct dentry *, char *, size_t); | 45 | ssize_t ocfs2_listxattr(struct dentry *, char *, size_t); |
@@ -96,5 +94,7 @@ int ocfs2_reflink_xattrs(struct inode *old_inode, | |||
96 | bool preserve_security); | 94 | bool preserve_security); |
97 | int ocfs2_init_security_and_acl(struct inode *dir, | 95 | int ocfs2_init_security_and_acl(struct inode *dir, |
98 | struct inode *inode, | 96 | struct inode *inode, |
99 | const struct qstr *qstr); | 97 | const struct qstr *qstr, |
98 | struct posix_acl *default_acl, | ||
99 | struct posix_acl *acl); | ||
100 | #endif /* OCFS2_XATTR_H */ | 100 | #endif /* OCFS2_XATTR_H */ |