Whamcloud - gitweb
Branch: b_new_cmd
authorwangdi <wangdi>
Thu, 15 Jun 2006 08:11:09 +0000 (08:11 +0000)
committerwangdi <wangdi>
Thu, 15 Jun 2006 08:11:09 +0000 (08:11 +0000)
1) add lov in mdd
2) some cleanup and typo fixes

lustre/mdd/mdd_handler.c
lustre/mdt/mdt_handler.c
lustre/utils/create_iam.c

index cf16c6c..46b09d0 100644 (file)
@@ -409,22 +409,51 @@ static struct lu_device *mdd_device_fini(const struct lu_context *ctx,
         return next;
 }
 
+static int mdd_lov_init(struct mdd_device *mdd, struct lustre_cfg *cfg)
+{
+        int rc;
+        ENTRY;
+
+        /*FIXME lov device is a dt or obd device in this cycle?*/ 
+        rc = dt_device_init(&mdd->mdd_lov_dev, NULL); 
+        if (rc) 
+                GOTO(out, rc);
+               
+        mdd->mdd_lov_dev.dd_lu_dev.ld_obd = 
+                class_name2obd(lustre_cfg_string(cfg, 3));
+out:
+        RETURN(rc); 
+}
+
 static int mdd_process_config(const struct lu_context *ctx,
                               struct lu_device *d, struct lustre_cfg *cfg)
 {
         struct mdd_device *m = lu2mdd_dev(d);
         struct lu_device *next = &m->mdd_child->dd_lu_dev;
-        int err;
+        int rc;
 
         switch(cfg->lcfg_command) {
-
+        case LCFG_SETUP:
+                rc = next->ld_ops->ldo_process_config(ctx, next, cfg);
+                if (rc)
+                        GOTO(out, rc);
+                rc = mdd_mount(ctx, m);
+                if (rc)
+                        GOTO(out, rc);
+                rc = mdd_lov_init(m, cfg);
+                if (rc) {
+                        CERROR("lov init error %d \n", rc);
+                        /*FIXME umount the mdd*/
+                        GOTO(out, rc);
+                }
+                break;
         default:
-                err = next->ld_ops->ldo_process_config(ctx, next, cfg);
-                if (err == 0 && cfg->lcfg_command == LCFG_SETUP)
-                        err = mdd_mount(ctx, m);
+                rc = next->ld_ops->ldo_process_config(ctx, next, cfg);
+                break;
         }
-
-        RETURN(err);
+out:
+        RETURN(rc);
 }
 
 static struct lu_device_operations mdd_lu_ops = {
@@ -956,10 +985,13 @@ struct lu_device *mdd_device_alloc(const struct lu_context *ctx,
 static void mdd_device_free(const struct lu_context *ctx, struct lu_device *lu)
 {
         struct mdd_device *m = lu2mdd_dev(lu);
+        struct dt_device *dt_lov = &m->mdd_lov_dev;
 
         LASSERT(atomic_read(&lu->ld_ref) == 0);
         md_device_fini(&m->mdd_md_dev);
-
+        
+        class_put_type(dt_lov->dd_lu_dev.ld_type->ldt_obd_type);
+        
         OBD_FREE_PTR(m);
 }
 
index e0f69c3..2e792f6 100644 (file)
@@ -1705,12 +1705,12 @@ static struct lu_device *mdt_layer_setup(const struct lu_context *ctx,
         }
 
         ldt = type->typ_lu;
-        ldt->ldt_obd_type = type;
         if (ldt == NULL) {
                 CERROR("type: '%s'\n", typename);
                 GOTO(out_type, rc = -EINVAL);
         }
-
+        
+        ldt->ldt_obd_type = type;
         d = ldt->ldt_ops->ldto_device_alloc(ctx, ldt, cfg);
         if (IS_ERR(d)) {
                 CERROR("Cannot allocate device: '%s'\n", typename);
index cfc6a0a..ff7544a 100644 (file)
@@ -74,7 +74,6 @@ struct dx_countlimit {
         u_int16_t count;
 };
 
-#define LEAF_HEAD_MAGIC 0x1976
 int main(int argc, char **argv)
 {
         int rc;
@@ -193,7 +192,7 @@ int main(int argc, char **argv)
         /* form leaf */
         head = memset(buf, 0, blocksize);
         *head = (struct iam_leaf_head) {
-                .ill_magic = cpu_to_le16(LEAF_HEAD_MAGIC),
+                .ill_magic = cpu_to_le16(IAM_LEAF_HEADER_MAGIC),
                 /*
                  * Leaf contains an entry with the smallest possible key
                  * (created by zeroing).