1 /* -*- mode: c; c-basic-offset: 8; indent-tabs-mode: nil; -*-
2 * vim:expandtab:shiftwidth=8:tabstop=8:
6 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
8 * This program is free software; you can redistribute it and/or modify
9 * it under the terms of the GNU General Public License version 2 only,
10 * as published by the Free Software Foundation.
12 * This program is distributed in the hope that it will be useful, but
13 * WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
15 * General Public License version 2 for more details (a copy is included
16 * in the LICENSE file that accompanied this code).
18 * You should have received a copy of the GNU General Public License
19 * version 2 along with this program; If not, see
20 * http://www.sun.com/software/products/lustre/docs/GPLv2.pdf
22 * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
23 * CA 95054 USA or visit www.sun.com if you need additional information or
29 * Copyright 2008 Sun Microsystems, Inc. All rights reserved
30 * Use is subject to license terms.
33 * This file is part of Lustre, http://www.lustre.org/
34 * Lustre is a trademark of Sun Microsystems, Inc.
36 * lustre/mdd/mdd_lov.c
38 * Lustre Metadata Server (mds) handling of striped file data
40 * Author: Peter Braam <braam@clusterfs.com>
41 * Author: wangdi <wangdi@clusterfs.com>
45 # define EXPORT_SYMTAB
47 #define DEBUG_SUBSYSTEM S_MDS
49 #include <linux/module.h>
51 #include <obd_class.h>
52 #include <lustre_ver.h>
53 #include <obd_support.h>
55 #include <lprocfs_status.h>
56 #include <lustre_mds.h>
57 #include <lustre_fid.h>
58 #include <lustre/lustre_idl.h>
60 #include "mdd_internal.h"
62 static int mdd_notify(struct obd_device *host, struct obd_device *watched,
63 enum obd_notify_event ev, void *owner, void *data)
65 struct mdd_device *mdd = owner;
69 LASSERT(owner != NULL);
72 case OBD_NOTIFY_ACTIVE:
74 case OBD_NOTIFY_SYNC_NONBLOCK:
75 rc = md_do_upcall(NULL, &mdd->mdd_md_dev,
78 case OBD_NOTIFY_CONFIG:
79 rc = md_do_upcall(NULL, &mdd->mdd_md_dev,
82 #ifdef HAVE_QUOTA_SUPPORT
83 case OBD_NOTIFY_QUOTA:
84 rc = md_do_upcall(NULL, &mdd->mdd_md_dev,
89 CDEBUG(D_INFO, "Unhandled notification %#x\n", ev);
95 /* The obd is created for handling data stack for mdd */
96 int mdd_init_obd(const struct lu_env *env, struct mdd_device *mdd,
97 struct lustre_cfg *cfg)
99 char *dev = lustre_cfg_string(cfg, 0);
100 int rc, name_size, uuid_size;
103 struct lustre_cfg_bufs *bufs;
104 struct lustre_cfg *lcfg;
105 struct obd_device *obd;
108 mds_id = lu_site2md(mdd2lu_dev(mdd)->ld_site)->ms_node_id;
109 name_size = strlen(MDD_OBD_NAME) + 35;
110 uuid_size = strlen(MDD_OBD_UUID) + 35;
112 OBD_ALLOC(name, name_size);
113 OBD_ALLOC(uuid, uuid_size);
114 if (name == NULL || uuid == NULL)
115 GOTO(cleanup_mem, rc = -ENOMEM);
119 GOTO(cleanup_mem, rc = -ENOMEM);
121 snprintf(name, strlen(MDD_OBD_NAME) + 35, "%s-%s-%d",
122 MDD_OBD_NAME, dev, mds_id);
124 snprintf(uuid, strlen(MDD_OBD_UUID) + 35, "%s-%s-%d",
125 MDD_OBD_UUID, dev, mds_id);
127 lustre_cfg_bufs_reset(bufs, name);
128 lustre_cfg_bufs_set_string(bufs, 1, MDD_OBD_TYPE);
129 lustre_cfg_bufs_set_string(bufs, 2, uuid);
130 lustre_cfg_bufs_set_string(bufs, 3, (char*)dev/* MDD_OBD_PROFILE */);
131 lustre_cfg_bufs_set_string(bufs, 4, (char*)dev);
133 lcfg = lustre_cfg_new(LCFG_ATTACH, bufs);
136 GOTO(cleanup_mem, rc = -ENOMEM);
138 rc = class_attach(lcfg);
140 GOTO(lcfg_cleanup, rc);
142 obd = class_name2obd(name);
144 CERROR("Can not find obd %s\n", MDD_OBD_NAME);
148 obd->obd_recovering = 1;
149 obd->u.mds.mds_id = mds_id;
150 rc = class_setup(obd, lcfg);
152 GOTO(class_detach, rc);
155 * Add here for obd notify mechanism, when adding a new ost, the mds
156 * will notify this mdd. The mds will be used for quota also.
158 obd->obd_upcall.onu_upcall = mdd_notify;
159 obd->obd_upcall.onu_owner = mdd;
160 mdd->mdd_obd_dev = obd;
164 class_detach(obd, lcfg);
166 lustre_cfg_free(lcfg);
169 OBD_FREE(name, name_size);
171 OBD_FREE(uuid, uuid_size);
175 int mdd_fini_obd(const struct lu_env *env, struct mdd_device *mdd,
176 struct lustre_cfg *lcfg)
178 struct obd_device *obd;
182 obd = mdd2obd_dev(mdd);
185 rc = class_cleanup(obd, lcfg);
187 GOTO(lcfg_cleanup, rc);
189 obd->obd_upcall.onu_upcall = NULL;
190 obd->obd_upcall.onu_owner = NULL;
191 rc = class_detach(obd, lcfg);
193 GOTO(lcfg_cleanup, rc);
194 mdd->mdd_obd_dev = NULL;
201 int mdd_get_md(const struct lu_env *env, struct mdd_object *obj,
202 void *md, int *md_size, const char *name)
207 rc = mdo_xattr_get(env, obj, mdd_buf_get(env, md, *md_size), name,
208 mdd_object_capa(env, obj));
210 * XXX: Handling of -ENODATA, the right way is to have ->do_md_get()
211 * exported by dt layer.
213 if (rc == 0 || rc == -ENODATA) {
217 CERROR("Error %d reading eadata - %d\n", rc, *md_size);
219 /* XXX: Convert lov EA but fixed after verification test. */
226 int mdd_get_md_locked(const struct lu_env *env, struct mdd_object *obj,
227 void *md, int *md_size, const char *name)
230 mdd_read_lock(env, obj, MOR_TGT_CHILD);
231 rc = mdd_get_md(env, obj, md, md_size, name);
232 mdd_read_unlock(env, obj);
236 static int mdd_lov_set_stripe_md(const struct lu_env *env,
237 struct mdd_object *obj, struct lu_buf *buf,
238 struct thandle *handle)
240 struct mdd_device *mdd = mdo2mdd(&obj->mod_obj);
241 struct obd_device *obd = mdd2obd_dev(mdd);
242 struct obd_export *lov_exp = obd->u.mds.mds_osc_exp;
243 struct lov_stripe_md *lsm = NULL;
247 LASSERT(S_ISDIR(mdd_object_type(obj)) || S_ISREG(mdd_object_type(obj)));
248 rc = obd_iocontrol(OBD_IOC_LOV_SETSTRIPE, lov_exp, 0,
252 obd_free_memmd(lov_exp, &lsm);
254 rc = mdd_xattr_set_txn(env, obj, buf, XATTR_NAME_LOV, 0, handle);
256 CDEBUG(D_INFO, "set lov ea of "DFID" rc %d \n", PFID(mdo2fid(obj)), rc);
261 * Permission check is done before call it,
262 * no need check again.
264 static int mdd_lov_set_dir_md(const struct lu_env *env,
265 struct mdd_object *obj, struct lu_buf *buf,
266 struct thandle *handle)
268 struct lov_user_md *lum = NULL;
272 LASSERT(S_ISDIR(mdd_object_type(obj)));
273 lum = (struct lov_user_md*)buf->lb_buf;
275 /* if { size, offset, count } = { 0, -1, 0 } and no pool (i.e. all default
276 * values specified) then delete default striping from dir. */
277 if (lum->lmm_stripe_size == 0 && lum->lmm_stripe_count == 0 &&
278 lum->lmm_stripe_offset == (typeof(lum->lmm_stripe_offset))(-1) &&
279 lum->lmm_magic != LOV_USER_MAGIC_V3) {
280 rc = mdd_xattr_set_txn(env, obj, &LU_BUF_NULL,
281 XATTR_NAME_LOV, 0, handle);
284 CDEBUG(D_INFO, "delete lov ea of "DFID" rc %d \n",
285 PFID(mdo2fid(obj)), rc);
287 rc = mdd_lov_set_stripe_md(env, obj, buf, handle);
292 int mdd_lsm_sanity_check(const struct lu_env *env, struct mdd_object *obj)
294 struct lu_attr *tmp_la = &mdd_env_info(env)->mti_la;
295 struct md_ucred *uc = md_ucred(env);
299 rc = mdd_la_get(env, obj, tmp_la, BYPASS_CAPA);
303 if ((uc->mu_fsuid != tmp_la->la_uid) &&
304 !mdd_capable(uc, CFS_CAP_FOWNER))
305 rc = mdd_permission_internal_locked(env, obj, tmp_la,
306 MAY_WRITE, MOR_TGT_CHILD);
311 int mdd_lov_set_md(const struct lu_env *env, struct mdd_object *pobj,
312 struct mdd_object *child, struct lov_mds_md *lmmp,
313 int lmm_size, struct thandle *handle, int set_stripe)
320 buf = mdd_buf_get(env, lmmp, lmm_size);
321 mode = mdd_object_type(child);
322 if (S_ISREG(mode) && lmm_size > 0) {
324 rc = mdd_lov_set_stripe_md(env, child, buf, handle);
326 rc = mdd_xattr_set_txn(env, child, buf,
327 XATTR_NAME_LOV, 0, handle);
329 } else if (S_ISDIR(mode)) {
330 if (lmmp == NULL && lmm_size == 0) {
331 struct mdd_device *mdd = mdd_obj2mdd_dev(child);
332 struct lov_mds_md *lmm = mdd_max_lmm_get(env, mdd);
333 int size = sizeof(struct lov_mds_md_v3);
335 /* Get parent dir stripe and set */
337 rc = mdd_get_md_locked(env, pobj, lmm, &size,
340 buf = mdd_buf_get(env, lmm, size);
341 rc = mdd_xattr_set_txn(env, child, buf,
342 XATTR_NAME_LOV, 0, handle);
344 CERROR("error on copy stripe info: rc "
348 LASSERT(lmmp != NULL && lmm_size > 0);
349 rc = mdd_lov_set_dir_md(env, child, buf, handle);
352 CDEBUG(D_INFO, "Set lov md %p size %d for fid "DFID" rc %d\n",
353 lmmp, lmm_size, PFID(mdo2fid(child)), rc);
358 * XXX: this is for create lsm object id, which should identify the lsm object
359 * unique in the whole mds, as I see. But it seems, we still not need it
360 * now. Right? So just borrow the ll_fid_build_ino().
362 static obd_id mdd_lov_create_id(const struct lu_fid *fid)
364 return fid_flatten(fid);
367 int mdd_lov_objid_prepare(struct mdd_device *mdd, struct lov_mds_md *lmm)
369 /* copy mds_lov code is using wrong layer */
370 return mds_lov_prepare_objids(mdd->mdd_obd_dev, lmm);
373 void mdd_lov_objid_update(struct mdd_device *mdd, struct lov_mds_md *lmm)
375 /* copy mds_lov code is using wrong layer */
376 mds_lov_update_objids(mdd->mdd_obd_dev, lmm);
379 void mdd_lov_create_finish(const struct lu_env *env, struct mdd_device *mdd,
380 struct lov_mds_md *lmm, int lmm_size,
381 const struct md_op_spec *spec)
383 if (lmm && !spec->no_create)
384 OBD_FREE(lmm, lmm_size);
387 int mdd_lov_create(const struct lu_env *env, struct mdd_device *mdd,
388 struct mdd_object *parent, struct mdd_object *child,
389 struct lov_mds_md **lmm, int *lmm_size,
390 const struct md_op_spec *spec, struct lu_attr *la)
392 struct obd_device *obd = mdd2obd_dev(mdd);
393 struct obd_export *lov_exp = obd->u.mds.mds_osc_exp;
394 struct lu_site *site = mdd2lu_dev(mdd)->ld_site;
396 struct lov_stripe_md *lsm = NULL;
397 const void *eadata = spec->u.sp_ea.eadata;
398 __u32 create_flags = spec->sp_cr_flags;
399 struct obd_trans_info *oti = &mdd_env_info(env)->mti_oti;
403 if (!md_should_create(create_flags)) {
409 /* replay case, has objects already, only get lov from eadata */
410 if (spec->no_create != 0) {
411 *lmm = (struct lov_mds_md *)spec->u.sp_ea.eadata;
412 *lmm_size = spec->u.sp_ea.eadatalen;
413 LASSERT(*lmm_size == lov_mds_md_size((*lmm)->lmm_stripe_count,
418 if (OBD_FAIL_CHECK(OBD_FAIL_MDS_ALLOC_OBDO))
419 GOTO(out_ids, rc = -ENOMEM);
421 LASSERT(lov_exp != NULL);
422 oa = &mdd_env_info(env)->mti_oa;
424 oa->o_uid = 0; /* must have 0 uid / gid on OST */
426 oa->o_gr = mdt_to_obd_objgrp(lu_site2md(site)->ms_node_id);
427 oa->o_mode = S_IFREG | 0600;
428 oa->o_id = mdd_lov_create_id(mdd_object_fid(child));
429 oa->o_valid = OBD_MD_FLID | OBD_MD_FLTYPE | OBD_MD_FLFLAGS |
430 OBD_MD_FLMODE | OBD_MD_FLUID | OBD_MD_FLGID | OBD_MD_FLGROUP;
433 if (!(create_flags & MDS_OPEN_HAS_OBJS)) {
434 if (create_flags & MDS_OPEN_HAS_EA) {
435 LASSERT(eadata != NULL);
436 rc = obd_iocontrol(OBD_IOC_LOV_SETSTRIPE, lov_exp,
437 0, &lsm, (void*)eadata);
440 lsm->lsm_object_id = oa->o_id;
441 lsm->lsm_object_gr = oa->o_gr;
442 } else if (parent != NULL) {
443 /* get lov ea from parent and set to lov */
444 struct lov_mds_md *_lmm;
447 _lmm_size = mdd_lov_mdsize(env, mdd);
448 _lmm = mdd_max_lmm_get(env, mdd);
451 GOTO(out_oti, rc = -ENOMEM);
453 rc = mdd_get_md_locked(env, parent, _lmm,
457 rc = obd_iocontrol(OBD_IOC_LOV_SETSTRIPE,
465 OBD_FAIL_TIMEOUT(OBD_FAIL_MDS_OPEN_WAIT_CREATE, 10);
466 rc = obd_create(lov_exp, oa, &lsm, oti);
469 CERROR("Create error for "DFID": %d\n",
470 PFID(mdo2fid(child)), rc);
475 LASSERT_MDS_GROUP(lsm->lsm_object_gr);
477 LASSERT(eadata != NULL);
478 rc = obd_iocontrol(OBD_IOC_LOV_SETEA, lov_exp, 0, &lsm,
482 lsm->lsm_object_id = oa->o_id;
483 lsm->lsm_object_gr = oa->o_gr;
487 * Sometimes, we may truncate some object(without lsm) then open it
488 * (with write flags), so creating lsm above. The Nonzero(truncated)
489 * size should tell ost, since size attr is in charge by OST.
491 if (la->la_size && la->la_valid & LA_SIZE) {
492 struct obd_info *oinfo = &mdd_env_info(env)->mti_oi;
494 memset(oinfo, 0, sizeof(*oinfo));
496 /* When setting attr to ost, FLBKSZ is not needed. */
497 oa->o_valid &= ~OBD_MD_FLBLKSZ;
498 obdo_from_la(oa, la, OBD_MD_FLTYPE | OBD_MD_FLATIME |
499 OBD_MD_FLMTIME | OBD_MD_FLCTIME | OBD_MD_FLSIZE);
502 * XXX: Pack lustre id to OST, in OST, it will be packed by
503 * filter_fid, but can not see what is the usages. So just pack
504 * o_seq o_ver here, maybe fix it after this cycle.
506 oa->o_fid = fid_seq(mdd_object_fid(child));
507 oa->o_generation = fid_oid(mdd_object_fid(child));
508 oa->o_valid |= OBD_MD_FLFID | OBD_MD_FLGENER;
511 oinfo->oi_capa = NULL;
512 oinfo->oi_policy.l_extent.start = la->la_size;
513 oinfo->oi_policy.l_extent.end = OBD_OBJECT_EOF;
515 rc = obd_punch_rqset(lov_exp, oinfo, oti);
517 CERROR("Error setting attrs for "DFID": rc %d\n",
518 PFID(mdo2fid(child)), rc);
520 CERROR("obd_setattr for "DFID" rc %d\n",
521 PFID(mdo2fid(child)), rc);
528 /* blksize should be changed after create data object */
529 la->la_valid |= LA_BLKSIZE;
530 la->la_blksize = oa->o_blksize;
532 rc = obd_packmd(lov_exp, lmm, lsm);
534 CERROR("Cannot pack lsm, err = %d\n", rc);
537 if (mdd_lov_objid_prepare(mdd, *lmm) != 0) {
538 CERROR("Not have memory for update objid\n");
541 GOTO(out_oti, rc = -ENOMEM);
547 oti_free_cookies(oti);
550 obd_free_memmd(lov_exp, &lsm);
556 * used when destroying orphans and from mds_reint_unlink() when MDS wants to
557 * destroy objects on OSS.
560 int mdd_lovobj_unlink(const struct lu_env *env, struct mdd_device *mdd,
561 struct mdd_object *obj, struct lu_attr *la,
562 struct lov_mds_md *lmm, int lmm_size,
563 struct llog_cookie *logcookies,
566 struct obd_device *obd = mdd2obd_dev(mdd);
567 struct obd_export *lov_exp = obd->u.mds.mds_osc_exp;
568 struct lov_stripe_md *lsm = NULL;
569 struct obd_trans_info *oti = &mdd_env_info(env)->mti_oti;
570 struct obdo *oa = &mdd_env_info(env)->mti_oa;
571 struct lu_site *site = mdd2lu_dev(mdd)->ld_site;
578 rc = obd_unpackmd(lov_exp, &lsm, lmm, lmm_size);
580 CERROR("Error unpack md %p\n", lmm);
583 LASSERT(rc >= sizeof(*lsm));
587 oa->o_id = lsm->lsm_object_id;
588 oa->o_gr = mdt_to_obd_objgrp(lu_site2md(site)->ms_node_id);
589 oa->o_mode = la->la_mode & S_IFMT;
590 oa->o_valid = OBD_MD_FLID | OBD_MD_FLTYPE | OBD_MD_FLGROUP;
593 if (log_unlink && logcookies) {
594 oa->o_valid |= OBD_MD_FLCOOKIE;
595 oti->oti_logcookies = logcookies;
598 CDEBUG(D_INFO, "destroying OSS object %d/%d\n",
599 (int)oa->o_id, (int)oa->o_gr);
601 rc = obd_destroy(lov_exp, oa, lsm, oti, NULL, NULL);
603 obd_free_memmd(lov_exp, &lsm);
608 * called with obj locked.
610 int mdd_lov_destroy(const struct lu_env *env, struct mdd_device *mdd,
611 struct mdd_object *obj, struct lu_attr *la)
613 struct md_attr *ma = &mdd_env_info(env)->mti_ma;
617 LASSERT(mdd_write_locked(env, obj) != 0);
619 if (unlikely(!S_ISREG(mdd_object_type(obj))))
622 if (unlikely(la->la_nlink != 0)) {
623 CWARN("Attempt to destroy OSS object when nlink == %d\n",
628 ma->ma_lmm_size = mdd_lov_mdsize(env, mdd);
629 ma->ma_lmm = mdd_max_lmm_get(env, mdd);
630 ma->ma_cookie_size = mdd_lov_cookiesize(env, mdd);
631 ma->ma_cookie = mdd_max_cookie_get(env, mdd);
632 if (ma->ma_lmm == NULL || ma->ma_cookie == NULL)
633 RETURN(rc = -ENOMEM);
637 rc = mdd_get_md(env, obj, ma->ma_lmm, &ma->ma_lmm_size,
641 CWARN("Get lov ea failed for "DFID" rc = %d\n",
642 PFID(mdo2fid(obj)), rc);
648 ma->ma_valid = MA_LOV;
650 rc = mdd_unlink_log(env, mdd, obj, ma);
652 CWARN("mds unlink log for "DFID" failed: %d\n",
653 PFID(mdo2fid(obj)), rc);
657 if (ma->ma_valid & MA_COOKIE)
658 rc = mdd_lovobj_unlink(env, mdd, obj, la,
659 ma->ma_lmm, ma->ma_lmm_size,
664 int mdd_unlink_log(const struct lu_env *env, struct mdd_device *mdd,
665 struct mdd_object *mdd_cobj, struct md_attr *ma)
667 LASSERT(ma->ma_valid & MA_LOV);
669 if ((ma->ma_cookie_size > 0) &&
670 (mds_log_op_unlink(mdd2obd_dev(mdd), ma->ma_lmm, ma->ma_lmm_size,
671 ma->ma_cookie, ma->ma_cookie_size) > 0)) {
672 CDEBUG(D_HA, "DEBUG: unlink log is added for object "DFID"\n",
673 PFID(mdd_object_fid(mdd_cobj)));
674 ma->ma_valid |= MA_COOKIE;
679 int mdd_log_op_setattr(struct obd_device *obd, __u32 uid, __u32 gid,
680 struct lov_mds_md *lmm, int lmm_size,
681 struct llog_cookie *logcookies, int cookies_size)
683 struct mds_obd *mds = &obd->u.mds;
684 struct lov_stripe_md *lsm = NULL;
685 struct llog_setattr64_rec *lsr;
686 struct llog_ctxt *ctxt;
690 if (IS_ERR(mds->mds_osc_obd))
691 RETURN(PTR_ERR(mds->mds_osc_obd));
693 rc = obd_unpackmd(mds->mds_osc_exp, &lsm, lmm, lmm_size);
697 rc = obd_checkmd(mds->mds_osc_exp, obd->obd_self_export, lsm);
701 OBD_ALLOC(lsr, sizeof(*lsr));
703 GOTO(out, rc = -ENOMEM);
705 /* prepare setattr log record */
706 lsr->lsr_hdr.lrh_len = lsr->lsr_tail.lrt_len = sizeof(*lsr);
707 lsr->lsr_hdr.lrh_type = MDS_SETATTR64_REC;
711 /* write setattr log */
712 ctxt = llog_get_context(obd, LLOG_MDS_OST_ORIG_CTXT);
713 rc = llog_add(ctxt, &lsr->lsr_hdr, lsm, logcookies,
714 cookies_size / sizeof(struct llog_cookie));
718 OBD_FREE(lsr, sizeof(*lsr));
720 obd_free_memmd(mds->mds_osc_exp, &lsm);
724 int mdd_setattr_log(const struct lu_env *env, struct mdd_device *mdd,
725 const struct md_attr *ma,
726 struct lov_mds_md *lmm, int lmm_size,
727 struct llog_cookie *logcookies, int cookies_size)
729 struct obd_device *obd = mdd2obd_dev(mdd);
731 /* journal chown/chgrp in llog, just like unlink */
733 CDEBUG(D_INFO, "setattr llog for uid/gid=%lu/%lu\n",
734 (unsigned long)ma->ma_attr.la_uid,
735 (unsigned long)ma->ma_attr.la_gid);
736 return mdd_log_op_setattr(obd, ma->ma_attr.la_uid,
737 ma->ma_attr.la_gid, lmm,
738 lmm_size, logcookies,
744 static int mdd_osc_setattr_async(struct obd_device *obd, __u32 uid, __u32 gid,
745 struct lov_mds_md *lmm, int lmm_size,
746 struct llog_cookie *logcookies, __u64 id, __u32 gen,
749 struct mds_obd *mds = &obd->u.mds;
750 struct obd_trans_info oti = { 0 };
751 struct obd_info oinfo = { { { 0 } } };
755 if (OBD_FAIL_CHECK(OBD_FAIL_MDS_OST_SETATTR))
758 /* first get memory EA */
759 OBDO_ALLOC(oinfo.oi_oa);
765 rc = obd_unpackmd(mds->mds_osc_exp, &oinfo.oi_md, lmm, lmm_size);
767 CERROR("Error unpack md %p for inode "LPU64"\n", lmm, id);
771 rc = obd_checkmd(mds->mds_osc_exp, obd->obd_self_export, oinfo.oi_md);
773 CERROR("Error revalidate lsm %p \n", oinfo.oi_md);
778 oinfo.oi_oa->o_uid = uid;
779 oinfo.oi_oa->o_gid = gid;
780 oinfo.oi_oa->o_id = oinfo.oi_md->lsm_object_id;
781 oinfo.oi_oa->o_gr = oinfo.oi_md->lsm_object_gr;
782 oinfo.oi_oa->o_valid |= OBD_MD_FLID | OBD_MD_FLGROUP |
783 OBD_MD_FLUID | OBD_MD_FLGID;
785 oinfo.oi_oa->o_valid |= OBD_MD_FLCOOKIE;
786 oti.oti_logcookies = logcookies;
789 oinfo.oi_oa->o_fid = id;
790 oinfo.oi_oa->o_generation = gen;
791 oinfo.oi_oa->o_valid |= OBD_MD_FLFID | OBD_MD_FLGENER;
794 /* do async setattr from mds to ost not waiting for responses. */
795 rc = obd_setattr_async(mds->mds_osc_exp, &oinfo, &oti, NULL);
797 CDEBUG(D_INODE, "mds to ost setattr objid 0x"LPX64
798 " on ost error %d\n", oinfo.oi_md->lsm_object_id, rc);
801 obd_free_memmd(mds->mds_osc_exp, &oinfo.oi_md);
802 OBDO_FREE(oinfo.oi_oa);
806 int mdd_lov_setattr_async(const struct lu_env *env, struct mdd_object *obj,
807 struct lov_mds_md *lmm, int lmm_size,
808 struct llog_cookie *logcookies)
810 struct mdd_device *mdd = mdo2mdd(&obj->mod_obj);
811 struct obd_device *obd = mdd2obd_dev(mdd);
812 struct lu_attr *tmp_la = &mdd_env_info(env)->mti_la;
813 const struct lu_fid *fid = mdd_object_fid(obj);
817 mdd_read_lock(env, obj, MOR_TGT_CHILD);
818 rc = mdo_attr_get(env, obj, tmp_la, mdd_object_capa(env, obj));
819 mdd_read_unlock(env, obj);
823 rc = mdd_osc_setattr_async(obd, tmp_la->la_uid, tmp_la->la_gid, lmm,
824 lmm_size, logcookies, fid_seq(fid),