From b1f73bad76669f9a991f308350df4e98fcb2be59 Mon Sep 17 00:00:00 2001 From: tappro Date: Thu, 22 Jun 2006 21:49:01 +0000 Subject: [PATCH] move mdsno_t into lustre_idl.h and use this type in code for mds number. --- lustre/cmm/cmm_device.c | 8 ++++---- lustre/cmm/cmm_internal.h | 4 ++-- lustre/cmm/cmm_object.c | 34 +++++++++++++++++++++------------- lustre/cmm/mdc_internal.h | 2 +- lustre/fld/fld_internal.h | 7 +++---- lustre/fld/fld_request.c | 8 ++++---- lustre/include/lustre/lustre_idl.h | 6 ++++-- lustre/include/lustre_fld.h | 6 +++--- lustre/lmv/lmv_fld.c | 8 ++++---- 9 files changed, 46 insertions(+), 37 deletions(-) diff --git a/lustre/cmm/cmm_device.c b/lustre/cmm/cmm_device.c index 7d35f35..fe9e4c1 100644 --- a/lustre/cmm/cmm_device.c +++ b/lustre/cmm/cmm_device.c @@ -86,10 +86,10 @@ extern struct lu_device_type mdc_device_type; static int cmm_add_mdc(const struct lu_context *ctx, struct cmm_device *cm, struct lustre_cfg *cfg) { - struct lu_device_type *ldt = &mdc_device_type; - struct lu_device *ld; - struct mdc_device *mc, *tmp; - __u32 mdc_num; + struct lu_device_type *ldt = &mdc_device_type; + struct lu_device *ld; + struct mdc_device *mc, *tmp; + mdsno_t mdc_num; int rc; ENTRY; diff --git a/lustre/cmm/cmm_internal.h b/lustre/cmm/cmm_internal.h index ef73eff..1215ad3 100644 --- a/lustre/cmm/cmm_internal.h +++ b/lustre/cmm/cmm_internal.h @@ -42,7 +42,7 @@ struct cmm_device { /* underlaying device in MDS stack, usually MDD */ struct md_device *cmm_child; /* other MD servers in cluster */ - __u32 cmm_local_num; + mdsno_t cmm_local_num; __u32 cmm_tgt_count; struct list_head cmm_targets; spinlock_t cmm_tgt_guard; @@ -92,7 +92,7 @@ struct cml_object { struct cmr_object { struct cmm_object cmm_obj; /* mds number where object is placed */ - __u32 cmo_num; + mdsno_t cmo_num; }; static inline struct cmm_device *cmm_obj2dev(struct cmm_object *c) diff --git a/lustre/cmm/cmm_object.c b/lustre/cmm/cmm_object.c index de413dd..a547404 100644 --- a/lustre/cmm/cmm_object.c +++ b/lustre/cmm/cmm_object.c @@ -44,11 +44,10 @@ static int cmm_special_fid(const struct lu_fid *fid) return !range_within(space, fid_seq(fid)); } -static int cmm_fld_lookup(struct cmm_device *cm, - const struct lu_fid *fid) +static int cmm_fld_lookup(struct cmm_device *cm, + const struct lu_fid *fid, mdsno_t *mds) { - __u64 mds; - int rc; + int rc = 0; ENTRY; LASSERT(fid_is_sane(fid)); @@ -56,19 +55,26 @@ static int cmm_fld_lookup(struct cmm_device *cm, /* XXX: is this correct? We need this to prevent FLD lookups while CMM * did not initialized yet all MDCs. */ if (cmm_special_fid(fid)) - mds = 0; + *mds = 0; else { - rc = fld_client_lookup(&cm->cmm_fld, fid_seq(fid), &mds); + rc = fld_client_lookup(&cm->cmm_fld, fid_seq(fid), mds); if (rc) { CERROR("can't find mds by seq "LPU64", rc %d\n", fid_seq(fid), rc); RETURN(rc); } } - CWARN("CMM: got MDS "LPU64" for sequence: "LPU64"\n", - mds, fid_seq(fid)); - RETURN((int)mds); + if (*mds >= cm->cmm_tgt_count) { + CERROR("Got invalid mdsno: %u (max: %u)\n", + *mds, cm->cmm_tgt_count); + rc = -EINVAL; + } else { + CDEBUG(D_INFO, "CMM: got MDS %u for sequence: "LPU64"\n", + *mds, fid_seq(fid)); + } + + RETURN (rc); } static struct md_object_operations cml_mo_ops; @@ -86,15 +92,17 @@ struct lu_object *cmm_object_alloc(const struct lu_context *ctx, struct lu_object *lo = NULL; const struct lu_fid *fid = &loh->loh_fid; struct cmm_device *cd; - int mdsnum; + mdsno_t mdsnum; + int rc = 0; + ENTRY; cd = lu2cmm_dev(ld); if (cd->cmm_flags & CMM_INITIALIZED) { /* get object location */ - mdsnum = cmm_fld_lookup(lu2cmm_dev(ld), fid); - if (mdsnum < 0) - RETURN(ERR_PTR(mdsnum)); + rc = cmm_fld_lookup(lu2cmm_dev(ld), fid, &mdsnum); + if (rc) + RETURN(ERR_PTR(rc)); } else /* * Device is not yet initialized, cmm_object is being created diff --git a/lustre/cmm/mdc_internal.h b/lustre/cmm/mdc_internal.h index 4ae5048..624d857 100644 --- a/lustre/cmm/mdc_internal.h +++ b/lustre/cmm/mdc_internal.h @@ -45,7 +45,7 @@ struct mdc_device { struct md_device mc_md_dev; /* other MD servers in cluster */ struct list_head mc_linkage; - __u32 mc_num; + mdsno_t mc_num; struct mdc_cli_desc mc_desc; }; diff --git a/lustre/fld/fld_internal.h b/lustre/fld/fld_internal.h index dd1f5e1..238e684 100644 --- a/lustre/fld/fld_internal.h +++ b/lustre/fld/fld_internal.h @@ -28,12 +28,11 @@ #include -typedef __u64 mdsno_t; typedef __u64 fidseq_t; struct fld_cache { struct hlist_node fld_list; - __u64 fld_mds; + mdsno_t fld_mds; __u64 fld_seq; }; @@ -51,8 +50,8 @@ struct fld_list { struct fld_item { struct list_head fld_list; - __u64 fld_seq; - __u64 fld_mds; + __u64 fld_seq; + mdsno_t fld_mds; }; enum fld_op { diff --git a/lustre/fld/fld_request.c b/lustre/fld/fld_request.c index faf4a6a..d96b81d 100644 --- a/lustre/fld/fld_request.c +++ b/lustre/fld/fld_request.c @@ -339,7 +339,7 @@ out_req: int fld_client_create(struct lu_client_fld *fld, - __u64 seq, __u64 mds) + __u64 seq, mdsno_t mds) { struct obd_export *fld_exp; struct md_fld md_fld; @@ -363,7 +363,7 @@ EXPORT_SYMBOL(fld_client_create); int fld_client_delete(struct lu_client_fld *fld, - __u64 seq, __u64 mds) + __u64 seq, mdsno_t mds) { struct obd_export *fld_exp; struct md_fld md_fld; @@ -387,7 +387,7 @@ EXPORT_SYMBOL(fld_client_delete); static int fld_client_get(struct lu_client_fld *fld, - __u64 seq, __u64 *mds) + __u64 seq, mdsno_t *mds) { struct obd_export *fld_exp; struct md_fld md_fld; @@ -410,7 +410,7 @@ fld_client_get(struct lu_client_fld *fld, /* lookup fid in the namespace of pfid according to the name */ int fld_client_lookup(struct lu_client_fld *fld, - __u64 seq, __u64 *mds) + __u64 seq, mdsno_t *mds) { #ifdef __KERNEL__ struct fld_cache *fld_entry; diff --git a/lustre/include/lustre/lustre_idl.h b/lustre/include/lustre/lustre_idl.h index a96e451..260f983 100644 --- a/lustre/include/lustre/lustre_idl.h +++ b/lustre/include/lustre/lustre_idl.h @@ -124,6 +124,8 @@ #define LUSTRE_LOG_VERSION 0x00050000 #define LUSTRE_MGS_VERSION 0x00060000 +typedef __u64 mdsno_t; + struct lu_range { __u64 lr_start; __u64 lr_end; @@ -1160,8 +1162,8 @@ extern void lustre_swab_lmv_desc (struct lmv_desc *ld); /* end adding MDT by huanghua@clusterfs.com */ struct md_fld { - __u64 mf_seq; - __u64 mf_mds; + __u64 mf_seq; + mdsno_t mf_mds; }; extern void lustre_swab_md_fld (struct md_fld *mf); diff --git a/lustre/include/lustre_fld.h b/lustre/include/lustre_fld.h index a727fdf..f02dd32 100644 --- a/lustre/include/lustre_fld.h +++ b/lustre/include/lustre_fld.h @@ -79,12 +79,12 @@ int fld_client_del_export(struct lu_client_fld *fld, struct obd_export *exp); int fld_client_create(struct lu_client_fld *fld, - __u64 seq, __u64 mds); + __u64 seq, mdsno_t mds); int fld_client_delete(struct lu_client_fld *fld, - __u64 seq, __u64 mds); + __u64 seq, mdsno_t mds); int fld_client_lookup(struct lu_client_fld *fld, - __u64 seq, __u64 *mds); + __u64 seq, mdsno_t *mds); #endif diff --git a/lustre/lmv/lmv_fld.c b/lustre/lmv/lmv_fld.c index 4d5ab1e..aec66ae 100644 --- a/lustre/lmv/lmv_fld.c +++ b/lustre/lmv/lmv_fld.c @@ -48,7 +48,7 @@ int lmv_fld_lookup(struct obd_device *obd, const struct lu_fid *fid) { struct lmv_obd *lmv = &obd->u.lmv; - __u64 mds; + mdsno_t mds; int rc; ENTRY; @@ -59,10 +59,10 @@ int lmv_fld_lookup(struct obd_device *obd, const struct lu_fid *fid) fid_seq(fid), rc); RETURN(rc); } - CDEBUG(D_WARNING, "LMV: got MDS "LPU64" for sequence: "LPU64"\n", + CDEBUG(D_WARNING, "LMV: got MDS %u for sequence: "LPU64"\n", mds, fid_seq(fid)); - if (mds >= lmv->desc.ld_tgt_count || mds < 0) { - CERROR("Got invalid mdsno: %llu (max: %d)\n", + if (mds >= lmv->desc.ld_tgt_count) { + CERROR("Got invalid mdsno: %u (max: %d)\n", mds, lmv->desc.ld_tgt_count); mds = (__u64)-EINVAL; } -- 1.8.3.1