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/
30 * Lustre is a trademark of Sun Microsystems, Inc.
32 * lustre/mdt/mdt_xattr.c
34 * Lustre Metadata Target (mdt) extended attributes management.
36 * Author: Peter Braam <braam@clusterfs.com>
37 * Author: Andreas Dilger <adilger@clusterfs.com>
38 * Author: Phil Schwan <phil@clusterfs.com>
39 * Author: Huang Hua <huanghua@clusterfs.com>
42 #define DEBUG_SUBSYSTEM S_MDS
44 #include <linux/xattr.h>
45 #include <obd_class.h>
46 #include <lustre_nodemap.h>
47 #include <lustre_acl.h>
48 #include <lustre_lmv.h>
49 #include "mdt_internal.h"
52 /* return EADATA length to the caller. negative value means error */
53 static int mdt_getxattr_pack_reply(struct mdt_thread_info * info)
55 struct req_capsule *pill = info->mti_pill;
56 struct ptlrpc_request *req = mdt_info_req(info);
57 const char *xattr_name;
59 static const char user_string[] = "user.";
65 valid = info->mti_body->mbo_valid & (OBD_MD_FLXATTR | OBD_MD_FLXATTRLS);
67 /* Determine how many bytes we need */
68 if (valid == OBD_MD_FLXATTR) {
69 xattr_name = req_capsule_client_get(pill, &RMF_NAME);
73 if (!(exp_connect_flags(req->rq_export) & OBD_CONNECT_XATTR) &&
74 !strncmp(xattr_name, user_string, sizeof(user_string) - 1))
77 size = mo_xattr_get(info->mti_env,
78 mdt_object_child(info->mti_object),
79 &LU_BUF_NULL, xattr_name);
80 if (size == -ENODATA) {
81 /* XXX: Some client code will not handle -ENODATA
82 * 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... */
100 size = info->mti_body->mbo_eadatasize;
101 if (size <= 0 || size > info->mti_mdt->mdt_max_ea_size ||
102 size & (sizeof(__u32) - 1)) {
103 DEBUG_REQ(D_ERROR, req,
104 "%s: invalid EA size(%d) for FLXATTRALL\n",
105 mdt_obd_name(info->mti_mdt), size);
108 req_capsule_set_size(pill, &RMF_EAVALS, RCL_SERVER, size);
109 req_capsule_set_size(pill, &RMF_EAVALS_LENS, RCL_SERVER, size);
111 CDEBUG(D_INFO, "Valid bits: %#llx\n",
112 info->mti_body->mbo_valid);
117 if (size != -EOPNOTSUPP && size != -ENOENT)
118 CERROR("%s: error geting EA size for '%s': rc = %d\n",
119 mdt_obd_name(info->mti_mdt), xattr_name, size);
123 if (req_capsule_has_field(pill, &RMF_ACL, RCL_SERVER))
124 req_capsule_set_size(pill, &RMF_ACL, RCL_SERVER,
125 LUSTRE_POSIX_ACL_MAX_SIZE_OLD);
127 req_capsule_set_size(pill, &RMF_EADATA, RCL_SERVER,
128 info->mti_body->mbo_eadatasize == 0 ? 0 : size);
130 rc2 = req_capsule_server_pack(pill);
134 if (OBD_FAIL_CHECK(OBD_FAIL_MDS_GETXATTR_PACK))
137 RETURN(rc < 0 ? rc : size);
140 static int mdt_nodemap_map_acl(struct mdt_thread_info *info, void *buf,
141 size_t size, const char *name,
142 enum nodemap_tree_type tree_type)
144 struct lu_nodemap *nodemap;
145 struct obd_export *exp = info->mti_exp;
150 if (strcmp(name, XATTR_NAME_ACL_ACCESS) == 0 ||
151 strcmp(name, XATTR_NAME_ACL_DEFAULT) == 0) {
152 if (size > info->mti_mdt->mdt_max_ea_size ||
153 (!exp_connect_large_acl(exp) &&
154 size > LUSTRE_POSIX_ACL_MAX_SIZE_OLD))
155 GOTO(out, rc = -ERANGE);
157 nodemap = nodemap_get_from_exp(exp);
159 GOTO(out, rc = PTR_ERR(nodemap));
161 rc = nodemap_map_acl(nodemap, buf, size, tree_type);
162 nodemap_putref(nodemap);
170 static int mdt_getxattr_all(struct mdt_thread_info *info,
171 struct mdt_body *reqbody, struct mdt_body *repbody,
172 struct lu_buf *buf, struct md_object *next)
174 const struct lu_env *env = info->mti_env;
175 char *v, *b, *eadatahead, *eadatatail;
177 int eadatasize, eavallen = 0, eavallens = 0, rc;
182 * The format of the pill is the following:
183 * EADATA: attr1\0attr2\0...attrn\0
184 * EAVALS: val1val2...valn
185 * EAVALS_LENS: 4,4,...4
188 eadatahead = buf->lb_buf;
190 /* Fill out EADATA first */
191 rc = mo_xattr_list(env, next, buf);
193 GOTO(out_shrink, rc);
196 eadatatail = eadatahead + eadatasize;
198 v = req_capsule_server_get(info->mti_pill, &RMF_EAVALS);
199 sizes = req_capsule_server_get(info->mti_pill, &RMF_EAVALS_LENS);
201 /* Fill out EAVALS and EAVALS_LENS */
202 for (b = eadatahead; b < eadatatail; b += strlen(b) + 1, v += rc) {
204 buf->lb_len = reqbody->mbo_eadatasize - eavallen;
205 rc = mo_xattr_get(env, next, buf, b);
207 GOTO(out_shrink, rc);
208 rc = mdt_nodemap_map_acl(info, buf->lb_buf, rc, b,
209 NODEMAP_FS_TO_CLIENT);
211 GOTO(out_shrink, rc);
212 sizes[eavallens] = rc;
223 repbody->mbo_aclsize = eavallen;
224 repbody->mbo_max_mdsize = eavallens;
226 req_capsule_shrink(info->mti_pill, &RMF_EAVALS, eavallen, RCL_SERVER);
227 req_capsule_shrink(info->mti_pill, &RMF_EAVALS_LENS,
228 eavallens * sizeof(__u32), RCL_SERVER);
229 req_capsule_shrink(info->mti_pill, &RMF_EADATA, eadatasize, RCL_SERVER);
236 int mdt_getxattr(struct mdt_thread_info *info)
238 struct ptlrpc_request *req = mdt_info_req(info);
239 struct mdt_body *reqbody;
240 struct mdt_body *repbody = NULL;
241 struct md_object *next;
247 LASSERT(info->mti_object != NULL);
248 LASSERT(lu_object_assert_exists(&info->mti_object->mot_obj));
250 CDEBUG(D_INODE, "getxattr "DFID"\n", PFID(&info->mti_body->mbo_fid1));
252 rc = req_check_sepol(info->mti_pill);
254 RETURN(err_serious(rc));
256 reqbody = req_capsule_client_get(info->mti_pill, &RMF_MDT_BODY);
258 RETURN(err_serious(-EFAULT));
260 rc = mdt_init_ucred(info, reqbody);
262 RETURN(err_serious(rc));
264 next = mdt_object_child(info->mti_object);
265 easize = mdt_getxattr_pack_reply(info);
266 if (easize == -ENODATA)
267 GOTO(out, rc = easize);
269 GOTO(out, rc = err_serious(easize));
271 repbody = req_capsule_server_get(info->mti_pill, &RMF_MDT_BODY);
272 LASSERT(repbody != NULL);
274 /* No need further getxattr. */
275 if (easize == 0 || reqbody->mbo_eadatasize == 0)
276 GOTO(out, rc = easize);
278 buf = &info->mti_buf;
279 buf->lb_buf = req_capsule_server_get(info->mti_pill, &RMF_EADATA);
280 buf->lb_len = easize;
282 valid = info->mti_body->mbo_valid & (OBD_MD_FLXATTR | OBD_MD_FLXATTRLS);
284 if (valid == OBD_MD_FLXATTR) {
285 const char *xattr_name = req_capsule_client_get(info->mti_pill,
287 rc = mo_xattr_get(info->mti_env, next, buf, xattr_name);
291 rc = mdt_nodemap_map_acl(info, buf->lb_buf, rc, xattr_name,
292 NODEMAP_FS_TO_CLIENT);
293 } else if (valid == OBD_MD_FLXATTRLS) {
294 CDEBUG(D_INODE, "listxattr\n");
296 rc = mo_xattr_list(info->mti_env, next, buf);
298 CDEBUG(D_INFO, "listxattr failed: %d\n", rc);
299 } else if (valid == OBD_MD_FLXATTRALL) {
300 rc = mdt_getxattr_all(info, reqbody, repbody,
308 mdt_counter_incr(req, LPROC_MDT_GETXATTR);
309 /* LU-11109: Set OBD_MD_FLXATTR on success so that
310 * newer clients can distinguish between nonexistent
311 * xattrs and zero length values. */
312 repbody->mbo_valid |= OBD_MD_FLXATTR;
313 repbody->mbo_eadatasize = rc;
316 mdt_exit_ucred(info);
320 /* update dir layout after migration/restripe */
321 int mdt_dir_layout_update(struct mdt_thread_info *info)
323 const struct lu_env *env = info->mti_env;
324 struct mdt_device *mdt = info->mti_mdt;
325 struct lu_ucred *uc = mdt_ucred(info);
326 struct mdt_reint_record *rr = &info->mti_rr;
327 struct lmv_user_md *lmu = rr->rr_eadata;
328 __u32 lum_stripe_count = lmu->lum_stripe_count;
329 struct md_layout_change *mlc = &info->mti_mlc;
330 struct lmv_mds_md_v1 *lmv;
331 struct md_attr *ma = &info->mti_attr;
332 struct ldlm_enqueue_info *einfo = &info->mti_einfo[0];
333 struct mdt_object *pobj = NULL;
334 struct mdt_object *obj;
335 struct mdt_lock_handle *lhp = NULL;
336 struct mdt_lock_handle *lhc;
342 if (!mdt->mdt_enable_dir_migration)
345 if (!md_capable(uc, CFS_CAP_SYS_ADMIN) &&
346 uc->uc_gid != mdt->mdt_enable_remote_dir_gid &&
347 mdt->mdt_enable_remote_dir_gid != -1)
350 obj = mdt_object_find(env, mdt, rr->rr_fid1);
352 RETURN(PTR_ERR(obj));
354 /* get parent from PFID */
355 rc = mdt_attr_get_pfid(info, obj, &ma->ma_pfid);
359 pobj = mdt_object_find(env, mdt, &ma->ma_pfid);
361 GOTO(put_obj, rc = PTR_ERR(pobj));
363 /* revoke object remote LOOKUP lock */
364 if (mdt_object_remote(pobj)) {
365 rc = mdt_revoke_remote_lookup_lock(info, pobj, obj);
371 * lock parent if dir will be shrunk to 1 stripe, because dir will be
372 * converted to normal directory, as will change dir FID and update
373 * namespace of parent.
375 lhp = &info->mti_lh[MDT_LH_PARENT];
376 mdt_lock_reg_init(lhp, LCK_PW);
378 if (le32_to_cpu(lmu->lum_stripe_count) < 2) {
379 rc = mdt_reint_object_lock(info, pobj, lhp,
380 MDS_INODELOCK_UPDATE, true);
386 lhc = &info->mti_lh[MDT_LH_CHILD];
387 mdt_lock_reg_init(lhc, LCK_EX);
388 rc = mdt_reint_striped_lock(info, obj, lhc, MDS_INODELOCK_FULL, einfo,
391 GOTO(unlock_pobj, rc);
393 rc = mdt_stripe_get(info, obj, ma, XATTR_NAME_LMV);
395 GOTO(unlock_obj, rc);
397 /* user may run 'lfs migrate' multiple times, so it's shrunk already */
398 if (!(ma->ma_valid & MA_LMV))
399 GOTO(unlock_obj, rc = -EALREADY);
401 lmv = &ma->ma_lmv->lmv_md_v1;
402 if (!lmv_is_sane(lmv))
403 GOTO(unlock_obj, rc = -EBADF);
406 if (!lmv_is_layout_changing(lmv))
407 GOTO(unlock_obj, rc = -EALREADY);
409 lum_stripe_count = lmu->lum_stripe_count;
410 if (!lum_stripe_count)
411 lum_stripe_count = cpu_to_le32(1);
413 if (lmv_is_migrating(lmv)) {
414 if (lmv->lmv_migrate_offset != lum_stripe_count) {
415 CERROR("%s: "DFID" migrate mdt count mismatch %u != %u\n",
416 mdt_obd_name(info->mti_mdt), PFID(rr->rr_fid1),
417 lmv->lmv_migrate_offset, lmu->lum_stripe_count);
418 GOTO(unlock_obj, rc = -EINVAL);
421 if (lmu->lum_stripe_offset != lmv->lmv_master_mdt_index) {
422 CERROR("%s: "DFID" migrate mdt index mismatch %u != %u\n",
423 mdt_obd_name(info->mti_mdt), PFID(rr->rr_fid1),
424 lmv->lmv_master_mdt_index,
425 lmu->lum_stripe_offset);
426 GOTO(unlock_obj, rc = -EINVAL);
429 if (lum_stripe_count > 1 && lmu->lum_hash_type &&
430 lmu->lum_hash_type !=
431 (lmv->lmv_hash_type & cpu_to_le32(LMV_HASH_TYPE_MASK))) {
432 CERROR("%s: "DFID" migrate mdt hash mismatch %u != %u\n",
433 mdt_obd_name(info->mti_mdt), PFID(rr->rr_fid1),
434 lmv->lmv_hash_type, lmu->lum_hash_type);
435 GOTO(unlock_obj, rc = -EINVAL);
439 } else if (lmv_is_splitting(lmv)) {
440 if (lmv->lmv_stripe_count != lum_stripe_count) {
441 CERROR("%s: "DFID" stripe count mismatch %u != %u\n",
442 mdt_obd_name(info->mti_mdt), PFID(rr->rr_fid1),
443 lmv->lmv_stripe_count, lmu->lum_stripe_count);
444 GOTO(unlock_obj, rc = -EINVAL);
447 if (lmu->lum_stripe_offset != LMV_OFFSET_DEFAULT) {
448 CERROR("%s: "DFID" dir split offset %u != -1\n",
449 mdt_obd_name(info->mti_mdt), PFID(rr->rr_fid1),
450 lmu->lum_stripe_offset);
451 GOTO(unlock_obj, rc = -EINVAL);
454 if (lmu->lum_hash_type &&
455 lmu->lum_hash_type !=
456 (lmv->lmv_hash_type & cpu_to_le32(LMV_HASH_TYPE_MASK))) {
457 CERROR("%s: "DFID" split hash mismatch %u != %u\n",
458 mdt_obd_name(info->mti_mdt), PFID(rr->rr_fid1),
459 lmv->lmv_hash_type, lmu->lum_hash_type);
460 GOTO(unlock_obj, rc = -EINVAL);
462 } else if (lmv_is_merging(lmv)) {
463 if (lmv->lmv_merge_offset != lum_stripe_count) {
464 CERROR("%s: "DFID" stripe count mismatch %u != %u\n",
465 mdt_obd_name(info->mti_mdt), PFID(rr->rr_fid1),
466 lmv->lmv_merge_offset, lmu->lum_stripe_count);
467 GOTO(unlock_obj, rc = -EINVAL);
470 if (lmu->lum_stripe_offset != LMV_OFFSET_DEFAULT) {
471 CERROR("%s: "DFID" dir merge offset %u != -1\n",
472 mdt_obd_name(info->mti_mdt), PFID(rr->rr_fid1),
473 lmu->lum_stripe_offset);
474 GOTO(unlock_obj, rc = -EINVAL);
477 if (lmu->lum_hash_type &&
478 lmu->lum_hash_type !=
479 (lmv->lmv_merge_hash & cpu_to_le32(LMV_HASH_TYPE_MASK))) {
480 CERROR("%s: "DFID" merge hash mismatch %u != %u\n",
481 mdt_obd_name(info->mti_mdt), PFID(rr->rr_fid1),
482 lmv->lmv_merge_hash, lmu->lum_hash_type);
483 GOTO(unlock_obj, rc = -EINVAL);
486 if (lum_stripe_count < lmv->lmv_stripe_count)
491 mlc->mlc_opc = MD_LAYOUT_SHRINK;
492 mlc->mlc_buf.lb_buf = rr->rr_eadata;
493 mlc->mlc_buf.lb_len = rr->rr_eadatalen;
494 rc = mo_layout_change(env, mdt_object_child(obj), mlc);
496 struct lu_buf *buf = &info->mti_buf;
497 u32 version = le32_to_cpu(lmv->lmv_layout_version);
499 lmv->lmv_hash_type &= ~LMV_HASH_FLAG_LAYOUT_CHANGE;
500 lmv->lmv_layout_version = cpu_to_le32(++version);
502 buf->lb_len = sizeof(*lmv);
503 rc = mo_xattr_set(env, mdt_object_child(obj), buf,
504 XATTR_NAME_LMV, LU_XATTR_REPLACE);
506 GOTO(unlock_obj, rc);
509 mdt_reint_striped_unlock(info, obj, lhc, einfo, rc);
511 mdt_object_unlock(info, pobj, lhp, rc);
513 mdt_object_put(env, pobj);
515 mdt_object_put(env, obj);
520 int mdt_reint_setxattr(struct mdt_thread_info *info,
521 struct mdt_lock_handle *unused)
523 struct ptlrpc_request *req = mdt_info_req(info);
524 struct mdt_lock_handle *lh;
525 const struct lu_env *env = info->mti_env;
526 struct lu_buf *buf = &info->mti_buf;
527 struct mdt_reint_record *rr = &info->mti_rr;
528 struct md_attr *ma = &info->mti_attr;
529 struct lu_attr *attr = &info->mti_attr.ma_attr;
530 struct mdt_object *obj;
531 struct md_object *child;
532 __u64 valid = attr->la_valid;
533 const char *xattr_name = rr->rr_name.ln_name;
534 int xattr_len = rr->rr_eadatalen;
535 __u64 lockpart = MDS_INODELOCK_UPDATE;
539 CDEBUG(D_INODE, "setxattr for "DFID": %s %s\n", PFID(rr->rr_fid1),
540 valid & OBD_MD_FLXATTR ? "set" : "remove", xattr_name);
542 if (info->mti_dlm_req)
543 ldlm_request_cancel(req, info->mti_dlm_req, 0, LATF_SKIP);
545 if (OBD_FAIL_CHECK(OBD_FAIL_MDS_SETXATTR))
546 RETURN(err_serious(-ENOMEM));
548 rc = mdt_init_ucred_reint(info);
552 if (strncmp(xattr_name, XATTR_USER_PREFIX,
553 sizeof(XATTR_USER_PREFIX) - 1) == 0) {
554 if (!(exp_connect_flags(req->rq_export) & OBD_CONNECT_XATTR))
555 GOTO(out, rc = -EOPNOTSUPP);
556 } else if (strncmp(xattr_name, XATTR_TRUSTED_PREFIX,
557 sizeof(XATTR_TRUSTED_PREFIX) - 1) == 0) {
559 /* setxattr(LMV) with lum is used to shrink dir layout */
560 if (strcmp(xattr_name, XATTR_NAME_LMV) == 0) {
561 __u32 *magic = rr->rr_eadata;
563 /* we don't let to remove LMV? */
567 if (le32_to_cpu(*magic) == LMV_USER_MAGIC ||
568 le32_to_cpu(*magic) == LMV_USER_MAGIC_SPECIFIC) {
569 rc = mdt_dir_layout_update(info);
574 if (!md_capable(mdt_ucred(info), CFS_CAP_SYS_ADMIN))
575 GOTO(out, rc = -EPERM);
577 if (strcmp(xattr_name, XATTR_NAME_LOV) == 0 ||
578 strcmp(xattr_name, XATTR_NAME_LMA) == 0 ||
579 strcmp(xattr_name, XATTR_NAME_LMV) == 0 ||
580 strcmp(xattr_name, XATTR_NAME_LINK) == 0 ||
581 strcmp(xattr_name, XATTR_NAME_FID) == 0 ||
582 strcmp(xattr_name, XATTR_NAME_VERSION) == 0 ||
583 strcmp(xattr_name, XATTR_NAME_SOM) == 0 ||
584 strcmp(xattr_name, XATTR_NAME_HSM) == 0 ||
585 strcmp(xattr_name, XATTR_NAME_LFSCK_NAMESPACE) == 0)
587 } else if ((valid & OBD_MD_FLXATTR) &&
588 (strcmp(xattr_name, XATTR_NAME_ACL_ACCESS) == 0 ||
589 strcmp(xattr_name, XATTR_NAME_ACL_DEFAULT) == 0)) {
590 rc = mdt_nodemap_map_acl(info, rr->rr_eadata, xattr_len,
591 xattr_name, NODEMAP_CLIENT_TO_FS);
594 /* ACLs were mapped out, return an error so the user knows */
596 GOTO(out, rc = -EPERM);
597 } else if ((strlen(xattr_name) > sizeof(XATTR_LUSTRE_LOV)) &&
598 strncmp(xattr_name, XATTR_LUSTRE_LOV,
599 strlen(XATTR_LUSTRE_LOV)) == 0) {
601 if (!allowed_lustre_lov(xattr_name)) {
602 CERROR("%s: invalid xattr name: %s\n",
603 mdt_obd_name(info->mti_mdt), xattr_name);
604 GOTO(out, rc = -EINVAL);
607 lockpart |= MDS_INODELOCK_LAYOUT;
610 /* Revoke all clients' lookup lock, since the access
611 * permissions for this inode is changed when ACL_ACCESS is
612 * set. This isn't needed for ACL_DEFAULT, since that does
613 * not change the access permissions of this inode, nor any
614 * other existing inodes. It is setting the ACLs inherited
615 * by new directories/files at create time. */
616 /* We need revoke both LOOKUP|PERM lock here, see mdt_attr_set. */
617 if (!strcmp(xattr_name, XATTR_NAME_ACL_ACCESS))
618 lockpart |= MDS_INODELOCK_PERM | MDS_INODELOCK_LOOKUP;
619 /* We need to take the lock on behalf of old clients so that newer
620 * clients flush their xattr caches */
622 lockpart |= MDS_INODELOCK_XATTR;
624 lh = &info->mti_lh[MDT_LH_PARENT];
625 /* ACLs were sent to clients under LCK_CR locks, so taking LCK_EX
627 mdt_lock_reg_init(lh, LCK_EX);
628 obj = mdt_object_find_lock(info, rr->rr_fid1, lh, lockpart);
630 GOTO(out, rc = PTR_ERR(obj));
632 tgt_vbr_obj_set(env, mdt_obj2dt(obj));
633 rc = mdt_version_get_check_save(info, obj, 0);
635 GOTO(out_unlock, rc);
637 if (unlikely(!(valid & OBD_MD_FLCTIME))) {
638 /* This isn't strictly an error, but all current clients
639 * should set OBD_MD_FLCTIME when setting attributes. */
640 CWARN("%s: client miss to set OBD_MD_FLCTIME when "
641 "setxattr %s: [object "DFID"] [valid %llu]\n",
642 mdt_obd_name(info->mti_mdt), xattr_name,
643 PFID(rr->rr_fid1), valid);
644 attr->la_ctime = ktime_get_real_seconds();
646 attr->la_valid = LA_CTIME;
647 child = mdt_object_child(obj);
648 if (valid & OBD_MD_FLXATTR) {
651 if (attr->la_flags & XATTR_REPLACE)
652 flags |= LU_XATTR_REPLACE;
654 if (attr->la_flags & XATTR_CREATE)
655 flags |= LU_XATTR_CREATE;
657 mdt_fail_write(env, info->mti_mdt->mdt_bottom,
658 OBD_FAIL_MDS_SETXATTR_WRITE);
660 buf->lb_buf = rr->rr_eadata;
661 buf->lb_len = xattr_len;
662 rc = mo_xattr_set(env, child, buf, xattr_name, flags);
663 /* update ctime after xattr changed */
665 ma->ma_attr_flags |= MDS_PERM_BYPASS;
666 mo_attr_set(env, child, ma);
668 } else if (valid & OBD_MD_FLXATTRRM) {
669 rc = mo_xattr_del(env, child, xattr_name);
670 /* update ctime after xattr changed */
672 ma->ma_attr_flags |= MDS_PERM_BYPASS;
673 mo_attr_set(env, child, ma);
676 CDEBUG(D_INFO, "valid bits: %#llx\n", valid);
681 mdt_counter_incr(req, LPROC_MDT_SETXATTR);
685 mdt_object_unlock_put(info, obj, lh, rc);
687 mdt_exit_ucred(info);