Whamcloud - gitweb
LU-1187 mdt: Add pre_cleanup phase in MDT stack cleanup
authorwangdi <di.wang@whamcloud.com>
Wed, 2 Oct 2013 15:37:40 +0000 (08:37 -0700)
committerOleg Drokin <green@whamcloud.com>
Thu, 31 Jan 2013 21:35:55 +0000 (16:35 -0500)
Add pre_cleanup phase in MDT stack cleanup, so MD OSP can be
disconnected before cleanup MDT stack.

Signed-off-by: wang di <di.wang@whamcloud.com>
Change-Id: Id1a56c393c22b4fc526c81c05b11bfb656a80559
Reviewed-on: http://review.whamcloud.com/4929
Tested-by: Hudson
Tested-by: Maloo <whamcloud.maloo@gmail.com>
Reviewed-by: Alex Zhuravlev <alexey.zhuravlev@intel.com>
Reviewed-by: Mike Pershin <mike.pershin@intel.com>
Reviewed-by: Oleg Drokin <green@whamcloud.com>
lustre/include/lustre_cfg.h
lustre/lod/lod_dev.c
lustre/mdt/mdt_handler.c
lustre/osp/lwp_dev.c
lustre/osp/osp_dev.c

index 92742af..21ac8e6 100644 (file)
@@ -86,6 +86,8 @@ enum lcfg_command_type {
         LCFG_POOL_REM           = 0x00ce022, /**< remove an ost from a pool */
         LCFG_POOL_DEL           = 0x00ce023, /**< destroy an ost pool name */
         LCFG_SET_LDLM_TIMEOUT   = 0x00ce030, /**< set ldlm_timeout */
+       LCFG_PRE_CLEANUP        = 0x00cf031, /**< call type-specific pre
+                                             * cleanup cleanup */
 };
 
 struct lustre_cfg_bufs {
index 4a672dc..5d8f5fe 100644 (file)
@@ -405,11 +405,15 @@ static int lod_process_config(const struct lu_env *env,
                GOTO(out, rc);
        }
        case LCFG_CLEANUP:
+       case LCFG_PRE_CLEANUP: {
                lu_dev_del_linkage(dev->ld_site, dev);
                lod_cleanup_desc_tgts(env, lod, &lod->lod_mdt_descs, lcfg);
                lod_cleanup_desc_tgts(env, lod, &lod->lod_ost_descs, lcfg);
 
                lod_seq_fini_cli(lod);
+
+               if (lcfg->lcfg_command == LCFG_PRE_CLEANUP)
+                       break;
                /*
                 * do cleanup on underlying storage only when
                 * all OSPs are cleaned up, as they use that OSD as well
@@ -424,7 +428,7 @@ static int lod_process_config(const struct lu_env *env,
                if (rc)
                        CERROR("error in disconnect from storage: %d\n", rc);
                break;
-
+       }
        default:
               CERROR("%s: unknown command %u\n", lod2obd(lod)->obd_name,
                      lcfg->lcfg_command);
index 2f98d85..f2fc8f0 100644 (file)
@@ -3959,6 +3959,43 @@ static int mdt_fld_init(const struct lu_env *env,
        RETURN(0);
 }
 
+static void mdt_stack_pre_fini(const struct lu_env *env,
+                          struct mdt_device *m, struct lu_device *top)
+{
+       struct obd_device       *obd = mdt2obd_dev(m);
+       struct lustre_cfg_bufs  *bufs;
+       struct lustre_cfg       *lcfg;
+       struct mdt_thread_info  *info;
+       ENTRY;
+
+       LASSERT(top);
+
+       info = lu_context_key_get(&env->le_ctx, &mdt_thread_key);
+       LASSERT(info != NULL);
+
+       bufs = &info->mti_u.bufs;
+
+       LASSERT(m->mdt_child_exp);
+       LASSERT(m->mdt_child_exp->exp_obd);
+       obd = m->mdt_child_exp->exp_obd;
+
+       /* process cleanup, pass mdt obd name to get obd umount flags */
+       /* XXX: this is needed because all layers are referenced by
+        * objects (some of them are pinned by osd, for example *
+        * the proper solution should be a model where object used
+        * by osd only doesn't have mdt/mdd slices -bzzz */
+       lustre_cfg_bufs_reset(bufs, obd->obd_name);
+       lustre_cfg_bufs_set_string(bufs, 1, NULL);
+       lcfg = lustre_cfg_new(LCFG_PRE_CLEANUP, bufs);
+       if (!lcfg) {
+               CERROR("%s:Cannot alloc lcfg!\n", mdt_obd_name(m));
+               return;
+       }
+       top->ld_ops->ldo_process_config(env, top, lcfg);
+       lustre_cfg_free(lcfg);
+       EXIT;
+}
+
 static void mdt_stack_fini(const struct lu_env *env,
                            struct mdt_device *m, struct lu_device *top)
 {
@@ -4343,6 +4380,8 @@ static void mdt_fini(const struct lu_env *env, struct mdt_device *m)
 
         ping_evictor_stop();
 
+
+       mdt_stack_pre_fini(env, m, md2lu_dev(m->mdt_child));
         mdt_llog_ctxt_unclone(env, m, LLOG_CHANGELOG_ORIG_CTXT);
         obd_exports_barrier(obd);
         obd_zombie_barrier();
index ed5dba9..85c2641 100644 (file)
@@ -191,6 +191,7 @@ static int lwp_process_config(const struct lu_env *env,
        ENTRY;
 
        switch (lcfg->lcfg_command) {
+       case LCFG_PRE_CLEANUP:
        case LCFG_CLEANUP:
                rc = lwp_disconnect(d);
                break;
index aaf5073..b2db05e 100644 (file)
@@ -380,6 +380,9 @@ static int osp_process_config(const struct lu_env *env,
        ENTRY;
 
        switch (lcfg->lcfg_command) {
+       case LCFG_PRE_CLEANUP:
+               rc = osp_disconnect(d);
+               break;
        case LCFG_CLEANUP:
                lu_dev_del_linkage(dev->ld_site, dev);
                rc = osp_shutdown(env, d);