Whamcloud - gitweb
LU-8066 mgc: migrate away from procfs 50/29250/16
authorJames Simmons <uja.ornl@yahoo.com>
Thu, 12 Apr 2018 02:22:32 +0000 (22:22 -0400)
committerOleg Drokin <oleg.drokin@intel.com>
Wed, 2 May 2018 02:22:31 +0000 (02:22 +0000)
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 <uja.ornl@yahoo.com>
Reviewed-on: https://review.whamcloud.com/29250
Tested-by: Jenkins
Tested-by: Maloo <hpdd-maloo@intel.com>
Reviewed-by: Dmitry Eremin <dmitry.eremin@intel.com>
Reviewed-by: Andreas Dilger <andreas.dilger@intel.com>
lustre/mgc/lproc_mgc.c
lustre/mgc/mgc_internal.h
lustre/mgc/mgc_request.c

index 912c151..b15e8b7 100644 (file)
 
 #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);
+}
index af0bb87..50a13eb 100644 (file)
 #include <lustre_log.h>
 #include <lustre_export.h>
 
-#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);
 
index 135f8f2..6dd4cc1 100644 (file)
@@ -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);
 }