Whamcloud - gitweb
- enable client connect only if mds is configured and ost is active. Port from 1_6...
authortappro <tappro>
Thu, 20 Sep 2007 08:53:42 +0000 (08:53 +0000)
committertappro <tappro>
Thu, 20 Sep 2007 08:53:42 +0000 (08:53 +0000)
  b:13060
  i: nikita, nathan

lustre/include/md_object.h
lustre/include/obd.h
lustre/mdd/mdd_lov.c
lustre/mdt/mdt_handler.c
lustre/mdt/mdt_internal.h
lustre/obdclass/obd_mount.c

index c4ebbb0..7fa59b2 100644 (file)
@@ -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 {
index 6e09db1..a11b770 100644 (file)
@@ -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).
index ec21996..eef4fa5 100644 (file)
 
 #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;
 
index 0497cfd..f4c80ee 100644 (file)
@@ -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);
 }
index 084e6d1..e1a405a 100644 (file)
@@ -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;
index 29d5022..990c3cf 100644 (file)
@@ -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);