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;
};
/*
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;
ptlrpc_unregister_service(m->mds_fld_service);
m->mds_fld_service = NULL;
}
+ mutex_unlock(&m->mds_health_mutex);
+
EXIT;
}
return l;
}
+ mutex_init(&m->mds_health_mutex);
+
rc = mds_start_ptlrpc_service(m);
if (rc != 0) {
.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)
mutex_init(&mgs->mgs_mutex);
mgs->mgs_start_time = cfs_time_current_sec();
spin_lock_init(&mgs->mgs_lock);
+ mutex_init(&mgs->mgs_health_mutex);
rc = lproc_mgs_setup(mgs, lustre_cfg_string(lcfg, 3));
if (rc != 0) {
ping_evictor_stop();
+ mutex_lock(&mgs->mgs_health_mutex);
ptlrpc_unregister_service(mgs->mgs_service);
+ mutex_unlock(&mgs->mgs_health_mutex);
obd_exports_barrier(obd);
obd_zombie_barrier();
RETURN(rc);
}
+static int mgs_health_check(const struct lu_env *env, struct obd_device *obd)
+{
+ struct mgs_device *mgs = lu2mgs_dev(obd->obd_lu_dev);
+ int rc = 0;
+
+ mutex_lock(&mgs->mgs_health_mutex);
+ rc |= ptlrpc_service_health_check(mgs->mgs_service);
+ mutex_unlock(&mgs->mgs_health_mutex);
+
+ return rc != 0 ? 1 : 0;
+}
+
/* use obd ops to offer management infrastructure */
static struct obd_ops mgs_obd_device_ops = {
.o_owner = THIS_MODULE,
.o_init_export = mgs_init_export,
.o_destroy_export = mgs_destroy_export,
.o_iocontrol = mgs_iocontrol,
+ .o_health_check = mgs_health_check,
};
static int __init mgs_init(void)
struct obd_device *mgs_obd;
struct local_oid_storage *mgs_los;
struct mutex mgs_mutex;
+ struct mutex mgs_health_mutex;
struct lu_target mgs_lut;
};
.ldt_ctx_tags = LCT_LOCAL,
};
+static int osd_health_check(const struct lu_env *env, struct obd_device *obd)
+{
+ struct osd_device *osd = osd_dev(obd->obd_lu_dev);
+ struct super_block *sb = osd_sb(osd);
+
+ return (osd->od_mnt == NULL || sb->s_flags & MS_RDONLY);
+}
+
/*
* lprocfs legacy support.
*/
.o_connect = osd_obd_connect,
.o_disconnect = osd_obd_disconnect,
.o_fid_alloc = osd_fid_alloc,
+ .o_health_check = osd_health_check,
};
static int __init osd_mod_init(void)
static int ost_health_check(const struct lu_env *env, struct obd_device *obd)
{
- struct ost_obd *ost = &obd->u.ost;
- int rc = 0;
+ struct ost_obd *ost = &obd->u.ost;
+ int rc = 0;
mutex_lock(&ost->ost_health_mutex);
- rc |= ptlrpc_service_health_check(ost->ost_service);
- rc |= ptlrpc_service_health_check(ost->ost_create_service);
- rc |= ptlrpc_service_health_check(ost->ost_io_service);
+ rc |= ptlrpc_service_health_check(ost->ost_service);
+ rc |= ptlrpc_service_health_check(ost->ost_create_service);
+ rc |= ptlrpc_service_health_check(ost->ost_io_service);
+ rc |= ptlrpc_service_health_check(ost->ost_seq_service);
mutex_unlock(&ost->ost_health_mutex);
- /*
- * health_check to return 0 on healthy
- * and 1 on unhealthy.
- */
- if( rc != 0)
- rc = 1;
-
- return rc;
+ return rc != 0 ? 1 : 0;
}
/* use obd ops to offer management infrastructure */