Whamcloud - gitweb
use old MDC odb to communicate with server
authortappro <tappro>
Fri, 12 May 2006 09:29:31 +0000 (09:29 +0000)
committertappro <tappro>
Fri, 12 May 2006 09:29:31 +0000 (09:29 +0000)
cmm_fld_lookup stub can distinguish MDS by range of seq
remove unneeded stuff

lustre/cmm/Makefile.in
lustre/cmm/autoMakefile.am
lustre/cmm/cmm_device.c
lustre/cmm/cmm_object.c
lustre/cmm/mdc_device.c
lustre/cmm/mdc_internal.h
lustre/cmm/mdc_object.c

index c910e24..6264e0f 100644 (file)
@@ -1,5 +1,4 @@
-MODULES := cmm cmmmdc
-cmm-objs := cmm_device.o cmm_object.o
-cmmmdc-objs := mdc_device.o mdc_object.o
+MODULES := cmm
+cmm-objs := cmm_device.o cmm_object.o mdc_device.o mdc_object.o
 
 @INCLUDE_RULES@
index 0690e09..53fe374 100644 (file)
@@ -4,9 +4,8 @@
 # See the file COPYING in this distribution
 
 if MODULES
-modulefs_DATA = cmm$(KMODEXT) cmmmdc$(KMODEXT)
+modulefs_DATA = cmm$(KMODEXT)
 endif
 
 MOSTLYCLEANFILES := @MOSTLYCLEANFILES@ 
-DIST_SOURCES = $(cmm-objs:%.o=%.c) $(cmmmdc-objs:%.o=%.c) \
-        cmm_internal.h mdc_internal.h
+DIST_SOURCES = $(cmm-objs:%.o=%.c) cmm_internal.h mdc_internal.h
index 6cc2ad0..0b87a37 100644 (file)
@@ -83,7 +83,7 @@ int cmm_statfs(struct lu_context *ctxt, struct md_device *md,
 
         ENTRY;
         rc = cmm_child_ops(cmm_dev)->mdo_statfs(ctxt,
-                                                    cmm_dev->cmm_child, sfs);
+                                                cmm_dev->cmm_child, sfs);
         RETURN (rc);
 }
 
@@ -93,25 +93,20 @@ static struct md_device_operations cmm_md_ops = {
         .mdo_statfs         = cmm_statfs,
 };
 
