Whamcloud - gitweb
update cmm/mdc
authortappro <tappro>
Thu, 4 May 2006 19:29:22 +0000 (19:29 +0000)
committertappro <tappro>
Thu, 4 May 2006 19:29:22 +0000 (19:29 +0000)
lustre/cmm/cmm_device.c
lustre/cmm/cmm_object.c
lustre/cmm/mdc_device.c
lustre/cmm/mdc_object.c

index f39f8ba..cb448b2 100644 (file)
@@ -56,8 +56,8 @@ static inline int lu_device_is_cmm(struct lu_device *d)
        return ergo(d != NULL && d->ld_ops != NULL, d->ld_ops == &cmm_lu_ops);
 }
 
-int cmm_root_get(struct lu_context *ctx,
-                 struct md_device *md, struct lu_fid *fid)
+int cmm_root_get(struct lu_context *ctx, struct md_device *md,
+                 struct lu_fid *fid)
 {
         struct cmm_device *cmm_dev = md2cmm_dev(md);
 
@@ -65,9 +65,8 @@ int cmm_root_get(struct lu_context *ctx,
                                                     cmm_dev->cmm_child, fid);
 }
 
-int cmm_config(struct lu_context *ctxt,
-               struct md_device *md, const char *name,
-               void *buf, int size, int mode)
+int cmm_config(struct lu_context *ctxt, struct md_device *md,
+               const char *name, void *buf, int size, int mode)
 {
         struct cmm_device *cmm_dev = md2cmm_dev(md);
         int rc;
@@ -77,8 +76,8 @@ int cmm_config(struct lu_context *ctxt,
         RETURN(rc);
 }
 
-int cmm_statfs(struct lu_context *ctxt,
-               struct md_device *md, struct kstatfs *sfs) {
+int cmm_statfs(struct lu_context *ctxt, struct md_device *md,
+               struct kstatfs *sfs) {
         struct cmm_device *cmm_dev = md2cmm_dev(md);
        int rc;
 
@@ -92,44 +91,8 @@ static struct md_device_operations cmm_md_ops = {
         .mdo_root_get       = cmm_root_get,
         .mdo_config         = cmm_config,
         .mdo_statfs         = cmm_statfs,
-        .mdo_object_create  = cmm_object_create
-
 };
 
-static int cmm_device_init(struct lu_device *d, struct lu_device *next)
-{
-        struct cmm_device *m = lu2cmm_dev(d);
-        int err = 0;
-
-        ENTRY;
-
-        INIT_LIST_HEAD(&m->cmm_targets);
-        m->cmm_tgt_count = 0;
-        m->cmm_child = lu2md_dev(next);
-
-        RETURN(err);
-}
-
-static struct lu_device *cmm_device_fini(struct lu_device *ld)
-{
-       struct cmm_device *cm = lu2cmm_dev(ld);
-        struct mdc_device *mc, *tmp;
-        ENTRY;
-        
-        /* finish all mdc devices */
-        list_for_each_entry_safe(mc, tmp, &cm->cmm_targets, mc_linkage) {
-                struct lu_device *ld_m = mdc2lu_dev(mc);
-
-                list_del(&mc->mc_linkage);
-                lu_device_put(cmm2lu_dev(cm));
-                ld->ld_type->ldt_ops->ldto_device_fini(ld_m);
-                ld->ld_type->ldt_ops->ldto_device_free(ld_m);
-        }
-
-        EXIT;
-        return md2lu_dev(cm->cmm_child);
-}
-
 /* 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)
 {
@@ -182,7 +145,6 @@ static int cmm_process_config(struct lu_device *d, struct lustre_cfg *cfg)
         RETURN(err);
 }
 
-
 static struct lu_device_operations cmm_lu_ops = {
        .ldo_object_alloc   = cmm_object_alloc,
        .ldo_object_free    = cmm_object_free,
@@ -190,6 +152,8 @@ static struct lu_device_operations cmm_lu_ops = {
         .ldo_process_config = cmm_process_config
 };
 
+/* --- lu_device_type operations --- */
+
 struct lu_device *cmm_device_alloc(struct lu_device_type *t,
                                    struct lustre_cfg *cfg)
 {
@@ -231,6 +195,40 @@ void cmm_type_fini(struct lu_device_type *t)
         return;
 }
 
+static int cmm_device_init(struct lu_device *d, struct lu_device *next)
+{
+        struct cmm_device *m = lu2cmm_dev(d);
+        int err = 0;
+
+        ENTRY;
+
+        INIT_LIST_HEAD(&m->cmm_targets);
+        m->cmm_tgt_count = 0;
+        m->cmm_child = lu2md_dev(next);
+
+        RETURN(err);
+}
+
+static struct lu_device *cmm_device_fini(struct lu_device *ld)
+{
+       struct cmm_device *cm = lu2cmm_dev(ld);
+        struct mdc_device *mc, *tmp;
+        ENTRY;
+        
+        /* finish all mdc devices */
+        list_for_each_entry_safe(mc, tmp, &cm->cmm_targets, mc_linkage) {
+                struct lu_device *ld_m = mdc2lu_dev(mc);
+
+                list_del(&mc->mc_linkage);
+                lu_device_put(cmm2lu_dev(cm));
+                ld->ld_type->ldt_ops->ldto_device_fini(ld_m);
+                ld->ld_type->ldt_ops->ldto_device_free(ld_m);
+        }
+
+        EXIT;
+        return md2lu_dev(cm->cmm_child);
+}
+
 static struct lu_device_type_operations cmm_device_type_ops = {
         .ldto_init = cmm_type_init,
         .ldto_fini = cmm_type_fini,
index 573b418..64d7cf0 100644 (file)
@@ -41,7 +41,9 @@ static struct lu_object_operations cmm_obj_ops;
 
 static int cmm_fld_lookup(struct lu_fid *fid)
 {
-        /* return master MDS for now */
+        int rc;
+        /* temporary hack for proto mkdir */
+        rc = fid_seq(fid) == LUSTRE_ROOT_FID_SEQ ? 0 : 1;
         return 0;
 }
 
@@ -84,7 +86,7 @@ struct lu_object *cmm_object_alloc(struct lu_context *ctx,
                RETURN(NULL);
 }
 
-int cmm_object_init(struct lu_context *ctxt, struct lu_object *o)
+int cmm_object_init(struct lu_context *ctx, struct lu_object *o)
 {
        struct cmm_device *d = lu2cmm_dev(o->lo_dev);
        struct lu_device  *under;
@@ -99,7 +101,7 @@ int cmm_object_init(struct lu_context *ctxt, struct lu_object *o)
         if (under == NULL)
                 RETURN(-ENOENT);
 
-        below = under->ld_ops->ldo_object_alloc(ctxt, under);
+        below = under->ld_ops->ldo_object_alloc(ctx, under);
        if (below != NULL) {
                 struct cmm_object *co = lu2cmm_obj(o);
 
@@ -117,7 +119,7 @@ void cmm_object_free(struct lu_context *ctx, struct lu_object *o)
         OBD_FREE_PTR(mo);
 }
 
-void cmm_object_release(struct lu_context *ctxt, struct lu_object *o)
+void cmm_object_release(struct lu_context *ctx, struct lu_object *o)
 {
         return;
 }
@@ -134,7 +136,7 @@ static int cmm_object_print(struct lu_context *ctx,
 }
 
 /* Metadata API */
-int cmm_object_create(struct lu_context *ctxt, struct md_object *mo)
+int cmm_object_create(struct lu_context *ctx, struct md_object *mo)
 {
         struct cmm_object *cmo = md2cmm_obj(mo);
         struct md_object  *nxo = cmm2child_obj(cmo);
@@ -144,11 +146,11 @@ int cmm_object_create(struct lu_context *ctxt, struct md_object *mo)
 
         LASSERT (cmm_is_local_obj(cmo));
         
-        rc = md_device_get(nxo)->md_ops->mdo_object_create(ctxt, nxo);
+        rc = nxo->mo_ops->moo_object_create(ctx, nxo);
         
         RETURN(rc);
 }
-int cmm_mkdir(struct lu_context *ctxt, struct lu_attr *attr,
+int cmm_mkdir(struct lu_context *ctx, struct lu_attr *attr,
               struct md_object *p, const char *name, struct md_object *c)
 {
        struct cmm_object *cmm_p = md2cmm_obj(p);
@@ -158,17 +160,16 @@ int cmm_mkdir(struct lu_context *ctxt, struct lu_attr *attr,
 
         if (cmm_is_local_obj(cmm_c)) {
                 /* fully local mkdir */
-                rc = local->mo_dir_ops->mdo_mkdir(ctxt, attr, local, name,
+                rc = local->mo_dir_ops->mdo_mkdir(ctx, attr, local, name,
                                                       cmm2child_obj(cmm_c));
         } else {
                 struct lu_fid *fid = &c->mo_lu.lo_header->loh_fid;
                 struct md_object *remote = cmm2child_obj(cmm_c);
 
                 /* remote object creation and local name insert */
-                rc = md_device_get(remote)->md_ops->mdo_object_create(ctxt,
-                                                                      remote);
+                rc = remote->mo_ops->moo_object_create(ctx, remote);
                 if (rc == 0) {
-                        rc = local->mo_dir_ops->mdo_name_insert(ctxt, local,
+                        rc = local->mo_dir_ops->mdo_name_insert(ctx, local,
                                                                 name, fid,
                                                                 attr);
                 }
@@ -177,20 +178,22 @@ int cmm_mkdir(struct lu_context *ctxt, struct lu_attr *attr,
         RETURN(rc);
 }
 
-int cmm_attr_get(struct lu_context *ctxt, struct md_object *obj,
+int cmm_attr_get(struct lu_context *ctx, struct md_object *obj,
                  struct lu_attr *attr)
 {
         struct md_object *next = cmm2child_obj(md2cmm_obj(obj));
 
-        return next->mo_ops->moo_attr_get(ctxt, next, attr);
+        return next->mo_ops->moo_attr_get(ctx, next, attr);
 }
 
 static struct md_dir_operations cmm_dir_ops = {
-        .mdo_mkdir      = cmm_mkdir,
+        .mdo_mkdir         = cmm_mkdir,
 };
 
 static struct md_object_operations cmm_mo_ops = {
         .moo_attr_get      = cmm_attr_get,
+        .moo_object_create = cmm_object_create,
+
 };
 
 static struct lu_object_operations cmm_obj_ops = {
index 908a559..e3937e7 100644 (file)
@@ -59,7 +59,7 @@ static int mdc_root_get(struct lu_context *ctx, struct md_device *md,
         return -EOPNOTSUPP;
 }
 
-static int mdc_config(struct lu_context *ctxt,
+static int mdc_config(struct lu_context *ctx,
                       struct md_device *md, const char *name,
                       void *buf, int size, int mode)
 {
@@ -70,7 +70,7 @@ static int mdc_config(struct lu_context *ctxt,
         RETURN(rc);
 }
 
-static int mdc_statfs(struct lu_context *ctxt,
+static int mdc_statfs(struct lu_context *ctx,
                       struct md_device *md, struct kstatfs *sfs) {
         //struct mdc_device *mdc_dev = md2mdc_dev(md);
        int rc;
@@ -80,20 +80,10 @@ static int mdc_statfs(struct lu_context *ctxt,
         RETURN (rc);
 }
 
-static int mdc_object_create(struct lu_context *ctxt, struct md_object *mo)
-{
-        int rc;
-
-        rc = -EOPNOTSUPP;
-
-        RETURN(rc);
-}
-
 static struct md_device_operations mdc_md_ops = {
         .mdo_root_get       = mdc_root_get,
         .mdo_config         = mdc_config,
         .mdo_statfs         = mdc_statfs,
-        .mdo_object_create  = mdc_object_create
 };
 
 static int mdc_process_config(struct lu_device *ld, struct lustre_cfg *cfg)
index 1fd5151..71c5a76 100644 (file)
@@ -92,10 +92,61 @@ static int mdc_object_print(struct lu_context *ctx,
        return seq_printf(f, LUSTRE_MDC0_NAME"-object@%p", lo);
 }
 
+static int mdc_object_create(struct lu_context *ctx, struct md_object *mo)
+{
+        struct mdc_device *mc = md2mdc_dev(md_device_get(mo));
+        int rc;
+        struct mdt_rec_create *rec;
+        struct ptlrpc_request *req;
+        int size = sizeof(struct mdt_rec_create);
+        int level;
+
+        req = ptlrpc_prep_req(mc->mc_desc.cl_import, LUSTRE_MDS_VERSION,
+                              MDS_REINT, 1, &size, NULL);
+        if (req == NULL)
+                RETURN(-ENOMEM);
+/*
+        mdc_create_pack(req, MDS_REQ_REC_OFF, op_data, data, datalen, mode,
+                        uid, gid, cap_effective, rdev);
+*/
+        rec = lustre_msg_buf(req->rq_reqmsg, MDS_REQ_REC_OFF, sizeof (*rec));
+        rec->cr_opcode = REINT_CREATE;
+        rec->cr_fsuid = 0;//uid;
+        rec->cr_fsgid = 0;//gid;
+        rec->cr_cap = 0;//cap_effective;
+        rec->cr_fid1 = mo->mo_lu.lo_header->loh_fid;
+        memset(&rec->cr_fid2, 0, sizeof(rec->cr_fid2));
+        rec->cr_mode = S_IFDIR;//mode;
+        rec->cr_rdev = 0;//rdev;
+        rec->cr_time = 0;//op_data->mod_time;
+        rec->cr_suppgid = 0;//op_data->suppgids[0];
+
+        
+        size = sizeof(struct mdt_body);
+        req->rq_replen = lustre_msg_size(1, &size);
+
+        level = LUSTRE_IMP_FULL;
+        req->rq_send_state = level;
+        //mdc_get_rpc_lock(rpc_lock, NULL);
+        rc = ptlrpc_queue_wait(req);
+        //mdc_put_rpc_lock(rpc_lock, NULL);
+        if (rc)
+                CDEBUG(D_INFO, "error in handling %d\n", rc);
+        else if (!lustre_swab_repbuf(req, 0, sizeof(struct mdt_body),
+                                     lustre_swab_mdt_body)) {
+                CERROR ("Can't unpack mdt_body\n");
+                rc = -EPROTO;
+        } else 
+                CDEBUG(D_INFO, "Done MDC req!\n");
+
+        RETURN(rc);
+}
+
 static struct md_dir_operations mdc_dir_ops = {
 };
 
 static struct md_object_operations mdc_mo_ops = {
+        .moo_object_create  = mdc_object_create
 };
 
 static struct lu_object_operations mdc_obj_ops = {