Whamcloud - gitweb
- call ldto_device_fini() in obd_precleanup()
authortappro <tappro>
Wed, 16 Aug 2006 20:25:11 +0000 (20:25 +0000)
committertappro <tappro>
Wed, 16 Aug 2006 20:25:11 +0000 (20:25 +0000)
- separate mdt_fini() from mdt_free()
- correct operation order in  mdt_fini()

lustre/include/obd_class.h
lustre/mdt/mdt_handler.c

index 7371f53..d22bc67 100644 (file)
@@ -384,12 +384,33 @@ static inline int obd_precleanup(struct obd_device *obd,
                                  enum obd_cleanup_stage cleanup_stage)
 {
         int rc;
+        DECLARE_LU_VARS(ldt, d);
         ENTRY;
 
-        OBD_CHECK_DT_OP(obd, precleanup, 0);
-        OBD_COUNTER_INCREMENT(obd, precleanup);
+        OBD_CHECK_DEV(obd);
+#ifdef __KERNEL__
+        ldt = obd->obd_type->typ_lu;
+        d = obd->obd_lu_dev;
+        if (ldt != NULL && d != NULL) {
+                struct lu_context ctx;
 
-        rc = OBP(obd, precleanup)(obd, cleanup_stage);
+                rc = lu_context_init(&ctx, ldt->ldt_ctx_tags);
+                if (rc == 0) {
+                        lu_context_enter(&ctx);
+                        ldt->ldt_ops->ldto_device_fini(&ctx, d);
+                        lu_context_exit(&ctx);
+                        lu_context_fini(&ctx);
+                        obd->obd_lu_dev = NULL;
+                        rc = 0;
+                }
+        } else
+#endif
+        {
+                OBD_CHECK_DT_OP(obd, precleanup, 0);
+                rc = OBP(obd, precleanup)(obd, cleanup_stage);
+        }
+        
+        OBD_COUNTER_INCREMENT(obd, precleanup);
         RETURN(rc);
 }
 
index 3dddc9d..f76593c 100644 (file)
@@ -2238,15 +2238,14 @@ static void mdt_fini(const struct lu_context *ctx, struct mdt_device *m)
         ping_evictor_stop();
         mdt_stop_ptlrpc_service(m);
 
-        mdt_fld_fini(ctx, m);
         mdt_seq_fini(ctx, m);
         mdt_seq_fini_cli(m);
+        
+        mdt_fld_fini(ctx, m);
+
         /* finish the stack */
         mdt_stack_fini(ctx, m, md2lu_dev(m->mdt_child));
 
-        LASSERT(atomic_read(&d->ld_ref) == 0);
-        md_device_fini(&m->mdt_md_dev);
-
         if (m->mdt_namespace != NULL) {
                 ldlm_namespace_free(m->mdt_namespace, 0);
                 m->mdt_namespace = NULL;
@@ -2256,6 +2255,8 @@ static void mdt_fini(const struct lu_context *ctx, struct mdt_device *m)
                 lu_site_fini(ls);
                 OBD_FREE_PTR(ls);
         }
+        LASSERT(atomic_read(&d->ld_ref) == 0);
+        md_device_fini(&m->mdt_md_dev);
 
         EXIT;
 }
@@ -2357,6 +2358,7 @@ err_fini_site:
         lu_site_fini(s);
 err_free_site:
         OBD_FREE_PTR(s);
+        
         md_device_fini(&m->mdt_md_dev);
         return (rc);
 }
@@ -2675,12 +2677,18 @@ static struct obd_ops mdt_obd_device_ops = {
         .o_init_export    = mdt_init_export,    /* By Huang Hua*/
         .o_destroy_export = mdt_destroy_export, /* By Huang Hua*/
 };
+      
+static void mdt_device_fini(const struct lu_context *ctx, struct lu_device *d)
+{
+        struct mdt_device *m = mdt_dev(d);
+
+        mdt_fini(ctx, m);
+}
 
 static void mdt_device_free(const struct lu_context *ctx, struct lu_device *d)
 {
         struct mdt_device *m = mdt_dev(d);
 
-        mdt_fini(ctx, m);
         OBD_FREE_PTR(m);
 }
 
@@ -2789,7 +2797,8 @@ static struct lu_device_type_operations mdt_device_type_ops = {
         .ldto_fini = mdt_type_fini,
 
         .ldto_device_alloc = mdt_device_alloc,
-        .ldto_device_free  = mdt_device_free
+        .ldto_device_free  = mdt_device_free,
+        .ldto_device_fini  = mdt_device_fini
 };
 
 static struct lu_device_type mdt_device_type = {