Whamcloud - gitweb
LU-6971 cleanup: not support remote client anymore
[fs/lustre-release.git] / lustre / mdt / mdt_mds.c
index 367f659..1e84321 100644 (file)
@@ -23,7 +23,7 @@
  * Copyright (c) 2007, 2010, Oracle and/or its affiliates. All rights reserved.
  * Use is subject to license terms.
  *
- * Copyright (c) 2013, Intel Corporation.
+ * Copyright (c) 2013, 2015, Intel Corporation.
  */
 /*
  * This file is part of Lustre, http://www.lustre.org/
 
 struct mds_device {
        /* super-class */
-       struct md_device           mds_md_dev;
-       struct ptlrpc_service     *mds_regular_service;
-       struct ptlrpc_service     *mds_readpage_service;
-       struct ptlrpc_service     *mds_out_service;
-       struct ptlrpc_service     *mds_setattr_service;
-       struct ptlrpc_service     *mds_mdsc_service;
-       struct ptlrpc_service     *mds_mdss_service;
-       struct ptlrpc_service     *mds_fld_service;
+       struct md_device         mds_md_dev;
+       struct ptlrpc_service   *mds_regular_service;
+       struct ptlrpc_service   *mds_readpage_service;
+       struct ptlrpc_service   *mds_out_service;
+       struct ptlrpc_service   *mds_setattr_service;
+       struct ptlrpc_service   *mds_mdsc_service;
+       struct ptlrpc_service   *mds_mdss_service;
+       struct ptlrpc_service   *mds_fld_service;
+       struct mutex             mds_health_mutex;
 };
 
 /*
  *  * Initialized in mdt_mod_init().
  *   */
 static unsigned long mdt_num_threads;
-CFS_MODULE_PARM(mdt_num_threads, "ul", ulong, 0444,
-               "number of MDS service threads to start "
-               "(deprecated in favor of mds_num_threads)");
+module_param(mdt_num_threads, ulong, 0444);
+MODULE_PARM_DESC(mdt_num_threads, "number of MDS service threads to start (deprecated in favor of mds_num_threads)");
 
 static unsigned long mds_num_threads;
-CFS_MODULE_PARM(mds_num_threads, "ul", ulong, 0444,
-               "number of MDS service threads to start");
+module_param(mds_num_threads, ulong, 0444);
+MODULE_PARM_DESC(mds_num_threads, "number of MDS service threads to start");
 
 static char *mds_num_cpts;
-CFS_MODULE_PARM(mds_num_cpts, "c", charp, 0444,
-               "CPU partitions MDS threads should run on");
+module_param(mds_num_cpts, charp, 0444);
+MODULE_PARM_DESC(mds_num_cpts, "CPU partitions MDS threads should run on");
 
 static unsigned long mds_rdpg_num_threads;
-CFS_MODULE_PARM(mds_rdpg_num_threads, "ul", ulong, 0444,
-               "number of MDS readpage service threads to start");
+module_param(mds_rdpg_num_threads, ulong, 0444);
+MODULE_PARM_DESC(mds_rdpg_num_threads, "number of MDS readpage service threads to start");
 
 static char *mds_rdpg_num_cpts;
-CFS_MODULE_PARM(mds_rdpg_num_cpts, "c", charp, 0444,
-               "CPU partitions MDS readpage threads should run on");
+module_param(mds_rdpg_num_cpts, charp, 0444);
+MODULE_PARM_DESC(mds_rdpg_num_cpts, "CPU partitions MDS readpage threads should run on");
 
 /* NB: these two should be removed along with setattr service in the future */
 static unsigned long mds_attr_num_threads;
-CFS_MODULE_PARM(mds_attr_num_threads, "ul", ulong, 0444,
-               "number of MDS setattr service threads to start");
+module_param(mds_attr_num_threads, ulong, 0444);
+MODULE_PARM_DESC(mds_attr_num_threads, "number of MDS setattr service threads to start");
 
 static char *mds_attr_num_cpts;
