diff --git a/lustre/include/md_object.h b/lustre/include/md_object.h index c4ebbb0fe6db46c06524abda8862157d340c97e7..7fa59b25a12613c62049b53067da8272ab43d42c 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 6e09db1f6218b2af5e391bb144eba4664be7198d..a11b770c28176a6e2874a51ae543d886724421df 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 ec219966debfa03daeabd3e7a2e14a0fe584d746..eef4fa54f8682572e7c0ca6570a2610ce0a18f41 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 0497cfd1dfb9bc6454818ed5fa7cbed0f5edca31..f4c80ee61950f152092aa80021a606468929c6f0 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 084e6d1ebf3105d7c35bbd4299a08753e1330069..e1a405a2bb12e0f71ac4a9b1392b06b6adc9f7cc 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 29d50224505701843071a4a6f958a90abe4c433e..990c3cf8940174c0e277c785a35d7f78ba389696 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);