From fcbde1a986172c74e731a58279482e5254e43759 Mon Sep 17 00:00:00 2001 From: yury Date: Wed, 4 Oct 2006 12:39:19 +0000 Subject: [PATCH] - fix error handling in lov_llog_origin_add() (-ENOSPC is possible); - small cleanups. --- lustre/lov/lov_log.c | 11 +++++++---- lustre/mdd/mdd_handler.c | 3 +-- lustre/mdd/mdd_lov.c | 50 ++++++++++++++++++++++++++++-------------------- lustre/mgc/mgc_request.c | 4 ++-- 4 files changed, 39 insertions(+), 29 deletions(-) diff --git a/lustre/lov/lov_log.c b/lustre/lov/lov_log.c index cc7f8ef..1d3a7fd 100644 --- a/lustre/lov/lov_log.c +++ b/lustre/lov/lov_log.c @@ -60,14 +60,14 @@ static int lov_llog_origin_add(struct llog_ctxt *ctxt, struct obd_device *obd = ctxt->loc_obd; struct lov_obd *lov = &obd->u.lov; struct lov_oinfo *loi; - int i, rc = 0; + int i, rc = 0, rc1; ENTRY; LASSERTF(logcookies && numcookies >= lsm->lsm_stripe_count, "logcookies %p, numcookies %d lsm->lsm_stripe_count %d \n", logcookies, numcookies, lsm->lsm_stripe_count); - for (i = 0,loi = lsm->lsm_oinfo; i < lsm->lsm_stripe_count; i++,loi++) { + for (i = 0, loi = lsm->lsm_oinfo; i < lsm->lsm_stripe_count; i++,loi++) { struct obd_device *child = lov->lov_tgts[loi->loi_ost_idx]->ltd_exp->exp_obd; struct llog_ctxt *cctxt = llog_get_context(child, ctxt->loc_idx); @@ -90,8 +90,11 @@ static int lov_llog_origin_add(struct llog_ctxt *ctxt, break; } LASSERT(lsm->lsm_object_gr == loi->loi_gr); - rc += llog_add(cctxt, rec, NULL, logcookies + rc, - numcookies - rc); + rc1 = llog_add(cctxt, rec, NULL, logcookies + rc, + numcookies - rc); + if (rc1 < 0) + RETURN(rc); + rc += rc1; } RETURN(rc); diff --git a/lustre/mdd/mdd_handler.c b/lustre/mdd/mdd_handler.c index 6527482..4866110 100644 --- a/lustre/mdd/mdd_handler.c +++ b/lustre/mdd/mdd_handler.c @@ -151,7 +151,6 @@ static void mdd_txn_param_build(const struct lu_env *env, int op) /* init credits for each ops */ num_entries = ARRAY_SIZE(mdd_txn_descrs); - LASSERT(num_entries > 0); spin_lock(&mdd_txn_lock); @@ -159,7 +158,7 @@ static void mdd_txn_param_build(const struct lu_env *env, int op) if (mdd_txn_descrs[i].mod_op == op) { LASSERT(mdd_txn_descrs[i].mod_credits > 0); mdd_env_info(env)->mti_param.tp_credits = - mdd_txn_descrs[i].mod_credits; + mdd_txn_descrs[i].mod_credits; spin_unlock(&mdd_txn_lock); return; } diff --git a/lustre/mdd/mdd_lov.c b/lustre/mdd/mdd_lov.c index 6d0bcc8..85c040e 100644 --- a/lustre/mdd/mdd_lov.c +++ b/lustre/mdd/mdd_lov.c @@ -320,9 +320,10 @@ int mdd_lov_set_md(const struct lu_env *env, struct mdd_object *pobj, RETURN(rc); } -/* FIXME: this is for create lsm object id, which should identify the - * lsm object unique in the whole mds, as I see. But it seems, we - * still not need it now. right? so just borrow the ll_fid_build_ino +/* + * XXX: this is for create lsm object id, which should identify the lsm object + * unique in the whole mds, as I see. But it seems, we still not need it + * now. Right? So just borrow the ll_fid_build_ino(). */ static obd_id mdd_lov_create_id(const struct lu_fid *fid) { @@ -395,7 +396,7 @@ int mdd_lov_create(const struct lu_env *env, struct mdd_device *mdd, ENTRY; if (create_flags & MDS_OPEN_DELAY_CREATE || - !(create_flags & FMODE_WRITE)) + !(create_flags & FMODE_WRITE)) RETURN(0); oti_init(oti, NULL); @@ -410,7 +411,7 @@ int mdd_lov_create(const struct lu_env *env, struct mdd_device *mdd, } if (OBD_FAIL_CHECK_ONCE(OBD_FAIL_MDS_ALLOC_OBDO)) - GOTO(out_ids, rc = -ENOMEM); + GOTO(out_ids, rc = -ENOMEM); LASSERT(lov_exp != NULL); oa = obdo_alloc(); @@ -439,6 +440,7 @@ int mdd_lov_create(const struct lu_env *env, struct mdd_device *mdd, /* get lov ea from parent and set to lov */ struct lov_mds_md *__lmm; int __lmm_size, returned_lmm_size; + __lmm_size = mdd_lov_mdsize(env, mdd); returned_lmm_size = __lmm_size; @@ -447,7 +449,8 @@ int mdd_lov_create(const struct lu_env *env, struct mdd_device *mdd, GOTO(out_oa, rc = -ENOMEM); rc = mdd_get_md_locked(env, parent, __lmm, - &returned_lmm_size, MDS_LOV_MD_NAME); + &returned_lmm_size, + MDS_LOV_MD_NAME); if (rc > 0) rc = obd_iocontrol(OBD_IOC_LOV_SETSTRIPE, lov_exp, 0, &lsm, __lmm); @@ -458,7 +461,7 @@ int mdd_lov_create(const struct lu_env *env, struct mdd_device *mdd, rc = obd_create(lov_exp, oa, &lsm, oti); if (rc) { if (rc > 0) { - CERROR("create errro for "DFID": %d \n", + CERROR("Create error for "DFID": %d\n", PFID(mdo2fid(child)), rc); rc = -EIO; } @@ -474,11 +477,11 @@ int mdd_lov_create(const struct lu_env *env, struct mdd_device *mdd, lsm->lsm_object_id = oa->o_id; lsm->lsm_object_gr = oa->o_gr; } + /* - * Sometimes, we may truncate some object(without lsm) - * then open (with write flags)it, so creating lsm above. - * The Nonzero(truncated) size should tell ost. since size - * attr is in charged by OST. + * Sometimes, we may truncate some object(without lsm) then open (with + * write flags)it, so creating lsm above. The Nonzero(truncated) size + * should tell ost. since size attr is in charged by OST. */ if (la->la_size && la->la_valid & LA_SIZE) { struct obd_info *oinfo = &mdd_env_info(env)->mti_oi; @@ -486,23 +489,26 @@ int mdd_lov_create(const struct lu_env *env, struct mdd_device *mdd, memset(oinfo, 0, sizeof(*oinfo)); oa->o_size = la->la_size; - /* when setting attr to ost, FLBKSZ is not needed */ + + /* When setting attr to ost, FLBKSZ is not needed. */ oa->o_valid &= ~OBD_MD_FLBLKSZ; obdo_from_la(oa, la, OBD_MD_FLTYPE | OBD_MD_FLATIME | - OBD_MD_FLMTIME | OBD_MD_FLCTIME | OBD_MD_FLSIZE); - - /* FIXME:pack lustre id to OST, in OST, it will be packed - * by filter_fid, but can not see what is the usages. So just - * pack o_seq o_ver here, maybe fix it after this cycle*/ - oa->o_fid = lu_object_fid(mdd2lu_obj(child))->f_seq; - oa->o_generation = lu_object_fid(mdd2lu_obj(child))->f_oid; + OBD_MD_FLMTIME | OBD_MD_FLCTIME | OBD_MD_FLSIZE); + + /* + * XXX: Pack lustre id to OST, in OST, it will be packed by + * filter_fid, but can not see what is the usages. So just pack + * o_seq o_ver here, maybe fix it after this cycle. + */ + oa->o_fid = fid_seq(lu_object_fid(mdd2lu_obj(child))); + oa->o_generation = fid_oid(lu_object_fid(mdd2lu_obj(child))); oa->o_valid |= OBD_MD_FLFID | OBD_MD_FLGENER; oinfo->oi_oa = oa; oinfo->oi_md = lsm; rc = obd_setattr(lov_exp, oinfo, oti); if (rc) { - CERROR("error setting attrs for "DFID": rc %d\n", + CERROR("Error setting attrs for "DFID": rc %d\n", PFID(mdo2fid(child)), rc); if (rc > 0) { CERROR("obd_setattr for "DFID" rc %d\n", @@ -512,6 +518,7 @@ int mdd_lov_create(const struct lu_env *env, struct mdd_device *mdd, GOTO(out_oa, rc); } } + /* blksize should be changed after create data object */ la->la_valid |= LA_BLKSIZE; la->la_blksize = oa->o_blksize; @@ -523,6 +530,7 @@ int mdd_lov_create(const struct lu_env *env, struct mdd_device *mdd, } *lmm_size = rc; rc = 0; + EXIT; out_oa: oti_free_cookies(oti); obdo_free(oa); @@ -531,7 +539,7 @@ out_ids: obd_free_memmd(lov_exp, &lsm); if (rc != 0) mdd_lov_objid_free(env, mdd); - RETURN(rc); + return rc; } int mdd_unlink_log(const struct lu_env *env, struct mdd_device *mdd, diff --git a/lustre/mgc/mgc_request.c b/lustre/mgc/mgc_request.c index 1f8bcd0..b1abd04 100644 --- a/lustre/mgc/mgc_request.c +++ b/lustre/mgc/mgc_request.c @@ -45,7 +45,6 @@ #include #include - int mgc_logname2resid(char *logname, struct ldlm_res_id *res_id) { char *name_end; @@ -70,6 +69,7 @@ int mgc_logname2resid(char *logname, struct ldlm_res_id *res_id) memcpy(&resname, logname, len); memset(res_id, 0, sizeof(*res_id)); + /* Always use the same endianness for the resid */ res_id->name[0] = cpu_to_le64(resname); CDEBUG(D_MGC, "log %s to resid "LPX64"/"LPX64" (%.8s)\n", logname, @@ -115,7 +115,7 @@ static void config_log_put(struct config_llog_data *cld) /* Find a config log by name */ static struct config_llog_data *config_log_find(char *logname, - struct config_llog_instance *cfg) + struct config_llog_instance *cfg) { struct list_head *tmp; struct config_llog_data *cld; -- 1.8.3.1