From: John L. Hammond Date: Wed, 29 Oct 2014 17:15:06 +0000 (-0500) Subject: LU-5418 echo: replace lov_stripe_md with lov_oinfo X-Git-Tag: 2.6.91~64 X-Git-Url: https://git.whamcloud.com/?a=commitdiff_plain;h=eecdcf3004952f5d3a7126e0d6790c0be82f0a56;p=fs%2Flustre-release.git LU-5418 echo: replace lov_stripe_md with lov_oinfo In echo_client replace uses of struct lov_stripe_md with struct lov_oinfo (since the instances of the former really only contained a single instance of the latter). Remove the then unneccessary functions echo_alloc_memmd(), echo_free_memmd(), osc_unpackmd(), and obd_alloc_memmd(). Remove the struct lov_stripe_md * parameter from obd_create(). Flatten osc_create() and osc_real_create() into a single function. Signed-off-by: John L. Hammond Change-Id: I5fe276bcc56e1fa8138a4d3f20b9d5297cf74f3f Reviewed-on: http://review.whamcloud.com/12447 Tested-by: Jenkins Tested-by: Maloo Reviewed-by: Bobi Jam Reviewed-by: Jinshan Xiong Reviewed-by: Andreas Dilger --- diff --git a/lustre/include/obd.h b/lustre/include/obd.h index 5d1dde4..b938315 100644 --- a/lustre/include/obd.h +++ b/lustre/include/obd.h @@ -932,9 +932,8 @@ struct obd_ops { struct lov_stripe_md *mem_src); int (*o_unpackmd)(struct obd_export *exp,struct lov_stripe_md **mem_tgt, struct lov_mds_md *disk_src, int disk_len); - int (*o_create)(const struct lu_env *env, struct obd_export *exp, - struct obdo *oa, struct lov_stripe_md **ea, - struct obd_trans_info *oti); + int (*o_create)(const struct lu_env *env, struct obd_export *exp, + struct obdo *oa, struct obd_trans_info *oti); int (*o_destroy)(const struct lu_env *env, struct obd_export *exp, struct obdo *oa, struct lov_stripe_md *ea, struct obd_trans_info *oti, struct obd_export *md_exp, diff --git a/lustre/include/obd_class.h b/lustre/include/obd_class.h index cf29104..01ea331 100644 --- a/lustre/include/obd_class.h +++ b/lustre/include/obd_class.h @@ -754,15 +754,6 @@ static inline int obd_unpackmd(struct obd_export *exp, RETURN(rc); } -/* helper functions */ -static inline int obd_alloc_memmd(struct obd_export *exp, - struct lov_stripe_md **mem_tgt) -{ - LASSERT(mem_tgt); - LASSERT(*mem_tgt == NULL); - return obd_unpackmd(exp, mem_tgt, NULL, 0); -} - static inline int obd_free_memmd(struct obd_export *exp, struct lov_stripe_md **mem_tgt) { @@ -776,17 +767,16 @@ static inline int obd_free_memmd(struct obd_export *exp, } static inline int obd_create(const struct lu_env *env, struct obd_export *exp, - struct obdo *obdo, struct lov_stripe_md **ea, - struct obd_trans_info *oti) + struct obdo *obdo, struct obd_trans_info *oti) { - int rc; - ENTRY; + int rc; + ENTRY; - EXP_CHECK_DT_OP(exp, create); - EXP_COUNTER_INCREMENT(exp, create); + EXP_CHECK_DT_OP(exp, create); + EXP_COUNTER_INCREMENT(exp, create); - rc = OBP(exp->exp_obd, create)(env, exp, obdo, ea, oti); - RETURN(rc); + rc = OBP(exp->exp_obd, create)(env, exp, obdo, oti); + RETURN(rc); } static inline int obd_destroy(const struct lu_env *env, struct obd_export *exp, diff --git a/lustre/obdecho/echo.c b/lustre/obdecho/echo.c index 73c74c2..18dc6a4 100644 --- a/lustre/obdecho/echo.c +++ b/lustre/obdecho/echo.c @@ -116,8 +116,7 @@ static int echo_destroy_export(struct obd_export *exp) } static int echo_create(const struct lu_env *env, struct obd_export *exp, - struct obdo *oa, struct lov_stripe_md **ea, - struct obd_trans_info *oti) + struct obdo *oa, struct obd_trans_info *oti) { struct obd_device *obd = class_exp2obd(exp); diff --git a/lustre/obdecho/echo_client.c b/lustre/obdecho/echo_client.c index d8ea518..cc4feef 100644 --- a/lustre/obdecho/echo_client.c +++ b/lustre/obdecho/echo_client.c @@ -69,19 +69,18 @@ struct echo_device { }; struct echo_object { - struct cl_object eo_cl; - struct cl_object_header eo_hdr; - - struct echo_device *eo_dev; + struct cl_object eo_cl; + struct cl_object_header eo_hdr; + struct echo_device *eo_dev; struct list_head eo_obj_chain; - struct lov_stripe_md *eo_lsm; + struct lov_oinfo *eo_oinfo; atomic_t eo_npages; - int eo_deleted; + int eo_deleted; }; struct echo_object_conf { - struct cl_object_conf eoc_cl; - struct lov_stripe_md **eoc_md; + struct cl_object_conf eoc_cl; + struct lov_oinfo **eoc_oinfo; }; struct echo_page { @@ -163,8 +162,6 @@ struct echo_object_conf *cl2echo_conf(const struct cl_object_conf *c) /** @} echo_helpers */ -static struct echo_object *cl_echo_object_find(struct echo_device *d, - struct lov_stripe_md **lsm); static int cl_echo_object_put(struct echo_object *eco); static int cl_echo_object_brw(struct echo_object *eco, int rw, obd_off offset, struct page **pages, int npages, int async); @@ -439,13 +436,15 @@ static int echo_object_init(const struct lu_env *env, struct lu_object *obj, const struct cl_object_conf *cconf = lu2cl_conf(conf); struct echo_object_conf *econf = cl2echo_conf(cconf); - LASSERT(econf->eoc_md); - eco->eo_lsm = *econf->eoc_md; - /* clear the lsm pointer so that it won't get freed. */ - *econf->eoc_md = NULL; - } else { - eco->eo_lsm = NULL; - } + LASSERT(econf->eoc_oinfo != NULL); + + /* Transfer the oinfo pointer to eco that it won't be + * freed. */ + eco->eo_oinfo = *econf->eoc_oinfo; + *econf->eoc_oinfo = NULL; + } else { + eco->eo_oinfo = NULL; + } eco->eo_dev = ed; atomic_set(&eco->eo_npages, 0); @@ -458,57 +457,6 @@ static int echo_object_init(const struct lu_env *env, struct lu_object *obj, RETURN(0); } -/* taken from osc_unpackmd() */ -static int echo_alloc_memmd(struct echo_device *ed, - struct lov_stripe_md **lsmp) -{ - int lsm_size; - - ENTRY; - - /* If export is lov/osc then use their obd method */ - if (ed->ed_next != NULL) - return obd_alloc_memmd(ed->ed_ec->ec_exp, lsmp); - /* OFD has no unpackmd method, do everything here */ - lsm_size = lov_stripe_md_size(1); - - LASSERT(*lsmp == NULL); - OBD_ALLOC(*lsmp, lsm_size); - if (*lsmp == NULL) - RETURN(-ENOMEM); - - OBD_ALLOC((*lsmp)->lsm_oinfo[0], sizeof(struct lov_oinfo)); - if ((*lsmp)->lsm_oinfo[0] == NULL) { - OBD_FREE(*lsmp, lsm_size); - RETURN(-ENOMEM); - } - - loi_init((*lsmp)->lsm_oinfo[0]); - (*lsmp)->lsm_maxbytes = LUSTRE_EXT3_STRIPE_MAXBYTES; - ostid_set_seq_echo(&(*lsmp)->lsm_oi); - - RETURN(lsm_size); -} - -static int echo_free_memmd(struct echo_device *ed, struct lov_stripe_md **lsmp) -{ - int lsm_size; - - ENTRY; - - /* If export is lov/osc then use their obd method */ - if (ed->ed_next != NULL) - return obd_free_memmd(ed->ed_ec->ec_exp, lsmp); - /* OFD has no unpackmd method, do everything here */ - lsm_size = lov_stripe_md_size(1); - - LASSERT(*lsmp != NULL); - OBD_FREE((*lsmp)->lsm_oinfo[0], sizeof(struct lov_oinfo)); - OBD_FREE(*lsmp, lsm_size); - *lsmp = NULL; - RETURN(0); -} - static void echo_object_free(const struct lu_env *env, struct lu_object *obj) { struct echo_object *eco = cl2echo_obj(lu2cl(obj)); @@ -524,8 +472,9 @@ static void echo_object_free(const struct lu_env *env, struct lu_object *obj) lu_object_fini(obj); lu_object_header_fini(obj->lo_header); - if (eco->eo_lsm) - echo_free_memmd(eco->eo_dev, &eco->eo_lsm); + if (eco->eo_oinfo != NULL) + OBD_FREE_PTR(eco->eo_oinfo); + OBD_SLAB_FREE_PTR(eco, echo_object_kmem); EXIT; } @@ -1018,26 +967,22 @@ static struct lu_device_type echo_device_type = { */ /* Interfaces to echo client obd device */ -static struct echo_object *cl_echo_object_find(struct echo_device *d, - struct lov_stripe_md **lsmp) +static struct echo_object * +cl_echo_object_find(struct echo_device *d, const struct ost_id *oi) { - struct lu_env *env; - struct echo_thread_info *info; - struct echo_object_conf *conf; - struct lov_stripe_md *lsm; - struct echo_object *eco; - struct cl_object *obj; - struct lu_fid *fid; - int refcheck; + struct lu_env *env; + struct echo_thread_info *info; + struct echo_object_conf *conf; + struct echo_object *eco; + struct cl_object *obj; + struct lov_oinfo *oinfo = NULL; + struct lu_fid *fid; + int refcheck; int rc; ENTRY; - LASSERT(lsmp); - lsm = *lsmp; - LASSERT(lsm); - LASSERTF(ostid_id(&lsm->lsm_oi) != 0, DOSTID"\n", POSTID(&lsm->lsm_oi)); - LASSERTF(ostid_seq(&lsm->lsm_oi) == FID_SEQ_ECHO, DOSTID"\n", - POSTID(&lsm->lsm_oi)); + LASSERTF(ostid_id(oi) != 0, DOSTID"\n", POSTID(oi)); + LASSERTF(ostid_seq(oi) == FID_SEQ_ECHO, DOSTID"\n", POSTID(oi)); /* Never return an object if the obd is to be freed. */ if (echo_dev2cl(d)->cd_lu_dev.ld_obd->obd_stopping) @@ -1050,16 +995,20 @@ static struct echo_object *cl_echo_object_find(struct echo_device *d, info = echo_env_info(env); conf = &info->eti_conf; if (d->ed_next) { - struct lov_oinfo *oinfo = lsm->lsm_oinfo[0]; + OBD_ALLOC_PTR(oinfo); + if (oinfo == NULL) + GOTO(out, eco = ERR_PTR(-ENOMEM)); - LASSERT(oinfo != NULL); - oinfo->loi_oi = lsm->lsm_oi; + oinfo->loi_oi = *oi; conf->eoc_cl.u.coc_oinfo = oinfo; - } - conf->eoc_md = lsmp; + } + + /* If echo_object_init() is successful then ownership of oinfo + * is transferred to the object. */ + conf->eoc_oinfo = &oinfo; - fid = &info->eti_fid; - rc = ostid_to_fid(fid, &lsm->lsm_oi, 0); + fid = &info->eti_fid; + rc = ostid_to_fid(fid, oi, 0); if (rc != 0) GOTO(out, eco = ERR_PTR(rc)); @@ -1077,6 +1026,9 @@ static struct echo_object *cl_echo_object_find(struct echo_device *d, } out: + if (oinfo != NULL) + OBD_FREE_PTR(oinfo); + cl_env_put(env, &refcheck); RETURN(eco); } @@ -2090,38 +2042,23 @@ out_env: static int echo_create_object(const struct lu_env *env, struct echo_device *ed, struct obdo *oa, struct obd_trans_info *oti) { - struct echo_object *eco; - struct echo_client_obd *ec = ed->ed_ec; - struct lov_stripe_md *lsm = NULL; - int rc; - int created = 0; - ENTRY; - - if ((oa->o_valid & OBD_MD_FLID) == 0) { /* no obj id */ - CERROR ("No valid oid\n"); - RETURN(-EINVAL); - } - - rc = echo_alloc_memmd(ed, &lsm); - if (rc < 0) { - CERROR("Cannot allocate md: rc = %d\n", rc); - GOTO(failed, rc); - } + struct echo_object *eco; + struct echo_client_obd *ec = ed->ed_ec; + int created = 0; + int rc; + ENTRY; - /* setup object ID here */ - if (oa->o_valid & OBD_MD_FLID) { - LASSERT(oa->o_valid & OBD_MD_FLGROUP); - lsm->lsm_oi = oa->o_oi; + if (!(oa->o_valid & OBD_MD_FLID) || + !(oa->o_valid & OBD_MD_FLGROUP) || + !fid_seq_is_echo(ostid_seq(&oa->o_oi))) { + CERROR("invalid oid "DOSTID"\n", POSTID(&oa->o_oi)); + RETURN(-EINVAL); } - if (ostid_id(&lsm->lsm_oi) == 0) - ostid_set_id(&lsm->lsm_oi, ++last_object_id); + if (ostid_id(&oa->o_oi) == 0) + ostid_set_id(&oa->o_oi, ++last_object_id); - /* Only echo objects are allowed to be created */ - LASSERT((oa->o_valid & OBD_MD_FLGROUP) && - (ostid_seq(&oa->o_oi) == FID_SEQ_ECHO)); - - rc = obd_create(env, ec->ec_exp, oa, &lsm, oti); + rc = obd_create(env, ec->ec_exp, oa, oti); if (rc != 0) { CERROR("Cannot create objects: rc = %d\n", rc); GOTO(failed, rc); @@ -2129,11 +2066,9 @@ static int echo_create_object(const struct lu_env *env, struct echo_device *ed, created = 1; - /* See what object ID we were given */ - oa->o_oi = lsm->lsm_oi; - oa->o_valid |= OBD_MD_FLID; + oa->o_valid |= OBD_MD_FLID; - eco = cl_echo_object_find(ed, &lsm); + eco = cl_echo_object_find(ed, &oa->o_oi); if (IS_ERR(eco)) GOTO(failed, rc = PTR_ERR(eco)); cl_echo_object_put(eco); @@ -2141,47 +2076,38 @@ static int echo_create_object(const struct lu_env *env, struct echo_device *ed, CDEBUG(D_INFO, "oa oid "DOSTID"\n", POSTID(&oa->o_oi)); EXIT; - failed: - if (created && rc) - obd_destroy(env, ec->ec_exp, oa, lsm, oti, NULL, NULL); - if (lsm) - echo_free_memmd(ed, &lsm); - if (rc) - CERROR("create object failed with: rc = %d\n", rc); - return (rc); +failed: + if (created && rc != 0) + obd_destroy(env, ec->ec_exp, oa, NULL, oti, NULL, NULL); + + if (rc != 0) + CERROR("create object failed with: rc = %d\n", rc); + + return rc; } static int echo_get_object(struct echo_object **ecop, struct echo_device *ed, - struct obdo *oa) + struct obdo *oa) { - struct lov_stripe_md *lsm = NULL; - struct echo_object *eco; - int rc; - ENTRY; + struct echo_object *eco; + int rc; + ENTRY; - if ((oa->o_valid & OBD_MD_FLID) == 0 || ostid_id(&oa->o_oi) == 0) { - /* disallow use of object id 0 */ - CERROR ("No valid oid\n"); - RETURN(-EINVAL); - } + if (!(oa->o_valid & OBD_MD_FLID) || + !(oa->o_valid & OBD_MD_FLGROUP) || + ostid_id(&oa->o_oi) == 0) { + CERROR("invalid oid "DOSTID"\n", POSTID(&oa->o_oi)); + RETURN(-EINVAL); + } - rc = echo_alloc_memmd(ed, &lsm); - if (rc < 0) - RETURN(rc); + rc = 0; + eco = cl_echo_object_find(ed, &oa->o_oi); + if (!IS_ERR(eco)) + *ecop = eco; + else + rc = PTR_ERR(eco); - lsm->lsm_oi = oa->o_oi; - if (!(oa->o_valid & OBD_MD_FLGROUP)) - ostid_set_seq_echo(&lsm->lsm_oi); - - rc = 0; - eco = cl_echo_object_find(ed, &lsm); - if (!IS_ERR(eco)) - *ecop = eco; - else - rc = PTR_ERR(eco); - if (lsm) - echo_free_memmd(ed, &lsm); - RETURN(rc); + RETURN(rc); } static void echo_put_object(struct echo_object *eco) diff --git a/lustre/ofd/ofd_obd.c b/lustre/ofd/ofd_obd.c index 561509e..dfd190f 100644 --- a/lustre/ofd/ofd_obd.c +++ b/lustre/ofd/ofd_obd.c @@ -1102,8 +1102,7 @@ out: * \retval negative value on error */ int ofd_echo_create(const struct lu_env *env, struct obd_export *exp, - struct obdo *oa, struct lov_stripe_md **ea, - struct obd_trans_info *oti) + struct obdo *oa, struct obd_trans_info *oti) { struct ofd_device *ofd = ofd_exp(exp); struct ofd_thread_info *info; @@ -1161,11 +1160,6 @@ int ofd_echo_create(const struct lu_env *env, struct obd_export *exp, ofd_grant_commit(env, ofd_obd(ofd)->obd_self_export, rc); out: mutex_unlock(&oseq->os_create_lock); - if (rc == 0 && ea != NULL) { - struct lov_stripe_md *lsm = *ea; - - lsm->lsm_oi = oa->o_oi; - } ofd_seq_put(env, oseq); out_sem: diff --git a/lustre/osc/osc_internal.h b/lustre/osc/osc_internal.h index c353f1c..c26e70f 100644 --- a/lustre/osc/osc_internal.h +++ b/lustre/osc/osc_internal.h @@ -90,11 +90,6 @@ struct osc_cache_waiter { int ocw_rc; }; -int osc_create(const struct lu_env *env, struct obd_export *exp, - struct obdo *oa, struct lov_stripe_md **ea, - struct obd_trans_info *oti); -int osc_real_create(struct obd_export *exp, struct obdo *oa, - struct lov_stripe_md **ea, struct obd_trans_info *oti); void osc_wake_cache_waiters(struct client_obd *cli); int osc_shrink_grant_to_target(struct client_obd *cli, __u64 target_bytes); void osc_update_next_shrink(struct client_obd *cli); diff --git a/lustre/osc/osc_request.c b/lustre/osc/osc_request.c index 63653fa..3eb7c7c 100644 --- a/lustre/osc/osc_request.c +++ b/lustre/osc/osc_request.c @@ -100,68 +100,6 @@ static void osc_release_ppga(struct brw_page **ppga, obd_count count); static int brw_interpret(const struct lu_env *env, struct ptlrpc_request *req, void *data, int rc); -/* Unpack OSC object metadata from disk storage (LE byte order). */ -static int osc_unpackmd(struct obd_export *exp, struct lov_stripe_md **lsmp, - struct lov_mds_md *lmm, int lmm_bytes) -{ - int lsm_size; - struct obd_import *imp = class_exp2cliimp(exp); - ENTRY; - - if (lmm != NULL) { - if (lmm_bytes < sizeof(*lmm)) { - CERROR("%s: lov_mds_md too small: %d, need %d\n", - exp->exp_obd->obd_name, lmm_bytes, - (int)sizeof(*lmm)); - RETURN(-EINVAL); - } - /* XXX LOV_MAGIC etc check? */ - - if (unlikely(ostid_id(&lmm->lmm_oi) == 0)) { - CERROR("%s: zero lmm_object_id: rc = %d\n", - exp->exp_obd->obd_name, -EINVAL); - RETURN(-EINVAL); - } - } - - lsm_size = lov_stripe_md_size(1); - if (lsmp == NULL) - RETURN(lsm_size); - - if (*lsmp != NULL && lmm == NULL) { - OBD_FREE((*lsmp)->lsm_oinfo[0], sizeof(struct lov_oinfo)); - OBD_FREE(*lsmp, lsm_size); - *lsmp = NULL; - RETURN(0); - } - - if (*lsmp == NULL) { - OBD_ALLOC(*lsmp, lsm_size); - if (unlikely(*lsmp == NULL)) - RETURN(-ENOMEM); - OBD_ALLOC((*lsmp)->lsm_oinfo[0], sizeof(struct lov_oinfo)); - if (unlikely((*lsmp)->lsm_oinfo[0] == NULL)) { - OBD_FREE(*lsmp, lsm_size); - RETURN(-ENOMEM); - } - loi_init((*lsmp)->lsm_oinfo[0]); - } else if (unlikely(ostid_id(&(*lsmp)->lsm_oi) == 0)) { - RETURN(-EBADF); - } - - if (lmm != NULL) - /* XXX zero *lsmp? */ - ostid_le_to_cpu(&lmm->lmm_oi, &(*lsmp)->lsm_oi); - - if (imp != NULL && - (imp->imp_connect_data.ocd_connect_flags & OBD_CONNECT_MAXBYTES)) - (*lsmp)->lsm_maxbytes = imp->imp_connect_data.ocd_maxbytes; - else - (*lsmp)->lsm_maxbytes = LUSTRE_EXT3_STRIPE_MAXBYTES; - - RETURN(lsm_size); -} - static inline void osc_pack_capa(struct ptlrpc_request *req, struct ost_body *body, void *capa) { @@ -429,24 +367,17 @@ static int osc_setattr_async(struct obd_export *exp, struct obd_info *oinfo, oinfo->oi_cb_up, oinfo, rqset); } -int osc_real_create(struct obd_export *exp, struct obdo *oa, - struct lov_stripe_md **ea, struct obd_trans_info *oti) +static int osc_create(const struct lu_env *env, struct obd_export *exp, + struct obdo *oa, struct obd_trans_info *oti) { struct ptlrpc_request *req; struct ost_body *body; - struct lov_stripe_md *lsm; int rc; ENTRY; - LASSERT(oa); - LASSERT(ea); - - lsm = *ea; - if (!lsm) { - rc = obd_alloc_memmd(exp, &lsm); - if (rc < 0) - RETURN(rc); - } + LASSERT(oa != NULL); + LASSERT(oa->o_valid & OBD_MD_FLGROUP); + LASSERT(fid_seq_is_echo(ostid_seq(&oa->o_oi))); req = ptlrpc_request_alloc(class_exp2cliimp(exp), &RQF_OST_CREATE); if (req == NULL) @@ -487,13 +418,6 @@ int osc_real_create(struct obd_export *exp, struct obdo *oa, oa->o_blksize = cli_brw_size(exp->exp_obd); oa->o_valid |= OBD_MD_FLBLKSZ; - /* XXX LOV STACKING: the lsm that is passed to us from LOV does not - * have valid lsm_oinfo data structs, so don't go touching that. - * This needs to be fixed in a big way. - */ - lsm->lsm_oi = oa->o_oi; - *ea = lsm; - if (oti != NULL) { if (oa->o_valid & OBD_MD_FLCOOKIE) { if (oti->oti_logcookies == NULL) @@ -508,9 +432,7 @@ int osc_real_create(struct obd_export *exp, struct obdo *oa, out_req: ptlrpc_req_finished(req); out: - if (rc && !*ea) - obd_free_memmd(exp, &lsm); - RETURN(rc); + RETURN(rc); } int osc_punch_base(struct obd_export *exp, struct obd_info *oinfo, @@ -690,26 +612,6 @@ static int osc_can_send_destroy(struct client_obd *cli) return 0; } -int osc_create(const struct lu_env *env, struct obd_export *exp, - struct obdo *oa, struct lov_stripe_md **ea, - struct obd_trans_info *oti) -{ - int rc = 0; - ENTRY; - - LASSERT(oa); - LASSERT(ea); - LASSERT(oa->o_valid & OBD_MD_FLGROUP); - - if (!fid_seq_is_mdt(ostid_seq(&oa->o_oi))) - RETURN(osc_real_create(exp, oa, ea, oti)); - - /* we should not get here anymore */ - LBUG(); - - RETURN(rc); -} - /* Destroy requests can be async always on the client, and we don't even really * care about the return code since the client cannot do anything at all about * a destroy failure. @@ -3198,7 +3100,6 @@ struct obd_ops osc_obd_ops = { .o_disconnect = osc_disconnect, .o_statfs = osc_statfs, .o_statfs_async = osc_statfs_async, - .o_unpackmd = osc_unpackmd, .o_create = osc_create, .o_destroy = osc_destroy, .o_getattr = osc_getattr,