From: wangdi Date: Fri, 14 Jul 2006 10:25:45 +0000 (+0000) Subject: Branch: b_new_cmd X-Git-Tag: v1_8_0_110~486^2~1422 X-Git-Url: https://git.whamcloud.com/?a=commitdiff_plain;h=42674ca0cbd669f08bcc8a547c14e4d3d7d57268;p=fs%2Flustre-release.git Branch: b_new_cmd fix set lov md for reg file --- diff --git a/lustre/mdd/mdd_handler.c b/lustre/mdd/mdd_handler.c index fc13810..55ad6ed 100644 --- a/lustre/mdd/mdd_handler.c +++ b/lustre/mdd/mdd_handler.c @@ -736,15 +736,16 @@ static int mdd_create(const struct lu_context *ctxt, struct md_object *pobj, struct mdd_object *mdo = md2mdd_obj(pobj); struct mdd_object *son = md2mdd_obj(child); struct dt_object *dt_son = mdd_object_child(son); + struct lov_mds_md *lmm = NULL; struct thandle *handle; - int rc, created = 0, inserted = 0, ref_add = 0; + int rc, created = 0, inserted = 0, ref_add = 0, lmm_size; ENTRY; /* no RPC inside the transaction, so OST objects should be created at * first */ if (S_ISREG(attr->la_mode)) { - rc = mdd_lov_create(ctxt, mdd, son); + rc = mdd_lov_create(ctxt, mdd, son, &lmm, &lmm_size); if (rc) RETURN(rc); } @@ -809,7 +810,7 @@ static int mdd_create(const struct lu_context *ctxt, struct md_object *pobj, GOTO(cleanup, rc); ref_add = 1; } - rc = mdd_lov_set_md(ctxt, pobj, child); + rc = mdd_lov_set_md(ctxt, pobj, child, lmm, lmm_size); if (rc) { CERROR("error on stripe info copy %d \n", rc); } diff --git a/lustre/mdd/mdd_internal.h b/lustre/mdd/mdd_internal.h index ce2dc0c..6be1f5a 100644 --- a/lustre/mdd/mdd_internal.h +++ b/lustre/mdd/mdd_internal.h @@ -61,9 +61,11 @@ int mdd_notify(struct md_device *md, struct obd_device *watched, int mdd_xattr_set(const struct lu_context *ctxt, struct md_object *obj, const void *buf, int buf_len, const char *name); int mdd_lov_set_md(const struct lu_context *ctxt, struct md_object *pobj, - struct md_object *child); + struct md_object *child, struct lov_mds_md *lmm, + int lmm_size); int mdd_lov_create(const struct lu_context *ctxt, struct mdd_device *mdd, - struct mdd_object *child); + struct mdd_object *child, struct lov_mds_md **lmm, + int *lmm_size); struct mdd_thread_info *mdd_ctx_info(const struct lu_context *ctx); extern struct lu_device_operations mdd_lu_ops; static inline int lu_device_is_mdd(struct lu_device *d) diff --git a/lustre/mdd/mdd_lov.c b/lustre/mdd/mdd_lov.c index a066a77..f37d8e0 100644 --- a/lustre/mdd/mdd_lov.c +++ b/lustre/mdd/mdd_lov.c @@ -242,7 +242,8 @@ static int mdd_get_md(const struct lu_context *ctxt, struct md_object *obj, } int mdd_lov_set_md(const struct lu_context *ctxt, struct md_object *pobj, - struct md_object *child) + struct md_object *child, struct lov_mds_md *lmmp, + int lmm_size) { struct dt_object *next = mdd_object_child(md2mdd_obj(child)); int rc = 0; @@ -250,25 +251,34 @@ int mdd_lov_set_md(const struct lu_context *ctxt, struct md_object *pobj, if (dt_is_dir(ctxt, next)) { struct lov_mds_md *lmm = &mdd_ctx_info(ctxt)->mti_lmm; - int lmm_size = sizeof(lmm); - rc = mdd_get_md(ctxt, pobj, &lmm, &lmm_size, 1); + int size = sizeof(lmm); + rc = mdd_get_md(ctxt, pobj, &lmm, &size, 1); if (rc > 0) { - rc = mdd_xattr_set(ctxt, child, lmm, lmm_size, MDS_LOV_MD_NAME); + rc = mdd_xattr_set(ctxt, child, lmm, size, + MDS_LOV_MD_NAME); if (rc) - CERROR("error on copy stripe info: rc = %d\n", rc); + CERROR("error on copy stripe info: rc = %d\n", + rc); } + } else if (lmmp) { + LASSERT(lmm_size > 0); + rc = mdd_xattr_set(ctxt, child, lmmp, lmm_size, + MDS_LOV_MD_NAME); + if (rc) + CERROR("error on copy stripe info: rc = %d\n", + rc); } RETURN(rc); } int mdd_lov_create(const struct lu_context *ctxt, struct mdd_device *mdd, - struct mdd_object *child) + struct mdd_object *child, struct lov_mds_md **lmm, + int *lmm_size) { struct md_lov_info *mli = &mdd->mdd_lov_info; struct obdo *oa; - struct lov_mds_md *lmm = NULL; struct lov_stripe_md *lsm = NULL; - int rc = 0, lmm_size; + int rc = 0; ENTRY; oa = obdo_alloc(); @@ -284,14 +294,13 @@ int mdd_lov_create(const struct lu_context *ctxt, struct mdd_device *mdd, if (rc) GOTO(out_oa, rc); - rc = obd_packmd(mli->md_lov_exp, &lmm, lsm); + rc = obd_packmd(mli->md_lov_exp, lmm, lsm); if (rc < 0) { CERROR("cannot pack lsm, err = %d\n", rc); GOTO(out_oa, rc); } - lmm_size = rc; + *lmm_size = rc; rc = 0; - /*FIXME: did not set MD here */ out_oa: obdo_free(oa); RETURN(rc);