diff options
author | James Simmons <jsimmons@infradead.org> | 2016-07-11 09:40:10 -0400 |
---|---|---|
committer | Greg Kroah-Hartman <gregkh@linuxfoundation.org> | 2016-08-15 12:23:55 -0400 |
commit | 2c563880ea8fdc900693ae372fa07b3894f8ff63 (patch) | |
tree | 60ac0b6abf24fac9f33cc380f47b0633c098951b | |
parent | 1b851095d64e55a4345cddf4928256b1452b25ed (diff) |
staging: lustre: llite: basic port to xattr_handler API
Port the xattr functionality to the new xattr_handler API.
This is smallest changes needed to move to this new API. The
function ll_removexattr can be replaced by generic_removexattr
as well since it also uses the xattr_handler set xattr backend.
To tell the difference between the two cases we test the flag
passed in for XATTR_REPLACE. The ll_getxattr function is
replaced by the generic_getxattr function.
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/file.c | 6 | ||||
-rw-r--r-- | drivers/staging/lustre/lustre/llite/llite_internal.h | 8 | ||||
-rw-r--r-- | drivers/staging/lustre/lustre/llite/llite_lib.c | 1 | ||||
-rw-r--r-- | drivers/staging/lustre/lustre/llite/namei.c | 12 | ||||
-rw-r--r-- | drivers/staging/lustre/lustre/llite/symlink.c | 6 | ||||
-rw-r--r-- | drivers/staging/lustre/lustre/llite/xattr.c | 195 |
6 files changed, 141 insertions, 87 deletions
diff --git a/drivers/staging/lustre/lustre/llite/file.c b/drivers/staging/lustre/lustre/llite/file.c index 57281b9e31ff..58a7401046e0 100644 --- a/drivers/staging/lustre/lustre/llite/file.c +++ b/drivers/staging/lustre/lustre/llite/file.c | |||
@@ -3213,10 +3213,10 @@ const struct inode_operations ll_file_inode_operations = { | |||
3213 | .setattr = ll_setattr, | 3213 | .setattr = ll_setattr, |
3214 | .getattr = ll_getattr, | 3214 | .getattr = ll_getattr, |
3215 | .permission = ll_inode_permission, | 3215 | .permission = ll_inode_permission, |
3216 | .setxattr = ll_setxattr, | 3216 | .setxattr = generic_setxattr, |
3217 | .getxattr = ll_getxattr, | 3217 | .getxattr = generic_getxattr, |
3218 | .listxattr = ll_listxattr, | 3218 | .listxattr = ll_listxattr, |
3219 | .removexattr = ll_removexattr, | 3219 | .removexattr = generic_removexattr, |
3220 | .fiemap = ll_fiemap, | 3220 | .fiemap = ll_fiemap, |
3221 | .get_acl = ll_get_acl, | 3221 | .get_acl = ll_get_acl, |
3222 | }; | 3222 | }; |
diff --git a/drivers/staging/lustre/lustre/llite/llite_internal.h b/drivers/staging/lustre/lustre/llite/llite_internal.h index 4d6d589a1677..27d3f7706d44 100644 --- a/drivers/staging/lustre/lustre/llite/llite_internal.h +++ b/drivers/staging/lustre/lustre/llite/llite_internal.h | |||
@@ -42,6 +42,7 @@ | |||
42 | #include "../include/lustre_mdc.h" | 42 | #include "../include/lustre_mdc.h" |
43 | #include "../include/lustre_intent.h" | 43 | #include "../include/lustre_intent.h" |
44 | #include <linux/compat.h> | 44 | #include <linux/compat.h> |
45 | #include <linux/xattr.h> | ||
45 | #include <linux/posix_acl_xattr.h> | 46 | #include <linux/posix_acl_xattr.h> |
46 | #include "vvp_internal.h" | 47 | #include "vvp_internal.h" |
47 | 48 | ||
@@ -933,12 +934,9 @@ static inline __u64 ll_file_maxbytes(struct inode *inode) | |||
933 | } | 934 | } |
934 | 935 | ||
935 | /* llite/xattr.c */ | 936 | /* llite/xattr.c */ |
936 | int ll_setxattr(struct dentry *dentry, struct inode *inode, | 937 | extern const struct xattr_handler *ll_xattr_handlers[]; |
937 | const char *name, const void *value, size_t size, int flags); | 938 | |
938 | ssize_t ll_getxattr(struct dentry *dentry, struct inode *inode, | ||
939 | const char *name, void *buffer, size_t size); | ||
940 | ssize_t ll_listxattr(struct dentry *dentry, char *buffer, size_t size); | 939 | ssize_t ll_listxattr(struct dentry *dentry, char *buffer, size_t size); |
941 | int ll_removexattr(struct dentry *dentry, const char *name); | ||
942 | 940 | ||
943 | /** | 941 | /** |
944 | * Common IO arguments for various VFS I/O interfaces. | 942 | * Common IO arguments for various VFS I/O interfaces. |
diff --git a/drivers/staging/lustre/lustre/llite/llite_lib.c b/drivers/staging/lustre/lustre/llite/llite_lib.c index 546063e728db..75d568f5bb90 100644 --- a/drivers/staging/lustre/lustre/llite/llite_lib.c +++ b/drivers/staging/lustre/lustre/llite/llite_lib.c | |||
@@ -418,6 +418,7 @@ static int client_common_fill_super(struct super_block *sb, char *md, char *dt, | |||
418 | CDEBUG(D_SUPER, "rootfid "DFID"\n", PFID(&sbi->ll_root_fid)); | 418 | CDEBUG(D_SUPER, "rootfid "DFID"\n", PFID(&sbi->ll_root_fid)); |
419 | 419 | ||
420 | sb->s_op = &lustre_super_operations; | 420 | sb->s_op = &lustre_super_operations; |
421 | sb->s_xattr = ll_xattr_handlers; | ||
421 | #if THREAD_SIZE >= 8192 /*b=17630*/ | 422 | #if THREAD_SIZE >= 8192 /*b=17630*/ |
422 | sb->s_export_op = &lustre_export_operations; | 423 | sb->s_export_op = &lustre_export_operations; |
423 | #endif | 424 | #endif |
diff --git a/drivers/staging/lustre/lustre/llite/namei.c b/drivers/staging/lustre/lustre/llite/namei.c index 3664bfd0178b..1e75f5b09c31 100644 --- a/drivers/staging/lustre/lustre/llite/namei.c +++ b/drivers/staging/lustre/lustre/llite/namei.c | |||
@@ -1101,10 +1101,10 @@ const struct inode_operations ll_dir_inode_operations = { | |||
1101 | .setattr = ll_setattr, | 1101 | .setattr = ll_setattr, |
1102 | .getattr = ll_getattr, | 1102 | .getattr = ll_getattr, |
1103 | .permission = ll_inode_permission, | 1103 | .permission = ll_inode_permission, |
1104 | .setxattr = ll_setxattr, | 1104 | .setxattr = generic_setxattr, |
1105 | .getxattr = ll_getxattr, | 1105 | .getxattr = generic_getxattr, |
1106 | .listxattr = ll_listxattr, | 1106 | .listxattr = ll_listxattr, |
1107 | .removexattr = ll_removexattr, | 1107 | .removexattr = generic_removexattr, |
1108 | .get_acl = ll_get_acl, | 1108 | .get_acl = ll_get_acl, |
1109 | }; | 1109 | }; |
1110 | 1110 | ||
@@ -1112,9 +1112,9 @@ const struct inode_operations ll_special_inode_operations = { | |||
1112 | .setattr = ll_setattr, | 1112 | .setattr = ll_setattr, |
1113 | .getattr = ll_getattr, | 1113 | .getattr = ll_getattr, |
1114 | .permission = ll_inode_permission, | 1114 | .permission = ll_inode_permission, |
1115 | .setxattr = ll_setxattr, | 1115 | .setxattr = generic_setxattr, |
1116 | .getxattr = ll_getxattr, | 1116 | .getxattr = generic_getxattr, |
1117 | .listxattr = ll_listxattr, | 1117 | .listxattr = ll_listxattr, |
1118 | .removexattr = ll_removexattr, | 1118 | .removexattr = generic_removexattr, |
1119 | .get_acl = ll_get_acl, | 1119 | .get_acl = ll_get_acl, |
1120 | }; | 1120 | }; |
diff --git a/drivers/staging/lustre/lustre/llite/symlink.c b/drivers/staging/lustre/lustre/llite/symlink.c index 8c8bdfe1ad71..4601be94dd22 100644 --- a/drivers/staging/lustre/lustre/llite/symlink.c +++ b/drivers/staging/lustre/lustre/llite/symlink.c | |||
@@ -155,8 +155,8 @@ const struct inode_operations ll_fast_symlink_inode_operations = { | |||
155 | .get_link = ll_get_link, | 155 | .get_link = ll_get_link, |
156 | .getattr = ll_getattr, | 156 | .getattr = ll_getattr, |
157 | .permission = ll_inode_permission, | 157 | .permission = ll_inode_permission, |
158 | .setxattr = ll_setxattr, | 158 | .setxattr = generic_setxattr, |
159 | .getxattr = ll_getxattr, | 159 | .getxattr = generic_getxattr, |
160 | .listxattr = ll_listxattr, | 160 | .listxattr = ll_listxattr, |
161 | .removexattr = ll_removexattr, | 161 | .removexattr = generic_removexattr, |
162 | }; | 162 | }; |
diff --git a/drivers/staging/lustre/lustre/llite/xattr.c b/drivers/staging/lustre/lustre/llite/xattr.c index a034a5f61d22..a02b80269b5c 100644 --- a/drivers/staging/lustre/lustre/llite/xattr.c +++ b/drivers/staging/lustre/lustre/llite/xattr.c | |||
@@ -99,46 +99,57 @@ int xattr_type_filter(struct ll_sb_info *sbi, int xattr_type) | |||
99 | return 0; | 99 | return 0; |
100 | } | 100 | } |
101 | 101 | ||
102 | static | 102 | static int |
103 | int ll_setxattr_common(struct inode *inode, const char *name, | 103 | ll_xattr_set_common(const struct xattr_handler *handler, |
104 | const void *value, size_t size, | 104 | struct dentry *dentry, struct inode *inode, |
105 | int flags, __u64 valid) | 105 | const char *name, const void *value, size_t size, |
106 | int flags) | ||
106 | { | 107 | { |
108 | char fullname[strlen(handler->prefix) + strlen(name) + 1]; | ||
107 | struct ll_sb_info *sbi = ll_i2sbi(inode); | 109 | struct ll_sb_info *sbi = ll_i2sbi(inode); |
108 | struct ptlrpc_request *req = NULL; | 110 | struct ptlrpc_request *req = NULL; |
109 | int xattr_type, rc; | ||
110 | const char *pv = value; | 111 | const char *pv = value; |
112 | __u64 valid; | ||
113 | int rc; | ||
111 | 114 | ||
112 | xattr_type = get_xattr_type(name); | 115 | if (flags == XATTR_REPLACE) { |
113 | rc = xattr_type_filter(sbi, xattr_type); | 116 | ll_stats_ops_tally(ll_i2sbi(inode), LPROC_LL_REMOVEXATTR, 1); |
117 | valid = OBD_MD_FLXATTRRM; | ||
118 | } else { | ||
119 | ll_stats_ops_tally(ll_i2sbi(inode), LPROC_LL_SETXATTR, 1); | ||
120 | valid = OBD_MD_FLXATTR; | ||
121 | } | ||
122 | |||
123 | rc = xattr_type_filter(sbi, handler->flags); | ||
114 | if (rc) | 124 | if (rc) |
115 | return rc; | 125 | return rc; |
116 | 126 | ||
117 | if ((xattr_type == XATTR_ACL_ACCESS_T || | 127 | if ((handler->flags == XATTR_ACL_ACCESS_T || |
118 | xattr_type == XATTR_ACL_DEFAULT_T) && | 128 | handler->flags == XATTR_ACL_DEFAULT_T) && |
119 | !inode_owner_or_capable(inode)) | 129 | !inode_owner_or_capable(inode)) |
120 | return -EPERM; | 130 | return -EPERM; |
121 | 131 | ||
122 | /* b10667: ignore lustre special xattr for now */ | 132 | /* b10667: ignore lustre special xattr for now */ |
123 | if ((xattr_type == XATTR_TRUSTED_T && strcmp(name, "trusted.lov") == 0) || | 133 | if ((handler->flags == XATTR_TRUSTED_T && !strcmp(name, "lov")) || |
124 | (xattr_type == XATTR_LUSTRE_T && strcmp(name, "lustre.lov") == 0)) | 134 | (handler->flags == XATTR_LUSTRE_T && !strcmp(name, "lov"))) |
125 | return 0; | 135 | return 0; |
126 | 136 | ||
127 | /* b15587: ignore security.capability xattr for now */ | 137 | /* b15587: ignore security.capability xattr for now */ |
128 | if ((xattr_type == XATTR_SECURITY_T && | 138 | if ((handler->flags == XATTR_SECURITY_T && |
129 | strcmp(name, "security.capability") == 0)) | 139 | !strcmp(name, "capability"))) |
130 | return 0; | 140 | return 0; |
131 | 141 | ||
132 | /* LU-549: Disable security.selinux when selinux is disabled */ | 142 | /* LU-549: Disable security.selinux when selinux is disabled */ |
133 | if (xattr_type == XATTR_SECURITY_T && !selinux_is_enabled() && | 143 | if (handler->flags == XATTR_SECURITY_T && !selinux_is_enabled() && |
134 | strcmp(name, "security.selinux") == 0) | 144 | strcmp(name, "selinux") == 0) |
135 | return -EOPNOTSUPP; | 145 | return -EOPNOTSUPP; |
136 | 146 | ||
147 | sprintf(fullname, "%s%s\n", handler->prefix, name); | ||
137 | rc = md_setxattr(sbi->ll_md_exp, ll_inode2fid(inode), | 148 | rc = md_setxattr(sbi->ll_md_exp, ll_inode2fid(inode), |
138 | valid, name, pv, size, 0, flags, | 149 | valid, fullname, pv, size, 0, flags, |
139 | ll_i2suppgid(inode), &req); | 150 | ll_i2suppgid(inode), &req); |
140 | if (rc) { | 151 | if (rc) { |
141 | if (rc == -EOPNOTSUPP && xattr_type == XATTR_USER_T) { | 152 | if (rc == -EOPNOTSUPP && handler->flags == XATTR_USER_T) { |
142 | LCONSOLE_INFO("Disabling user_xattr feature because it is not supported on the server\n"); | 153 | LCONSOLE_INFO("Disabling user_xattr feature because it is not supported on the server\n"); |
143 | sbi->ll_flags &= ~LL_SBI_USER_XATTR; | 154 | sbi->ll_flags &= ~LL_SBI_USER_XATTR; |
144 | } | 155 | } |
@@ -149,8 +160,10 @@ int ll_setxattr_common(struct inode *inode, const char *name, | |||
149 | return 0; | 160 | return 0; |
150 | } | 161 | } |
151 | 162 | ||
152 | int ll_setxattr(struct dentry *dentry, struct inode *inode, | 163 | static int ll_xattr_set(const struct xattr_handler *handler, |
153 | const char *name, const void *value, size_t size, int flags) | 164 | struct dentry *dentry, struct inode *inode, |
165 | const char *name, const void *value, size_t size, | ||
166 | int flags) | ||
154 | { | 167 | { |
155 | LASSERT(inode); | 168 | LASSERT(inode); |
156 | LASSERT(name); | 169 | LASSERT(name); |
@@ -158,20 +171,24 @@ int ll_setxattr(struct dentry *dentry, struct inode *inode, | |||
158 | CDEBUG(D_VFSTRACE, "VFS Op:inode="DFID"(%p), xattr %s\n", | 171 | CDEBUG(D_VFSTRACE, "VFS Op:inode="DFID"(%p), xattr %s\n", |
159 | PFID(ll_inode2fid(inode)), inode, name); | 172 | PFID(ll_inode2fid(inode)), inode, name); |
160 | 173 | ||
161 | ll_stats_ops_tally(ll_i2sbi(inode), LPROC_LL_SETXATTR, 1); | 174 | if (!strcmp(name, "lov")) { |
162 | |||
163 | if ((strncmp(name, XATTR_TRUSTED_PREFIX, | ||
164 | sizeof(XATTR_TRUSTED_PREFIX) - 1) == 0 && | ||
165 | strcmp(name + sizeof(XATTR_TRUSTED_PREFIX) - 1, "lov") == 0) || | ||
166 | (strncmp(name, XATTR_LUSTRE_PREFIX, | ||
167 | sizeof(XATTR_LUSTRE_PREFIX) - 1) == 0 && | ||
168 | strcmp(name + sizeof(XATTR_LUSTRE_PREFIX) - 1, "lov") == 0)) { | ||
169 | struct lov_user_md *lump = (struct lov_user_md *)value; | 175 | struct lov_user_md *lump = (struct lov_user_md *)value; |
176 | int op_type = flags == XATTR_REPLACE ? LPROC_LL_REMOVEXATTR : | ||
177 | LPROC_LL_SETXATTR; | ||
170 | int rc = 0; | 178 | int rc = 0; |
171 | 179 | ||
180 | ll_stats_ops_tally(ll_i2sbi(inode), op_type, 1); | ||
181 | |||
172 | if (size != 0 && size < sizeof(struct lov_user_md)) | 182 | if (size != 0 && size < sizeof(struct lov_user_md)) |
173 | return -EINVAL; | 183 | return -EINVAL; |
174 | 184 | ||
185 | /* | ||
186 | * It is possible to set an xattr to a "" value of zero size. | ||
187 | * For this case we are going to treat it as a removal. | ||
188 | */ | ||
189 | if (!size && lump) | ||
190 | lump = NULL; | ||
191 | |||
175 | /* Attributes that are saved via getxattr will always have | 192 | /* Attributes that are saved via getxattr will always have |
176 | * the stripe_offset as 0. Instead, the MDS should be | 193 | * the stripe_offset as 0. Instead, the MDS should be |
177 | * allowed to pick the starting OST index. b=17846 | 194 | * allowed to pick the starting OST index. b=17846 |
@@ -194,27 +211,13 @@ int ll_setxattr(struct dentry *dentry, struct inode *inode, | |||
194 | 211 | ||
195 | return rc; | 212 | return rc; |
196 | 213 | ||
197 | } else if (strcmp(name, XATTR_NAME_LMA) == 0 || | 214 | } else if (!strcmp(name, "lma") || !strcmp(name, "link")) { |
198 | strcmp(name, XATTR_NAME_LINK) == 0) | 215 | ll_stats_ops_tally(ll_i2sbi(inode), LPROC_LL_SETXATTR, 1); |
199 | return 0; | 216 | return 0; |
217 | } | ||
200 | 218 | ||
201 | return ll_setxattr_common(inode, name, value, size, flags, | 219 | return ll_xattr_set_common(handler, dentry, inode, name, value, size, |
202 | OBD_MD_FLXATTR); | 220 | flags); |
203 | } | ||
204 | |||
205 | int ll_removexattr(struct dentry *dentry, const char *name) | ||
206 | { | ||
207 | struct inode *inode = d_inode(dentry); | ||
208 | |||
209 | LASSERT(inode); | ||
210 | LASSERT(name); | ||
211 | |||
212 | CDEBUG(D_VFSTRACE, "VFS Op:inode="DFID"(%p), xattr %s\n", | ||
213 | PFID(ll_inode2fid(inode)), inode, name); | ||
214 | |||
215 | ll_stats_ops_tally(ll_i2sbi(inode), LPROC_LL_REMOVEXATTR, 1); | ||
216 | return ll_setxattr_common(inode, name, NULL, 0, 0, | ||
217 | OBD_MD_FLXATTRRM); | ||
218 | } | 221 | } |
219 | 222 | ||
220 | static int | 223 | static int |
@@ -300,30 +303,31 @@ out: | |||
300 | return rc; | 303 | return rc; |
301 | } | 304 | } |
302 | 305 | ||
303 | static | 306 | static int ll_xattr_get_common(const struct xattr_handler *handler, |
304 | int ll_getxattr_common(struct inode *inode, const char *name, | 307 | struct dentry *dentry, struct inode *inode, |
305 | void *buffer, size_t size) | 308 | const char *name, void *buffer, size_t size) |
306 | { | 309 | { |
310 | char fullname[strlen(handler->prefix) + strlen(name) + 1]; | ||
307 | struct ll_sb_info *sbi = ll_i2sbi(inode); | 311 | struct ll_sb_info *sbi = ll_i2sbi(inode); |
308 | int xattr_type, rc; | ||
309 | struct ll_inode_info *lli = ll_i2info(inode); | 312 | struct ll_inode_info *lli = ll_i2info(inode); |
313 | int rc; | ||
310 | 314 | ||
311 | CDEBUG(D_VFSTRACE, "VFS Op:inode="DFID"(%p)\n", | 315 | CDEBUG(D_VFSTRACE, "VFS Op:inode="DFID"(%p)\n", |
312 | PFID(ll_inode2fid(inode)), inode); | 316 | PFID(ll_inode2fid(inode)), inode); |
313 | 317 | ||
314 | xattr_type = get_xattr_type(name); | 318 | ll_stats_ops_tally(ll_i2sbi(inode), LPROC_LL_GETXATTR, 1); |
315 | rc = xattr_type_filter(sbi, xattr_type); | 319 | |
320 | rc = xattr_type_filter(sbi, handler->flags); | ||
316 | if (rc) | 321 | if (rc) |
317 | return rc; | 322 | return rc; |
318 | 323 | ||
319 | /* b15587: ignore security.capability xattr for now */ | 324 | /* b15587: ignore security.capability xattr for now */ |
320 | if ((xattr_type == XATTR_SECURITY_T && | 325 | if ((handler->flags == XATTR_SECURITY_T && !strcmp(name, "capability"))) |
321 | strcmp(name, "security.capability") == 0)) | ||
322 | return -ENODATA; | 326 | return -ENODATA; |
323 | 327 | ||
324 | /* LU-549: Disable security.selinux when selinux is disabled */ | 328 | /* LU-549: Disable security.selinux when selinux is disabled */ |
325 | if (xattr_type == XATTR_SECURITY_T && !selinux_is_enabled() && | 329 | if (handler->flags == XATTR_SECURITY_T && !selinux_is_enabled() && |
326 | strcmp(name, "security.selinux") == 0) | 330 | !strcmp(name, "selinux")) |
327 | return -EOPNOTSUPP; | 331 | return -EOPNOTSUPP; |
328 | 332 | ||
329 | #ifdef CONFIG_FS_POSIX_ACL | 333 | #ifdef CONFIG_FS_POSIX_ACL |
@@ -331,7 +335,7 @@ int ll_getxattr_common(struct inode *inode, const char *name, | |||
331 | * we just have path resolution to the target inode, so we have great | 335 | * we just have path resolution to the target inode, so we have great |
332 | * chance that cached ACL is uptodate. | 336 | * chance that cached ACL is uptodate. |
333 | */ | 337 | */ |
334 | if (xattr_type == XATTR_ACL_ACCESS_T) { | 338 | if (handler->flags == XATTR_ACL_ACCESS_T) { |
335 | struct posix_acl *acl; | 339 | struct posix_acl *acl; |
336 | 340 | ||
337 | spin_lock(&lli->lli_lock); | 341 | spin_lock(&lli->lli_lock); |
@@ -345,15 +349,17 @@ int ll_getxattr_common(struct inode *inode, const char *name, | |||
345 | posix_acl_release(acl); | 349 | posix_acl_release(acl); |
346 | return rc; | 350 | return rc; |
347 | } | 351 | } |
348 | if (xattr_type == XATTR_ACL_DEFAULT_T && !S_ISDIR(inode->i_mode)) | 352 | if (handler->flags == XATTR_ACL_DEFAULT_T && !S_ISDIR(inode->i_mode)) |
349 | return -ENODATA; | 353 | return -ENODATA; |
350 | #endif | 354 | #endif |
351 | return ll_xattr_list(inode, name, xattr_type, buffer, size, | 355 | sprintf(fullname, "%s%s\n", handler->prefix, name); |
356 | return ll_xattr_list(inode, fullname, handler->flags, buffer, size, | ||
352 | OBD_MD_FLXATTR); | 357 | OBD_MD_FLXATTR); |
353 | } | 358 | } |
354 | 359 | ||
355 | ssize_t ll_getxattr(struct dentry *dentry, struct inode *inode, | 360 | static int ll_xattr_get(const struct xattr_handler *handler, |
356 | const char *name, void *buffer, size_t size) | 361 | struct dentry *dentry, struct inode *inode, |
362 | const char *name, void *buffer, size_t size) | ||
357 | { | 363 | { |
358 | LASSERT(inode); | 364 | LASSERT(inode); |
359 | LASSERT(name); | 365 | LASSERT(name); |
@@ -361,20 +367,15 @@ ssize_t ll_getxattr(struct dentry *dentry, struct inode *inode, | |||
361 | CDEBUG(D_VFSTRACE, "VFS Op:inode="DFID"(%p), xattr %s\n", | 367 | CDEBUG(D_VFSTRACE, "VFS Op:inode="DFID"(%p), xattr %s\n", |
362 | PFID(ll_inode2fid(inode)), inode, name); | 368 | PFID(ll_inode2fid(inode)), inode, name); |
363 | 369 | ||
364 | ll_stats_ops_tally(ll_i2sbi(inode), LPROC_LL_GETXATTR, 1); | 370 | if (!strcmp(name, "lov")) { |
365 | |||
366 | if ((strncmp(name, XATTR_TRUSTED_PREFIX, | ||
367 | sizeof(XATTR_TRUSTED_PREFIX) - 1) == 0 && | ||
368 | strcmp(name + sizeof(XATTR_TRUSTED_PREFIX) - 1, "lov") == 0) || | ||
369 | (strncmp(name, XATTR_LUSTRE_PREFIX, | ||
370 | sizeof(XATTR_LUSTRE_PREFIX) - 1) == 0 && | ||
371 | strcmp(name + sizeof(XATTR_LUSTRE_PREFIX) - 1, "lov") == 0)) { | ||
372 | struct lov_stripe_md *lsm; | 371 | struct lov_stripe_md *lsm; |
373 | struct lov_user_md *lump; | 372 | struct lov_user_md *lump; |
374 | struct lov_mds_md *lmm = NULL; | 373 | struct lov_mds_md *lmm = NULL; |
375 | struct ptlrpc_request *request = NULL; | 374 | struct ptlrpc_request *request = NULL; |
376 | int rc = 0, lmmsize = 0; | 375 | int rc = 0, lmmsize = 0; |
377 | 376 | ||
377 | ll_stats_ops_tally(ll_i2sbi(inode), LPROC_LL_GETXATTR, 1); | ||
378 | |||
378 | if (!S_ISREG(inode->i_mode) && !S_ISDIR(inode->i_mode)) | 379 | if (!S_ISREG(inode->i_mode) && !S_ISDIR(inode->i_mode)) |
379 | return -ENODATA; | 380 | return -ENODATA; |
380 | 381 | ||
@@ -440,7 +441,7 @@ out: | |||
440 | return rc; | 441 | return rc; |
441 | } | 442 | } |
442 | 443 | ||
443 | return ll_getxattr_common(inode, name, buffer, size); | 444 | return ll_xattr_get_common(handler, dentry, inode, name, buffer, size); |
444 | } | 445 | } |
445 | 446 | ||
446 | ssize_t ll_listxattr(struct dentry *dentry, char *buffer, size_t size) | 447 | ssize_t ll_listxattr(struct dentry *dentry, char *buffer, size_t size) |
@@ -520,3 +521,57 @@ out: | |||
520 | 521 | ||
521 | return rc; | 522 | return rc; |
522 | } | 523 | } |
524 | |||
525 | static const struct xattr_handler ll_user_xattr_handler = { | ||
526 | .prefix = XATTR_USER_PREFIX, | ||
527 | .flags = XATTR_USER_T, | ||
528 | .get = ll_xattr_get_common, | ||
529 | .set = ll_xattr_set_common, | ||
530 | }; | ||
531 | |||
532 | static const struct xattr_handler ll_trusted_xattr_handler = { | ||
533 | .prefix = XATTR_TRUSTED_PREFIX, | ||
534 | .flags = XATTR_TRUSTED_T, | ||
535 | .get = ll_xattr_get, | ||
536 | .set = ll_xattr_set, | ||
537 | }; | ||
538 | |||
539 | static const struct xattr_handler ll_security_xattr_handler = { | ||
540 | .prefix = XATTR_SECURITY_PREFIX, | ||
541 | .flags = XATTR_SECURITY_T, | ||
542 | .get = ll_xattr_get_common, | ||
543 | .set = ll_xattr_set_common, | ||
544 | }; | ||
545 | |||
546 | static const struct xattr_handler ll_acl_access_xattr_handler = { | ||
547 | .prefix = XATTR_NAME_POSIX_ACL_ACCESS, | ||
548 | .flags = XATTR_ACL_ACCESS_T, | ||
549 | .get = ll_xattr_get_common, | ||
550 | .set = ll_xattr_set_common, | ||
551 | }; | ||
552 | |||
553 | static const struct xattr_handler ll_acl_default_xattr_handler = { | ||
554 | .prefix = XATTR_NAME_POSIX_ACL_DEFAULT, | ||
555 | .flags = XATTR_ACL_DEFAULT_T, | ||
556 | .get = ll_xattr_get_common, | ||
557 | .set = ll_xattr_set_common, | ||
558 | }; | ||
559 | |||
560 | static const struct xattr_handler ll_lustre_xattr_handler = { | ||
561 | .prefix = XATTR_LUSTRE_PREFIX, | ||
562 | .flags = XATTR_LUSTRE_T, | ||
563 | .get = ll_xattr_get, | ||
564 | .set = ll_xattr_set, | ||
565 | }; | ||
566 | |||
567 | const struct xattr_handler *ll_xattr_handlers[] = { | ||
568 | &ll_user_xattr_handler, | ||
569 | &ll_trusted_xattr_handler, | ||
570 | &ll_security_xattr_handler, | ||
571 | #ifdef CONFIG_FS_POSIX_ACL | ||
572 | &ll_acl_access_xattr_handler, | ||
573 | &ll_acl_default_xattr_handler, | ||
574 | #endif | ||
575 | &ll_lustre_xattr_handler, | ||
576 | NULL, | ||
577 | }; | ||