+extern struct lu_device_type mdc_device_type;
+
 /* add new MDC to the CMM, create MDC lu_device and connect it to mdc_obd */
 static int cmm_add_mdc(struct cmm_device * cm, struct lustre_cfg *cfg)
 {
-        struct lu_device_type *ldt;
+        struct lu_device_type *ldt = &mdc_device_type;
         struct lu_device *ld;
-        struct obd_device *obd;
-        const char *name = lustre_cfg_string(cfg, 1);
         int rc;
         ENTRY;
         
         /*TODO check this MDC exists already */
-        obd = class_name2obd(name);
-        if (obd) {
-                ld = obd->obd_lu_dev;
-        } else {
-                RETURN(-ENOENT);
-        }
+
+        ld = ldt->ldt_ops->ldto_device_alloc(ldt, cfg);
         
-        ldt = ld->ld_type;
         ld->ld_site = cmm2lu_dev(cm)->ld_site;
 
         rc = ldt->ldt_ops->ldto_device_init(ld, NULL);
index ad3bc90..ee1ec77 100644 (file)
@@ -43,8 +43,9 @@ static int cmm_fld_lookup(struct lu_fid *fid)
 {
         int rc;
         /* temporary hack for proto mkdir */
-        rc = fid_seq(fid) == LUSTRE_ROOT_FID_SEQ ? 0 : 1;
-        RETURN(0);
+        rc = (unsigned long)fid_seq(fid) / LUSTRE_SEQ_RANGE;
+        CWARN("Get MDS %d for sequence: "LPU64"\n", rc, fid_seq(fid));
+        RETURN(rc);
 }
 
 /* get child device by mdsnum*/
index dfdfecb..1df4ba4 100644 (file)
@@ -37,7 +37,6 @@
 #include "mdc_internal.h"
 
 #include <linux/lprocfs_status.h>
-#include <linux/module.h>
 #include <linux/lustre_ver.h>
 
 static struct lu_device_operations mdc_lu_ops;
@@ -86,17 +85,64 @@ static struct md_device_operations mdc_md_ops = {
         .mdo_statfs         = mdc_statfs,
 };
 
+static int mdc_add_obd(struct mdc_device *mc, struct lustre_cfg *cfg)
+{
+        struct mdc_cli_desc *desc = &mc->mc_desc;
+        struct obd_device *mdc, *mdt;
+        const char *srv = lustre_cfg_string(cfg, 0);
+        const char *uuid_str = lustre_cfg_string(cfg, 1);
+        const char *index = lustre_cfg_string(cfg, 2);
+        struct obd_uuid uuid;
+        int rc = 0;
+
+        //find mdt obd to get group uuid
+        mdt = class_name2obd(srv);
+        if (mdt == NULL) {
+                CERROR("No such OBD %s\n", srv);
+                LBUG();
+        }
+        obd_str2uuid(&uuid, uuid_str);
+        mdc = class_find_client_obd(&uuid, LUSTRE_MDC_NAME, &mdt->obd_uuid);
+        if (!mdc) {
+                CERROR("Cannot find MDC OBD connected to %s\n", uuid_str);
+                rc = -ENOENT;
+        } else if (!mdc->obd_set_up) {
+                CERROR("target %s not set up\n", mdc->obd_name);
+                rc = -EINVAL;
+        } else {
+                struct lustre_handle conn = {0, };
+                struct obd_connect_data conn_data = {
+                        .ocd_connect_flags = OBD_CONNECT_SEQRNG
+                                             | OBD_CONNECT_VERSION,
+                        .ocd_version = LUSTRE_VERSION_CODE
+                };
+
+                CDEBUG(D_CONFIG, "connect to %s(%s)\n",
+                       mdc->obd_name, mdc->obd_uuid.uuid);
+                
+                rc = obd_connect(&conn, mdc, &mdt->obd_uuid, NULL);
+
+                if (rc) {
+                        CERROR("target %s connect error %d\n",
+                               mdc->obd_name, rc);
+                } else {
+                        desc->cl_exp = class_conn2export(&conn);
+                        mc->mc_num = simple_strtol(index, NULL, 10);
+                }
+        }
+        
+        RETURN(rc);
+}
+
 static int mdc_process_config(struct lu_device *ld, struct lustre_cfg *cfg)
 {
         struct mdc_device *mc = lu2mdc_dev(ld);
-        const char *index = lustre_cfg_string(cfg, 2);
         int rc;
 
         ENTRY;
         switch (cfg->lcfg_command) {
         case LCFG_ADD_MDC:
-                mc->mc_num = simple_strtol(index, NULL, 10);
-                rc = 0;
+                rc = mdc_add_obd(mc, cfg);
                 break;
         default:
                 rc = -EOPNOTSUPP;
@@ -110,7 +156,7 @@ static struct lu_device_operations mdc_lu_ops = {
 
         .ldo_process_config = mdc_process_config
 };
-
+#if 0
 static int mdc_device_connect(struct mdc_device *mc)
 {
         struct mdc_cli_desc *desc = &mc->mc_desc;
@@ -250,7 +296,46 @@ struct lu_device *mdc_device_alloc(struct lu_device_type *ldt,
 
         RETURN (ld);
 }
+#endif
+static int mdc_device_init(struct lu_device *ld, struct lu_device *next)
+{
+        struct mdc_device *mc = lu2mdc_dev(ld);
+        int rc = 0;
+
+        ENTRY;
 
+        RETURN(rc);
+}
+
+static struct lu_device *mdc_device_fini(struct lu_device *ld)
+{
+       struct mdc_device *mc = lu2mdc_dev(ld);
+       
+        ENTRY;
+
+        RETURN (NULL);
+}
+
+struct lu_device *mdc_device_alloc(struct lu_device_type *ldt,
+                                   struct lustre_cfg *cfg)
+{
+        struct lu_device  *ld;
+        struct mdc_device *mc;
+
+        ENTRY;
+
+        OBD_ALLOC_PTR(mc);
+        if (mc == NULL) {
+                ld = ERR_PTR(-ENOMEM);
+        } else {
+                md_device_init(&mc->mc_md_dev, ldt);
+                mc->mc_md_dev.md_ops = &mdc_md_ops;
+               ld = mdc2lu_dev(mc);
+                ld->ld_ops = &mdc_lu_ops;
+        }
+
+        RETURN (ld);
+}
 void mdc_device_free(struct lu_device *ld)
 {
         struct mdc_device *mc = lu2mdc_dev(ld);
@@ -286,7 +371,7 @@ struct lu_device_type mdc_device_type = {
         .ldt_name = LUSTRE_MDC0_NAME,
         .ldt_ops  = &mdc_device_type_ops
 };
-
+#if 0
 static struct obd_ops mdc0_obd_device_ops = {
         .o_owner           = THIS_MODULE
 };
@@ -323,3 +408,4 @@ MODULE_DESCRIPTION("Lustre Metadata Client Prototype ("LUSTRE_MDC0_NAME")");
 MODULE_LICENSE("GPL");
 
 cfs_module(mdc, "0.0.1", mdc0_mod_init, mdc0_mod_exit);
+#endif
index 1ddca20..668fed1 100644 (file)
 #include <linux/md_object.h>
 
 struct mdc_cli_desc {
-        struct obd_connect_data cl_conn_data;
-        struct semaphore        cl_rpcl_sem;
-        struct ptlrpc_client    cl_ldlm_client; 
-        struct obd_uuid         cl_server_uuid;
-        struct obd_uuid         cl_target_uuid;
-        struct obd_import       *cl_import;
+        struct obd_connect_data  cl_conn_data;
+        struct obd_uuid          cl_srv_uuid;
+        struct obd_uuid          cl_cli_uuid;
+        struct obd_export        *cl_exp;
 };
 
 struct mdc_device {
index 357ae33..3953bf1 100644 (file)
 #endif
 
 #define DEBUG_SUBSYSTEM S_MDS
-
+#include <linux/obd_support.h>
+#include <linux/lustre_lib.h>
+#include <linux/lustre_net.h>
+#include <linux/lustre_idl.h>
+#include <linux/obd_class.h>
 #include "mdc_internal.h"
 
 static struct md_object_operations mdc_mo_ops;
@@ -96,12 +100,19 @@ static int mdc_object_create(struct lu_context *ctx, struct md_object *mo,
                              struct lu_attr *attr)
 {
         struct mdc_device *mc = md2mdc_dev(md_device_get(mo));
-        int rc;
-        struct mdt_rec_create *rec;
+        struct obd_export *exp = mc->mc_desc.cl_exp;
         struct ptlrpc_request *req;
-        int size = sizeof(struct mdt_rec_create);
-        int level;
+        struct md_op_data op_data = {
+                .fid1 = mo->mo_lu.lo_header->loh_fid,
+                .fid2 = { 0 },
+                .mod_time = attr->la_mtime,
+                .name = NULL,
+                .namelen = 0,
+        };
+        int rc;
 
+        
+#if 0
         req = ptlrpc_prep_req(mc->mc_desc.cl_import, LUSTRE_MDS_VERSION,
                               MDS_REINT, 1, &size, NULL);
         if (req == NULL)
@@ -139,7 +150,9 @@ static int mdc_object_create(struct lu_context *ctx, struct md_object *mo,
                 rc = -EPROTO;
         } else
                 CDEBUG(D_INFO, "Done MDC req!\n");
-
+#endif
+        rc = md_create(exp, &op_data, NULL, 0, attr->la_mode, attr->la_uid,
+                       attr->la_gid, 0, 0, &req);
         RETURN(rc);
 }