Whamcloud - gitweb
- add mdd_device_shutdown()
authortappro <tappro>
Tue, 15 Aug 2006 22:30:49 +0000 (22:30 +0000)
committertappro <tappro>
Tue, 15 Aug 2006 22:30:49 +0000 (22:30 +0000)
- rename mdd_cleanup_obd() to the mdd_fini_obd() and call it from
  mdd_device_shutdown()
- rename mdd2_obd() helper to the mdd2obd_dev() to make it similar with others
- add mdd_obd_dev field into mdd_device and store mdd_obd pointer in it

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

index bb8ed07..33c4684 100644 (file)
@@ -414,33 +414,19 @@ static int mdd_mount(const struct lu_context *ctx, struct mdd_device *mdd)
                 rc = 0;
         } else
                 rc = PTR_ERR(root);
-        RETURN(rc);
-}
 
-static int mdd_fs_setup(const struct lu_context *ctx, struct mdd_device *mdd)
-{
-        /*create PENDING and OBJECTS dir for open and llog*/
-        return 0;
-}
-
-static int mdd_fs_cleanup(struct mdd_device *mdd)
-{
-        /*create PENDING and OBJECTS dir for open and llog*/
-        return 0;
+        RETURN(rc);
 }
 
 static int mdd_device_init(const struct lu_context *ctx,
                            struct lu_device *d, struct lu_device *next)
 {
         struct mdd_device *mdd = lu2mdd_dev(d);
-        int rc;
+        int rc = 0;
         ENTRY;
 
         mdd->mdd_child = lu2dt_dev(next);
 
-        rc = mdd_fs_setup(ctx, mdd);
-        if (rc)
-                mdd_fs_cleanup(mdd);
         RETURN(rc);
 }
 
@@ -452,6 +438,11 @@ static struct lu_device *mdd_device_fini(const struct lu_context *ctx,
 
         return next;
 }
+static void mdd_device_shutdown(const struct lu_context *ctxt,
+                                struct mdd_device *m)
+{
+        mdd_fini_obd(ctxt, m);
+}
 
 static int mdd_process_config(const struct lu_context *ctxt,
                               struct lu_device *d, struct lustre_cfg *cfg)
@@ -478,6 +469,8 @@ static int mdd_process_config(const struct lu_context *ctxt,
                         GOTO(out, rc);
                 }
                 break;
+        case LCFG_CLEANUP:
+                mdd_device_shutdown(ctxt, m);
         default:
                 rc = next->ld_ops->ldo_process_config(ctxt, next, cfg);
                 break;
@@ -1874,9 +1867,9 @@ static struct obd_ops mdd_obd_device_ops = {
         .o_owner = THIS_MODULE
 };
 
