From f2d5622c4cd325a6e0fcca95193ef5cfa5bb3af1 Mon Sep 17 00:00:00 2001 From: James Simmons Date: Wed, 11 Apr 2018 22:22:32 -0400 Subject: [PATCH] LU-8066 mgc: migrate away from procfs Move mgc to using the new sysfs ping and conn_uuid. Move all sysfs/debugfs handling to lprocfs_mgc.c and implement proper error handling. Change-Id: Iecbfac0afedaef9a2b6be33ce026d61008a33136 Signed-off-by: James Simmons Reviewed-on: https://review.whamcloud.com/29250 Tested-by: Jenkins Tested-by: Maloo Reviewed-by: Dmitry Eremin Reviewed-by: Andreas Dilger --- lustre/mgc/lproc_mgc.c | 42 ++++++++++++++++++++++++++++++------------ lustre/mgc/mgc_internal.h | 4 +--- lustre/mgc/mgc_request.c | 20 +++++++++----------- 3 files changed, 40 insertions(+), 26 deletions(-) diff --git a/lustre/mgc/lproc_mgc.c b/lustre/mgc/lproc_mgc.c index 912c151..b15e8b7 100644 --- a/lustre/mgc/lproc_mgc.c +++ b/lustre/mgc/lproc_mgc.c @@ -39,30 +39,26 @@ #ifdef CONFIG_PROC_FS -LPROC_SEQ_FOPS_RO_TYPE(mgc, connect_flags); -LPROC_SEQ_FOPS_RO_TYPE(mgc, server_uuid); -LPROC_SEQ_FOPS_RO_TYPE(mgc, conn_uuid); -LPROC_SEQ_FOPS_RO_TYPE(mgc, import); -LPROC_SEQ_FOPS_RO_TYPE(mgc, state); +LDEBUGFS_SEQ_FOPS_RO_TYPE(mgc, connect_flags); -LPROC_SEQ_FOPS_WR_ONLY(mgc, ping); +LDEBUGFS_SEQ_FOPS_RO_TYPE(mgc, server_uuid); + +LDEBUGFS_SEQ_FOPS_RO_TYPE(mgc, import); + +LDEBUGFS_SEQ_FOPS_RO_TYPE(mgc, state); static int mgc_ir_state_seq_show(struct seq_file *m, void *v) { return lprocfs_mgc_rd_ir_state(m, m->private); } -LPROC_SEQ_FOPS_RO(mgc_ir_state); + +LDEBUGFS_SEQ_FOPS_RO(mgc_ir_state); struct lprocfs_vars lprocfs_mgc_obd_vars[] = { - { .name = "ping", - .fops = &mgc_ping_fops, - .proc_mode = 0222 }, { .name = "connect_flags", .fops = &mgc_connect_flags_fops }, { .name = "mgs_server_uuid", .fops = &mgc_server_uuid_fops }, - { .name = "mgs_conn_uuid", - .fops = &mgc_conn_uuid_fops }, { .name = "import", .fops = &mgc_import_fops }, { .name = "state", @@ -72,3 +68,25 @@ struct lprocfs_vars lprocfs_mgc_obd_vars[] = { { NULL } }; #endif /* CONFIG_PROC_FS */ + +LUSTRE_RO_ATTR(conn_uuid); +LUSTRE_WO_ATTR(ping); + +static struct attribute *mgc_attrs[] = { + &lustre_attr_conn_uuid.attr, + &lustre_attr_ping.attr, + NULL, +}; + +int mgc_tunables_init(struct obd_device *obd) +{ + int rc; + + obd->obd_ktype.default_attrs = mgc_attrs; + obd->obd_vars = lprocfs_mgc_obd_vars; + rc = lprocfs_obd_setup(obd, true); + if (rc) + return rc; + + return sptlrpc_lprocfs_cliobd_attach(obd); +} diff --git a/lustre/mgc/mgc_internal.h b/lustre/mgc/mgc_internal.h index af0bb87..50a13eb 100644 --- a/lustre/mgc/mgc_internal.h +++ b/lustre/mgc/mgc_internal.h @@ -39,10 +39,8 @@ #include #include -#ifdef CONFIG_PROC_FS -extern struct lprocfs_vars lprocfs_mgc_obd_vars[]; +int mgc_tunables_init(struct obd_device *obd); int lprocfs_mgc_rd_ir_state(struct seq_file *m, void *data); -#endif /* CONFIG_PROC_FS */ int mgc_process_log(struct obd_device *mgc, struct config_llog_data *cld); diff --git a/lustre/mgc/mgc_request.c b/lustre/mgc/mgc_request.c index 135f8f2..6dd4cc1 100644 --- a/lustre/mgc/mgc_request.c +++ b/lustre/mgc/mgc_request.c @@ -538,16 +538,15 @@ static int config_log_end(char *logname, struct config_llog_instance *cfg) RETURN(rc); } -#ifdef CONFIG_PROC_FS int lprocfs_mgc_rd_ir_state(struct seq_file *m, void *data) { struct obd_device *obd = data; struct obd_import *imp; struct obd_connect_data *ocd; struct config_llog_data *cld; - ENTRY; - LASSERT(obd != NULL); + ENTRY; + LASSERT(obd); LPROCFS_CLIMP_CHECK(obd); imp = obd->u.cli.cl_import; ocd = &imp->imp_connect_data; @@ -569,7 +568,6 @@ int lprocfs_mgc_rd_ir_state(struct seq_file *m, void *data) LPROCFS_CLIMP_EXIT(obd); RETURN(0); } -#endif /* reenqueue any lost locks */ #define RQ_RUNNING 0x1 @@ -967,11 +965,9 @@ static int mgc_setup(struct obd_device *obd, struct lustre_cfg *lcfg) GOTO(err_cleanup, rc); } -#ifdef CONFIG_PROC_FS - obd->obd_vars = lprocfs_mgc_obd_vars; - lprocfs_obd_setup(obd, true); -#endif - sptlrpc_lprocfs_cliobd_attach(obd); + rc = mgc_tunables_init(obd); + if (rc) + GOTO(err_sysfs, rc); if (atomic_inc_return(&mgc_count) == 1) { rq_state = 0; @@ -984,7 +980,7 @@ static int mgc_setup(struct obd_device *obd, struct lustre_cfg *lcfg) CERROR("%s: cannot start requeue thread: rc = %d; " "no more log updates\n", obd->obd_name, rc); - GOTO(err_cleanup, rc); + GOTO(err_sysfs, rc); } /* rc is the task_struct pointer of mgc_requeue_thread. */ rc = 0; @@ -993,6 +989,8 @@ static int mgc_setup(struct obd_device *obd, struct lustre_cfg *lcfg) RETURN(rc); +err_sysfs: + lprocfs_obd_cleanup(obd); err_cleanup: client_obd_cleanup(obd); err_decref: @@ -2291,7 +2289,7 @@ static struct obd_ops mgc_obd_ops = { static int __init mgc_init(void) { - return class_register_type(&mgc_obd_ops, NULL, true, NULL, + return class_register_type(&mgc_obd_ops, NULL, false, NULL, LUSTRE_MGC_NAME, NULL); } -- 1.8.3.1