From 1d3c17c697fcabe8a8ae0d23a8e915a268ad2e71 Mon Sep 17 00:00:00 2001 From: tappro Date: Thu, 20 Sep 2007 08:53:42 +0000 Subject: [PATCH 1/1] - enable client connect only if mds is configured and ost is active. Port from 1_6 into new MDS devices. b:13060 i: nikita, nathan --- lustre/include/md_object.h | 1 + lustre/include/obd.h | 6 ++++++ lustre/mdd/mdd_lov.c | 22 ++++++++++++++++------ lustre/mdt/mdt_handler.c | 24 +++++++++++++++++++++--- lustre/mdt/mdt_internal.h | 4 +++- lustre/obdclass/obd_mount.c | 2 +- 6 files changed, 48 insertions(+), 11 deletions(-) diff --git a/lustre/include/md_object.h b/lustre/include/md_object.h index c4ebbb0..7fa59b2 100644 --- a/lustre/include/md_object.h +++ b/lustre/include/md_object.h @@ -305,6 +305,7 @@ enum md_upcall_event { /*sync the md layer*/ MD_LOV_SYNC = (1 << 0), MD_NO_TRANS = (1 << 1), /* Just for split, no need trans, for replay */ + MD_LOV_CONFIG = (1 << 2) }; struct md_upcall { diff --git a/lustre/include/obd.h b/lustre/include/obd.h index 6e09db1..a11b770 100644 --- a/lustre/include/obd.h +++ b/lustre/include/obd.h @@ -791,6 +791,12 @@ enum obd_notify_event { OBD_NOTIFY_CONFIG }; +/* bit-mask flags for config events */ +enum config_flags { + CONFIG_LOG = 0x1, /* finished processing config log */ + CONFIG_SYNC = 0x2 /* mdt synced 1 ost */ +}; + /* * Data structure used to pass obd_notify()-event to non-obd listeners (llite * and liblustre being main examples). diff --git a/lustre/mdd/mdd_lov.c b/lustre/mdd/mdd_lov.c index ec21996..eef4fa5 100644 --- a/lustre/mdd/mdd_lov.c +++ b/lustre/mdd/mdd_lov.c @@ -44,17 +44,27 @@ #include "mdd_internal.h" -static int mdd_lov_update(struct obd_device *host, - struct obd_device *watched, - enum obd_notify_event ev, void *owner) +static int mdd_notify(struct obd_device *host, struct obd_device *watched, + enum obd_notify_event ev, void *owner) { struct mdd_device *mdd = owner; int rc = 0; ENTRY; LASSERT(owner != NULL); - - rc = md_do_upcall(NULL, &mdd->mdd_md_dev, MD_LOV_SYNC); + switch (ev) + { + case OBD_NOTIFY_ACTIVE: + case OBD_NOTIFY_SYNC: + case OBD_NOTIFY_SYNC_NONBLOCK: + rc = md_do_upcall(NULL, &mdd->mdd_md_dev, MD_LOV_SYNC); + break; + case OBD_NOTIFY_CONFIG: + rc = md_do_upcall(NULL, &mdd->mdd_md_dev, MD_LOV_CONFIG); + break; + default: + CDEBUG(D_INFO, "Unhandled notification %#x\n", ev); + } RETURN(rc); } @@ -122,7 +132,7 @@ int mdd_init_obd(const struct lu_env *env, struct mdd_device *mdd, * Add here for obd notify mechanism, when adding a new ost, the mds * will notify this mdd. */ - obd->obd_upcall.onu_upcall = mdd_lov_update; + obd->obd_upcall.onu_upcall = mdd_notify; obd->obd_upcall.onu_owner = mdd; mdd->mdd_obd_dev = obd; diff --git a/lustre/mdt/mdt_handler.c b/lustre/mdt/mdt_handler.c index 0497cfd..f4c80ee 100644 --- a/lustre/mdt/mdt_handler.c +++ b/lustre/mdt/mdt_handler.c @@ -4357,6 +4357,18 @@ out: return rc; } +static void mdt_allow_cli(struct mdt_device *m, unsigned int flag) +{ + if (flag & CONFIG_LOG) + m->mdt_fl_cfglog = 1; + if (flag & CONFIG_SYNC) + m->mdt_fl_synced = 1; + + if (m->mdt_fl_cfglog && m->mdt_fl_synced) + /* Open for clients */ + m->mdt_md_dev.md_lu_dev.ld_obd->obd_no_conn = 0; +} + static int mdt_upcall(const struct lu_env *env, struct md_device *md, enum md_upcall_event ev) { @@ -4373,12 +4385,17 @@ static int mdt_upcall(const struct lu_env *env, struct md_device *md, &m->mdt_max_cookiesize); CDEBUG(D_INFO, "get max mdsize %d max cookiesize %d\n", m->mdt_max_mdsize, m->mdt_max_cookiesize); + mdt_allow_cli(m, CONFIG_SYNC); break; case MD_NO_TRANS: mti = lu_context_key_get(&env->le_ctx, &mdt_thread_key); mti->mti_no_need_trans = 1; CDEBUG(D_INFO, "disable mdt trans for this thread\n"); break; + case MD_LOV_CONFIG: + /* Check that MDT is not yet configured */ + LASSERT(!m->mdt_fl_cfglog); + break; default: CERROR("invalid event\n"); rc = -EINVAL; @@ -4389,15 +4406,16 @@ static int mdt_upcall(const struct lu_env *env, struct md_device *md, static int mdt_obd_notify(struct obd_device *host, struct obd_device *watched, - enum obd_notify_event ev, void *owner) + enum obd_notify_event ev, void *data) { ENTRY; switch (ev) { case OBD_NOTIFY_CONFIG: - host->obd_no_conn = 0; + mdt_allow_cli(mdt_dev(host->obd_lu_dev), (unsigned int)data); + break; default: - CDEBUG(D_INFO, "Notification 0x%x\n", ev); + CDEBUG(D_INFO, "Unhandled notification %#x\n", ev); } RETURN(0); } diff --git a/lustre/mdt/mdt_internal.h b/lustre/mdt/mdt_internal.h index 084e6d1..e1a405a 100644 --- a/lustre/mdt/mdt_internal.h +++ b/lustre/mdt/mdt_internal.h @@ -149,7 +149,9 @@ struct mdt_device { mo_mds_capa :1, mo_oss_capa :1; } mdt_opts; - + /* mdt state flags */ + __u32 mdt_fl_cfglog:1, + mdt_fl_synced:1; /* lock to pretect epoch and write count */ spinlock_t mdt_ioepoch_lock; __u64 mdt_ioepoch; diff --git a/lustre/obdclass/obd_mount.c b/lustre/obdclass/obd_mount.c index 29d5022..990c3cf 100644 --- a/lustre/obdclass/obd_mount.c +++ b/lustre/obdclass/obd_mount.c @@ -1193,7 +1193,7 @@ out_mgc: } /* log has been fully processed */ - obd_notify(obd, NULL, OBD_NOTIFY_CONFIG, 0); + obd_notify(obd, NULL, OBD_NOTIFY_CONFIG, (void *)CONFIG_LOG); } RETURN(rc); -- 1.8.3.1