From: wangdi Date: Wed, 2 Oct 2013 15:37:40 +0000 (-0700) Subject: LU-1187 mdt: Add pre_cleanup phase in MDT stack cleanup X-Git-Tag: 2.3.61~62 X-Git-Url: https://git.whamcloud.com/?p=fs%2Flustre-release.git;a=commitdiff_plain;h=1012193babecb36ce331880188aed4f4db5b1daf LU-1187 mdt: Add pre_cleanup phase in MDT stack cleanup Add pre_cleanup phase in MDT stack cleanup, so MD OSP can be disconnected before cleanup MDT stack. Signed-off-by: wang di Change-Id: Id1a56c393c22b4fc526c81c05b11bfb656a80559 Reviewed-on: http://review.whamcloud.com/4929 Tested-by: Hudson Tested-by: Maloo Reviewed-by: Alex Zhuravlev Reviewed-by: Mike Pershin Reviewed-by: Oleg Drokin --- diff --git a/lustre/include/lustre_cfg.h b/lustre/include/lustre_cfg.h index 92742af..21ac8e6 100644 --- a/lustre/include/lustre_cfg.h +++ b/lustre/include/lustre_cfg.h @@ -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 { diff --git a/lustre/lod/lod_dev.c b/lustre/lod/lod_dev.c index 4a672dc..5d8f5fe 100644 --- a/lustre/lod/lod_dev.c +++ b/lustre/lod/lod_dev.c @@ -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); diff --git a/lustre/mdt/mdt_handler.c b/lustre/mdt/mdt_handler.c index 2f98d85..f2fc8f0 100644 --- a/lustre/mdt/mdt_handler.c +++ b/lustre/mdt/mdt_handler.c @@ -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(); diff --git a/lustre/osp/lwp_dev.c b/lustre/osp/lwp_dev.c index ed5dba9..85c2641 100644 --- a/lustre/osp/lwp_dev.c +++ b/lustre/osp/lwp_dev.c @@ -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; diff --git a/lustre/osp/osp_dev.c b/lustre/osp/osp_dev.c index aaf5073..b2db05e 100644 --- a/lustre/osp/osp_dev.c +++ b/lustre/osp/osp_dev.c @@ -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);