Whamcloud - gitweb
Branch: b_new_cmd
authorwangdi <wangdi>
Sun, 3 Sep 2006 05:18:32 +0000 (05:18 +0000)
committerwangdi <wangdi>
Sun, 3 Sep 2006 05:18:32 +0000 (05:18 +0000)
serval fixes about multi mdses setup

lustre/mdd/mdd_handler.c
lustre/mdd/mdd_internal.h
lustre/mdd/mdd_lov.c
lustre/mds/handler.c
lustre/mds/mds_fs.c
lustre/mdt/mdt_handler.c
lustre/mgs/mgs_llog.c

index 3d56791..a307136 100644 (file)
@@ -521,8 +521,8 @@ static int mdd_process_config(const struct lu_context *ctxt,
         struct mdd_device *m    = lu2mdd_dev(d);
         struct dt_device  *dt   = m->mdd_child;
         struct lu_device  *next = &dt->dd_lu_dev;
-        char              *dev = lustre_cfg_string(cfg, 0);
         int rc;
+        ENTRY;
 
         switch (cfg->lcfg_command) {
         case LCFG_SETUP:
@@ -534,7 +534,7 @@ static int mdd_process_config(const struct lu_context *ctxt,
                 rc = mdd_mount(ctxt, m);
                 if (rc)
                         GOTO(out, rc);
-                rc = mdd_init_obd(ctxt, m, dev);
+                rc = mdd_init_obd(ctxt, m, cfg);
                 if (rc) {
                         CERROR("lov init error %d \n", rc);
                         GOTO(out, rc);
index 37e9f77..fc08bb3 100644 (file)
@@ -78,7 +78,7 @@ struct mdd_thread_info {
 };
 
 int mdd_init_obd(const struct lu_context *ctxt, struct mdd_device *mdd,
-                 char *dev);
+                 struct lustre_cfg *cfg);
 int mdd_fini_obd(const struct lu_context *, struct mdd_device *);
 int mdd_xattr_set_txn(const struct lu_context *ctxt, struct mdd_object *obj,
                       const void *buf, int buf_len, const char *name, int fl,
index 1b8e6cd..bb310d5 100644 (file)
@@ -66,33 +66,59 @@ static int mdd_lov_update(struct obd_device *host,
 
 /*The obd is created for handling data stack for mdd*/
 int mdd_init_obd(const struct lu_context *ctxt, struct mdd_device *mdd,
-                 char *dev)
+                 struct lustre_cfg *cfg)
 {
         struct lustre_cfg_bufs *bufs;
         struct lustre_cfg      *lcfg;
         struct obd_device      *obd;
-        int rc;
+        char                   *dev = lustre_cfg_string(cfg, 0);
+        char                   *index_string = lustre_cfg_string(cfg, 2);
+        char                   *name, *uuid, *p;
+        int rc, name_size, uuid_size, index;
         ENTRY;
 
-        OBD_ALLOC_PTR(bufs);
-        if (!bufs)
+        LASSERT(index_string);
+
+        index = simple_strtol(index_string, &p, 10);
+
+        name_size = strlen(MDD_OBD_NAME) + 5;
+        uuid_size = strlen(MDD_OBD_UUID) + 5;
+
+        OBD_ALLOC(name, name_size);
+        OBD_ALLOC(uuid, uuid_size);
+        if (!name || !uuid) {
+                if (name)
+                        OBD_FREE(name, name_size);
+                if (uuid)
+                        OBD_FREE(uuid, uuid_size);
                 RETURN(-ENOMEM);
-        lustre_cfg_bufs_reset(bufs, MDD_OBD_NAME);
+        }
+
+        OBD_ALLOC_PTR(bufs);
+        if (!bufs) {
+                GOTO(cleanup_mem, rc = -ENOMEM);
+        }
+
+        snprintf(name, strlen(MDD_OBD_NAME) + 5, "%s-%d",
+                                              MDD_OBD_NAME, index);
+        snprintf(uuid, strlen(MDD_OBD_UUID) + 5, "%s-%d",
+                                              MDD_OBD_UUID, index);
+        lustre_cfg_bufs_reset(bufs, name);
         lustre_cfg_bufs_set_string(bufs, 1, MDD_OBD_TYPE);
-        lustre_cfg_bufs_set_string(bufs, 2, MDD_OBD_UUID);
+        lustre_cfg_bufs_set_string(bufs, 2, uuid);
         lustre_cfg_bufs_set_string(bufs, 3, (char*)dev/*MDD_OBD_PROFILE*/);
         lustre_cfg_bufs_set_string(bufs, 4, (char*)dev);
 
         lcfg = lustre_cfg_new(LCFG_ATTACH, bufs);
         OBD_FREE_PTR(bufs);
         if (!lcfg)
-                RETURN(-ENOMEM);
+                GOTO(cleanup_mem, rc = -ENOMEM);
 
         rc = class_attach(lcfg);
         if (rc)
                 GOTO(lcfg_cleanup, rc);
 
-        obd = class_name2obd(MDD_OBD_NAME);
+        obd = class_name2obd(name);
         if (!obd) {
                 CERROR("can not find obd %s \n", MDD_OBD_NAME);
                 LBUG();
@@ -112,6 +138,9 @@ class_detach:
                 class_detach(obd, lcfg);
 lcfg_cleanup:
         lustre_cfg_free(lcfg);
+cleanup_mem:
+        OBD_FREE(name, name_size);
+        OBD_FREE(uuid, uuid_size);
         RETURN(rc);
 }
 
@@ -306,6 +335,7 @@ int mdd_lov_create(const struct lu_context *ctxt, struct mdd_device *mdd,
 
         OBD_FAIL_RETURN((OBD_FAIL_MDS_ALLOC_OBDO), -ENOMEM);
 
+        LASSERT(lov_exp != NULL);
         oa = obdo_alloc();
         if (oa == NULL)
                 RETURN(-ENOMEM);
index 503b16f..57faa56 100644 (file)
@@ -2130,7 +2130,7 @@ int mds_postrecov(struct obd_device *obd)
         }
 
         /* clean PENDING dir */
-        if (strcmp(obd->obd_name, MDD_OBD_NAME))
+        if (strncmp(obd->obd_name, MDD_OBD_NAME, strlen(MDD_OBD_NAME)))
                 rc = mds_cleanup_pending(obd);
                 if (rc < 0)
                         GOTO(out, rc);
@@ -2175,7 +2175,7 @@ static int mds_precleanup(struct obd_device *obd, enum obd_cleanup_stage stage)
                 /*XXX Use this for mdd mds cleanup, so comment out 
                  *this target_cleanup_recovery for this tmp MDD MDS
                  *Wangdi*/
-                if (strcmp(obd->obd_name, MDD_OBD_NAME))
+                if (strncmp(obd->obd_name, MDD_OBD_NAME, strlen(MDD_OBD_NAME)))
                         target_cleanup_recovery(obd); 
                 mds_lov_early_clean(obd);
                 break;
@@ -2749,7 +2749,7 @@ static int mds_cmd_setup(struct obd_device *obd, struct lustre_cfg *lcfg)
         ENTRY;
 
         CDEBUG(D_INFO, "obd %s setup \n", obd->obd_name);
-        if (strcmp(obd->obd_name, MDD_OBD_NAME))
+        if (strncmp(obd->obd_name, MDD_OBD_NAME, strlen(MDD_OBD_NAME)))
                 RETURN(0);
      
         if (lcfg->lcfg_bufcount < 5) {
index c223723..3eda0f4 100644 (file)
@@ -659,7 +659,8 @@ int mds_obd_create(struct obd_export *exp, struct obdo *oa,
         /* the owner of object file should always be root */
         ucred.luc_cap = current->cap_effective | CAP_SYS_RESOURCE;
 
-        if (strcmp(exp->exp_obd->obd_name, MDD_OBD_NAME)) {
+        if (strncmp(exp->exp_obd->obd_name, MDD_OBD_NAME,
+                                   strlen(MDD_OBD_NAME))) {
                 RETURN(0);
         }
         
index b22e03f..ada0592 100644 (file)
@@ -2911,6 +2911,7 @@ static struct lu_device *mdt_device_alloc(const struct lu_context *ctx,
                 if (result != 0) {
                         OBD_FREE_PTR(m);
                         l = ERR_PTR(result);
+                        return l;
                 }
                 m->mdt_md_dev.md_upcall.mu_upcall = mdt_upcall;
         } else
index 2d2a8bf..cad741d 100644 (file)
@@ -1243,6 +1243,7 @@ static int mgs_write_log_mdc_to_mdt(struct obd_device *obd, struct fs_db *fsdb,
         rc = record_setup(obd, llh, mdcname, mti->mti_uuid, nodeuuid, 0, 0);
         rc = mgs_write_log_failnids(obd, mti, llh, mdcname);
         snprintf(index, sizeof(index), "%d", idx);
+
         rc = record_mdc_add(obd, llh, logname, mdcuuid, mti->mti_uuid,
                             index, "1");
         rc = record_marker(obd, llh, fsdb, CM_END, mti->mti_svname, "add mdc"); 
@@ -1423,7 +1424,7 @@ static int mgs_write_log_osc_to_lov(struct obd_device *obd, struct fs_db *fsdb,
                                     char *logname, char *lovname, int flags)
 {
         struct llog_handle *llh = NULL;
-        char *nodeuuid, *oscname, *oscuuid, *lovuuid;
+        char *nodeuuid, *svname, *oscname, *oscuuid, *lovuuid;
         char index[5];
         int i, rc;
 
@@ -1439,7 +1440,8 @@ static int mgs_write_log_osc_to_lov(struct obd_device *obd, struct fs_db *fsdb,
   
 
         name_create(&nodeuuid, libcfs_nid2str(mti->mti_nids[0]), "");
-        name_create(&oscname, mti->mti_svname, "-osc");
+        name_create(&svname, mti->mti_svname, lovname);
+        name_create(&oscname, svname, "-osc");
         name_create(&oscuuid, oscname, "_UUID");
         name_create(&lovuuid, lovname, "_UUID");
 
@@ -1477,6 +1479,7 @@ out:
         name_destroy(lovuuid);
         name_destroy(oscuuid);
         name_destroy(oscname);
+        name_destroy(svname);
         name_destroy(nodeuuid);
         RETURN(rc);
 }