Whamcloud - gitweb
move mdsno_t into lustre_idl.h and use this type in code for mds number.
authortappro <tappro>
Thu, 22 Jun 2006 21:49:01 +0000 (21:49 +0000)
committertappro <tappro>
Thu, 22 Jun 2006 21:49:01 +0000 (21:49 +0000)
lustre/cmm/cmm_device.c
lustre/cmm/cmm_internal.h
lustre/cmm/cmm_object.c
lustre/cmm/mdc_internal.h
lustre/fld/fld_internal.h
lustre/fld/fld_request.c
lustre/include/lustre/lustre_idl.h
lustre/include/lustre_fld.h
lustre/lmv/lmv_fld.c

index 7d35f35..fe9e4c1 100644 (file)
@@ -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;
 
index ef73eff..1215ad3 100644 (file)
@@ -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)
index de413dd..a547404 100644 (file)
@@ -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
index 4ae5048..624d857 100644 (file)
@@ -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;
 };
 
index dd1f5e1..238e684 100644 (file)
 
 #include <linux/types.h>
 
-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 {
index faf4a6a..d96b81d 100644 (file)
@@ -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;
index a96e451..260f983 100644 (file)
 #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);
index a727fdf..f02dd32 100644 (file)
@@ -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
index 4d5ab1e..aec66ae 100644 (file)
@@ -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;
         }