-struct lu_device *mdd_device_alloc(const struct lu_context *ctx,
-                                   struct lu_device_type *t,
-                                   struct lustre_cfg *lcfg)
+static struct lu_device *mdd_device_alloc(const struct lu_context *ctx,
+                                          struct lu_device_type *t,
+                                          struct lustre_cfg *lcfg)
 {
         struct lu_device  *l;
         struct mdd_device *m;
@@ -1894,7 +1887,8 @@ struct lu_device *mdd_device_alloc(const struct lu_context *ctx,
         return l;
 }
 
-static void mdd_device_free(const struct lu_context *ctx, struct lu_device *lu)
+static void mdd_device_free(const struct lu_context *ctx,
+                            struct lu_device *lu)
 {
         struct mdd_device *m = lu2mdd_dev(lu);
 
index 0afcc41..fa408cf 100644 (file)
@@ -35,6 +35,7 @@ struct dt_device;
 struct mdd_device {
         struct md_device                 mdd_md_dev;
         struct dt_device                *mdd_child;
+        struct obd_device               *mdd_obd_dev;
         struct lu_fid                    mdd_root_fid;
         struct dt_device_param           mdd_dt_conf;
 };
@@ -61,6 +62,7 @@ struct mdd_thread_info {
 
 int mdd_init_obd(const struct lu_context *ctxt, struct mdd_device *mdd,
                  char *dev);
+int mdd_fini_obd(const struct lu_context *, struct mdd_device *);
 int mdd_xattr_set_txn(const struct lu_context *ctxt, struct mdd_object *obj,
                       const void *buf, int buf_len, const char *name, int fl,
                       struct thandle *txn);
@@ -139,9 +141,9 @@ static inline struct dt_object* mdd_object_child(struct mdd_object *o)
         return container_of0(lu_object_next(mdd2lu_obj(o)),
                              struct dt_object, do_lu);
 }
-static inline struct obd_device *mdd2_obd(struct mdd_device *mdd)
+static inline struct obd_device *mdd2obd_dev(struct mdd_device *mdd)
 {
-        return mdd->mdd_md_dev.md_lu_dev.ld_obd;
+        return mdd->mdd_obd_dev;
 }
 
 static inline const struct lu_fid *mdo2fid(const struct mdd_object *obj)
@@ -158,14 +160,14 @@ static inline umode_t mdd_object_type(const struct lu_context *ctxt,
 static inline int mdd_lov_mdsize(const struct lu_context *ctxt,
                                  struct mdd_device *mdd)
 {
-        struct obd_device *obd = mdd2_obd(mdd);
+        struct obd_device *obd = mdd2obd_dev(mdd);
         return obd->u.mds.mds_max_mdsize;
 }
 
 static inline int mdd_lov_cookiesize(const struct lu_context *ctxt,
                                      struct mdd_device *mdd)
 {
-        struct obd_device *obd = mdd2_obd(mdd);
+        struct obd_device *obd = mdd2obd_dev(mdd);
         return obd->u.mds.mds_max_cookiesize;
 }
 
index d734115..e2abed2 100644 (file)
@@ -60,7 +60,7 @@ static int mdd_lov_update(struct obd_device *host,
         ENTRY;
 
         LASSERT(owner != NULL);
-        obd = mdd2_obd(mdd);
+        obd = mdd2obd_dev(mdd);
 
         upcall_dev = mdd->mdd_md_dev.md_upcall.mu_upcall_dev;
 
@@ -104,10 +104,10 @@ int mdd_init_obd(const struct lu_context *ctxt, struct mdd_device *mdd,
                 GOTO(class_detach, rc);
         /*Add here for obd notify mechiasm,
          *when adding a new ost, the mds will notify this mdd*/
-
         obd->obd_upcall.onu_owner = mdd;
         obd->obd_upcall.onu_upcall = mdd_lov_update;
-        mdd->mdd_md_dev.md_lu_dev.ld_obd = obd;
+
+        mdd->mdd_obd_dev = obd;
 class_detach:
         if (rc)
                 class_detach(obd, lcfg);
@@ -116,7 +116,7 @@ lcfg_cleanup:
         RETURN(rc);
 }
 
-int mdd_cleanup_obd(struct mdd_device *mdd)
+int mdd_fini_obd(const struct lu_context *ctxt, struct mdd_device *mdd)
 {
         struct lustre_cfg_bufs bufs;
         struct lustre_cfg      *lcfg;
@@ -124,7 +124,7 @@ int mdd_cleanup_obd(struct mdd_device *mdd)
         int rc;
         ENTRY;
 
-        obd = mdd->mdd_md_dev.md_lu_dev.ld_obd;
+        obd = mdd2obd_dev(mdd);
         LASSERT(obd);
 
         lustre_cfg_bufs_reset(&bufs, MDD_OBD_NAME);
@@ -139,7 +139,7 @@ int mdd_cleanup_obd(struct mdd_device *mdd)
         rc = class_detach(obd, lcfg);
         if (rc)
                 GOTO(lcfg_cleanup, rc);
-        mdd->mdd_md_dev.md_lu_dev.ld_obd = NULL;
+        mdd->mdd_obd_dev = NULL;
 lcfg_cleanup:
         lustre_cfg_free(lcfg);
         RETURN(rc);
@@ -182,7 +182,7 @@ static int mdd_lov_set_stripe_md(const struct lu_context *ctxt,
                                  int lmm_size, struct thandle *handle)
 {
         struct mdd_device       *mdd = mdo2mdd(&obj->mod_obj);
-        struct obd_device       *obd = mdd2_obd(mdd);
+        struct obd_device       *obd = mdd2obd_dev(mdd);
         struct obd_export       *lov_exp = obd->u.mds.mds_osc_exp;
         struct lov_stripe_md    *lsm = NULL;
         int rc;
@@ -333,7 +333,7 @@ int mdd_lov_create(const struct lu_context *ctxt, struct mdd_device *mdd,
                    struct lov_mds_md **lmm, int *lmm_size,
                    const struct md_create_spec *spec, struct lu_attr *la)
 {
-        struct obd_device       *obd = mdd2_obd(mdd);
+        struct obd_device       *obd = mdd2obd_dev(mdd);
         struct obd_export       *lov_exp = obd->u.mds.mds_osc_exp;
         struct obdo             *oa;
         struct lov_stripe_md    *lsm = NULL;
@@ -451,7 +451,7 @@ out_oa:
 int mdd_unlink_log(const struct lu_context *ctxt, struct mdd_device *mdd,
                    struct mdd_object *mdd_cobj, struct md_attr *ma)
 {
-        struct obd_device *obd = mdd2_obd(mdd);
+        struct obd_device *obd = mdd2obd_dev(mdd);
 
         if (mds_log_op_unlink(obd, NULL, ma->ma_lmm, ma->ma_lmm_size,
                                  ma->ma_cookie, ma->ma_cookie_size) > 0) {
@@ -464,7 +464,7 @@ int mdd_lov_setattr_async(const struct lu_context *ctxt, struct mdd_object *obj,
                           struct lov_mds_md *lmm, int lmm_size)
 {
         struct mdd_device       *mdd = mdo2mdd(&obj->mod_obj);
-        struct obd_device       *obd = mdd2_obd(mdd);
+        struct obd_device       *obd = mdd2obd_dev(mdd);
         struct lu_attr          *tmp_la = &mdd_ctx_info(ctxt)->mti_la;
         struct dt_object        *next = mdd_object_child(obj);
         __u32  seq  = lu_object_fid(mdd2lu_obj(obj))->f_seq;