From: John L. Hammond Date: Wed, 11 Feb 2015 17:12:00 +0000 (-0600) Subject: LU-5814 obd: rename obd_unpackmd() to md_unpackmd() X-Git-Tag: 2.7.56~25 X-Git-Url: https://git.whamcloud.com/?p=fs%2Flustre-release.git;a=commitdiff_plain;h=8f27184b14a192848429e52ac234805c324e1f7a LU-5814 obd: rename obd_unpackmd() to md_unpackmd() obd_unpackmd() is only implemented by LMV so move it from OBD operations to OBD MD operations and update the prototype to refectl the actual usage. Remove the unused function obd_free_memmd(). Signed-off-by: John L. Hammond Change-Id: I0cbbb003a94f1e5a04ba24c2a49223ff8fa16da9 Signed-off-by: Jinshan Xiong Reviewed-on: http://review.whamcloud.com/13737 Tested-by: Jenkins Tested-by: Maloo Reviewed-by: James Simmons Reviewed-by: Andreas Dilger --- diff --git a/lustre/include/lustre_lmv.h b/lustre/include/lustre_lmv.h index 7e23297..6c13fe7 100644 --- a/lustre/include/lustre_lmv.h +++ b/lustre/include/lustre_lmv.h @@ -78,9 +78,6 @@ lsm_md_eq(const struct lmv_stripe_md *lsm1, const struct lmv_stripe_md *lsm2) } union lmv_mds_md; -int lmv_alloc_md(union lmv_mds_md **lmmp, int stripe_count); -void lmv_free_md(union lmv_mds_md *lmm); -int lmv_alloc_memmd(struct lmv_stripe_md **lsmp, int stripe_count); void lmv_free_memmd(struct lmv_stripe_md *lsm); int lmvea_load_shards(const struct lu_env *env, struct dt_object *obj, diff --git a/lustre/include/obd.h b/lustre/include/obd.h index d19e0b2..c658de1 100644 --- a/lustre/include/obd.h +++ b/lustre/include/obd.h @@ -854,8 +854,6 @@ struct obd_ops { struct obd_statfs *osfs, __u64 max_age, __u32 flags); int (*o_statfs_async)(struct obd_export *exp, struct obd_info *oinfo, __u64 max_age, struct ptlrpc_request_set *set); - 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); int (*o_destroy)(const struct lu_env *env, struct obd_export *exp, @@ -1055,6 +1053,8 @@ struct md_ops { const struct lmv_stripe_md *, const char *name, int namelen, struct lu_fid *fid); + int (*m_unpackmd)(struct obd_export *exp, struct lmv_stripe_md **plsm, + const union lmv_mds_md *lmv, size_t lmv_size); }; static inline struct md_open_data *obd_mod_alloc(void) diff --git a/lustre/include/obd_class.h b/lustre/include/obd_class.h index d92d66b..1c6a3ae 100644 --- a/lustre/include/obd_class.h +++ b/lustre/include/obd_class.h @@ -686,40 +686,6 @@ obd_process_config(struct obd_device *obd, int datalen, void *data) RETURN(rc); } -/* Unpack an MD struct from disk to in-memory format. - * Returns +ve size of unpacked MD (0 for free), or -ve error. - * - * If @mem_tgt == NULL, MD size is returned (max size if @disk_src == NULL). - * If @*mem_tgt != NULL and @disk_src == NULL, @*mem_tgt will be freed. - * If @*mem_tgt == NULL, it will be allocated - */ -static inline int obd_unpackmd(struct obd_export *exp, - struct lov_stripe_md **mem_tgt, - struct lov_mds_md *disk_src, - int disk_len) -{ - int rc; - ENTRY; - - EXP_CHECK_DT_OP(exp, unpackmd); - EXP_COUNTER_INCREMENT(exp, unpackmd); - - rc = OBP(exp->exp_obd, unpackmd)(exp, mem_tgt, disk_src, disk_len); - RETURN(rc); -} - -static inline int obd_free_memmd(struct obd_export *exp, - struct lov_stripe_md **mem_tgt) -{ - int rc; - - LASSERT(mem_tgt); - LASSERT(*mem_tgt); - rc = obd_unpackmd(exp, mem_tgt, NULL, 0); - *mem_tgt = NULL; - return rc; -} - static inline int obd_create(const struct lu_env *env, struct obd_export *exp, struct obdo *obdo) { @@ -1660,6 +1626,25 @@ static inline int md_get_fid_from_lsm(struct obd_export *exp, RETURN(rc); } + +/* Unpack an MD struct from disk to in-memory format. + * Returns +ve size of unpacked MD (0 for free), or -ve error. + * + * If *plsm != NULL and lmm == NULL then *lsm will be freed. + * If *plsm == NULL then it will be allocated. + */ +static inline int md_unpackmd(struct obd_export *exp, + struct lmv_stripe_md **plsm, + const union lmv_mds_md *lmm, size_t lmm_size) +{ + int rc; + ENTRY; + EXP_CHECK_MD_OP(exp, unpackmd); + EXP_MD_COUNTER_INCREMENT(exp, unpackmd); + rc = MDP(exp->exp_obd, unpackmd)(exp, plsm, lmm, lmm_size); + RETURN(rc); +} + /* OBD Metadata Support */ extern int obd_init_caches(void); diff --git a/lustre/lmv/lmv_internal.h b/lustre/lmv/lmv_internal.h index aa61b22..9f0ec1d 100644 --- a/lustre/lmv/lmv_internal.h +++ b/lustre/lmv/lmv_internal.h @@ -60,9 +60,6 @@ int __lmv_fid_alloc(struct lmv_obd *lmv, struct lu_fid *fid, u32 mds); int lmv_fid_alloc(const struct lu_env *env, struct obd_export *exp, struct lu_fid *fid, struct md_op_data *op_data); -int lmv_unpack_md(struct obd_export *exp, struct lmv_stripe_md **lsmp, - const union lmv_mds_md *lmm, int stripe_count); - int lmv_revalidate_slaves(struct obd_export *exp, const struct lmv_stripe_md *lsm, ldlm_blocking_callback cb_blocking, diff --git a/lustre/lmv/lmv_obd.c b/lustre/lmv/lmv_obd.c index 861e336..0b914d7 100644 --- a/lustre/lmv/lmv_obd.c +++ b/lustre/lmv/lmv_obd.c @@ -2947,8 +2947,8 @@ static int lmv_unpack_md_v1(struct obd_export *exp, struct lmv_stripe_md *lsm, RETURN(rc); } -int lmv_unpack_md(struct obd_export *exp, struct lmv_stripe_md **lsmp, - const union lmv_mds_md *lmm, int stripe_count) +static int lmv_unpackmd(struct obd_export *exp, struct lmv_stripe_md **lsmp, + const union lmv_mds_md *lmm, size_t lmm_size) { struct lmv_stripe_md *lsm; int lsm_size; @@ -2976,17 +2976,6 @@ int lmv_unpack_md(struct obd_export *exp, struct lmv_stripe_md **lsmp, RETURN(0); } - /* Alloc memmd */ - if (lsm == NULL && lmm == NULL) { - lsm_size = lmv_stripe_md_size(stripe_count); - OBD_ALLOC(lsm, lsm_size); - if (lsm == NULL) - RETURN(-ENOMEM); - lsm->lsm_md_stripe_count = stripe_count; - *lsmp = lsm; - RETURN(0); - } - if (le32_to_cpu(lmm->lmv_magic) == LMV_MAGIC_STRIPE) RETURN(-EPERM); @@ -3036,24 +3025,12 @@ int lmv_unpack_md(struct obd_export *exp, struct lmv_stripe_md **lsmp, RETURN(lsm_size); } -int lmv_alloc_memmd(struct lmv_stripe_md **lsmp, int stripes) -{ - return lmv_unpack_md(NULL, lsmp, NULL, stripes); -} - void lmv_free_memmd(struct lmv_stripe_md *lsm) { - lmv_unpack_md(NULL, &lsm, NULL, 0); + lmv_unpackmd(NULL, &lsm, NULL, 0); } EXPORT_SYMBOL(lmv_free_memmd); -int lmv_unpackmd(struct obd_export *exp, struct lov_stripe_md **lsmp, - struct lov_mds_md *lmm, int disk_len) -{ - return lmv_unpack_md(exp, (struct lmv_stripe_md **)lsmp, - (union lmv_mds_md *)lmm, disk_len); -} - static int lmv_cancel_unused(struct obd_export *exp, const struct lu_fid *fid, ldlm_policy_data_t *policy, ldlm_mode_t mode, ldlm_cancel_flags_t flags, void *opaque) @@ -3386,7 +3363,6 @@ struct obd_ops lmv_obd_ops = { .o_statfs = lmv_statfs, .o_get_info = lmv_get_info, .o_set_info_async = lmv_set_info_async, - .o_unpackmd = lmv_unpackmd, .o_notify = lmv_notify, .o_get_uuid = lmv_get_uuid, .o_iocontrol = lmv_iocontrol, @@ -3424,6 +3400,7 @@ struct md_ops lmv_md_ops = { .m_intent_getattr_async = lmv_intent_getattr_async, .m_revalidate_lock = lmv_revalidate_lock, .m_get_fid_from_lsm = lmv_get_fid_from_lsm, + .m_unpackmd = lmv_unpackmd, }; int __init lmv_init(void) diff --git a/lustre/mdc/mdc_request.c b/lustre/mdc/mdc_request.c index f378eb8..fa082a2 100644 --- a/lustre/mdc/mdc_request.c +++ b/lustre/mdc/mdc_request.c @@ -463,8 +463,8 @@ int mdc_get_lustre_md(struct obd_export *exp, struct ptlrpc_request *req, if (md->layout.lb_buf == NULL) GOTO(out, rc = -EPROTO); } else if (md->body->mbo_valid & OBD_MD_FLDIREA) { - int lmvsize; - struct lov_mds_md *lmv; + const union lmv_mds_md *lmv; + size_t lmv_size; if (!S_ISDIR(md->body->mbo_mode)) { CDEBUG(D_INFO, "OBD_MD_FLDIREA set, should be a " @@ -472,21 +472,20 @@ int mdc_get_lustre_md(struct obd_export *exp, struct ptlrpc_request *req, GOTO(out, rc = -EPROTO); } - if (md->body->mbo_eadatasize == 0) { + lmv_size = md->body->mbo_eadatasize; + if (lmv_size == 0) { CDEBUG(D_INFO, "OBD_MD_FLDIREA is set, " "but eadatasize 0\n"); RETURN(-EPROTO); } if (md->body->mbo_valid & OBD_MD_MEA) { - lmvsize = md->body->mbo_eadatasize; lmv = req_capsule_server_sized_get(pill, &RMF_MDT_MD, - lmvsize); - if (!lmv) + lmv_size); + if (lmv == NULL) GOTO(out, rc = -EPROTO); - rc = obd_unpackmd(md_exp, (void *)&md->lmv, lmv, - lmvsize); + rc = md_unpackmd(md_exp, &md->lmv, lmv, lmv_size); if (rc < 0) GOTO(out, rc); diff --git a/lustre/obdclass/lprocfs_status_server.c b/lustre/obdclass/lprocfs_status_server.c index b3b1ee1..c06964d 100644 --- a/lustre/obdclass/lprocfs_status_server.c +++ b/lustre/obdclass/lprocfs_status_server.c @@ -436,7 +436,6 @@ void lprocfs_init_ops_stats(int num_private_stats, struct lprocfs_stats *stats) LPROCFS_OBD_OP_INIT(num_private_stats, stats, fid_alloc); LPROCFS_OBD_OP_INIT(num_private_stats, stats, statfs); LPROCFS_OBD_OP_INIT(num_private_stats, stats, statfs_async); - LPROCFS_OBD_OP_INIT(num_private_stats, stats, unpackmd); LPROCFS_OBD_OP_INIT(num_private_stats, stats, create); LPROCFS_OBD_OP_INIT(num_private_stats, stats, destroy); LPROCFS_OBD_OP_INIT(num_private_stats, stats, setattr);