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/
31 * lustre/mdt/mdt_xattr.c
33 * Lustre Metadata Target (mdt) extended attributes management.
35 * Author: Peter Braam <braam@clusterfs.com>
36 * Author: Andreas Dilger <adilger@clusterfs.com>
37 * Author: Phil Schwan <phil@clusterfs.com>
38 * Author: Huang Hua <huanghua@clusterfs.com>
41 #define DEBUG_SUBSYSTEM S_MDS
43 #include <linux/xattr.h>
44 #include <obd_class.h>
45 #include <lustre_nodemap.h>
46 #include <lustre_acl.h>
47 #include <lustre_lmv.h>
48 #include "mdt_internal.h"
51 /* return EADATA length to the caller. negative value means error */
52 static int mdt_getxattr_pack_reply(struct mdt_thread_info *info)
54 struct req_capsule *pill = info->mti_pill;
55 struct ptlrpc_request *req = mdt_info_req(info);
56 const char *xattr_name;
58 static const char user_string[] = "user.";
64 valid = info->mti_body->mbo_valid & (OBD_MD_FLXATTR | OBD_MD_FLXATTRLS);
66 /* Determine how many bytes we need */
67 if (valid == OBD_MD_FLXATTR) {
68 xattr_name = req_capsule_client_get(pill, &RMF_NAME);
72 if (!(exp_connect_flags(req->rq_export) & OBD_CONNECT_XATTR) &&
73 !strncmp(xattr_name, user_string, sizeof(user_string) - 1))
76 size = mo_xattr_get(info->mti_env,
77 mdt_object_child(info->mti_object),
78 &LU_BUF_NULL, xattr_name);
79 if (size == -ENODATA) {
80 /* XXX: Some client code will not handle -ENODATA
81 * for XATTR_NAME_LOV (trusted.lov) properly.
83 if (strcmp(xattr_name, XATTR_NAME_LOV) == 0)
90 } else if (valid == OBD_MD_FLXATTRLS) {
92 size = mo_xattr_list(info->mti_env,
93 mdt_object_child(info->mti_object),
95 } else if (valid == OBD_MD_FLXATTRALL) {
97 /* N.B. eadatasize = 0 is not valid for FLXATTRALL */
98 /* We could calculate accurate sizes, but this would
99 * introduce a lot of overhead, let's do it later...
101 size = info->mti_body->mbo_eadatasize;
102 if (size <= 0 || size > info->mti_mdt->mdt_max_ea_size ||
103 size & (sizeof(__u32) - 1)) {
104 DEBUG_REQ(D_ERROR, req,
105 "%s: invalid EA size(%d) for FLXATTRALL\n",
106 mdt_obd_name(info->mti_mdt), size);
109 req_capsule_set_size(pill, &RMF_EAVALS, RCL_SERVER, size);
110 req_capsule_set_size(pill, &RMF_EAVALS_LENS, RCL_SERVER, size);
112 CDEBUG(D_INFO, "Valid bits: %#llx\n",
113 info->mti_body->mbo_valid);
118 if (size != -EOPNOTSUPP && size != -ENOENT)
119 CERROR("%s: error geting EA size for '%s': rc = %d\n",
120 mdt_obd_name(info->mti_mdt), xattr_name, size);
124 if (req_capsule_has_field(pill, &RMF_ACL, RCL_SERVER))
125 req_capsule_set_size(pill, &RMF_ACL, RCL_SERVER,
126 LUSTRE_POSIX_ACL_MAX_SIZE_OLD);
128 req_capsule_set_size(pill, &RMF_EADATA, RCL_SERVER,
129 info->mti_body->mbo_eadatasize == 0 ? 0 : size);
131 rc2 = req_capsule_server_pack(pill);
135 if (OBD_FAIL_CHECK(OBD_FAIL_MDS_GETXATTR_PACK))
138 RETURN(rc < 0 ? rc : size);
141 static int mdt_nodemap_map_acl(struct mdt_thread_info *info, void *buf,
142 size_t size, const char *name,
143 enum nodemap_tree_type tree_type)
145 struct lu_nodemap *nodemap;
146 struct obd_export *exp = info->mti_exp;
151 if (strcmp(name, XATTR_NAME_ACL_ACCESS) == 0 ||
152 strcmp(name, XATTR_NAME_ACL_DEFAULT) == 0) {
153 if (size > info->mti_mdt->mdt_max_ea_size ||
154 (!exp_connect_large_acl(exp) &&
155 size > LUSTRE_POSIX_ACL_MAX_SIZE_OLD))
156 GOTO(out, rc = -ERANGE);
158 nodemap = nodemap_get_from_exp(exp);
160 GOTO(out, rc = PTR_ERR(nodemap));
162 rc = nodemap_map_acl(nodemap, buf, size, tree_type);
163 nodemap_putref(nodemap);
171 static int mdt_getxattr_all(struct mdt_thread_info *info,
172 struct mdt_body *reqbody, struct mdt_body *repbody,
173 struct lu_buf *buf, struct md_object *next)
175 const struct lu_env *env = info->mti_env;
176 char *v, *b, *eadatahead, *eadatatail;
178 int eadatasize, eavallen = 0, eavallens = 0, rc;
183 * The format of the pill is the following:
184 * EADATA: attr1\0attr2\0...attrn\0
185 * EAVALS: val1val2...valn
186 * EAVALS_LENS: 4,4,...4
189 eadatahead = buf->lb_buf;
191 /* Fill out EADATA first */
192 rc = mo_xattr_list(env, next, buf);
194 GOTO(out_shrink, rc);
197 eadatatail = eadatahead + eadatasize;
199 v = req_capsule_server_get(info->mti_pill, &RMF_EAVALS);
200 sizes = req_capsule_server_get(info->mti_pill, &RMF_EAVALS_LENS);
202 /* Fill out EAVALS and EAVALS_LENS */
203 for (b = eadatahead; b < eadatatail; b += strlen(b) + 1, v += rc) {
205 buf->lb_len = reqbody->mbo_eadatasize - eavallen;
206 rc = mo_xattr_get(env, next, buf, b);
208 GOTO(out_shrink, rc);
209 rc = mdt_nodemap_map_acl(info, buf->lb_buf, rc, b,
210 NODEMAP_FS_TO_CLIENT);
212 GOTO(out_shrink, rc);
213 sizes[eavallens] = rc;
224 repbody->mbo_aclsize = eavallen;
225 repbody->mbo_max_mdsize = eavallens;
227 req_capsule_shrink(info->mti_pill, &RMF_EAVALS, eavallen, RCL_SERVER);
228 req_capsule_shrink(info->mti_pill, &RMF_EAVALS_LENS,
229 eavallens * sizeof(__u32), RCL_SERVER);
230 req_capsule_shrink(info->mti_pill, &RMF_EADATA, eadatasize, RCL_SERVER);
237 int mdt_getxattr(struct mdt_thread_info *info)
239 struct ptlrpc_request *req = mdt_info_req(info);
240 struct mdt_body *reqbody;
241 struct mdt_body *repbody = NULL;
242 struct md_object *next;
246 ktime_t kstart = ktime_get();
249 LASSERT(info->mti_object != NULL);
250 LASSERT(lu_object_assert_exists(&info->mti_object->mot_obj));
252 CDEBUG(D_INODE, "getxattr "DFID"\n", PFID(&info->mti_body->mbo_fid1));
254 rc = req_check_sepol(info->mti_pill);
256 RETURN(err_serious(rc));
258 reqbody = req_capsule_client_get(info->mti_pill, &RMF_MDT_BODY);
260 RETURN(err_serious(-EFAULT));
262 rc = mdt_init_ucred(info, reqbody);
264 RETURN(err_serious(rc));
266 next = mdt_object_child(info->mti_object);
267 easize = mdt_getxattr_pack_reply(info);
268 if (easize == -ENODATA)
269 GOTO(out, rc = easize);
271 GOTO(out, rc = err_serious(easize));
273 repbody = req_capsule_server_get(info->mti_pill, &RMF_MDT_BODY);
274 LASSERT(repbody != NULL);
276 /* No need further getxattr. */
277 if (easize == 0 || reqbody->mbo_eadatasize == 0)
278 GOTO(out, rc = easize);
280 buf = &info->mti_buf;
281 buf->lb_buf = req_capsule_server_get(info->mti_pill, &RMF_EADATA);
282 buf->lb_len = easize;
284 valid = info->mti_body->mbo_valid & (OBD_MD_FLXATTR | OBD_MD_FLXATTRLS);
286 if (valid == OBD_MD_FLXATTR) {
287 const char *xattr_name = req_capsule_client_get(info->mti_pill,
289 rc = mo_xattr_get(info->mti_env, next, buf, xattr_name);
293 rc = mdt_nodemap_map_acl(info, buf->lb_buf, rc, xattr_name,
294 NODEMAP_FS_TO_CLIENT);
295 } else if (valid == OBD_MD_FLXATTRLS) {
296 CDEBUG(D_INODE, "listxattr\n");
298 rc = mo_xattr_list(info->mti_env, next, buf);
300 CDEBUG(D_INFO, "listxattr failed: %d\n", rc);
301 } else if (valid == OBD_MD_FLXATTRALL) {
302 rc = mdt_getxattr_all(info, reqbody, repbody,
310 mdt_counter_incr(req, LPROC_MDT_GETXATTR,
311 ktime_us_delta(ktime_get(), kstart));
312 /* LU-11109: Set OBD_MD_FLXATTR on success so that
313 * newer clients can distinguish between nonexistent
314 * xattrs and zero length values.
316 repbody->mbo_valid |= OBD_MD_FLXATTR;
317 repbody->mbo_eadatasize = rc;
320 mdt_exit_ucred(info);
324 /* update dir layout after migration/restripe */
325 int mdt_dir_layout_update(struct mdt_thread_info *info)
327 const struct lu_env *env = info->mti_env;
328 struct mdt_device *mdt = info->mti_mdt;
329 struct lu_ucred *uc = mdt_ucred(info);
330 struct mdt_reint_record *rr = &info->mti_rr;
331 struct lmv_user_md *lmu = rr->rr_eadata;
332 __u32 lum_stripe_count = lmu->lum_stripe_count;
333 struct md_layout_change *mlc = &info->mti_mlc;
334 struct lmv_mds_md_v1 *lmv;
335 struct md_attr *ma = &info->mti_attr;
336 struct ldlm_enqueue_info *einfo = &info->mti_einfo[0];
337 struct mdt_object *pobj = NULL;
338 struct mdt_object *obj;
339 struct mdt_lock_handle *lhp = NULL;
340 struct mdt_lock_handle *lhc;
346 if (!mdt->mdt_enable_dir_migration)
349 if (!cap_raised(uc->uc_cap, CAP_SYS_ADMIN) &&
350 uc->uc_gid != mdt->mdt_enable_remote_dir_gid &&
351 mdt->mdt_enable_remote_dir_gid != -1)
354 obj = mdt_object_find(env, mdt, rr->rr_fid1);
356 RETURN(PTR_ERR(obj));
358 /* get parent from PFID */
359 rc = mdt_attr_get_pfid(info, obj, &ma->ma_pfid);
363 pobj = mdt_object_find(env, mdt, &ma->ma_pfid);
365 GOTO(put_obj, rc = PTR_ERR(pobj));
367 /* revoke object remote LOOKUP lock */
368 if (mdt_object_remote(pobj)) {
369 rc = mdt_revoke_remote_lookup_lock(info, pobj, obj);
375 * lock parent if dir will be shrunk to 1 stripe, because dir will be
376 * converted to normal directory, as will change dir FID and update
377 * namespace of parent.
379 lhp = &info->mti_lh[MDT_LH_PARENT];
380 mdt_lock_reg_init(lhp, LCK_PW);
382 if (le32_to_cpu(lmu->lum_stripe_count) < 2) {
383 rc = mdt_reint_object_lock(info, pobj, lhp,
384 MDS_INODELOCK_UPDATE, true);
390 lhc = &info->mti_lh[MDT_LH_CHILD];
391 mdt_lock_reg_init(lhc, LCK_EX);
392 rc = mdt_reint_striped_lock(info, obj, lhc, MDS_INODELOCK_FULL, einfo,
395 GOTO(unlock_pobj, rc);
397 rc = mdt_stripe_get(info, obj, ma, XATTR_NAME_LMV);
399 GOTO(unlock_obj, rc);
401 /* user may run 'lfs migrate' multiple times, so it's shrunk already */
402 if (!(ma->ma_valid & MA_LMV))
403 GOTO(unlock_obj, rc = -EALREADY);
405 lmv = &ma->ma_lmv->lmv_md_v1;
406 if (!lmv_is_sane(lmv))
407 GOTO(unlock_obj, rc = -EBADF);
410 if (!lmv_is_layout_changing(lmv))
411 GOTO(unlock_obj, rc = -EALREADY);
413 lum_stripe_count = lmu->lum_stripe_count;
414 if (!lum_stripe_count)
415 lum_stripe_count = cpu_to_le32(1);
417 if (lmv_is_migrating(lmv)) {
418 if (lmv->lmv_migrate_offset != lum_stripe_count) {
419 CERROR("%s: "DFID" migrate mdt count mismatch %u != %u\n",
420 mdt_obd_name(info->mti_mdt), PFID(rr->rr_fid1),
421 lmv->lmv_migrate_offset, lmu->lum_stripe_count);
422 GOTO(unlock_obj, rc = -EINVAL);
425 /* lum_stripe_offset is not checked, because subdir is migrated
426 * to where its parent is located to avoid unnecessary remote
430 if (lum_stripe_count > 1 && lmu->lum_hash_type &&
431 lmu->lum_hash_type !=
432 (lmv->lmv_hash_type & cpu_to_le32(LMV_HASH_TYPE_MASK))) {
433 CERROR("%s: "DFID" migrate mdt hash mismatch %u != %u\n",
434 mdt_obd_name(info->mti_mdt), PFID(rr->rr_fid1),
435 lmv->lmv_hash_type, lmu->lum_hash_type);
436 GOTO(unlock_obj, rc = -EINVAL);
440 } else if (lmv_is_splitting(lmv)) {
441 if (lmv->lmv_stripe_count != lum_stripe_count) {
442 CERROR("%s: "DFID" stripe count mismatch %u != %u\n",
443 mdt_obd_name(info->mti_mdt), PFID(rr->rr_fid1),
444 lmv->lmv_stripe_count, lmu->lum_stripe_count);
445 GOTO(unlock_obj, rc = -EINVAL);
448 if (lmu->lum_stripe_offset != LMV_OFFSET_DEFAULT) {
449 CERROR("%s: "DFID" dir split offset %u != -1\n",
450 mdt_obd_name(info->mti_mdt), PFID(rr->rr_fid1),
451 lmu->lum_stripe_offset);
452 GOTO(unlock_obj, rc = -EINVAL);
455 if (lmu->lum_hash_type &&
456 lmu->lum_hash_type !=
457 (lmv->lmv_hash_type & cpu_to_le32(LMV_HASH_TYPE_MASK))) {
458 CERROR("%s: "DFID" split hash mismatch %u != %u\n",
459 mdt_obd_name(info->mti_mdt), PFID(rr->rr_fid1),
460 lmv->lmv_hash_type, lmu->lum_hash_type);
461 GOTO(unlock_obj, rc = -EINVAL);
463 } else if (lmv_is_merging(lmv)) {
464 if (lmv->lmv_merge_offset != lum_stripe_count) {
465 CERROR("%s: "DFID" stripe count mismatch %u != %u\n",
466 mdt_obd_name(info->mti_mdt), PFID(rr->rr_fid1),
467 lmv->lmv_merge_offset, lmu->lum_stripe_count);
468 GOTO(unlock_obj, rc = -EINVAL);
471 if (lmu->lum_stripe_offset != LMV_OFFSET_DEFAULT) {
472 CERROR("%s: "DFID" dir merge offset %u != -1\n",
473 mdt_obd_name(info->mti_mdt), PFID(rr->rr_fid1),
474 lmu->lum_stripe_offset);
475 GOTO(unlock_obj, rc = -EINVAL);
478 if (lmu->lum_hash_type &&
479 (lmu->lum_hash_type & cpu_to_le32(LMV_HASH_TYPE_MASK)) !=
480 (lmv->lmv_merge_hash & cpu_to_le32(LMV_HASH_TYPE_MASK))) {
481 CERROR("%s: "DFID" merge hash mismatch %u != %u\n",
482 mdt_obd_name(info->mti_mdt), PFID(rr->rr_fid1),
483 lmv->lmv_merge_hash, lmu->lum_hash_type);
484 GOTO(unlock_obj, rc = -EINVAL);
487 if (lum_stripe_count < lmv->lmv_stripe_count)
492 mlc->mlc_opc = MD_LAYOUT_SHRINK;
493 mlc->mlc_buf.lb_buf = rr->rr_eadata;
494 mlc->mlc_buf.lb_len = rr->rr_eadatalen;
495 rc = mo_layout_change(env, mdt_object_child(obj), mlc);
497 struct lu_buf *buf = &info->mti_buf;
498 u32 version = le32_to_cpu(lmv->lmv_layout_version);
500 lmv->lmv_hash_type &= ~LMV_HASH_FLAG_LAYOUT_CHANGE;
501 lmv->lmv_layout_version = cpu_to_le32(++version);
502 lmv->lmv_migrate_offset = 0;
503 lmv->lmv_migrate_hash = 0;
505 buf->lb_len = sizeof(*lmv);
506 rc = mo_xattr_set(env, mdt_object_child(obj), buf,
507 XATTR_NAME_LMV, LU_XATTR_REPLACE);
509 GOTO(unlock_obj, rc);
512 mdt_reint_striped_unlock(info, obj, lhc, einfo, rc);
514 mdt_object_unlock(info, pobj, lhp, rc);
516 mdt_object_put(env, pobj);
518 mdt_object_put(env, obj);
523 int mdt_reint_setxattr(struct mdt_thread_info *info,
524 struct mdt_lock_handle *unused)
526 struct ptlrpc_request *req = mdt_info_req(info);
527 struct mdt_lock_handle *lh;
528 const struct lu_env *env = info->mti_env;
529 struct lu_buf *buf = &info->mti_buf;
530 struct mdt_reint_record *rr = &info->mti_rr;
531 struct md_attr *ma = &info->mti_attr;
532 struct lu_attr *attr = &info->mti_attr.ma_attr;
533 struct mdt_object *obj;
534 struct md_object *child;
535 __u64 valid = attr->la_valid;
536 const char *xattr_name = rr->rr_name.ln_name;
537 int xattr_len = rr->rr_eadatalen;
538 __u64 lockpart = MDS_INODELOCK_UPDATE;
539 ktime_t kstart = ktime_get();
543 CDEBUG(D_INODE, "setxattr for "DFID": %s %s\n", PFID(rr->rr_fid1),
544 valid & OBD_MD_FLXATTR ? "set" : "remove", xattr_name);
546 if (info->mti_dlm_req)
547 ldlm_request_cancel(req, info->mti_dlm_req, 0, LATF_SKIP);
549 if (OBD_FAIL_CHECK(OBD_FAIL_MDS_SETXATTR))
550 RETURN(err_serious(-ENOMEM));
552 rc = mdt_init_ucred_reint(info);
556 if (strncmp(xattr_name, XATTR_USER_PREFIX,
557 sizeof(XATTR_USER_PREFIX) - 1) == 0) {
558 if (!(exp_connect_flags(req->rq_export) & OBD_CONNECT_XATTR))
559 GOTO(out, rc = -EOPNOTSUPP);
560 } else if (strncmp(xattr_name, XATTR_TRUSTED_PREFIX,
561 sizeof(XATTR_TRUSTED_PREFIX) - 1) == 0) {
563 /* setxattr(LMV) with lum is used to shrink dir layout */
564 if (strcmp(xattr_name, XATTR_NAME_LMV) == 0) {
565 __u32 *magic = rr->rr_eadata;
567 /* we don't let to remove LMV? */
571 if (le32_to_cpu(*magic) == LMV_USER_MAGIC ||
572 le32_to_cpu(*magic) == LMV_USER_MAGIC_SPECIFIC) {
573 rc = mdt_dir_layout_update(info);
578 if (!cap_raised(mdt_ucred(info)->uc_cap, CAP_SYS_ADMIN))
579 GOTO(out, rc = -EPERM);
581 if (strcmp(xattr_name, XATTR_NAME_LOV) == 0 ||
582 strcmp(xattr_name, XATTR_NAME_LMA) == 0 ||
583 strcmp(xattr_name, XATTR_NAME_LMV) == 0 ||
584 strcmp(xattr_name, XATTR_NAME_LINK) == 0 ||
585 strcmp(xattr_name, XATTR_NAME_FID) == 0 ||
586 strcmp(xattr_name, XATTR_NAME_VERSION) == 0 ||
587 strcmp(xattr_name, XATTR_NAME_SOM) == 0 ||
588 strcmp(xattr_name, XATTR_NAME_HSM) == 0 ||
589 strcmp(xattr_name, XATTR_NAME_LFSCK_NAMESPACE) == 0)
591 } else if ((valid & OBD_MD_FLXATTR) &&
592 (strcmp(xattr_name, XATTR_NAME_ACL_ACCESS) == 0 ||
593 strcmp(xattr_name, XATTR_NAME_ACL_DEFAULT) == 0)) {
594 rc = mdt_nodemap_map_acl(info, rr->rr_eadata, xattr_len,
595 xattr_name, NODEMAP_CLIENT_TO_FS);
598 /* ACLs were mapped out, return an error so the user knows */
600 GOTO(out, rc = -EPERM);
601 } else if ((strlen(xattr_name) > sizeof(XATTR_LUSTRE_LOV)) &&
602 strncmp(xattr_name, XATTR_LUSTRE_LOV,
603 strlen(XATTR_LUSTRE_LOV)) == 0) {
605 if (!allowed_lustre_lov(xattr_name)) {
606 CERROR("%s: invalid xattr name: %s\n",
607 mdt_obd_name(info->mti_mdt), xattr_name);
608 GOTO(out, rc = -EINVAL);
611 lockpart |= MDS_INODELOCK_LAYOUT;
614 /* Revoke all clients' lookup lock, since the access
615 * permissions for this inode is changed when ACL_ACCESS is
616 * set. This isn't needed for ACL_DEFAULT, since that does
617 * not change the access permissions of this inode, nor any
618 * other existing inodes. It is setting the ACLs inherited
619 * by new directories/files at create time.
621 /* We need revoke both LOOKUP|PERM lock here, see mdt_attr_set. */
622 if (!strcmp(xattr_name, XATTR_NAME_ACL_ACCESS))
623 lockpart |= MDS_INODELOCK_PERM | MDS_INODELOCK_LOOKUP;
624 /* We need to take the lock on behalf of old clients so that newer
625 * clients flush their xattr caches
628 lockpart |= MDS_INODELOCK_XATTR;
630 lh = &info->mti_lh[MDT_LH_PARENT];
631 /* ACLs were sent to clients under LCK_CR locks, so taking LCK_EX
634 mdt_lock_reg_init(lh, LCK_EX);
635 obj = mdt_object_find_lock(info, rr->rr_fid1, lh, lockpart);
637 GOTO(out, rc = PTR_ERR(obj));
639 tgt_vbr_obj_set(env, mdt_obj2dt(obj));
640 rc = mdt_version_get_check_save(info, obj, 0);
642 GOTO(out_unlock, rc);
644 if (unlikely(!(valid & OBD_MD_FLCTIME))) {
645 /* This isn't strictly an error, but all current clients
646 * should set OBD_MD_FLCTIME when setting attributes.
648 CWARN("%s: client miss to set OBD_MD_FLCTIME when setxattr %s: [object "DFID"] [valid %llu]\n",
649 mdt_obd_name(info->mti_mdt), xattr_name,
650 PFID(rr->rr_fid1), valid);
651 attr->la_ctime = ktime_get_real_seconds();
653 attr->la_valid = LA_CTIME;
654 child = mdt_object_child(obj);
655 if (valid & OBD_MD_FLXATTR) {
658 if (attr->la_flags & XATTR_REPLACE)
659 flags |= LU_XATTR_REPLACE;
661 if (attr->la_flags & XATTR_CREATE)
662 flags |= LU_XATTR_CREATE;
664 mdt_fail_write(env, info->mti_mdt->mdt_bottom,
665 OBD_FAIL_MDS_SETXATTR_WRITE);
667 buf->lb_buf = rr->rr_eadata;
668 buf->lb_len = xattr_len;
669 rc = mo_xattr_set(env, child, buf, xattr_name, flags);
670 /* update ctime after xattr changed */
672 ma->ma_attr_flags |= MDS_PERM_BYPASS;
673 mo_attr_set(env, child, ma);
675 } else if (valid & OBD_MD_FLXATTRRM) {
676 rc = mo_xattr_del(env, child, xattr_name);
677 /* update ctime after xattr changed */
679 ma->ma_attr_flags |= MDS_PERM_BYPASS;
680 mo_attr_set(env, child, ma);
683 CDEBUG(D_INFO, "valid bits: %#llx\n", valid);
688 mdt_counter_incr(req, LPROC_MDT_SETXATTR,
689 ktime_us_delta(ktime_get(), kstart));
693 mdt_object_unlock_put(info, obj, lh, rc);
695 mdt_exit_ucred(info);