4 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
6 * This program is free software; you can redistribute it and/or modify
7 * it under the terms of the GNU General Public License version 2 only,
8 * as published by the Free Software Foundation.
10 * This program is distributed in the hope that it will be useful, but
11 * WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 * General Public License version 2 for more details (a copy is included
14 * in the LICENSE file that accompanied this code).
16 * You should have received a copy of the GNU General Public License
17 * version 2 along with this program; If not, see
18 * http://www.gnu.org/licenses/gpl-2.0.html
23 * Copyright (c) 2007, 2010, Oracle and/or its affiliates. All rights reserved.
24 * Use is subject to license terms.
26 * Copyright (c) 2011, 2017, Intel Corporation.
29 * This file is part of Lustre, http://www.lustre.org/
33 #include <linux/sched.h>
35 #include <linux/xattr.h>
36 #ifdef HAVE_LINUX_SELINUX_IS_ENABLED
37 #include <linux/selinux.h>
40 #define DEBUG_SUBSYSTEM S_LLITE
42 #include <obd_support.h>
43 #include <lustre_dlm.h>
44 #include <lustre_swab.h>
46 #include "llite_internal.h"
48 #ifndef HAVE_XATTR_HANDLER_NAME
49 static inline const char *xattr_prefix(const struct xattr_handler *handler)
51 return handler->prefix;
55 const struct xattr_handler *get_xattr_type(const char *name)
59 for (i = 0; ll_xattr_handlers[i]; i++) {
60 const char *prefix = xattr_prefix(ll_xattr_handlers[i]);
61 size_t prefix_len = strlen(prefix);
63 if (!strncmp(prefix, name, prefix_len))
64 return ll_xattr_handlers[i];
70 static int xattr_type_filter(struct ll_sb_info *sbi,
71 const struct xattr_handler *handler)
73 /* No handler means XATTR_OTHER_T */
77 if ((handler->flags == XATTR_ACL_ACCESS_T ||
78 handler->flags == XATTR_ACL_DEFAULT_T) &&
79 !test_bit(LL_SBI_ACL, sbi->ll_flags))
82 if (handler->flags == XATTR_USER_T &&
83 !test_bit(LL_SBI_USER_XATTR, sbi->ll_flags))
86 if (handler->flags == XATTR_TRUSTED_T &&
87 !capable(CAP_SYS_ADMIN))
93 #ifndef HAVE_USER_NAMESPACE_ARG
94 #define ll_xattr_set_common(hd, ns, de, inode, name, value, size, flags) \
95 ll_xattr_set_common(hd, de, inode, name, value, size, flags)
98 static int ll_xattr_set_common(const struct xattr_handler *handler,
99 struct mnt_idmap *map,
100 struct dentry *dentry, struct inode *inode,
101 const char *name, const void *value, size_t size,
104 struct ll_sb_info *sbi = ll_i2sbi(inode);
105 struct ptlrpc_request *req = NULL;
106 const char *pv = value;
108 ktime_t kstart = ktime_get();
113 /* VFS has locked the inode before calling this */
114 ll_set_inode_lock_owner(inode);
116 /* When setxattr() is called with a size of 0 the value is
117 * unconditionally replaced by "". When removexattr() is
118 * called we get a NULL value and XATTR_REPLACE for flags.
120 if (!value && flags == XATTR_REPLACE)
121 valid = OBD_MD_FLXATTRRM;
123 valid = OBD_MD_FLXATTR;
125 /* FIXME: enable IMA when the conditions are ready */
126 if (handler->flags == XATTR_SECURITY_T &&
127 (!strcmp(name, "ima") || !strcmp(name, "evm")))
128 GOTO(out, rc = -EOPNOTSUPP);
130 rc = xattr_type_filter(sbi, handler);
134 if ((handler->flags == XATTR_ACL_ACCESS_T ||
135 handler->flags == XATTR_ACL_DEFAULT_T) &&
136 !inode_owner_or_capable(map, inode))
137 GOTO(out, rc = -EPERM);
139 /* b10667: ignore lustre special xattr for now */
140 if (!strcmp(name, "hsm") ||
141 ((handler->flags == XATTR_TRUSTED_T && !strcmp(name, "lov")) ||
142 (handler->flags == XATTR_LUSTRE_T && !strcmp(name, "lov"))))
145 rc = ll_security_secctx_name_filter(sbi, handler->flags, name);
150 * In user.* namespace, only regular files and directories can have
151 * extended attributes.
153 if (handler->flags == XATTR_USER_T) {
154 if (!S_ISREG(inode->i_mode) && !S_ISDIR(inode->i_mode))
155 GOTO(out, rc = -EPERM);
158 /* This check is required for compatibility with 2.14, in which
159 * encryption context is stored in security.c xattr.
160 * Setting the encryption context should only be possible by llcrypt
161 * when defining an encryption policy on a directory.
162 * When new files/dirs are created in an encrypted dir, the enc
163 * context is set directly in the create request.
165 if (handler->flags == XATTR_SECURITY_T && strcmp(name, "c") == 0)
166 GOTO(out, rc = -EPERM);
168 if (handler->flags == XATTR_TRUSTED_T && !strcmp(name, "dmv") &&
169 (valid & OBD_MD_FLXATTR)) {
170 const struct lmv_user_md *clum;
171 struct lmv_user_md *lum;
174 GOTO(out, rc = -EINVAL);
176 clum = (const struct lmv_user_md *)value;
177 if (size != sizeof(*clum))
178 GOTO(out, rc = -EINVAL);
180 if (clum->lum_magic != LMV_USER_MAGIC)
181 GOTO(out, rc = -EINVAL);
183 /* skip default dmv */
184 if (clum->lum_stripe_offset == LMV_OFFSET_DEFAULT &&
185 clum->lum_stripe_count == 1 &&
186 clum->lum_hash_type == LMV_HASH_TYPE_UNKNOWN)
191 GOTO(out, rc = -ENOMEM);
194 rc = ll_dir_setstripe(inode, (struct lov_user_md *)lum, 1);
199 fullname = kasprintf(GFP_KERNEL, "%s%s", xattr_prefix(handler), name);
201 GOTO(out, rc = -ENOMEM);
203 rc = md_setxattr(sbi->ll_md_exp, ll_inode2fid(inode), valid, fullname,
204 pv, size, flags, ll_i2suppgid(inode), &req);
207 if (rc == -EOPNOTSUPP && handler->flags == XATTR_USER_T) {
208 LCONSOLE_INFO("Disabling user_xattr feature because it is not supported on the server\n");
209 clear_bit(LL_SBI_USER_XATTR, sbi->ll_flags);
213 ll_i2info(inode)->lli_synced_to_mds = false;
215 ptlrpc_req_finished(req);
217 ll_stats_ops_tally(ll_i2sbi(inode), valid == OBD_MD_FLXATTRRM ?
218 LPROC_LL_REMOVEXATTR : LPROC_LL_SETXATTR,
219 ktime_us_delta(ktime_get(), kstart));
221 ll_clear_inode_lock_owner(inode);
226 static int get_hsm_state(struct inode *inode, u32 *hus_states)
228 struct md_op_data *op_data;
229 struct hsm_user_state *hus;
236 op_data = ll_prep_md_op_data(NULL, inode, NULL, NULL, 0, 0,
237 LUSTRE_OPC_ANY, hus);
238 if (!IS_ERR(op_data)) {
239 rc = obd_iocontrol(LL_IOC_HSM_STATE_GET, ll_i2mdexp(inode),
240 sizeof(*op_data), op_data, NULL);
242 *hus_states = hus->hus_states;
244 CDEBUG(D_VFSTRACE, "obd_iocontrol failed. rc = %d\n",
247 ll_finish_md_op_data(op_data);
249 rc = PTR_ERR(op_data);
250 CDEBUG(D_VFSTRACE, "Could not prepare the opdata. rc = %d\n",
257 static int ll_adjust_lum(struct inode *inode, struct lov_user_md *lump,
260 struct lov_comp_md_v1 *comp_v1 = (struct lov_comp_md_v1 *)lump;
261 struct lov_user_md *v1 = lump;
262 bool need_clear_release = false;
263 bool release_checked = false;
264 bool is_composite = false;
272 if (lump->lmm_magic == LOV_USER_MAGIC_COMP_V1) {
273 if (size < sizeof(*comp_v1))
276 entry_count = comp_v1->lcm_entry_count;
277 if (size < offsetof(typeof(*comp_v1), lcm_entries[entry_count]))
282 for (i = 0; i < entry_count; i++) {
283 if (lump->lmm_magic == LOV_USER_MAGIC_COMP_V1) {
286 if (comp_v1->lcm_entries[i].lcme_offset + sizeof(*v1) >
290 ptr += comp_v1->lcm_entries[i].lcme_offset;
291 v1 = (struct lov_user_md *)ptr;
295 * Attributes that are saved via getxattr will always
296 * have the stripe_offset as 0. Instead, the MDS
297 * should be allowed to pick the starting OST index.
300 if (!is_composite && v1->lmm_stripe_offset == 0)
301 v1->lmm_stripe_offset = -1;
303 /* Avoid anyone directly setting the RELEASED flag. */
304 if (v1->lmm_pattern & LOV_PATTERN_F_RELEASED) {
305 if (!release_checked) {
308 rc = get_hsm_state(inode, &state);
312 if (!(state & HS_ARCHIVED))
313 need_clear_release = true;
314 release_checked = true;
316 if (need_clear_release)
317 v1->lmm_pattern ^= LOV_PATTERN_F_RELEASED;
324 static int ll_setstripe_ea(struct dentry *dentry, struct lov_user_md *lump,
327 struct inode *inode = dentry->d_inode;
331 * It is possible to set an xattr to a "" value of zero size.
332 * For this case we are going to treat it as a removal.
337 if (size && size < sizeof(*lump)) {
338 /* ll_adjust_lum() or ll_lov_user_md_size() might access
339 * before size - just give up now.
343 rc = ll_adjust_lum(inode, lump, size);
347 if (lump && S_ISREG(inode->i_mode)) {
348 u64 it_flags = FMODE_WRITE;
351 lum_size = ll_lov_user_md_size(lump);
352 if (lum_size < 0 || size < lum_size)
355 rc = ll_lov_setstripe_ea_info(inode, dentry, it_flags, lump,
358 * b=10667: ignore -EEXIST.
359 * Silently eat error on setting trusted.lov/lustre.lov
360 * attribute for platforms that added the default option
361 * to copy all attributes in 'cp' command. Both rsync and
362 * tar --xattrs also will try to set LOVEA for existing
367 } else if (S_ISDIR(inode->i_mode)) {
368 if (size != 0 && size < sizeof(struct lov_user_md))
371 rc = ll_dir_setstripe(inode, lump, 0);
377 #ifndef HAVE_USER_NAMESPACE_ARG
378 #define ll_xattr_set(hd, ns, de, inode, name, value, size, flags) \
379 ll_xattr_set(hd, de, inode, name, value, size, flags)
382 static int ll_xattr_set(const struct xattr_handler *handler,
383 struct mnt_idmap *map,
384 struct dentry *dentry, struct inode *inode,
385 const char *name, const void *value, size_t size,
388 ktime_t kstart = ktime_get();
389 int op_type = flags == XATTR_REPLACE ? LPROC_LL_REMOVEXATTR :
396 /* VFS has locked the inode before calling this */
397 ll_set_inode_lock_owner(inode);
399 CDEBUG(D_VFSTRACE, "VFS Op:inode=" DFID "(%p), xattr %s\n",
400 PFID(ll_inode2fid(inode)), inode, name);
402 /* lustre/trusted.lov.xxx would be passed through xattr API */
403 if (!strcmp(name, "lov")) {
404 rc = ll_setstripe_ea(dentry, (struct lov_user_md *)value,
406 ll_stats_ops_tally(ll_i2sbi(inode), op_type,
407 ktime_us_delta(ktime_get(), kstart));
409 } else if (!strcmp(name, "lma") || !strcmp(name, "link")) {
410 ll_stats_ops_tally(ll_i2sbi(inode), op_type,
411 ktime_us_delta(ktime_get(), kstart));
415 if (strncmp(name, "lov.", 4) == 0 &&
416 (__swab32(((struct lov_user_md *)value)->lmm_magic) &
417 le32_to_cpu(LOV_MAGIC_MASK)) == le32_to_cpu(LOV_MAGIC_MAGIC))
418 lustre_swab_lov_user_md((struct lov_user_md *)value, 0);
420 rc = ll_xattr_set_common(handler, map, dentry, inode, name,
423 ll_clear_inode_lock_owner(inode);
428 int ll_xattr_list(struct inode *inode, const char *name, int type, void *buffer,
429 size_t size, u64 valid)
431 struct ll_inode_info *lli = ll_i2info(inode);
432 struct ll_sb_info *sbi = ll_i2sbi(inode);
433 struct ptlrpc_request *req = NULL;
438 /* This check is required for compatibility with 2.14, in which
439 * encryption context is stored in security.c xattr. Accessing the
440 * encryption context should only be possible by llcrypt.
442 if (type == XATTR_SECURITY_T && strcmp(name, "security.c") == 0)
443 GOTO(out_xattr, rc = -EPERM);
445 if (sbi->ll_xattr_cache_enabled && type != XATTR_ACL_ACCESS_T &&
446 (type != XATTR_SECURITY_T || !ll_xattr_is_seclabel(name)) &&
447 (type != XATTR_TRUSTED_T || strcmp(name, XATTR_NAME_SOM))) {
448 rc = ll_xattr_cache_get(inode, name, buffer, size, valid);
450 goto getxattr_nocache;
454 /* Add "system.posix_acl_access" to the list */
455 if (lli->lli_posix_acl && valid & OBD_MD_FLXATTRLS) {
457 rc += sizeof(XATTR_NAME_ACL_ACCESS);
458 } else if (size - rc >= sizeof(XATTR_NAME_ACL_ACCESS)) {
459 memcpy(buffer + rc, XATTR_NAME_ACL_ACCESS,
460 sizeof(XATTR_NAME_ACL_ACCESS));
461 rc += sizeof(XATTR_NAME_ACL_ACCESS);
463 GOTO(out_xattr, rc = -ERANGE);
468 rc = md_getxattr(sbi->ll_md_exp, ll_inode2fid(inode), valid,
473 /* only detect the xattr size */
478 GOTO(out, rc = -ERANGE);
480 /* do not need swab xattr data */
481 xdata = req_capsule_server_sized_get(&req->rq_pill, &RMF_EADATA,
484 GOTO(out, rc = -EPROTO);
486 memcpy(buffer, xdata, rc);
492 if (rc == -EOPNOTSUPP && type == XATTR_USER_T) {
493 LCONSOLE_INFO("%s: disabling user_xattr feature because it is not supported on the server: rc = %d\n",
495 clear_bit(LL_SBI_USER_XATTR, sbi->ll_flags);
498 ptlrpc_req_finished(req);
502 static int ll_xattr_get_common(const struct xattr_handler *handler,
503 struct dentry *dentry,
505 const char *name, void *buffer, size_t size)
507 struct ll_sb_info *sbi = ll_i2sbi(inode);
508 ktime_t kstart = ktime_get();
514 rc = xattr_type_filter(sbi, handler);
518 rc = ll_security_secctx_name_filter(sbi, handler->flags, name);
522 #ifdef CONFIG_LUSTRE_FS_POSIX_ACL
523 /* posix acl is under protection of LOOKUP lock. when calling to this,
524 * we just have path resolution to the target inode, so we have great
525 * chance that cached ACL is uptodate.
527 if (handler->flags == XATTR_ACL_ACCESS_T) {
528 struct ll_inode_info *lli = ll_i2info(inode);
529 struct posix_acl *acl;
531 read_lock(&lli->lli_lock);
532 acl = posix_acl_dup(lli->lli_posix_acl);
533 read_unlock(&lli->lli_lock);
538 rc = posix_acl_to_xattr(&init_user_ns, acl, buffer, size);
539 posix_acl_release(acl);
542 if (handler->flags == XATTR_ACL_DEFAULT_T && !S_ISDIR(inode->i_mode))
546 fullname = kasprintf(GFP_KERNEL, "%s%s", xattr_prefix(handler), name);
550 rc = ll_xattr_list(inode, fullname, handler->flags, buffer, size,
553 ll_stats_ops_tally(ll_i2sbi(inode), LPROC_LL_GETXATTR,
554 ktime_us_delta(ktime_get(), kstart));
559 static ssize_t ll_getxattr_lov(struct inode *inode, void *buf, size_t buf_size)
563 if (S_ISREG(inode->i_mode)) {
564 struct cl_object *obj = ll_i2info(inode)->lli_clob;
565 struct cl_layout cl = {
566 .cl_buf.lb_buf = buf,
567 .cl_buf.lb_len = buf_size,
575 env = cl_env_get(&refcheck);
577 RETURN(PTR_ERR(env));
579 rc = cl_object_layout_get(env, obj, &cl);
584 GOTO(out_env, rc = -ENODATA);
591 LASSERT(buf && rc <= buf_size);
594 * Do not return layout gen for getxattr() since
595 * otherwise it would confuse tar --xattr by
596 * recognizing layout gen as stripe offset when the
597 * file is restored. See LU-2809.
599 if ((((struct lov_mds_md *)buf)->lmm_magic &
600 __swab32(LOV_MAGIC_MAGIC)) == __swab32(LOV_MAGIC_MAGIC))
601 lustre_swab_lov_user_md((struct lov_user_md *)buf,
604 switch (((struct lov_mds_md *)buf)->lmm_magic) {
607 case LOV_MAGIC_SPECIFIC:
608 ((struct lov_mds_md *)buf)->lmm_layout_gen = 0;
610 case LOV_MAGIC_COMP_V1:
611 case LOV_MAGIC_FOREIGN:
615 CERROR("%s: bad LOV magic %08x on "DFID": rc = %zd\n",
616 ll_i2sbi(inode)->ll_fsname,
617 ((struct lov_mds_md *)buf)->lmm_magic,
618 PFID(ll_inode2fid(inode)), rc);
623 cl_env_put(env, &refcheck);
626 } else if (S_ISDIR(inode->i_mode)) {
627 struct ptlrpc_request *req = NULL;
628 struct ptlrpc_request *root_req = NULL;
629 struct lov_mds_md *lmm = NULL;
632 rc = ll_dir_getstripe_default(inode, (void **)&lmm, &lmm_size,
638 GOTO(out_req, rc = lmm_size);
640 if (buf_size < lmm_size)
641 GOTO(out_req, rc = -ERANGE);
643 memcpy(buf, lmm, lmm_size);
644 GOTO(out_req, rc = lmm_size);
647 ptlrpc_req_finished(req);
649 ptlrpc_req_finished(root_req);
657 static int ll_xattr_get(const struct xattr_handler *handler,
658 struct dentry *dentry, struct inode *inode,
659 const char *name, void *buffer, size_t size)
664 CDEBUG(D_VFSTRACE, "VFS Op:inode="DFID"(%p), xattr %s\n",
665 PFID(ll_inode2fid(inode)), inode, name);
667 if (!strcmp(name, "lov")) {
668 ll_stats_ops_tally(ll_i2sbi(inode), LPROC_LL_GETXATTR, 1);
670 return ll_getxattr_lov(inode, buffer, size);
673 return ll_xattr_get_common(handler, dentry, inode, name, buffer, size);
676 ssize_t ll_listxattr(struct dentry *dentry, char *buffer, size_t size)
678 struct inode *inode = dentry->d_inode;
679 struct ll_sb_info *sbi = ll_i2sbi(inode);
680 ktime_t kstart = ktime_get();
687 CDEBUG(D_VFSTRACE, "VFS Op:inode="DFID"(%p)\n",
688 PFID(ll_inode2fid(inode)), inode);
690 rc = ll_xattr_list(inode, NULL, XATTR_OTHER_T, buffer, size,
696 * If we're being called to get the size of the xattr list
697 * (size == 0) then just assume that a lustre.lov xattr
707 const struct xattr_handler *xh = get_xattr_type(xattr_name);
708 bool hide_xattr = false;
710 /* Hide virtual project id xattr from the list when
711 * parent has the inherit flag and the same project id,
712 * so project id won't be messed up by copying the xattrs
713 * when mv to a tree with different project id.
715 if (xh && xh->flags == XATTR_TRUSTED_T &&
716 strcmp(xattr_name, XATTR_NAME_PROJID) == 0) {
717 struct dentry *parent = dget_parent(dentry);
718 struct inode *dir = d_inode(parent);
720 if ((ll_i2info(inode)->lli_projid ==
721 ll_i2info(dir)->lli_projid) &&
722 test_bit(LLIF_PROJECT_INHERIT,
723 &ll_i2info(dir)->lli_flags))
726 } else if (xh && xh->flags == XATTR_SECURITY_T &&
727 strcmp(xattr_name, "security.c") == 0) {
728 /* Listing xattrs should not expose encryption
729 * context. There is no handler defined for
730 * XATTR_ENCRYPTION_PREFIX, so this test is just
731 * needed for compatibility with 2.14, in which
732 * encryption context is stored in security.c xattr.
737 len = strnlen(xattr_name, rem - 1) + 1;
739 if (!xattr_type_filter(sbi, hide_xattr ? NULL : xh)) {
740 /* Skip OK xattr type, leave it in buffer. */
746 * Move up remaining xattrs in buffer
747 * removing the xattr that is not OK.
749 memmove(xattr_name, xattr_name + len, rem);
753 rc2 = ll_getxattr_lov(inode, NULL, 0);
760 if (size < rc + sizeof(XATTR_LUSTRE_LOV))
763 memcpy(buffer + rc, XATTR_LUSTRE_LOV, sizeof(XATTR_LUSTRE_LOV));
766 ll_stats_ops_tally(ll_i2sbi(inode), LPROC_LL_LISTXATTR,
767 ktime_us_delta(ktime_get(), kstart));
769 RETURN(rc + sizeof(XATTR_LUSTRE_LOV));
772 #ifdef HAVE_XATTR_HANDLER_SIMPLIFIED
773 static int ll_xattr_get_common_4_3(const struct xattr_handler *handler,
774 struct dentry *dentry, const char *name,
775 void *buffer, size_t size)
777 return ll_xattr_get_common(handler, dentry, dentry->d_inode, name,
781 static int ll_xattr_get_4_3(const struct xattr_handler *handler,
782 struct dentry *dentry, const char *name,
783 void *buffer, size_t size)
785 return ll_xattr_get(handler, dentry, dentry->d_inode, name, buffer,
789 static int ll_xattr_set_common_4_3(const struct xattr_handler *handler,
790 struct dentry *dentry, const char *name,
791 const void *value, size_t size, int flags)
793 return ll_xattr_set_common(handler, dentry, dentry->d_inode, name,
797 static int ll_xattr_set_4_3(const struct xattr_handler *handler,
798 struct dentry *dentry, const char *name,
799 const void *value, size_t size, int flags)
801 return ll_xattr_set(handler, dentry, dentry->d_inode, name, value,
805 #elif !defined(HAVE_USER_NAMESPACE_ARG) && \
806 !defined(HAVE_XATTR_HANDLER_INODE_PARAM)
807 const struct xattr_handler *get_xattr_handler(int handler_flag)
811 while (ll_xattr_handlers[i]) {
812 if (ll_xattr_handlers[i]->flags == handler_flag)
813 return ll_xattr_handlers[i];
819 static int ll_xattr_get_common_3_11(struct dentry *dentry, const char *name,
820 void *buffer, size_t size, int handler_flags)
822 const struct xattr_handler *handler = get_xattr_handler(handler_flags);
827 return ll_xattr_get_common(handler, dentry, dentry->d_inode, name,
831 static int ll_xattr_get_3_11(struct dentry *dentry, const char *name,
832 void *buffer, size_t size, int handler_flags)
834 const struct xattr_handler *handler = get_xattr_handler(handler_flags);
839 return ll_xattr_get(handler, dentry, dentry->d_inode, name, buffer,
843 static int ll_xattr_set_common_3_11(struct dentry *dentry, const char *name,
844 const void *value, size_t size, int flags,
847 const struct xattr_handler *handler = get_xattr_handler(handler_flags);
852 return ll_xattr_set_common(handler, NULL, dentry, dentry->d_inode, name,
856 static int ll_xattr_set_3_11(struct dentry *dentry, const char *name,
857 const void *value, size_t size, int flags,
860 const struct xattr_handler *handler = get_xattr_handler(handler_flags);
865 return ll_xattr_set(handler, NULL, dentry, dentry->d_inode, name, value,
870 static const struct xattr_handler ll_user_xattr_handler = {
871 .prefix = XATTR_USER_PREFIX,
872 .flags = XATTR_USER_T,
873 #if defined(HAVE_XATTR_HANDLER_SIMPLIFIED)
874 .get = ll_xattr_get_common_4_3,
875 .set = ll_xattr_set_common_4_3,
876 #elif !defined(HAVE_USER_NAMESPACE_ARG) && \
877 !defined(HAVE_XATTR_HANDLER_INODE_PARAM)
878 .get = ll_xattr_get_common_3_11,
879 .set = ll_xattr_set_common_3_11,
881 .get = ll_xattr_get_common,
882 .set = ll_xattr_set_common,
886 static const struct xattr_handler ll_trusted_xattr_handler = {
887 .prefix = XATTR_TRUSTED_PREFIX,
888 .flags = XATTR_TRUSTED_T,
889 #if defined(HAVE_XATTR_HANDLER_SIMPLIFIED)
890 .get = ll_xattr_get_4_3,
891 .set = ll_xattr_set_4_3,
892 #elif !defined(HAVE_USER_NAMESPACE_ARG) && \
893 !defined(HAVE_XATTR_HANDLER_INODE_PARAM)
894 .get = ll_xattr_get_3_11,
895 .set = ll_xattr_set_3_11,
902 static const struct xattr_handler ll_security_xattr_handler = {
903 .prefix = XATTR_SECURITY_PREFIX,
904 .flags = XATTR_SECURITY_T,
905 #if defined(HAVE_XATTR_HANDLER_SIMPLIFIED)
906 .get = ll_xattr_get_common_4_3,
907 .set = ll_xattr_set_common_4_3,
908 #elif !defined(HAVE_USER_NAMESPACE_ARG) && \
909 !defined(HAVE_XATTR_HANDLER_INODE_PARAM)
910 .get = ll_xattr_get_common_3_11,
911 .set = ll_xattr_set_common_3_11,
913 .get = ll_xattr_get_common,
914 .set = ll_xattr_set_common,
918 static const struct xattr_handler ll_acl_access_xattr_handler = {
919 #ifdef HAVE_XATTR_HANDLER_NAME
920 .name = XATTR_NAME_POSIX_ACL_ACCESS,
922 .prefix = XATTR_NAME_POSIX_ACL_ACCESS,
924 .flags = XATTR_ACL_ACCESS_T,
925 #if defined(HAVE_XATTR_HANDLER_SIMPLIFIED)
926 .get = ll_xattr_get_common_4_3,
927 .set = ll_xattr_set_common_4_3,
928 #elif !defined(HAVE_USER_NAMESPACE_ARG) && \
929 !defined(HAVE_XATTR_HANDLER_INODE_PARAM)
930 .get = ll_xattr_get_common_3_11,
931 .set = ll_xattr_set_common_3_11,
933 .get = ll_xattr_get_common,
934 .set = ll_xattr_set_common,
938 static const struct xattr_handler ll_acl_default_xattr_handler = {
939 #ifdef HAVE_XATTR_HANDLER_NAME
940 .name = XATTR_NAME_POSIX_ACL_DEFAULT,
942 .prefix = XATTR_NAME_POSIX_ACL_DEFAULT,
944 .flags = XATTR_ACL_DEFAULT_T,
945 #if defined(HAVE_XATTR_HANDLER_SIMPLIFIED)
946 .get = ll_xattr_get_common_4_3,
947 .set = ll_xattr_set_common_4_3,
948 #elif !defined(HAVE_USER_NAMESPACE_ARG) && \
949 !defined(HAVE_XATTR_HANDLER_INODE_PARAM)
950 .get = ll_xattr_get_common_3_11,
951 .set = ll_xattr_set_common_3_11,
953 .get = ll_xattr_get_common,
954 .set = ll_xattr_set_common,
958 static const struct xattr_handler ll_lustre_xattr_handler = {
959 .prefix = XATTR_LUSTRE_PREFIX,
960 .flags = XATTR_LUSTRE_T,
961 #if defined(HAVE_XATTR_HANDLER_SIMPLIFIED)
962 .get = ll_xattr_get_4_3,
963 .set = ll_xattr_set_4_3,
964 #elif !defined(HAVE_USER_NAMESPACE_ARG) && \
965 !defined(HAVE_XATTR_HANDLER_INODE_PARAM)
966 .get = ll_xattr_get_3_11,
967 .set = ll_xattr_set_3_11,
974 const struct xattr_handler *ll_xattr_handlers[] = {
975 &ll_user_xattr_handler,
976 &ll_trusted_xattr_handler,
977 &ll_security_xattr_handler,
978 #ifdef CONFIG_LUSTRE_FS_POSIX_ACL
979 &ll_acl_access_xattr_handler,
980 &ll_acl_default_xattr_handler,
982 &ll_lustre_xattr_handler,