From 21101003db70b812002fbab9375e60751b5af9e5 Mon Sep 17 00:00:00 2001 From: huanghua Date: Thu, 10 Aug 2006 15:28:02 +0000 Subject: [PATCH] (1) in mdd_lov_create(), allocate lmm before using it to call mdd_get_md(); (2) in mdd_lov_create(), free lsm after using. --- lustre/mdc/mdc_request.c | 1 - lustre/mdd/mdd_lov.c | 24 ++++++++++++++++++------ 2 files changed, 18 insertions(+), 7 deletions(-) diff --git a/lustre/mdc/mdc_request.c b/lustre/mdc/mdc_request.c index d683cdf..1e9f981 100644 --- a/lustre/mdc/mdc_request.c +++ b/lustre/mdc/mdc_request.c @@ -425,7 +425,6 @@ int mdc_get_lustre_md(struct obd_export *exp, struct ptlrpc_request *req, } else if (md->body->valid & OBD_MD_FLDIREA) { /* TODO: umka, please handle this case */ LASSERT(S_ISDIR(md->body->mode)); - CDEBUG(D_ERROR, "I got ea for dir. What to do?\n"); offset++; } diff --git a/lustre/mdd/mdd_lov.c b/lustre/mdd/mdd_lov.c index 61a1815..abbc310 100644 --- a/lustre/mdd/mdd_lov.c +++ b/lustre/mdd/mdd_lov.c @@ -420,12 +420,23 @@ int mdd_lov_create(const struct lu_context *ctxt, struct mdd_device *mdd, if (rc) GOTO(out_oa, rc); } else { - LASSERT(*lmm == NULL); - rc = mdd_get_md(ctxt, &parent->mod_obj, *lmm, - lmm_size); + /* get lov ea from parent and set to lov */ + struct lov_mds_md *__lmm; + int __lmm_size, returned_lmm_size; + __lmm_size = mdd2_obd(mdd)->u.mds.mds_max_mdsize; + + OBD_ALLOC(__lmm, __lmm_size); + if (__lmm == NULL) + GOTO(out_oa, rc = -ENOMEM); + + rc = mdd_get_md(ctxt, &parent->mod_obj, __lmm, + &returned_lmm_size); if (rc > 0) rc = obd_iocontrol(OBD_IOC_LOV_SETSTRIPE, - lov_exp, 0, &lsm, *lmm); + lov_exp, 0, &lsm, __lmm); + OBD_FREE(__lmm, __lmm_size); + if (rc) + GOTO(out_oa, rc); } rc = obd_create(lov_exp, oa, &lsm, NULL); if (rc) { @@ -440,9 +451,8 @@ int mdd_lov_create(const struct lu_context *ctxt, struct mdd_device *mdd, LASSERT(eadata != NULL); rc = obd_iocontrol(OBD_IOC_LOV_SETEA, lov_exp, 0, &lsm, (void*)eadata); - if (rc) { + if (rc) GOTO(out_oa, rc); - } lsm->lsm_object_id = oa->o_id; } /*Sometimes, we may truncate some object(without lsm) @@ -486,6 +496,8 @@ int mdd_lov_create(const struct lu_context *ctxt, struct mdd_device *mdd, rc = 0; out_oa: obdo_free(oa); + if (lsm) + obd_free_memmd(lov_exp, &lsm); RETURN(rc); } -- 1.8.3.1