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. */
119 if (!value && flags == XATTR_REPLACE)
120 valid = OBD_MD_FLXATTRRM;
122 valid = OBD_MD_FLXATTR;
124 /* FIXME: enable IMA when the conditions are ready */
125 if (handler->flags == XATTR_SECURITY_T &&
126 (!strcmp(name, "ima") || !strcmp(name, "evm")))
127 GOTO(out, rc = -EOPNOTSUPP);
129 rc = xattr_type_filter(sbi, handler);
133 if ((handler->flags == XATTR_ACL_ACCESS_T ||
134 handler->flags == XATTR_ACL_DEFAULT_T) &&
135 !inode_owner_or_capable(map, inode))
136 GOTO(out, rc = -EPERM);
138 /* b10667: ignore lustre special xattr for now */
139 if (!strcmp(name, "hsm") ||
140 ((handler->flags == XATTR_TRUSTED_T && !strcmp(name, "lov")) ||
141 (handler->flags == XATTR_LUSTRE_T && !strcmp(name, "lov"))))
144 rc = ll_security_secctx_name_filter(sbi, handler->flags, name);
149 * In user.* namespace, only regular files and directories can have
150 * extended attributes.
152 if (handler->flags == XATTR_USER_T) {
153 if (!S_ISREG(inode->i_mode) && !S_ISDIR(inode->i_mode))
154 GOTO(out, rc = -EPERM);
157 /* This check is required for compatibility with 2.14, in which
158 * encryption context is stored in security.c xattr.
159 * Setting the encryption context should only be possible by llcrypt
160 * when defining an encryption policy on a directory.
161 * When new files/dirs are created in an encrypted dir, the enc
162 * context is set directly in the create request.
164 if (handler->flags == XATTR_SECURITY_T && strcmp(name, "c") == 0)
165 GOTO(out, rc = -EPERM);
167 if (handler->flags == XATTR_TRUSTED_T && !strcmp(name, "dmv") &&
168 (valid & OBD_MD_FLXATTR)) {
169 const struct lmv_user_md *clum;
170 struct lmv_user_md *lum;
173 GOTO(out, rc = -EINVAL);
175 clum = (const struct lmv_user_md *)value;
176 if (size != sizeof(*clum))
177 GOTO(out, rc = -EINVAL);
179 if (clum->lum_magic != LMV_USER_MAGIC)
180 GOTO(out, rc = -EINVAL);
182 /* skip default dmv */
183 if (clum->lum_stripe_offset == LMV_OFFSET_DEFAULT &&
184 clum->lum_stripe_count == 1 &&
185 clum->lum_hash_type == LMV_HASH_TYPE_UNKNOWN)
190 GOTO(out, rc = -ENOMEM);
193 rc = ll_dir_setstripe(inode, (struct lov_user_md *)lum, 1);
198 fullname = kasprintf(GFP_KERNEL, "%s%s", xattr_prefix(handler), name);
200 GOTO(out, rc = -ENOMEM);
202 rc = md_setxattr(sbi->ll_md_exp, ll_inode2fid(inode), valid, fullname,
203 pv, size, flags, ll_i2suppgid(inode), &req);
206 if (rc == -EOPNOTSUPP && handler->flags == XATTR_USER_T) {
207 LCONSOLE_INFO("Disabling user_xattr feature because it is not supported on the server\n");
208 clear_bit(LL_SBI_USER_XATTR, sbi->ll_flags);
212 ll_i2info(inode)->lli_synced_to_mds = false;
214 ptlrpc_req_finished(req);
216 ll_stats_ops_tally(ll_i2sbi(inode), valid == OBD_MD_FLXATTRRM ?
217 LPROC_LL_REMOVEXATTR : LPROC_LL_SETXATTR,
218 ktime_us_delta(ktime_get(), kstart));
220 ll_clear_inode_lock_owner(inode);
225 static int get_hsm_state(struct inode *inode, u32 *hus_states)
227 struct md_op_data *op_data;
228 struct hsm_user_state *hus;
235 op_data = ll_prep_md_op_data(NULL, inode, NULL, NULL, 0, 0,
236 LUSTRE_OPC_ANY, hus);
237 if (!IS_ERR(op_data)) {
238 rc = obd_iocontrol(LL_IOC_HSM_STATE_GET, ll_i2mdexp(inode),
239 sizeof(*op_data), op_data, NULL);
241 *hus_states = hus->hus_states;
243 CDEBUG(D_VFSTRACE, "obd_iocontrol failed. rc = %d\n",
246 ll_finish_md_op_data(op_data);
248 rc = PTR_ERR(op_data);
249 CDEBUG(D_VFSTRACE, "Could not prepare the opdata. rc = %d\n",
256 static int ll_adjust_lum(struct inode *inode, struct lov_user_md *lump,
259 struct lov_comp_md_v1 *comp_v1 = (struct lov_comp_md_v1 *)lump;
260 struct lov_user_md *v1 = lump;
261 bool need_clear_release = false;
262 bool release_checked = false;
263 bool is_composite = false;
271 if (lump->lmm_magic == LOV_USER_MAGIC_COMP_V1) {
272 if (size < sizeof(*comp_v1))
275 entry_count = comp_v1->lcm_entry_count;
276 if (size < offsetof(typeof(*comp_v1), lcm_entries[entry_count]))
281 for (i = 0; i < entry_count; i++) {
282 if (lump->lmm_magic == LOV_USER_MAGIC_COMP_V1) {
285 if (comp_v1->lcm_entries[i].lcme_offset + sizeof(*v1) >
289 ptr += comp_v1->lcm_entries[i].lcme_offset;
290 v1 = (struct lov_user_md *)ptr;
294 * Attributes that are saved via getxattr will always
295 * have the stripe_offset as 0. Instead, the MDS
296 * should be allowed to pick the starting OST index.
299 if (!is_composite && v1->lmm_stripe_offset == 0)
300 v1->lmm_stripe_offset = -1;
302 /* Avoid anyone directly setting the RELEASED flag. */
303 if (v1->lmm_pattern & LOV_PATTERN_F_RELEASED) {
304 if (!release_checked) {
307 rc = get_hsm_state(inode, &state);
311 if (!(state & HS_ARCHIVED))
312 need_clear_release = true;
313 release_checked = true;
315 if (need_clear_release)
316 v1->lmm_pattern ^= LOV_PATTERN_F_RELEASED;
323 static int ll_setstripe_ea(struct dentry *dentry, struct lov_user_md *lump,
326 struct inode *inode = dentry->d_inode;
330 * It is possible to set an xattr to a "" value of zero size.
331 * For this case we are going to treat it as a removal.
336 if (size && size < sizeof(*lump)) {
337 /* ll_adjust_lum() or ll_lov_user_md_size() might access
338 * before size - just give up now.
342 rc = ll_adjust_lum(inode, lump, size);
346 if (lump && S_ISREG(inode->i_mode)) {
347 u64 it_flags = FMODE_WRITE;
350 lum_size = ll_lov_user_md_size(lump);
351 if (lum_size < 0 || size < lum_size)
354 rc = ll_lov_setstripe_ea_info(inode, dentry, it_flags, lump,
357 * b=10667: ignore -EEXIST.
358 * Silently eat error on setting trusted.lov/lustre.lov
359 * attribute for platforms that added the default option
360 * to copy all attributes in 'cp' command. Both rsync and
361 * tar --xattrs also will try to set LOVEA for existing
366 } else if (S_ISDIR(inode->i_mode)) {
367 if (size != 0 && size < sizeof(struct lov_user_md))
370 rc = ll_dir_setstripe(inode, lump, 0);
376 #ifndef HAVE_USER_NAMESPACE_ARG
377 #define ll_xattr_set(hd, ns, de, inode, name, value, size, flags) \
378 ll_xattr_set(hd, de, inode, name, value, size, flags)
381 static int ll_xattr_set(const struct xattr_handler *handler,
382 struct mnt_idmap *map,
383 struct dentry *dentry, struct inode *inode,
384 const char *name, const void *value, size_t size,
387 ktime_t kstart = ktime_get();
388 int op_type = flags == XATTR_REPLACE ? LPROC_LL_REMOVEXATTR :
395 /* VFS has locked the inode before calling this */
396 ll_set_inode_lock_owner(inode);
398 CDEBUG(D_VFSTRACE, "VFS Op:inode=" DFID "(%p), xattr %s\n",
399 PFID(ll_inode2fid(inode)), inode, name);
401 /* lustre/trusted.lov.xxx would be passed through xattr API */
402 if (!strcmp(name, "lov")) {
403 rc = ll_setstripe_ea(dentry, (struct lov_user_md *)value,
405 ll_stats_ops_tally(ll_i2sbi(inode), op_type,
406 ktime_us_delta(ktime_get(), kstart));
408 } else if (!strcmp(name, "lma") || !strcmp(name, "link")) {
409 ll_stats_ops_tally(ll_i2sbi(inode), op_type,
410 ktime_us_delta(ktime_get(), kstart));
414 if (strncmp(name, "lov.", 4) == 0 &&
415 (__swab32(((struct lov_user_md *)value)->lmm_magic) &
416 le32_to_cpu(LOV_MAGIC_MASK)) == le32_to_cpu(LOV_MAGIC_MAGIC))
417 lustre_swab_lov_user_md((struct lov_user_md *)value, 0);
419 rc = ll_xattr_set_common(handler, map, dentry, inode, name,
422 ll_clear_inode_lock_owner(inode);
427 int ll_xattr_list(struct inode *inode, const char *name, int type, void *buffer,
428 size_t size, u64 valid)
430 struct ll_inode_info *lli = ll_i2info(inode);
431 struct ll_sb_info *sbi = ll_i2sbi(inode);
432 struct ptlrpc_request *req = NULL;
437 /* This check is required for compatibility with 2.14, in which
438 * encryption context is stored in security.c xattr. Accessing the
439 * encryption context should only be possible by llcrypt.
441 if (type == XATTR_SECURITY_T && strcmp(name, "security.c") == 0)
442 GOTO(out_xattr, rc = -EPERM);
444 if (sbi->ll_xattr_cache_enabled && type != XATTR_ACL_ACCESS_T &&
445 (type != XATTR_SECURITY_T || !ll_xattr_is_seclabel(name)) &&
446 (type != XATTR_TRUSTED_T || strcmp(name, XATTR_NAME_SOM))) {
447 rc = ll_xattr_cache_get(inode, name, buffer, size, valid);
449 goto getxattr_nocache;
453 /* Add "system.posix_acl_access" to the list */
454 if (lli->lli_posix_acl && valid & OBD_MD_FLXATTRLS) {
456 rc += sizeof(XATTR_NAME_ACL_ACCESS);
457 } else if (size - rc >= sizeof(XATTR_NAME_ACL_ACCESS)) {
458 memcpy(buffer + rc, XATTR_NAME_ACL_ACCESS,
459 sizeof(XATTR_NAME_ACL_ACCESS));
460 rc += sizeof(XATTR_NAME_ACL_ACCESS);
462 GOTO(out_xattr, rc = -ERANGE);
467 rc = md_getxattr(sbi->ll_md_exp, ll_inode2fid(inode), valid,
472 /* only detect the xattr size */
477 GOTO(out, rc = -ERANGE);
479 /* do not need swab xattr data */
480 xdata = req_capsule_server_sized_get(&req->rq_pill, &RMF_EADATA,
483 GOTO(out, rc = -EPROTO);
485 memcpy(buffer, xdata, rc);
491 if (rc == -EOPNOTSUPP && type == XATTR_USER_T) {
492 LCONSOLE_INFO("%s: disabling user_xattr feature because it is not supported on the server: rc = %d\n",
494 clear_bit(LL_SBI_USER_XATTR, sbi->ll_flags);
497 ptlrpc_req_finished(req);
501 static int ll_xattr_get_common(const struct xattr_handler *handler,
502 struct dentry *dentry,
504 const char *name, void *buffer, size_t size)
506 struct ll_sb_info *sbi = ll_i2sbi(inode);
507 ktime_t kstart = ktime_get();
513 rc = xattr_type_filter(sbi, handler);
517 rc = ll_security_secctx_name_filter(sbi, handler->flags, name);
521 #ifdef CONFIG_LUSTRE_FS_POSIX_ACL
522 /* posix acl is under protection of LOOKUP lock. when calling to this,
523 * we just have path resolution to the target inode, so we have great
524 * chance that cached ACL is uptodate.
526 if (handler->flags == XATTR_ACL_ACCESS_T) {
527 struct ll_inode_info *lli = ll_i2info(inode);
528 struct posix_acl *acl;
530 read_lock(&lli->lli_lock);
531 acl = posix_acl_dup(lli->lli_posix_acl);
532 read_unlock(&lli->lli_lock);
537 rc = posix_acl_to_xattr(&init_user_ns, acl, buffer, size);
538 posix_acl_release(acl);
541 if (handler->flags == XATTR_ACL_DEFAULT_T && !S_ISDIR(inode->i_mode))
545 fullname = kasprintf(GFP_KERNEL, "%s%s", xattr_prefix(handler), name);
549 rc = ll_xattr_list(inode, fullname, handler->flags, buffer, size,
552 ll_stats_ops_tally(ll_i2sbi(inode), LPROC_LL_GETXATTR,
553 ktime_us_delta(ktime_get(), kstart));
558 static ssize_t ll_getxattr_lov(struct inode *inode, void *buf, size_t buf_size)
562 if (S_ISREG(inode->i_mode)) {
563 struct cl_object *obj = ll_i2info(inode)->lli_clob;
564 struct cl_layout cl = {
565 .cl_buf.lb_buf = buf,
566 .cl_buf.lb_len = buf_size,
574 env = cl_env_get(&refcheck);
576 RETURN(PTR_ERR(env));
578 rc = cl_object_layout_get(env, obj, &cl);
583 GOTO(out_env, rc = -ENODATA);
590 LASSERT(buf && rc <= buf_size);
593 * Do not return layout gen for getxattr() since
594 * otherwise it would confuse tar --xattr by
595 * recognizing layout gen as stripe offset when the
596 * file is restored. See LU-2809.
598 if ((((struct lov_mds_md *)buf)->lmm_magic &
599 __swab32(LOV_MAGIC_MAGIC)) == __swab32(LOV_MAGIC_MAGIC))
600 lustre_swab_lov_user_md((struct lov_user_md *)buf,
603 switch (((struct lov_mds_md *)buf)->lmm_magic) {
606 case LOV_MAGIC_SPECIFIC:
607 ((struct lov_mds_md *)buf)->lmm_layout_gen = 0;
609 case LOV_MAGIC_COMP_V1:
610 case LOV_MAGIC_FOREIGN:
614 CERROR("%s: bad LOV magic %08x on "DFID": rc = %zd\n",
615 ll_i2sbi(inode)->ll_fsname,
616 ((struct lov_mds_md *)buf)->lmm_magic,
617 PFID(ll_inode2fid(inode)), rc);
622 cl_env_put(env, &refcheck);
625 } else if (S_ISDIR(inode->i_mode)) {
626 struct ptlrpc_request *req = NULL;
627 struct ptlrpc_request *root_req = NULL;
628 struct lov_mds_md *lmm = NULL;
631 rc = ll_dir_getstripe_default(inode, (void **)&lmm, &lmm_size,
637 GOTO(out_req, rc = lmm_size);
639 if (buf_size < lmm_size)
640 GOTO(out_req, rc = -ERANGE);
642 memcpy(buf, lmm, lmm_size);
643 GOTO(out_req, rc = lmm_size);
646 ptlrpc_req_finished(req);
648 ptlrpc_req_finished(root_req);
656 static int ll_xattr_get(const struct xattr_handler *handler,
657 struct dentry *dentry, struct inode *inode,
658 const char *name, void *buffer, size_t size)
663 CDEBUG(D_VFSTRACE, "VFS Op:inode="DFID"(%p), xattr %s\n",
664 PFID(ll_inode2fid(inode)), inode, name);
666 if (!strcmp(name, "lov")) {
667 ll_stats_ops_tally(ll_i2sbi(inode), LPROC_LL_GETXATTR, 1);
669 return ll_getxattr_lov(inode, buffer, size);
672 return ll_xattr_get_common(handler, dentry, inode, name, buffer, size);
675 ssize_t ll_listxattr(struct dentry *dentry, char *buffer, size_t size)
677 struct inode *inode = dentry->d_inode;
678 struct ll_sb_info *sbi = ll_i2sbi(inode);
679 ktime_t kstart = ktime_get();
686 CDEBUG(D_VFSTRACE, "VFS Op:inode="DFID"(%p)\n",
687 PFID(ll_inode2fid(inode)), inode);
689 rc = ll_xattr_list(inode, NULL, XATTR_OTHER_T, buffer, size,
695 * If we're being called to get the size of the xattr list
696 * (size == 0) then just assume that a lustre.lov xattr
706 const struct xattr_handler *xh = get_xattr_type(xattr_name);
707 bool hide_xattr = false;
709 /* Hide virtual project id xattr from the list when
710 * parent has the inherit flag and the same project id,
711 * so project id won't be messed up by copying the xattrs
712 * when mv to a tree with different project id.
714 if (xh && xh->flags == XATTR_TRUSTED_T &&
715 strcmp(xattr_name, XATTR_NAME_PROJID) == 0) {
716 struct inode *dir = d_inode(dentry->d_parent);
718 if ((ll_i2info(inode)->lli_projid ==
719 ll_i2info(dir)->lli_projid) &&
720 test_bit(LLIF_PROJECT_INHERIT,
721 &ll_i2info(dir)->lli_flags))
723 } else if (xh && xh->flags == XATTR_SECURITY_T &&
724 strcmp(xattr_name, "security.c") == 0) {
725 /* Listing xattrs should not expose encryption
726 * context. There is no handler defined for
727 * XATTR_ENCRYPTION_PREFIX, so this test is just
728 * needed for compatibility with 2.14, in which
729 * encryption context is stored in security.c xattr.
734 len = strnlen(xattr_name, rem - 1) + 1;
736 if (!xattr_type_filter(sbi, hide_xattr ? NULL : xh)) {
737 /* Skip OK xattr type, leave it in buffer. */
743 * Move up remaining xattrs in buffer
744 * removing the xattr that is not OK.
746 memmove(xattr_name, xattr_name + len, rem);
750 rc2 = ll_getxattr_lov(inode, NULL, 0);
757 if (size < rc + sizeof(XATTR_LUSTRE_LOV))
760 memcpy(buffer + rc, XATTR_LUSTRE_LOV, sizeof(XATTR_LUSTRE_LOV));
763 ll_stats_ops_tally(ll_i2sbi(inode), LPROC_LL_LISTXATTR,
764 ktime_us_delta(ktime_get(), kstart));
766 RETURN(rc + sizeof(XATTR_LUSTRE_LOV));
769 #ifdef HAVE_XATTR_HANDLER_SIMPLIFIED
770 static int ll_xattr_get_common_4_3(const struct xattr_handler *handler,
771 struct dentry *dentry, const char *name,
772 void *buffer, size_t size)
774 return ll_xattr_get_common(handler, dentry, dentry->d_inode, name,
778 static int ll_xattr_get_4_3(const struct xattr_handler *handler,
779 struct dentry *dentry, const char *name,
780 void *buffer, size_t size)
782 return ll_xattr_get(handler, dentry, dentry->d_inode, name, buffer,
786 static int ll_xattr_set_common_4_3(const struct xattr_handler *handler,
787 struct dentry *dentry, const char *name,
788 const void *value, size_t size, int flags)
790 return ll_xattr_set_common(handler, dentry, dentry->d_inode, name,
794 static int ll_xattr_set_4_3(const struct xattr_handler *handler,
795 struct dentry *dentry, const char *name,
796 const void *value, size_t size, int flags)
798 return ll_xattr_set(handler, dentry, dentry->d_inode, name, value,
802 #elif !defined(HAVE_USER_NAMESPACE_ARG) && \
803 !defined(HAVE_XATTR_HANDLER_INODE_PARAM)
804 const struct xattr_handler *get_xattr_handler(int handler_flag)
808 while (ll_xattr_handlers[i]) {
809 if (ll_xattr_handlers[i]->flags == handler_flag)
810 return ll_xattr_handlers[i];
816 static int ll_xattr_get_common_3_11(struct dentry *dentry, const char *name,
817 void *buffer, size_t size, int handler_flags)
819 const struct xattr_handler *handler = get_xattr_handler(handler_flags);
824 return ll_xattr_get_common(handler, dentry, dentry->d_inode, name,
828 static int ll_xattr_get_3_11(struct dentry *dentry, const char *name,
829 void *buffer, size_t size, int handler_flags)
831 const struct xattr_handler *handler = get_xattr_handler(handler_flags);
836 return ll_xattr_get(handler, dentry, dentry->d_inode, name, buffer,
840 static int ll_xattr_set_common_3_11(struct dentry *dentry, const char *name,
841 const void *value, size_t size, int flags,
844 const struct xattr_handler *handler = get_xattr_handler(handler_flags);
849 return ll_xattr_set_common(handler, NULL, dentry, dentry->d_inode, name,
853 static int ll_xattr_set_3_11(struct dentry *dentry, const char *name,
854 const void *value, size_t size, int flags,
857 const struct xattr_handler *handler = get_xattr_handler(handler_flags);
862 return ll_xattr_set(handler, NULL, dentry, dentry->d_inode, name, value,
867 static const struct xattr_handler ll_user_xattr_handler = {
868 .prefix = XATTR_USER_PREFIX,
869 .flags = XATTR_USER_T,
870 #if defined(HAVE_XATTR_HANDLER_SIMPLIFIED)
871 .get = ll_xattr_get_common_4_3,
872 .set = ll_xattr_set_common_4_3,
873 #elif !defined(HAVE_USER_NAMESPACE_ARG) && \
874 !defined(HAVE_XATTR_HANDLER_INODE_PARAM)
875 .get = ll_xattr_get_common_3_11,
876 .set = ll_xattr_set_common_3_11,
878 .get = ll_xattr_get_common,
879 .set = ll_xattr_set_common,
883 static const struct xattr_handler ll_trusted_xattr_handler = {
884 .prefix = XATTR_TRUSTED_PREFIX,
885 .flags = XATTR_TRUSTED_T,
886 #if defined(HAVE_XATTR_HANDLER_SIMPLIFIED)
887 .get = ll_xattr_get_4_3,
888 .set = ll_xattr_set_4_3,
889 #elif !defined(HAVE_USER_NAMESPACE_ARG) && \
890 !defined(HAVE_XATTR_HANDLER_INODE_PARAM)
891 .get = ll_xattr_get_3_11,
892 .set = ll_xattr_set_3_11,
899 static const struct xattr_handler ll_security_xattr_handler = {
900 .prefix = XATTR_SECURITY_PREFIX,
901 .flags = XATTR_SECURITY_T,
902 #if defined(HAVE_XATTR_HANDLER_SIMPLIFIED)
903 .get = ll_xattr_get_common_4_3,
904 .set = ll_xattr_set_common_4_3,
905 #elif !defined(HAVE_USER_NAMESPACE_ARG) && \
906 !defined(HAVE_XATTR_HANDLER_INODE_PARAM)
907 .get = ll_xattr_get_common_3_11,
908 .set = ll_xattr_set_common_3_11,
910 .get = ll_xattr_get_common,
911 .set = ll_xattr_set_common,
915 static const struct xattr_handler ll_acl_access_xattr_handler = {
916 #ifdef HAVE_XATTR_HANDLER_NAME
917 .name = XATTR_NAME_POSIX_ACL_ACCESS,
919 .prefix = XATTR_NAME_POSIX_ACL_ACCESS,
921 .flags = XATTR_ACL_ACCESS_T,
922 #if defined(HAVE_XATTR_HANDLER_SIMPLIFIED)
923 .get = ll_xattr_get_common_4_3,
924 .set = ll_xattr_set_common_4_3,
925 #elif !defined(HAVE_USER_NAMESPACE_ARG) && \
926 !defined(HAVE_XATTR_HANDLER_INODE_PARAM)
927 .get = ll_xattr_get_common_3_11,
928 .set = ll_xattr_set_common_3_11,
930 .get = ll_xattr_get_common,
931 .set = ll_xattr_set_common,
935 static const struct xattr_handler ll_acl_default_xattr_handler = {
936 #ifdef HAVE_XATTR_HANDLER_NAME
937 .name = XATTR_NAME_POSIX_ACL_DEFAULT,
939 .prefix = XATTR_NAME_POSIX_ACL_DEFAULT,
941 .flags = XATTR_ACL_DEFAULT_T,
942 #if defined(HAVE_XATTR_HANDLER_SIMPLIFIED)
943 .get = ll_xattr_get_common_4_3,
944 .set = ll_xattr_set_common_4_3,
945 #elif !defined(HAVE_USER_NAMESPACE_ARG) && \
946 !defined(HAVE_XATTR_HANDLER_INODE_PARAM)
947 .get = ll_xattr_get_common_3_11,
948 .set = ll_xattr_set_common_3_11,
950 .get = ll_xattr_get_common,
951 .set = ll_xattr_set_common,
955 static const struct xattr_handler ll_lustre_xattr_handler = {
956 .prefix = XATTR_LUSTRE_PREFIX,
957 .flags = XATTR_LUSTRE_T,
958 #if defined(HAVE_XATTR_HANDLER_SIMPLIFIED)
959 .get = ll_xattr_get_4_3,
960 .set = ll_xattr_set_4_3,
961 #elif !defined(HAVE_USER_NAMESPACE_ARG) && \
962 !defined(HAVE_XATTR_HANDLER_INODE_PARAM)
963 .get = ll_xattr_get_3_11,
964 .set = ll_xattr_set_3_11,
971 const struct xattr_handler *ll_xattr_handlers[] = {
972 &ll_user_xattr_handler,
973 &ll_trusted_xattr_handler,
974 &ll_security_xattr_handler,
975 #ifdef CONFIG_LUSTRE_FS_POSIX_ACL
976 &ll_acl_access_xattr_handler,
977 &ll_acl_default_xattr_handler,
979 &ll_lustre_xattr_handler,