diff options
author | Dmitry Eremin <dmitry.eremin@intel.com> | 2018-05-29 10:21:41 -0400 |
---|---|---|
committer | Greg Kroah-Hartman <gregkh@linuxfoundation.org> | 2018-05-31 12:55:36 -0400 |
commit | bf3d126206133bf4f5a46caa986349cc58868f7e (patch) | |
tree | b318411ebc9d9197f06707db6234aff4eb960904 | |
parent | 409389254f6af62a0401ebd008b018fa6c206267 (diff) |
staging: lustre: llite: add support set_acl method in inode operations
Linux kernel v3.14 adds set_acl method to inode operations.
This patch adds support to Lustre for proper acl management.
Signed-off-by: Dmitry Eremin <dmitry.eremin@intel.com>
Signed-off-by: John L. Hammond <john.hammond@intel.com>
Signed-off-by: James Simmons <uja.ornl@yahoo.com>
Intel-bug-id: https://jira.hpdd.intel.com/browse/LU-9183
Reviewed-on: https://review.whamcloud.com/25965
Intel-bug-id: https://jira.hpdd.intel.com/browse/LU-10541
Reviewed-on: https://review.whamcloud.com/31588
Intel-bug-id: https://jira.hpdd.intel.com/browse/LU-10926
Reviewed-on: https://review.whamcloud.com/32045
Reviewed-by: Bob Glossman <bob.glossman@intel.com>
Reviewed-by: James Simmons <uja.ornl@yahoo.com>
Reviewed-by: Andreas Dilger <andreas.dilger@intel.com>
Reviewed-by: Dmitry Eremin <dmitry.eremin@intel.com>
Reviewed-by: Oleg Drokin <oleg.drokin@intel.com>
Signed-off-by: James Simmons <jsimmons@infradead.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
-rw-r--r-- | drivers/staging/lustre/lustre/llite/acl.c | 57 | ||||
-rw-r--r-- | drivers/staging/lustre/lustre/llite/llite_internal.h | 2 |
2 files changed, 59 insertions, 0 deletions
diff --git a/drivers/staging/lustre/lustre/llite/acl.c b/drivers/staging/lustre/lustre/llite/acl.c index d7c3bf993f57..de1499b088da 100644 --- a/drivers/staging/lustre/lustre/llite/acl.c +++ b/drivers/staging/lustre/lustre/llite/acl.c | |||
@@ -49,3 +49,60 @@ struct posix_acl *ll_get_acl(struct inode *inode, int type) | |||
49 | 49 | ||
50 | return acl; | 50 | return acl; |
51 | } | 51 | } |
52 | |||
53 | int ll_set_acl(struct inode *inode, struct posix_acl *acl, int type) | ||
54 | { | ||
55 | struct ll_sb_info *sbi = ll_i2sbi(inode); | ||
56 | struct ptlrpc_request *req = NULL; | ||
57 | const char *name = NULL; | ||
58 | size_t value_size = 0; | ||
59 | char *value = NULL; | ||
60 | int rc = 0; | ||
61 | |||
62 | switch (type) { | ||
63 | case ACL_TYPE_ACCESS: | ||
64 | name = XATTR_NAME_POSIX_ACL_ACCESS; | ||
65 | if (acl) | ||
66 | rc = posix_acl_update_mode(inode, &inode->i_mode, &acl); | ||
67 | break; | ||
68 | |||
69 | case ACL_TYPE_DEFAULT: | ||
70 | name = XATTR_NAME_POSIX_ACL_DEFAULT; | ||
71 | if (!S_ISDIR(inode->i_mode)) | ||
72 | rc = acl ? -EACCES : 0; | ||
73 | break; | ||
74 | |||
75 | default: | ||
76 | rc = -EINVAL; | ||
77 | break; | ||
78 | } | ||
79 | if (rc) | ||
80 | return rc; | ||
81 | |||
82 | if (acl) { | ||
83 | value_size = posix_acl_xattr_size(acl->a_count); | ||
84 | value = kmalloc(value_size, GFP_NOFS); | ||
85 | if (!value) { | ||
86 | rc = -ENOMEM; | ||
87 | goto out; | ||
88 | } | ||
89 | |||
90 | rc = posix_acl_to_xattr(&init_user_ns, acl, value, value_size); | ||
91 | if (rc < 0) | ||
92 | goto out_value; | ||
93 | } | ||
94 | |||
95 | rc = md_setxattr(sbi->ll_md_exp, ll_inode2fid(inode), | ||
96 | value ? OBD_MD_FLXATTR : OBD_MD_FLXATTRRM, | ||
97 | name, value, value_size, 0, 0, 0, &req); | ||
98 | |||
99 | ptlrpc_req_finished(req); | ||
100 | out_value: | ||
101 | kfree(value); | ||
102 | out: | ||
103 | if (rc) | ||
104 | forget_cached_acl(inode, type); | ||
105 | else | ||
106 | set_cached_acl(inode, type, acl); | ||
107 | return rc; | ||
108 | } | ||
diff --git a/drivers/staging/lustre/lustre/llite/llite_internal.h b/drivers/staging/lustre/lustre/llite/llite_internal.h index bdb1564eb464..c08a6e14b6d7 100644 --- a/drivers/staging/lustre/lustre/llite/llite_internal.h +++ b/drivers/staging/lustre/lustre/llite/llite_internal.h | |||
@@ -756,8 +756,10 @@ int ll_getattr(const struct path *path, struct kstat *stat, | |||
756 | u32 request_mask, unsigned int flags); | 756 | u32 request_mask, unsigned int flags); |
757 | #ifdef CONFIG_FS_POSIX_ACL | 757 | #ifdef CONFIG_FS_POSIX_ACL |
758 | struct posix_acl *ll_get_acl(struct inode *inode, int type); | 758 | struct posix_acl *ll_get_acl(struct inode *inode, int type); |
759 | int ll_set_acl(struct inode *inode, struct posix_acl *acl, int type); | ||
759 | #else | 760 | #else |
760 | #define ll_get_acl NULL | 761 | #define ll_get_acl NULL |
762 | #define ll_set_acl NULL | ||
761 | #endif /* CONFIG_FS_POSIX_ACL */ | 763 | #endif /* CONFIG_FS_POSIX_ACL */ |
762 | 764 | ||
763 | int ll_migrate(struct inode *parent, struct file *file, int mdtidx, | 765 | int ll_migrate(struct inode *parent, struct file *file, int mdtidx, |