Whamcloud - gitweb
Branch: b_new_cmd
authorwangdi <wangdi>
Wed, 5 Jul 2006 12:14:34 +0000 (12:14 +0000)
committerwangdi <wangdi>
Wed, 5 Jul 2006 12:14:34 +0000 (12:14 +0000)
update mdd lov

lustre/mdd/mdd_handler.c
lustre/mdd/mdd_internal.h
lustre/mdd/mdd_lov.c
lustre/osd/osd_handler.c

index d8ed37a..5904d01 100644 (file)
@@ -380,11 +380,6 @@ static struct lu_object_operations mdd_lu_obj_ops = {
        .loo_object_exists  = mdd_object_exists,
 };
 
-static struct dt_object* mdd_object_child(struct mdd_object *o)
-{
-        return container_of0(lu_object_next(&o->mod_obj.mo_lu),
-                             struct dt_object, do_lu);
-}
 
 static void mdd_lock(const struct lu_context *ctxt,
                      struct mdd_object *obj, enum dt_lock_mode mode)
@@ -512,8 +507,8 @@ static int __mdd_xattr_set(const struct lu_context *ctxt,struct mdd_device *mdd,
                                           handle);
 }
 
-static int mdd_xattr_set(const struct lu_context *ctxt, struct md_object *obj,
-                         const void *buf, int buf_len, const char *name)
+int mdd_xattr_set(const struct lu_context *ctxt, struct md_object *obj,
+                  const void *buf, int buf_len, const char *name)
 {
         struct mdd_device *mdd = mdo2mdd(obj);
         struct thandle *handle;
@@ -591,7 +586,6 @@ static int mdd_link(const struct lu_context *ctxt, struct md_object *tgt_obj,
         rc = __mdd_ref_add(ctxt, mdd_sobj, handle);
 exit:
         mdd_unlock2(ctxt, mdd_tobj, mdd_sobj);
-
         mdd_trans_stop(ctxt, mdd, handle);
         RETURN(rc);
 }
@@ -621,7 +615,6 @@ static int mdd_unlink(const struct lu_context *ctxt, struct md_object *pobj,
         if (rc)
                 GOTO(cleanup, rc);
 cleanup:
-       /*FIXME: error handling?*/
         mdd_lock2(ctxt, mdd_pobj, mdd_cobj);
         mdd_trans_stop(ctxt, mdd, handle);
         RETURN(rc);
@@ -774,7 +767,7 @@ static int mdd_create(const struct lu_context *ctxt,
         struct mdd_object *mdo = md2mdd_obj(pobj);
         struct mdd_object *son = md2mdd_obj(child);
         struct thandle *handle;
-        int rc = 0;
+        int rc = 0, created = 0, inserted = 0;
         ENTRY;
 
         mdd_txn_param_build(ctxt, &MDD_TXN_MKDIR);
@@ -826,18 +819,27 @@ static int mdd_create(const struct lu_context *ctxt,
         if (rc)
                 GOTO(cleanup, rc);
 
+        created = 1;
         rc = __mdd_index_insert(ctxt, mdo, lu_object_fid(&child->mo_lu),
                                 name, handle);
+        
+        inserted = 1;
+        rc = mdd_lov_set_md(ctxt, pobj, child);
         if (rc) {
-                int rc2;
-
-                rc2 = __mdd_object_destroy(ctxt, son, handle);
-                if (rc2)
-                        CERROR("Cannot cleanup insertion failure: %d/%d\n",
-                               rc, rc2);
+                CERROR("error on stripe info copy %d \n", rc);
         }
-
 cleanup:
+        if (rc && created) {
+                int rc1 = 0, rc2 = 0;
+
+                rc1 = __mdd_object_destroy(ctxt, son, handle);
+                if (inserted) 
+                        rc2 = __mdd_index_delete(ctxt, mdo, name, handle);
+                if (rc1 || rc2) 
+                        CERROR("error can not cleanup destory %d insert %d \n",
+                               rc1, rc2);
+        }
+
         mdd_unlock(ctxt, mdo, DT_WRITE_LOCK);
         mdd_trans_stop(ctxt, mdd, handle);
         RETURN(rc);
index 149f010..f37f2b9 100644 (file)
@@ -64,6 +64,7 @@ struct mdd_thread_info {
         struct lu_fid    mti_fid;
         struct lu_attr   mti_attr;
         struct lov_desc  mti_ld;
+        struct lov_mds_md mti_lmm;
 };
 
 int mdd_lov_init(const struct lu_context *ctxt, struct mdd_device *mdd,
@@ -73,6 +74,10 @@ int mdd_notify(const struct lu_context *ctxt, struct lu_device *ld,
                struct obd_device *watched, enum obd_notify_event ev,
                void *data);
 
+int mdd_xattr_set(const struct lu_context *ctxt, struct md_object *obj,
+                  const void *buf, int buf_len, const char *name);
+int mdd_lov_set_md(const struct lu_context *ctxt, struct md_object *pobj,
+                   struct md_object *child);
 struct mdd_thread_info *mdd_ctx_info(const struct lu_context *ctx);
 extern struct lu_device_operations mdd_lu_ops;
 static inline int lu_device_is_mdd(struct lu_device *d)
@@ -114,4 +119,11 @@ static inline struct dt_device_operations *mdd_child_ops(struct mdd_device *d)
 {
         return d->mdd_child->dd_ops;
 }
+
+static inline struct dt_object* mdd_object_child(struct mdd_object *o)
+{
+        return container_of0(lu_object_next(&o->mod_obj.mo_lu),
+                             struct dt_object, do_lu);
+}
+
 #endif
index 38b15d6..b315db8 100644 (file)
@@ -566,3 +566,47 @@ int mdd_notify(const struct lu_context *ctxt, struct lu_device *ld,
                                        !(ev == OBD_NOTIFY_SYNC));
         RETURN(rc);
 }
+
+static int mdd_get_md(const struct lu_context *ctxt, struct md_object *obj,
+                      void *md, int *md_size, int lock)
+{
+        struct dt_object *next;
+        int rc = 0;
+        int lmm_size;
+
+        next = mdd_object_child(md2mdd_obj(obj));
+        rc = next->do_ops->do_xattr_get(ctxt, next, md, *md_size, 
+                                        "lov");
+        if (rc < 0) {
+                CERROR("Error %d reading eadata \n", rc);
+        } else if (rc > 0) {
+                lmm_size = rc;
+                /*FIXME convert lov EA necessary for this version?*/
+                *md_size = lmm_size;
+                rc = lmm_size;
+        } else {
+                *md_size = 0;
+        }
+        
+        RETURN (rc);
+}
+
+int mdd_lov_set_md(const struct lu_context *ctxt, struct md_object *pobj,
+                   struct md_object *child)
+{
+        struct dt_object *next = mdd_object_child(md2mdd_obj(child));
+        int rc = 0;
+        ENTRY;
+
+        if (dt_is_dir(ctxt, next)) {
+                struct lov_mds_md *lmm = &mdd_ctx_info(ctxt)->mti_lmm;
+                int lmm_size = sizeof(lmm);
+                rc = mdd_get_md(ctxt, pobj, &lmm, &lmm_size, 1);
+                if (rc > 0) {
+                        rc = mdd_xattr_set(ctxt, child, lmm, lmm_size, "lov");
+                        if (rc)
+                                CERROR("error on copy stripe info: rc = %d\n", rc);
+                }
+        }
+        RETURN(rc);
+}
index 39563a6..4c9145a 100644 (file)
@@ -755,6 +755,19 @@ static int osd_object_ref_del(const struct lu_context *ctxt,
         return 0;
 }
 
+int osd_xattr_get(const struct lu_context *ctxt, struct dt_object *dt,
+                  void *buf, int buf_len, const char *name)
+{
+        return 0;
+}
+
+int osd_xattr_set(const struct lu_context *ctxt, struct dt_object *dt,
+                  const void *buf, int buf_len, const char *name, 
+                  struct thandle *handle)
+{
+        return 0;
+}
+
 static struct dt_object_operations osd_obj_ops = {
         .do_object_lock      = osd_object_lock,
         .do_object_unlock    = osd_object_unlock,
@@ -763,7 +776,9 @@ static struct dt_object_operations osd_obj_ops = {
         .do_object_destroy   = osd_object_destroy,
         .do_object_index_try = osd_index_try,
         .do_object_ref_add   = osd_object_ref_add,
-        .do_object_ref_del   = osd_object_ref_del
+        .do_object_ref_del   = osd_object_ref_del,
+        .do_xattr_get        = osd_xattr_get,
+        .do_xattr_set        = osd_xattr_set
 };
 
 static struct dt_body_operations osd_body_ops = {