Whamcloud - gitweb
LU-4136 obdclass: use obd_get_info to report network status 08/8408/4
authorBobi Jam <bobijam.xu@intel.com>
Wed, 27 Nov 2013 04:36:05 +0000 (12:36 +0800)
committerOleg Drokin <oleg.drokin@intel.com>
Mon, 16 Dec 2013 03:14:21 +0000 (03:14 +0000)
Use obd_get_info() to report MDT-OST connection status instead of
health_check(), so that /proc/fs/lustre/health_check does not
check MDT's connection status.

Signed-off-by: Bobi Jam <bobijam.xu@intel.com>
Change-Id: I8b4afcfdce3712fff893475b9c5cd44654f3762e
Reviewed-on: http://review.whamcloud.com/8408
Reviewed-by: Mike Pershin <mike.pershin@intel.com>
Tested-by: Jenkins
Tested-by: Maloo <hpdd-maloo@intel.com>
Reviewed-by: Alex Zhuravlev <alexey.zhuravlev@intel.com>
Reviewed-by: Oleg Drokin <oleg.drokin@intel.com>
lustre/include/obd.h
lustre/lod/lod_dev.c
lustre/mdd/mdd_device.c
lustre/mdt/mdt_handler.c
lustre/osp/osp_dev.c

index 13c6cd7..03ccfea 100644 (file)
@@ -1033,6 +1033,7 @@ enum obd_cleanup_stage {
 #define KEY_CACHE_SET          "cache_set"
 #define KEY_CACHE_LRU_SHRINK   "cache_lru_shrink"
 #define KEY_CHANGELOG_INDEX    "changelog_index"
+#define KEY_OSP_CONNECTED      "osp_connected"
 
 struct lu_context;
 
index 69de6f6..e36aee1 100644 (file)
@@ -869,25 +869,37 @@ static struct lu_device_type lod_device_type = {
        .ldt_ctx_tags = LCT_MD_THREAD,
 };
 
-static int lod_obd_health_check(const struct lu_env *env,
-               struct obd_device *obd)
+static int lod_obd_get_info(const struct lu_env *env, struct obd_export *exp,
+                           __u32 keylen, void *key, __u32 *vallen, void *val,
+                           struct lov_stripe_md *lsm)
 {
-       struct lod_device   *d = lu2lod_dev(obd->obd_lu_dev);
-       struct lod_ost_desc *ost;
-       int                  i, rc = 1;
-       ENTRY;
-
-       LASSERT(d);
-       lod_getref(&d->lod_ost_descs);
-       lod_foreach_ost(d, i) {
-               ost = OST_TGT(d, i);
-               LASSERT(ost && ost->ltd_ost);
-               rc = obd_health_check(env, ost->ltd_exp->exp_obd);
-               /* one healthy device is enough */
-               if (rc == 0)
-                       break;
+       int rc = -EINVAL;
+
+       if (KEY_IS(KEY_OSP_CONNECTED)) {
+               struct obd_device       *obd = exp->exp_obd;
+               struct lod_device       *d;
+               struct lod_ost_desc     *ost;
+               int                     i, rc = 1;
+
+               if (!obd->obd_set_up || obd->obd_stopping)
+                       RETURN(-EAGAIN);
+
+               d = lu2lod_dev(obd->obd_lu_dev);
+               lod_getref(&d->lod_ost_descs);
+               lod_foreach_ost(d, i) {
+                       ost = OST_TGT(d, i);
+                       LASSERT(ost && ost->ltd_ost);
+
+                       rc = obd_get_info(env, ost->ltd_exp, keylen, key,
+                                         vallen, val, lsm);
+                       /* one healthy device is enough */
+                       if (rc == 0)
+                               break;
+               }
+               lod_putref(d, &d->lod_ost_descs);
+               RETURN(rc);
        }
-       lod_putref(d, &d->lod_ost_descs);
+
        RETURN(rc);
 }
 
@@ -895,7 +907,7 @@ static struct obd_ops lod_obd_device_ops = {
        .o_owner        = THIS_MODULE,
        .o_connect      = lod_obd_connect,
        .o_disconnect   = lod_obd_disconnect,
-       .o_health_check = lod_obd_health_check,
+       .o_get_info     = lod_obd_get_info,
        .o_pool_new     = lod_pool_new,
        .o_pool_rem     = lod_pool_remove,
        .o_pool_add     = lod_pool_add,
index adb0fdc..750281a 100644 (file)
@@ -1159,15 +1159,26 @@ static int mdd_obd_disconnect(struct obd_export *exp)
        RETURN(rc);
 }
 
-static int mdd_obd_health_check(const struct lu_env *env,
-                               struct obd_device *obd)
+static int mdd_obd_get_info(const struct lu_env *env, struct obd_export *exp,
+                           __u32 keylen, void *key, __u32 *vallen, void *val,
+                           struct lov_stripe_md *lsm)
 {
-       struct mdd_device *mdd = lu2mdd_dev(obd->obd_lu_dev);
-       int                rc;
-       ENTRY;
+       int rc = -EINVAL;
+
+       if (KEY_IS(KEY_OSP_CONNECTED)) {
+               struct obd_device       *obd = exp->exp_obd;
+               struct mdd_device       *mdd;
+
+               if (!obd->obd_set_up || obd->obd_stopping)
+                       RETURN(-EAGAIN);
+
+               mdd = lu2mdd_dev(obd->obd_lu_dev);
+               LASSERT(mdd);
+               rc = obd_get_info(env, mdd->mdd_child_exp, keylen, key, vallen,
+                                 val, lsm);
+               RETURN(rc);
+       }
 
-       LASSERT(mdd);
-       rc = obd_health_check(env, mdd->mdd_child_exp->exp_obd);
        RETURN(rc);
 }
 
@@ -1175,7 +1186,7 @@ static struct obd_ops mdd_obd_device_ops = {
        .o_owner        = THIS_MODULE,
        .o_connect      = mdd_obd_connect,
        .o_disconnect   = mdd_obd_disconnect,
-       .o_health_check = mdd_obd_health_check
+       .o_get_info     = mdd_obd_get_info,
 };
 
 static int mdd_changelog_user_register(const struct lu_env *env,
index 09da14f..8daf7e1 100644 (file)
@@ -4870,7 +4870,9 @@ static int mdt_obd_connect(const struct lu_env *env,
         */
        if (!test_bit(MDT_FL_SYNCED, &mdt->mdt_state) && data != NULL &&
            !(data->ocd_connect_flags & OBD_CONNECT_LIGHTWEIGHT)) {
-               rc = obd_health_check(env, mdt->mdt_child_exp->exp_obd);
+               rc = obd_get_info(env, mdt->mdt_child_exp,
+                                 sizeof(KEY_OSP_CONNECTED),
+                                 KEY_OSP_CONNECTED, NULL, NULL, NULL);
                if (rc)
                        RETURN(-EAGAIN);
                set_bit(MDT_FL_SYNCED, &mdt->mdt_state);
index 0a4938c..096de6a 100644 (file)
@@ -1096,20 +1096,30 @@ static int osp_iocontrol(unsigned int cmd, struct obd_export *exp, int len,
        return rc;
 }
 
-static int osp_obd_health_check(const struct lu_env *env,
-                               struct obd_device *obd)
+static int osp_obd_get_info(const struct lu_env *env, struct obd_export *exp,
+                           __u32 keylen, void *key, __u32 *vallen, void *val,
+                           struct lov_stripe_md *lsm)
 {
-       struct osp_device *d = lu2osp_dev(obd->obd_lu_dev);
+       int rc = -EINVAL;
 
-       ENTRY;
+       if (KEY_IS(KEY_OSP_CONNECTED)) {
+               struct obd_device       *obd = exp->exp_obd;
+               struct osp_device       *osp;
 
-       /*
-        * 1.8/2.0 behaviour is that OST being connected once at least
-        * is considired "healthy". and one "healty" OST is enough to
-        * allow lustre clients to connect to MDS
-        */
-       LASSERT(d);
-       RETURN(!d->opd_imp_seen_connected);
+               if (!obd->obd_set_up || obd->obd_stopping)
+                       RETURN(-EAGAIN);
+
+               osp = lu2osp_dev(obd->obd_lu_dev);
+               LASSERT(osp);
+               /*
+                * 1.8/2.0 behaviour is that OST being connected once at least
+                * is considered "healthy". and one "healthy" OST is enough to
+                * allow lustre clients to connect to MDS
+                */
+               RETURN(!osp->opd_imp_seen_connected);
+       }
+
+       RETURN(rc);
 }
 
 /* context key constructor/destructor: mdt_key_init, mdt_key_fini */
@@ -1166,7 +1176,7 @@ static struct obd_ops osp_obd_device_ops = {
        .o_reconnect    = osp_reconnect,
        .o_connect      = osp_obd_connect,
        .o_disconnect   = osp_obd_disconnect,
-       .o_health_check = osp_obd_health_check,
+       .o_get_info     = osp_obd_get_info,
        .o_import_event = osp_import_event,
        .o_iocontrol    = osp_iocontrol,
        .o_statfs       = osp_obd_statfs,