-CFS_MODULE_PARM(mds_attr_num_cpts, "c", charp, 0444,
-               "CPU partitions MDS setattr threads should run on");
+module_param(mds_attr_num_cpts, charp, 0444);
+MODULE_PARM_DESC(mds_attr_num_cpts, "CPU partitions MDS setattr threads should run on");
 
 /* device init/fini methods */
 static void mds_stop_ptlrpc_service(struct mds_device *m)
 {
        ENTRY;
+
+       mutex_lock(&m->mds_health_mutex);
        if (m->mds_regular_service != NULL) {
                ptlrpc_unregister_service(m->mds_regular_service);
                m->mds_regular_service = NULL;
@@ -131,6 +133,8 @@ static void mds_stop_ptlrpc_service(struct mds_device *m)
                ptlrpc_unregister_service(m->mds_fld_service);
                m->mds_fld_service = NULL;
        }
+       mutex_unlock(&m->mds_health_mutex);
+
        EXIT;
 }
 
@@ -138,7 +142,7 @@ static int mds_start_ptlrpc_service(struct mds_device *m)
 {
        static struct ptlrpc_service_conf conf;
        struct obd_device *obd = m->mds_md_dev.md_lu_dev.ld_obd;
-       cfs_proc_dir_entry_t *procfs_entry;
+       struct proc_dir_entry *procfs_entry;
        int rc = 0;
        ENTRY;
 
@@ -464,6 +468,13 @@ static struct lu_device *mds_device_free(const struct lu_env *env,
        RETURN(NULL);
 }
 
+LPROC_SEQ_FOPS_RO_TYPE(mds, uuid);
+
+static struct lprocfs_vars lprocfs_mds_obd_vars[] = {
+       { "uuid",       &mds_uuid_fops  },
+       { NULL }
+};
+
 static struct lu_device *mds_device_alloc(const struct lu_env *env,
                                          struct lu_device_type *t,
                                          struct lustre_cfg *cfg)
@@ -487,13 +498,16 @@ static struct lu_device *mds_device_alloc(const struct lu_env *env,
        /* set this lu_device to obd, because error handling need it */
        obd->obd_lu_dev = l;
 
-       rc = lprocfs_obd_setup(obd, lprocfs_mds_obd_vars);
+       obd->obd_vars = lprocfs_mds_obd_vars;
+       rc = lprocfs_obd_setup(obd);
        if (rc != 0) {
                mds_device_free(env, l);
                l = ERR_PTR(rc);
                return l;
        }
 
+       mutex_init(&m->mds_health_mutex);
+
        rc = mds_start_ptlrpc_service(m);
 
        if (rc != 0) {
@@ -526,8 +540,28 @@ static struct lu_device_type mds_device_type = {
        .ldt_ctx_tags = LCT_MD_THREAD
 };
 
+static int mds_health_check(const struct lu_env *env, struct obd_device *obd)
+{
+       struct mds_device *mds = mds_dev(obd->obd_lu_dev);
+       int rc = 0;
+
+
+       mutex_lock(&mds->mds_health_mutex);
+       rc |= ptlrpc_service_health_check(mds->mds_regular_service);
+       rc |= ptlrpc_service_health_check(mds->mds_readpage_service);
+       rc |= ptlrpc_service_health_check(mds->mds_out_service);
+       rc |= ptlrpc_service_health_check(mds->mds_setattr_service);
+       rc |= ptlrpc_service_health_check(mds->mds_mdsc_service);
+       rc |= ptlrpc_service_health_check(mds->mds_mdss_service);
+       rc |= ptlrpc_service_health_check(mds->mds_fld_service);
+       mutex_unlock(&mds->mds_health_mutex);
+
+       return rc != 0 ? 1 : 0;
+}
+
 static struct obd_ops mds_obd_device_ops = {
        .o_owner           = THIS_MODULE,
+       .o_health_check    = mds_health_check,
 };
 
 int mds_mod_init(void)
@@ -539,11 +573,8 @@ int mds_mod_init(void)
                mds_num_threads = mdt_num_threads;
        }
 
-       return class_register_type(&mds_obd_device_ops, NULL, NULL,
-#ifndef HAVE_ONLY_PROCFS_SEQ
-                                       lprocfs_mds_module_vars,
-#endif
-                                       LUSTRE_MDS_NAME, &mds_device_type);
+       return class_register_type(&mds_obd_device_ops, NULL, true, NULL,
+                                  LUSTRE_MDS_NAME, &mds_device_type);
 }
 
 void mds_mod_exit(void)