Whamcloud - gitweb
rename cmm_mdc into mdc_device
authortappro <tappro>
Tue, 2 May 2006 19:44:48 +0000 (19:44 +0000)
committertappro <tappro>
Tue, 2 May 2006 19:44:48 +0000 (19:44 +0000)
make mkdir CMD-compatible

lustre/cmm/Makefile.in
lustre/cmm/cmm_device.c
lustre/cmm/cmm_internal.h
lustre/cmm/cmm_object.c
lustre/cmm/mdc_device.c [moved from lustre/cmm/cmm_mdc.c with 100% similarity]
lustre/cmm/mdc_object.c

index 9e8b43e..c910e24 100644 (file)
@@ -1,5 +1,5 @@
 MODULES := cmm cmmmdc
 cmm-objs := cmm_device.o cmm_object.o
-cmmmdc-objs := cmm_mdc.o mdc_object.o
+cmmmdc-objs := mdc_device.o mdc_object.o
 
 @INCLUDE_RULES@
index 94d2d2e..f39f8ba 100644 (file)
@@ -56,10 +56,44 @@ 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)
+{
+        struct cmm_device *cmm_dev = md2cmm_dev(md);
+
+        return cmm_child_ops(cmm_dev)->mdo_root_get(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)
+{
+        struct cmm_device *cmm_dev = md2cmm_dev(md);
+        int rc;
+        ENTRY;
+        rc = cmm_child_ops(cmm_dev)->mdo_config(ctxt, cmm_dev->cmm_child,
+                                                    name, buf, size, mode);
+        RETURN(rc);
+}
+
+int cmm_statfs(struct lu_context *ctxt,
+               struct md_device *md, struct kstatfs *sfs) {
+        struct cmm_device *cmm_dev = md2cmm_dev(md);
+       int rc;
+
+        ENTRY;
+        rc = cmm_child_ops(cmm_dev)->mdo_statfs(ctxt,
+                                                    cmm_dev->cmm_child, sfs);
+        RETURN (rc);
+}
+
 static struct md_device_operations cmm_md_ops = {
-        .mdo_root_get   = cmm_root_get,
-        .mdo_config     = cmm_config,
-        .mdo_statfs     = cmm_statfs
+        .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)
index 08fb439..a7586bd 100644 (file)
@@ -104,6 +104,7 @@ int cmm_config(struct lu_context *ctx, struct md_device *md, const char *name,
 int cmm_root_get(struct lu_context *ctx, struct md_device *m, struct lu_fid *f);
 int cmm_statfs(struct lu_context *ctx,
                struct md_device *m, struct kstatfs *sfs);
+int cmm_object_create(struct lu_context *, struct md_object *);
 int cmm_mkdir(struct lu_context *ctxt, struct lu_attr*,
               struct md_object *o, const char *name,
               struct md_object *child);
index 7331334..0889953 100644 (file)
@@ -136,56 +136,47 @@ static int cmm_object_print(struct lu_context *ctx,
 }
 
 /* Metadata API */
-int cmm_root_get(struct lu_context *ctx,
-                 struct md_device *md, struct lu_fid *fid)
+int cmm_object_create(struct lu_context *ctxt, struct md_object *mo)
 {
-        struct cmm_device *cmm_dev = md2cmm_dev(md);
+        struct cmm_object *cmo = md2cmm_obj(mo);
+        struct md_object  *nxo = cmm2child_obj(cmo);
+        int rc;
 
-        return cmm_child_ops(cmm_dev)->mdo_root_get(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)
-{
-        struct cmm_device *cmm_dev = md2cmm_dev(md);
-        int result;
         ENTRY;
-        result = cmm_child_ops(cmm_dev)->mdo_config(ctxt, cmm_dev->cmm_child,
-                                                    name, buf, size, mode);
-        RETURN(result);
-}
-
-int cmm_statfs(struct lu_context *ctxt,
-               struct md_device *md, struct kstatfs *sfs) {
-        struct cmm_device *cmm_dev = md2cmm_dev(md);
-       int result;
 
-        ENTRY;
-        result = cmm_child_ops(cmm_dev)->mdo_statfs(ctxt,
-                                                    cmm_dev->cmm_child, sfs);
-        RETURN (result);
+        LASSERT (cmm_is_local_obj(cmo));
+        
+        rc = md_device_get(nxo)->md_ops->mdo_object_create(ctxt, nxo);
+        
+        RETURN(rc);
 }
-
 int cmm_mkdir(struct lu_context *ctxt, struct lu_attr *attr,
               struct md_object *p, const char *name, struct md_object *c)
 {
        struct cmm_object *cmm_p = md2cmm_obj(p);
         struct cmm_object *cmm_c = md2cmm_obj(c);
         struct md_object  *local = cmm2child_obj(cmm_p);
-        int result;
+        int rc;
 
         if (cmm_is_local_obj(cmm_c)) {
                 /* fully local mkdir */
-                result = local->mo_dir_ops->mdo_mkdir(ctxt, attr, local, name,
+                rc = local->mo_dir_ops->mdo_mkdir(ctxt, 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 */
-                result = -EOPNOTSUPP;
+                rc = md_device_get(remote)->md_ops->mdo_object_create(ctxt,
+                                                                      remote);
+                if (rc == 0) {
+                        rc = local->mo_dir_ops->mdo_name_insert(ctxt, local,
+                                                                name, fid,
+                                                                attr);
+                }
         }
 
-        RETURN(result);
+        RETURN(rc);
 }
 
 int cmm_attr_get(struct lu_context *ctxt, struct md_object *obj,
@@ -197,16 +188,11 @@ int cmm_attr_get(struct lu_context *ctxt, struct md_object *obj,
 }
 
 static struct md_dir_operations cmm_dir_ops = {
-        .mdo_mkdir      = cmm_mkdir
-//        .mdo_rename     = cmm_rename,
-//        .mdo_link       = cmm_link,
+        .mdo_mkdir      = cmm_mkdir,
 };
 
 static struct md_object_operations cmm_mo_ops = {
-        .moo_attr_get   = cmm_attr_get,
-//        .moo_attr_set   = cmm_attr_set,
-//        .moo_xattr_get   = cmm_xattr_get,
-//        .moo_xattr_set   = cmm_xattr_set,
+        .moo_attr_get      = cmm_attr_get,
 };
 
 static struct lu_object_operations cmm_obj_ops = {
similarity index 100%
rename from lustre/cmm/cmm_mdc.c
rename to lustre/cmm/mdc_device.c
index b302c54..1fd5151 100644 (file)
@@ -58,7 +58,7 @@ struct lu_object *mdc_object_alloc(struct lu_context *ctx,
                RETURN(NULL);
 }
 
-int mdc_object_init(struct lu_context *ctxt, struct lu_object *lo)
+int mdc_object_init(struct lu_context *ctx, struct lu_object *lo)
 {
        //struct mdc_device *d = lu2mdc_dev(o->lo_dev);
        //struct lu_device  *under;
@@ -76,7 +76,7 @@ void mdc_object_free(struct lu_context *ctx, struct lu_object *lo)
         OBD_FREE_PTR(mco);
 }
 
-void mdc_object_release(struct lu_context *ctxt, struct lu_object *lo)
+void mdc_object_release(struct lu_context *ctx, struct lu_object *lo)
 {
         return;
 }