Whamcloud - gitweb
LU-3319 procfs: move configuration layer proc handling over to seq_file 95/7295/15
authorJames Simmons <uja.ornl@gmail.com>
Mon, 2 Dec 2013 16:36:10 +0000 (11:36 -0500)
committerOleg Drokin <oleg.drokin@intel.com>
Mon, 16 Dec 2013 03:16:44 +0000 (03:16 +0000)
Various Lustre layers have a configuration abstraction for logs
which implements a proc interface. For 3.10+ kernel support we
adapt this proc handling to using seq_files.

Signed-off-by: James Simmons <uja.ornl@gmail.com>
Change-Id: Ie507fd88cdf5193624991f7ab32bdc213a44aebc
Reviewed-on: http://review.whamcloud.com/7295
Reviewed-by: Peng Tao <bergwolf@gmail.com>
Tested-by: Jenkins
Tested-by: Maloo <hpdd-maloo@intel.com>
Reviewed-by: Bob Glossman <bob.glossman@intel.com>
Reviewed-by: Oleg Drokin <oleg.drokin@intel.com>
16 files changed:
lustre/include/obd_class.h
lustre/mdc/lproc_mdc.c
lustre/mdc/mdc_internal.h
lustre/mdc/mdc_request.c
lustre/mgc/lproc_mgc.c
lustre/mgc/mgc_internal.h
lustre/mgc/mgc_request.c
lustre/obdclass/llog_test.c
lustre/obdecho/Makefile.in
lustre/obdecho/autoMakefile.am
lustre/obdecho/echo.c
lustre/obdecho/echo_client.c
lustre/obdecho/lproc_echo.c [deleted file]
lustre/osc/lproc_osc.c
lustre/osc/osc_internal.h
lustre/osc/osc_request.c

index 5c6ff26..7019179 100644 (file)
@@ -159,18 +159,6 @@ int class_config_llog_handler(const struct lu_env *env,
 int class_add_conn(struct obd_device *obd, struct lustre_cfg *lcfg);
 int class_add_uuid(const char *uuid, __u64 nid);
 
 int class_add_conn(struct obd_device *obd, struct lustre_cfg *lcfg);
 int class_add_uuid(const char *uuid, __u64 nid);
 
-/*obdecho*/
-#ifndef HAVE_ONLY_PROCFS_SEQ
-#ifdef LPROCFS
-extern void lprocfs_echo_init_vars(struct lprocfs_static_vars *lvars);
-#else
-static inline void lprocfs_echo_init_vars(struct lprocfs_static_vars *lvars)
-{
-        memset(lvars, 0, sizeof(*lvars));
-}
-#endif
-#endif
-
 #define CFG_F_START     0x01   /* Set when we start updating from a log */
 #define CFG_F_MARKER    0x02   /* We are within a maker */
 #define CFG_F_SKIP      0x04   /* We should ignore this cfg command */
 #define CFG_F_START     0x01   /* Set when we start updating from a log */
 #define CFG_F_MARKER    0x02   /* We are within a maker */
 #define CFG_F_SKIP      0x04   /* We should ignore this cfg command */
index 6d7298f..cba4f61 100644 (file)
 
 #ifdef LPROCFS
 
 
 #ifdef LPROCFS
 
-static int mdc_rd_max_rpcs_in_flight(char *page, char **start, off_t off,
-                                     int count, int *eof, void *data)
+static int mdc_max_rpcs_in_flight_seq_show(struct seq_file *m, void *v)
 {
 {
-        struct obd_device *dev = data;
-        struct client_obd *cli = &dev->u.cli;
-        int rc;
+       struct obd_device *dev = m->private;
+       struct client_obd *cli = &dev->u.cli;
+       int rc;
 
 
-        client_obd_list_lock(&cli->cl_loi_list_lock);
-        rc = snprintf(page, count, "%u\n", cli->cl_max_rpcs_in_flight);
-        client_obd_list_unlock(&cli->cl_loi_list_lock);
-        return rc;
+       client_obd_list_lock(&cli->cl_loi_list_lock);
+       rc = seq_printf(m, "%u\n", cli->cl_max_rpcs_in_flight);
+       client_obd_list_unlock(&cli->cl_loi_list_lock);
+       return rc;
 }
 
 }
 
-static int mdc_wr_max_rpcs_in_flight(struct file *file, const char *buffer,
-                                     unsigned long count, void *data)
+static ssize_t mdc_max_rpcs_in_flight_seq_write(struct file *file,
+                                               const char *buffer,
+                                               size_t count,
+                                               loff_t *off)
 {
 {
-        struct obd_device *dev = data;
+       struct obd_device *dev = ((struct seq_file *)file->private_data)->private;
         struct client_obd *cli = &dev->u.cli;
         int val, rc;
 
         struct client_obd *cli = &dev->u.cli;
         int val, rc;
 
@@ -75,46 +76,56 @@ static int mdc_wr_max_rpcs_in_flight(struct file *file, const char *buffer,
 
         return count;
 }
 
         return count;
 }
+LPROC_SEQ_FOPS(mdc_max_rpcs_in_flight);
 
 
-static struct lprocfs_vars lprocfs_mdc_obd_vars[] = {
-        { "uuid",            lprocfs_rd_uuid,        0, 0 },
-        { "ping",            0, lprocfs_wr_ping,     0, 0, 0222 },
-        { "connect_flags",   lprocfs_rd_connect_flags, 0, 0 },
-        { "blocksize",       lprocfs_rd_blksize,     0, 0 },
-        { "kbytestotal",     lprocfs_rd_kbytestotal, 0, 0 },
-        { "kbytesfree",      lprocfs_rd_kbytesfree,  0, 0 },
-        { "kbytesavail",     lprocfs_rd_kbytesavail, 0, 0 },
-        { "filestotal",      lprocfs_rd_filestotal,  0, 0 },
-        { "filesfree",       lprocfs_rd_filesfree,   0, 0 },
-        /*{ "filegroups",      lprocfs_rd_filegroups,  0, 0 },*/
-        { "mds_server_uuid", lprocfs_rd_server_uuid, 0, 0 },
-        { "mds_conn_uuid",   lprocfs_rd_conn_uuid,   0, 0 },
-        /*
-         * FIXME: below proc entry is provided, but not in used, instead
-         * sbi->sb_md_brw_size is used, the per obd variable should be used
-         * when CMD is enabled, and dir pages are managed in MDC layer.
-         * Remember to enable proc write function.
-         */
-        { "max_pages_per_rpc",  lprocfs_obd_rd_max_pages_per_rpc,
-                                /* lprocfs_obd_wr_max_pages_per_rpc */0, 0 },
-        { "max_rpcs_in_flight", mdc_rd_max_rpcs_in_flight,
-                                mdc_wr_max_rpcs_in_flight, 0 },
-        { "timeouts",        lprocfs_rd_timeouts,    0, 0 },
-        { "import",          lprocfs_rd_import,      lprocfs_wr_import, 0 },
-        { "state",           lprocfs_rd_state,       0, 0 },
-        { "pinger_recov",    lprocfs_rd_pinger_recov,
-                             lprocfs_wr_pinger_recov, 0, 0 },
-        { 0 }
-};
+LPROC_SEQ_FOPS_WO_TYPE(mdc, ping);
 
 
-static struct lprocfs_vars lprocfs_mdc_module_vars[] = {
-        { "num_refs",        lprocfs_rd_numrefs,     0, 0 },
-        { 0 }
-};
+LPROC_SEQ_FOPS_RO_TYPE(mdc, uuid);
+LPROC_SEQ_FOPS_RO_TYPE(mdc, connect_flags);
+LPROC_SEQ_FOPS_RO_TYPE(mdc, blksize);
+LPROC_SEQ_FOPS_RO_TYPE(mdc, kbytestotal);
+LPROC_SEQ_FOPS_RO_TYPE(mdc, kbytesfree);
+LPROC_SEQ_FOPS_RO_TYPE(mdc, kbytesavail);
+LPROC_SEQ_FOPS_RO_TYPE(mdc, filestotal);
+LPROC_SEQ_FOPS_RO_TYPE(mdc, filesfree);
+LPROC_SEQ_FOPS_RO_TYPE(mdc, server_uuid);
+LPROC_SEQ_FOPS_RO_TYPE(mdc, conn_uuid);
+LPROC_SEQ_FOPS_RO_TYPE(mdc, timeouts);
+LPROC_SEQ_FOPS_RO_TYPE(mdc, state);
 
 
-void lprocfs_mdc_init_vars(struct lprocfs_static_vars *lvars)
+static int mdc_obd_max_pages_per_rpc_seq_show(struct seq_file *m, void *v)
 {
 {
-    lvars->module_vars  = lprocfs_mdc_module_vars;
-    lvars->obd_vars     = lprocfs_mdc_obd_vars;
+       return lprocfs_obd_max_pages_per_rpc_seq_show(m, m->private);
 }
 }
+LPROC_SEQ_FOPS_RO(mdc_obd_max_pages_per_rpc);
+
+LPROC_SEQ_FOPS_RW_TYPE(mdc, import);
+LPROC_SEQ_FOPS_RW_TYPE(mdc, pinger_recov);
+
+struct lprocfs_seq_vars lprocfs_mdc_obd_vars[] = {
+       { "uuid",               &mdc_uuid_fops,         0,      0 },
+       { "ping",               &mdc_ping_fops,         0,      0222 },
+       { "connect_flags",      &mdc_connect_flags_fops,0,      0 },
+       { "blocksize",          &mdc_blksize_fops,      0,      0 },
+       { "kbytestotal",        &mdc_kbytestotal_fops,  0,      0 },
+       { "kbytesfree",         &mdc_kbytesfree_fops,   0,      0 },
+       { "kbytesavail",        &mdc_kbytesavail_fops,  0,      0 },
+       { "filestotal",         &mdc_filestotal_fops,   0,      0 },
+       { "filesfree",          &mdc_filesfree_fops,    0,      0 },
+       { "mds_server_uuid",    &mdc_server_uuid_fops,  0,      0 },
+       { "mds_conn_uuid",      &mdc_conn_uuid_fops,    0,      0 },
+       /*
+        * FIXME: below proc entry is provided, but not in used, instead
+        * sbi->sb_md_brw_size is used, the per obd variable should be used
+        * when CMD is enabled, and dir pages are managed in MDC layer.
+        * Remember to enable proc write function.
+        */
+       { "max_pages_per_rpc",  &mdc_obd_max_pages_per_rpc_fops },
+       { "max_rpcs_in_flight", &mdc_max_rpcs_in_flight_fops    },
+       { "timeouts",           &mdc_timeouts_fops              },
+       { "import",             &mdc_import_fops                },
+       { "state",              &mdc_state_fops                 },
+       { "pinger_recov",       &mdc_pinger_recov_fops          },
+       { 0 }
+};
 #endif /* LPROCFS */
 #endif /* LPROCFS */
index adacb30..c87d86f 100644 (file)
 #include <lustre_mds.h>
 
 #ifdef LPROCFS
 #include <lustre_mds.h>
 
 #ifdef LPROCFS
-void lprocfs_mdc_init_vars(struct lprocfs_static_vars *lvars);
-#else
-static inline void lprocfs_mdc_init_vars(struct lprocfs_static_vars *lvars)
-{
-        memset(lvars, 0, sizeof(*lvars));
-}
+extern struct lprocfs_seq_vars lprocfs_mdc_obd_vars[];
 #endif
 
 void mdc_pack_body(struct ptlrpc_request *req, const struct lu_fid *fid,
 #endif
 
 void mdc_pack_body(struct ptlrpc_request *req, const struct lu_fid *fid,
index 850cef6..68c5f27 100644 (file)
@@ -2475,7 +2475,6 @@ struct ldlm_valblock_ops inode_lvbo = {
 static int mdc_setup(struct obd_device *obd, struct lustre_cfg *cfg)
 {
        struct client_obd               *cli = &obd->u.cli;
 static int mdc_setup(struct obd_device *obd, struct lustre_cfg *cfg)
 {
        struct client_obd               *cli = &obd->u.cli;
-       struct lprocfs_static_vars      lvars = { 0 };
        int                             rc;
        ENTRY;
 
        int                             rc;
        ENTRY;
 
@@ -2496,11 +2495,13 @@ static int mdc_setup(struct obd_device *obd, struct lustre_cfg *cfg)
         rc = client_obd_setup(obd, cfg);
         if (rc)
                 GOTO(err_close_lock, rc);
         rc = client_obd_setup(obd, cfg);
         if (rc)
                 GOTO(err_close_lock, rc);
-        lprocfs_mdc_init_vars(&lvars);
-        lprocfs_obd_setup(obd, lvars.obd_vars);
+#ifdef LPROCFS
+       obd->obd_vars = lprocfs_mdc_obd_vars;
+       lprocfs_seq_obd_setup(obd);
        lprocfs_alloc_md_stats(obd, 0);
        lprocfs_alloc_md_stats(obd, 0);
-        sptlrpc_lprocfs_cliobd_attach(obd);
-        ptlrpc_lprocfs_register_obd(obd);
+#endif
+       sptlrpc_lprocfs_cliobd_attach(obd);
+       ptlrpc_lprocfs_register_obd(obd);
 
         ns_register_cancel(obd->obd_namespace, mdc_cancel_for_recovery);
 
 
         ns_register_cancel(obd->obd_namespace, mdc_cancel_for_recovery);
 
@@ -2623,19 +2624,9 @@ static int mdc_llog_finish(struct obd_device *obd, int count)
 static int mdc_process_config(struct obd_device *obd, obd_count len, void *buf)
 {
         struct lustre_cfg *lcfg = buf;
 static int mdc_process_config(struct obd_device *obd, obd_count len, void *buf)
 {
         struct lustre_cfg *lcfg = buf;
-        struct lprocfs_static_vars lvars = { 0 };
-        int rc = 0;
-
-        lprocfs_mdc_init_vars(&lvars);
-        switch (lcfg->lcfg_command) {
-        default:
-                rc = class_process_proc_param(PARAM_MDC, lvars.obd_vars,
-                                              lcfg, obd);
-                if (rc > 0)
-                        rc = 0;
-                break;
-        }
-        return(rc);
+       int rc = class_process_proc_seq_param(PARAM_MDC, obd->obd_vars,
+                                             lcfg, obd);
+       return (rc > 0 ? 0: rc);
 }
 
 
 }
 
 
@@ -2797,12 +2788,9 @@ struct md_ops mdc_md_ops = {
 
 int __init mdc_init(void)
 {
 
 int __init mdc_init(void)
 {
-        struct lprocfs_static_vars lvars = { 0 };
-        lprocfs_mdc_init_vars(&lvars);
-
        return class_register_type(&mdc_obd_ops, &mdc_md_ops, NULL,
 #ifndef HAVE_ONLY_PROCFS_SEQ
        return class_register_type(&mdc_obd_ops, &mdc_md_ops, NULL,
 #ifndef HAVE_ONLY_PROCFS_SEQ
-                                       lvars.module_vars,
+                                       NULL,
 #endif
                                        LUSTRE_MDC_NAME, NULL);
 }
 #endif
                                        LUSTRE_MDC_NAME, NULL);
 }
index d5b6cff..648b6e5 100644 (file)
 
 #ifdef LPROCFS
 
 
 #ifdef LPROCFS
 
-static struct lprocfs_vars lprocfs_mgc_obd_vars[] = {
-        { "uuid",            lprocfs_rd_uuid,          0, 0 },
-        { "ping",            0, lprocfs_wr_ping,       0, 0, 0222 },
-        { "connect_flags",   lprocfs_rd_connect_flags, 0, 0 },
-        { "mgs_server_uuid", lprocfs_rd_server_uuid,   0, 0 },
-        { "mgs_conn_uuid",   lprocfs_rd_conn_uuid,     0, 0 },
-        { "import",          lprocfs_rd_import,        0, 0 },
-        { "state",           lprocfs_rd_state,         0, 0 },
-        { "ir_state",        lprocfs_mgc_rd_ir_state,  0, 0 },
-        { 0 }
-};
+LPROC_SEQ_FOPS_RO_TYPE(mgc, uuid);
+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);
 
 
-static struct lprocfs_vars lprocfs_mgc_module_vars[] = {
-        { "num_refs",        lprocfs_rd_numrefs,       0, 0 },
-        { 0 }
-};
+LPROC_SEQ_FOPS_WO_TYPE(mgc, ping);
 
 
-void lprocfs_mgc_init_vars(struct lprocfs_static_vars *lvars)
+static int mgc_ir_state_seq_show(struct seq_file *m, void *v)
 {
 {
-        lvars->module_vars = lprocfs_mgc_module_vars;
-        lvars->obd_vars    = lprocfs_mgc_obd_vars;
+       return lprocfs_mgc_rd_ir_state(m, m->private);
 }
 }
+LPROC_SEQ_FOPS_RO(mgc_ir_state);
+
+struct lprocfs_seq_vars lprocfs_mgc_obd_vars[] = {
+       { "uuid",               &mgc_uuid_fops,         0,      0 },
+       { "ping",               &mgc_ping_fops,         0,      0222 },
+       { "connect_flags",      &mgc_connect_flags_fops,0,      0 },
+       { "mgs_server_uuid",    &mgc_server_uuid_fops,  0,      0 },
+       { "mgs_conn_uuid",      &mgc_conn_uuid_fops,    0,      0 },
+       { "import",             &mgc_import_fops,       0,      0 },
+       { "state",              &mgc_state_fops,        0,      0 },
+       { "ir_state",           &mgc_ir_state_fops,     0,      0 },
+       { 0 }
+};
 #endif /* LPROCFS */
 #endif /* LPROCFS */
index a5f95b5..292a212 100644 (file)
 #include <lustre_export.h>
 
 #ifdef LPROCFS
 #include <lustre_export.h>
 
 #ifdef LPROCFS
-void lprocfs_mgc_init_vars(struct lprocfs_static_vars *lvars);
-int lprocfs_mgc_rd_ir_state(char *page, char **start, off_t off,
-                            int count, int *eof, void *data);
-#else
-static void lprocfs_mgc_init_vars(struct lprocfs_static_vars *lvars)
-{
-        memset(lvars, 0, sizeof(*lvars));
-}
-static inline int lprocfs_mgc_rd_ir_state(char *page, char **start,
-        off_t off, int count, int *eof, void *data)
-{
-        return 0;
-}
+extern struct lprocfs_seq_vars lprocfs_mgc_obd_vars[];
+int lprocfs_mgc_rd_ir_state(struct seq_file *m, void *data);
 #endif  /* LPROCFS */
 
 int mgc_process_log(struct obd_device *mgc, struct config_llog_data *cld);
 #endif  /* LPROCFS */
 
 int mgc_process_log(struct obd_device *mgc, struct config_llog_data *cld);
index a8a8f76..9b2f6a9 100644 (file)
@@ -462,33 +462,32 @@ static int config_log_end(char *logname, struct config_llog_instance *cfg)
         RETURN(rc);
 }
 
         RETURN(rc);
 }
 
-int lprocfs_mgc_rd_ir_state(char *page, char **start, off_t off,
-                            int count, int *eof, void *data)
+#ifdef LPROCFS
+int lprocfs_mgc_rd_ir_state(struct seq_file *m, void *data)
 {
         struct obd_device       *obd = data;
         struct obd_import       *imp = obd->u.cli.cl_import;
         struct obd_connect_data *ocd = &imp->imp_connect_data;
         struct config_llog_data *cld;
 {
         struct obd_device       *obd = data;
         struct obd_import       *imp = obd->u.cli.cl_import;
         struct obd_connect_data *ocd = &imp->imp_connect_data;
         struct config_llog_data *cld;
-        int rc = 0;
         ENTRY;
 
         ENTRY;
 
-        rc = snprintf(page, count, "imperative_recovery: %s\n",
-                     OCD_HAS_FLAG(ocd, IMP_RECOV) ? "ENABLED" : "DISABLED");
-        rc += snprintf(page + rc, count - rc, "client_state:\n");
+       seq_printf(m, "imperative_recovery: %s\n",
+                  OCD_HAS_FLAG(ocd, IMP_RECOV) ? "ENABLED" : "DISABLED");
+       seq_printf(m, "client_state:\n");
 
        spin_lock(&config_list_lock);
        cfs_list_for_each_entry(cld, &config_llog_list, cld_list_chain) {
                if (cld->cld_recover == NULL)
                        continue;
 
        spin_lock(&config_list_lock);
        cfs_list_for_each_entry(cld, &config_llog_list, cld_list_chain) {
                if (cld->cld_recover == NULL)
                        continue;
-               rc += snprintf(page + rc, count - rc,
-                              "    - { client: %s, nidtbl_version: %u }\n",
+               seq_printf(m,  "    - { client: %s, nidtbl_version: %u }\n",
                               cld->cld_logname,
                               cld->cld_recover->cld_cfg.cfg_last_idx);
        }
        spin_unlock(&config_list_lock);
 
                               cld->cld_logname,
                               cld->cld_recover->cld_cfg.cfg_last_idx);
        }
        spin_unlock(&config_list_lock);
 
-       RETURN(rc);
+       RETURN(0);
 }
 }
+#endif
 
 /* reenqueue any lost locks */
 #define RQ_RUNNING 0x1
 
 /* reenqueue any lost locks */
 #define RQ_RUNNING 0x1
@@ -891,7 +890,6 @@ static int mgc_cleanup(struct obd_device *obd)
 
 static int mgc_setup(struct obd_device *obd, struct lustre_cfg *lcfg)
 {
 
 static int mgc_setup(struct obd_device *obd, struct lustre_cfg *lcfg)
 {
-       struct lprocfs_static_vars      lvars;
        int                             rc;
        ENTRY;
 
        int                             rc;
        ENTRY;
 
@@ -909,8 +907,10 @@ static int mgc_setup(struct obd_device *obd, struct lustre_cfg *lcfg)
                GOTO(err_cleanup, rc);
        }
 
                GOTO(err_cleanup, rc);
        }
 
-       lprocfs_mgc_init_vars(&lvars);
-       lprocfs_obd_setup(obd, lvars.obd_vars);
+#ifdef LPROCFS
+       obd->obd_vars = lprocfs_mgc_obd_vars;
+       lprocfs_seq_obd_setup(obd);
+#endif
        sptlrpc_lprocfs_cliobd_attach(obd);
 
        if (cfs_atomic_inc_return(&mgc_count) == 1) {
        sptlrpc_lprocfs_cliobd_attach(obd);
 
        if (cfs_atomic_inc_return(&mgc_count) == 1) {
index 7402d9d..e0362ab 100644 (file)
@@ -954,16 +954,6 @@ cleanup_ctxt:
        return rc;
 }
 
        return rc;
 }
 
-#ifdef LPROCFS
-static struct lprocfs_vars lprocfs_llog_test_obd_vars[] = { {0} };
-static struct lprocfs_vars lprocfs_llog_test_module_vars[] = { {0} };
-static void lprocfs_llog_test_init_vars(struct lprocfs_static_vars *lvars)
-{
-    lvars->module_vars  = lprocfs_llog_test_module_vars;
-    lvars->obd_vars     = lprocfs_llog_test_obd_vars;
-}
-#endif
-
 static int llog_test_cleanup(struct obd_device *obd)
 {
        struct obd_device       *tgt;
 static int llog_test_cleanup(struct obd_device *obd)
 {
        struct obd_device       *tgt;
@@ -1067,12 +1057,9 @@ static struct obd_ops llog_obd_ops = {
 
 static int __init llog_test_init(void)
 {
 
 static int __init llog_test_init(void)
 {
-       struct lprocfs_static_vars lvars;
-
-       lprocfs_llog_test_init_vars(&lvars);
        return class_register_type(&llog_obd_ops, NULL, NULL,
 #ifndef HAVE_ONLY_PROCFS_SEQ
        return class_register_type(&llog_obd_ops, NULL, NULL,
 #ifndef HAVE_ONLY_PROCFS_SEQ
-                                       lvars.module_vars,
+                                       NULL,
 #endif
                                        "llog_test", NULL);
 }
 #endif
                                        "llog_test", NULL);
 }
index dcf9368..0c5fb86 100644 (file)
@@ -1,5 +1,5 @@
 MODULES := obdecho
 MODULES := obdecho
-obdecho-objs := echo_client.o lproc_echo.o
+obdecho-objs := echo_client.o
 @SERVER_TRUE@obdecho-objs += echo.o
 
 EXTRA_DIST = $(obdecho-objs:%.o=%.c) echo_internal.h
 @SERVER_TRUE@obdecho-objs += echo.o
 
 EXTRA_DIST = $(obdecho-objs:%.o=%.c) echo_internal.h
index d4d007f..1beff82 100644 (file)
@@ -51,7 +51,6 @@ endif
 if DARWIN
 macos_PROGRAMS = obdecho
 obdecho_SOURCES =      \
 if DARWIN
 macos_PROGRAMS = obdecho
 obdecho_SOURCES =      \
-       lproc_echo.c    \
        echo_client.c
 
 if SERVER
        echo_client.c
 
 if SERVER
index f6bb399..ee854f1 100644 (file)
@@ -559,14 +559,19 @@ commitrw_cleanup:
         return rc;
 }
 
         return rc;
 }
 
+LPROC_SEQ_FOPS_RO_TYPE(echo, uuid);
+static struct lprocfs_seq_vars lprocfs_echo_obd_vars[] = {
+       { "uuid",       &echo_uuid_fops         },
+       { 0 }
+};
+
 static int echo_setup(struct obd_device *obd, struct lustre_cfg *lcfg)
 {
 static int echo_setup(struct obd_device *obd, struct lustre_cfg *lcfg)
 {
-        struct lprocfs_static_vars lvars;
-        int                        rc;
-       __u64                      lock_flags = 0;
-        struct ldlm_res_id         res_id = {.name = {1}};
-        char                       ns_name[48];
-        ENTRY;
+       int                     rc;
+       __u64                   lock_flags = 0;
+       struct ldlm_res_id      res_id = {.name = {1}};
+       char                    ns_name[48];
+       ENTRY;
 
         obd->u.echo.eo_obt.obt_magic = OBT_MAGIC;
        spin_lock_init(&obd->u.echo.eo_lock);
 
         obd->u.echo.eo_obt.obt_magic = OBT_MAGIC;
        spin_lock_init(&obd->u.echo.eo_lock);
@@ -588,8 +593,8 @@ static int echo_setup(struct obd_device *obd, struct lustre_cfg *lcfg)
                                    LVB_T_NONE, NULL, &obd->u.echo.eo_nl_lock);
         LASSERT (rc == ELDLM_OK);
 
                                    LVB_T_NONE, NULL, &obd->u.echo.eo_nl_lock);
         LASSERT (rc == ELDLM_OK);
 
-        lprocfs_echo_init_vars(&lvars);
-        if (lprocfs_obd_setup(obd, lvars.obd_vars) == 0 &&
+       obd->obd_vars = lprocfs_echo_obd_vars;
+       if (lprocfs_seq_obd_setup(obd) == 0 &&
             lprocfs_alloc_obd_stats(obd, LPROC_ECHO_LAST) == 0) {
                 lprocfs_counter_init(obd->obd_stats, LPROC_ECHO_READ_BYTES,
                                      LPROCFS_CNTR_AVGMINMAX,
             lprocfs_alloc_obd_stats(obd, LPROC_ECHO_LAST) == 0) {
                 lprocfs_counter_init(obd->obd_stats, LPROC_ECHO_READ_BYTES,
                                      LPROCFS_CNTR_AVGMINMAX,
index 06ed2d5..4bea4aa 100644 (file)
@@ -3165,16 +3165,13 @@ static struct obd_ops echo_client_obd_ops = {
 
 int echo_client_init(void)
 {
 
 int echo_client_init(void)
 {
-        struct lprocfs_static_vars lvars = { 0 };
         int rc;
 
         int rc;
 
-        lprocfs_echo_init_vars(&lvars);
-
        rc = lu_kmem_init(echo_caches);
        if (rc == 0) {
                rc = class_register_type(&echo_client_obd_ops, NULL, NULL,
 #ifndef HAVE_ONLY_PROCFS_SEQ
        rc = lu_kmem_init(echo_caches);
        if (rc == 0) {
                rc = class_register_type(&echo_client_obd_ops, NULL, NULL,
 #ifndef HAVE_ONLY_PROCFS_SEQ
-                                       lvars.module_vars,
+                                       NULL,
 #endif
                                        LUSTRE_ECHO_CLIENT_NAME,
                                        &echo_device_type);
 #endif
                                        LUSTRE_ECHO_CLIENT_NAME,
                                        &echo_device_type);
@@ -3193,7 +3190,6 @@ void echo_client_exit(void)
 #ifdef __KERNEL__
 static int __init obdecho_init(void)
 {
 #ifdef __KERNEL__
 static int __init obdecho_init(void)
 {
-        struct lprocfs_static_vars lvars;
         int rc;
 
         ENTRY;
         int rc;
 
         ENTRY;
@@ -3201,8 +3197,6 @@ static int __init obdecho_init(void)
 
        LASSERT(PAGE_CACHE_SIZE % OBD_ECHO_BLOCK_SIZE == 0);
 
 
        LASSERT(PAGE_CACHE_SIZE % OBD_ECHO_BLOCK_SIZE == 0);
 
-        lprocfs_echo_init_vars(&lvars);
-
 # ifdef HAVE_SERVER_SUPPORT
         rc = echo_persistent_pages_init();
         if (rc != 0)
 # ifdef HAVE_SERVER_SUPPORT
         rc = echo_persistent_pages_init();
         if (rc != 0)
@@ -3210,7 +3204,7 @@ static int __init obdecho_init(void)
 
        rc = class_register_type(&echo_obd_ops, NULL, NULL,
 #ifndef HAVE_ONLY_PROCFS_SEQ
 
        rc = class_register_type(&echo_obd_ops, NULL, NULL,
 #ifndef HAVE_ONLY_PROCFS_SEQ
-                               lvars.module_vars,
+                               NULL,
 #endif
                                LUSTRE_ECHO_NAME, NULL);
        if (rc != 0)
 #endif
                                LUSTRE_ECHO_NAME, NULL);
        if (rc != 0)
diff --git a/lustre/obdecho/lproc_echo.c b/lustre/obdecho/lproc_echo.c
deleted file mode 100644 (file)
index 3092790..0000000
+++ /dev/null
@@ -1,55 +0,0 @@
-/*
- * GPL HEADER START
- *
- * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License version 2 only,
- * as published by the Free Software Foundation.
- *
- * This program is distributed in the hope that it will be useful, but
- * WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
- * General Public License version 2 for more details (a copy is included
- * in the LICENSE file that accompanied this code).
- *
- * You should have received a copy of the GNU General Public License
- * version 2 along with this program; If not, see
- * http://www.sun.com/software/products/lustre/docs/GPLv2.pdf
- *
- * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
- * CA 95054 USA or visit www.sun.com if you need additional information or
- * have any questions.
- *
- * GPL HEADER END
- */
-/*
- * Copyright (c) 2002, 2010, Oracle and/or its affiliates. All rights reserved.
- * Use is subject to license terms.
- */
-/*
- * This file is part of Lustre, http://www.lustre.org/
- * Lustre is a trademark of Sun Microsystems, Inc.
- */
-#define DEBUG_SUBSYSTEM S_ECHO
-
-#include <lprocfs_status.h>
-#include <obd_class.h>
-
-#ifdef LPROCFS
-static struct lprocfs_vars lprocfs_echo_obd_vars[] = {
-        { "uuid",         lprocfs_rd_uuid,        0, 0 },
-        { 0 }
-};
-
-static struct lprocfs_vars lprocfs_echo_module_vars[] = {
-        { "num_refs",     lprocfs_rd_numrefs,     0, 0 },
-        { 0 }
-};
-
-void lprocfs_echo_init_vars(struct lprocfs_static_vars *lvars)
-{
-    lvars->module_vars  = lprocfs_echo_module_vars;
-    lvars->obd_vars     = lprocfs_echo_obd_vars;
-}
-#endif /* LPROCFS */
index 428e51f..06bd4c9 100644 (file)
 #include "osc_internal.h"
 
 #ifdef LPROCFS
 #include "osc_internal.h"
 
 #ifdef LPROCFS
-static int osc_rd_active(char *page, char **start, off_t off,
-                         int count, int *eof, void *data)
+static int osc_active_seq_show(struct seq_file *m, void *v)
 {
 {
-        struct obd_device *dev = data;
-        int rc;
+       struct obd_device *dev = m->private;
+       int rc;
 
 
-        LPROCFS_CLIMP_CHECK(dev);
-        rc = snprintf(page, count, "%d\n", !dev->u.cli.cl_import->imp_deactive);
-        LPROCFS_CLIMP_EXIT(dev);
-        return rc;
+       LPROCFS_CLIMP_CHECK(dev);
+       rc = seq_printf(m, "%d\n", !dev->u.cli.cl_import->imp_deactive);
+       LPROCFS_CLIMP_EXIT(dev);
+       return rc;
 }
 
 }
 
-static int osc_wr_active(struct file *file, const char *buffer,
-                         unsigned long count, void *data)
+static ssize_t osc_active_seq_write(struct file *file, const char *buffer,
+                                   size_t count, loff_t *off)
 {
 {
-        struct obd_device *dev = data;
-        int val, rc;
+       struct obd_device *dev = ((struct seq_file *)file->private_data)->private;
+       int val, rc;
 
         rc = lprocfs_write_helper(buffer, count, &val);
         if (rc)
 
         rc = lprocfs_write_helper(buffer, count, &val);
         if (rc)
@@ -76,24 +75,25 @@ static int osc_wr_active(struct file *file, const char *buffer,
 
         return count;
 }
 
         return count;
 }
+LPROC_SEQ_FOPS(osc_active);
 
 
-static int osc_rd_max_rpcs_in_flight(char *page, char **start, off_t off,
-                                     int count, int *eof, void *data)
+static int osc_max_rpcs_in_flight_seq_show(struct seq_file *m, void *v)
 {
 {
-        struct obd_device *dev = data;
-        struct client_obd *cli = &dev->u.cli;
-        int rc;
+       struct obd_device *dev = m->private;
+       struct client_obd *cli = &dev->u.cli;
+       int rc;
 
 
-        client_obd_list_lock(&cli->cl_loi_list_lock);
-        rc = snprintf(page, count, "%u\n", cli->cl_max_rpcs_in_flight);
-        client_obd_list_unlock(&cli->cl_loi_list_lock);
-        return rc;
+       client_obd_list_lock(&cli->cl_loi_list_lock);
+       rc = seq_printf(m, "%u\n", cli->cl_max_rpcs_in_flight);
+       client_obd_list_unlock(&cli->cl_loi_list_lock);
+       return rc;
 }
 
 }
 
-static int osc_wr_max_rpcs_in_flight(struct file *file, const char *buffer,
-                                     unsigned long count, void *data)
+static ssize_t osc_max_rpcs_in_flight_seq_write(struct file *file,
+                                               const char *buffer,
+                                               size_t count, loff_t *off)
 {
 {
-        struct obd_device *dev = data;
+       struct obd_device *dev = ((struct seq_file *)file->private_data)->private;
         struct client_obd *cli = &dev->u.cli;
         struct ptlrpc_request_pool *pool = cli->cl_import->imp_rq_pool;
         int val, rc;
         struct client_obd *cli = &dev->u.cli;
         struct ptlrpc_request_pool *pool = cli->cl_import->imp_rq_pool;
         int val, rc;
@@ -116,11 +116,11 @@ static int osc_wr_max_rpcs_in_flight(struct file *file, const char *buffer,
         LPROCFS_CLIMP_EXIT(dev);
         return count;
 }
         LPROCFS_CLIMP_EXIT(dev);
         return count;
 }
+LPROC_SEQ_FOPS(osc_max_rpcs_in_flight);
 
 
-static int osc_rd_max_dirty_mb(char *page, char **start, off_t off, int count,
-                               int *eof, void *data)
+static int osc_max_dirty_mb_seq_show(struct seq_file *m, void *v)
 {
 {
-        struct obd_device *dev = data;
+       struct obd_device *dev = m->private;
         struct client_obd *cli = &dev->u.cli;
         long val;
         int mult;
         struct client_obd *cli = &dev->u.cli;
         long val;
         int mult;
@@ -129,14 +129,14 @@ static int osc_rd_max_dirty_mb(char *page, char **start, off_t off, int count,
         val = cli->cl_dirty_max;
         client_obd_list_unlock(&cli->cl_loi_list_lock);
 
         val = cli->cl_dirty_max;
         client_obd_list_unlock(&cli->cl_loi_list_lock);
 
-        mult = 1 << 20;
-        return lprocfs_read_frac_helper(page, count, val, mult);
+       mult = 1 << 20;
+       return lprocfs_seq_read_frac_helper(m, val, mult);
 }
 
 }
 
-static int osc_wr_max_dirty_mb(struct file *file, const char *buffer,
-                              unsigned long count, void *data)
+static ssize_t osc_max_dirty_mb_seq_write(struct file *file, const char *buffer,
+                                         size_t count, loff_t *off)
 {
 {
-       struct obd_device *dev = data;
+       struct obd_device *dev = ((struct seq_file *)file->private_data)->private;
        struct client_obd *cli = &dev->u.cli;
        int pages_number, mult, rc;
 
        struct client_obd *cli = &dev->u.cli;
        int pages_number, mult, rc;
 
@@ -157,16 +157,16 @@ static int osc_wr_max_dirty_mb(struct file *file, const char *buffer,
 
        return count;
 }
 
        return count;
 }
+LPROC_SEQ_FOPS(osc_max_dirty_mb);
 
 
-static int osc_rd_cached_mb(char *page, char **start, off_t off, int count,
-                           int *eof, void *data)
+static int osc_cached_mb_seq_show(struct seq_file *m, void *v)
 {
 {
-       struct obd_device *dev = data;
+       struct obd_device *dev = m->private;
        struct client_obd *cli = &dev->u.cli;
        int shift = 20 - PAGE_CACHE_SHIFT;
        int rc;
 
        struct client_obd *cli = &dev->u.cli;
        int shift = 20 - PAGE_CACHE_SHIFT;
        int rc;
 
-       rc = snprintf(page, count,
+       rc = seq_printf(m,
                      "used_mb: %d\n"
                      "busy_cnt: %d\n",
                      (cfs_atomic_read(&cli->cl_lru_in_list) +
                      "used_mb: %d\n"
                      "busy_cnt: %d\n",
                      (cfs_atomic_read(&cli->cl_lru_in_list) +
@@ -177,13 +177,13 @@ static int osc_rd_cached_mb(char *page, char **start, off_t off, int count,
 }
 
 /* shrink the number of caching pages to a specific number */
 }
 
 /* shrink the number of caching pages to a specific number */
-static int osc_wr_cached_mb(struct file *file, const char *buffer,
-                           unsigned long nob, void *data)
+static ssize_t
+osc_cached_mb_seq_write(struct file *file, const char *buffer,
+                       size_t count, loff_t *off)
 {
 {
-       struct obd_device *dev = data;
+       struct obd_device *dev = ((struct seq_file *)file->private_data)->private;
        struct client_obd *cli = &dev->u.cli;
        int pages_number, mult, rc;
        struct client_obd *cli = &dev->u.cli;
        int pages_number, mult, rc;
-       size_t count = nob;
 
        mult = 1 << (20 - PAGE_CACHE_SHIFT);
        buffer = lprocfs_find_named_value(buffer, "used_mb:", &count);
 
        mult = 1 << (20 - PAGE_CACHE_SHIFT);
        buffer = lprocfs_find_named_value(buffer, "used_mb:", &count);
@@ -208,37 +208,37 @@ static int osc_wr_cached_mb(struct file *file, const char *buffer,
 
        return count;
 }
 
        return count;
 }
+LPROC_SEQ_FOPS(osc_cached_mb);
 
 
-static int osc_rd_cur_dirty_bytes(char *page, char **start, off_t off,
-                                  int count, int *eof, void *data)
+static int osc_cur_dirty_bytes_seq_show(struct seq_file *m, void *v)
 {
 {
-        struct obd_device *dev = data;
-        struct client_obd *cli = &dev->u.cli;
-        int rc;
+       struct obd_device *dev = m->private;
+       struct client_obd *cli = &dev->u.cli;
+       int rc;
 
 
-        client_obd_list_lock(&cli->cl_loi_list_lock);
-        rc = snprintf(page, count, "%lu\n", cli->cl_dirty);
-        client_obd_list_unlock(&cli->cl_loi_list_lock);
-        return rc;
+       client_obd_list_lock(&cli->cl_loi_list_lock);
+       rc = seq_printf(m, "%lu\n", cli->cl_dirty);
+       client_obd_list_unlock(&cli->cl_loi_list_lock);
+       return rc;
 }
 }
+LPROC_SEQ_FOPS_RO(osc_cur_dirty_bytes);
 
 
-static int osc_rd_cur_grant_bytes(char *page, char **start, off_t off,
-                                  int count, int *eof, void *data)
+static int osc_cur_grant_bytes_seq_show(struct seq_file *m, void *v)
 {
 {
-        struct obd_device *dev = data;
-        struct client_obd *cli = &dev->u.cli;
-        int rc;
+       struct obd_device *dev = m->private;
+       struct client_obd *cli = &dev->u.cli;
+       int rc;
 
 
-        client_obd_list_lock(&cli->cl_loi_list_lock);
-        rc = snprintf(page, count, "%lu\n", cli->cl_avail_grant);
-        client_obd_list_unlock(&cli->cl_loi_list_lock);
-        return rc;
+       client_obd_list_lock(&cli->cl_loi_list_lock);
+       rc = seq_printf(m, "%lu\n", cli->cl_avail_grant);
+       client_obd_list_unlock(&cli->cl_loi_list_lock);
+       return rc;
 }
 
 }
 
-static int osc_wr_cur_grant_bytes(struct file *file, const char *buffer,
-                                  unsigned long count, void *data)
+static ssize_t osc_cur_grant_bytes_seq_write(struct file *file, const char *buffer,
+                                            size_t count, loff_t *off)
 {
 {
-        struct obd_device *obd = data;
+       struct obd_device *obd = ((struct seq_file *)file->private_data)->private;
         struct client_obd *cli = &obd->u.cli;
         int                rc;
         __u64              val;
         struct client_obd *cli = &obd->u.cli;
         int                rc;
         __u64              val;
@@ -266,39 +266,40 @@ static int osc_wr_cur_grant_bytes(struct file *file, const char *buffer,
                 return rc;
         return count;
 }
                 return rc;
         return count;
 }
+LPROC_SEQ_FOPS(osc_cur_grant_bytes);
 
 
-static int osc_rd_cur_lost_grant_bytes(char *page, char **start, off_t off,
-                                       int count, int *eof, void *data)
+static int osc_cur_lost_grant_bytes_seq_show(struct seq_file *m, void *v)
 {
 {
-        struct obd_device *dev = data;
-        struct client_obd *cli = &dev->u.cli;
-        int rc;
+       struct obd_device *dev = m->private;
+       struct client_obd *cli = &dev->u.cli;
+       int rc;
 
 
-        client_obd_list_lock(&cli->cl_loi_list_lock);
-        rc = snprintf(page, count, "%lu\n", cli->cl_lost_grant);
-        client_obd_list_unlock(&cli->cl_loi_list_lock);
-        return rc;
+       client_obd_list_lock(&cli->cl_loi_list_lock);
+       rc = seq_printf(m, "%lu\n", cli->cl_lost_grant);
+       client_obd_list_unlock(&cli->cl_loi_list_lock);
+       return rc;
 }
 }
+LPROC_SEQ_FOPS_RO(osc_cur_lost_grant_bytes);
 
 
-static int osc_rd_grant_shrink_interval(char *page, char **start, off_t off,
-                                        int count, int *eof, void *data)
+static int osc_grant_shrink_interval_seq_show(struct seq_file *m, void *v)
 {
 {
-        struct obd_device *obd = data;
+       struct obd_device *obd = m->private;
 
 
-        if (obd == NULL)
-                return 0;
-        return snprintf(page, count, "%d\n",
-                        obd->u.cli.cl_grant_shrink_interval);
+       if (obd == NULL)
+               return 0;
+       return seq_printf(m, "%d\n",
+                         obd->u.cli.cl_grant_shrink_interval);
 }
 
 }
 
-static int osc_wr_grant_shrink_interval(struct file *file, const char *buffer,
-                                        unsigned long count, void *data)
+static ssize_t osc_grant_shrink_interval_seq_write(struct file *file,
+                                                  const char *buffer,
+                                                  size_t count, loff_t *off)
 {
 {
-        struct obd_device *obd = data;
-        int val, rc;
+       struct obd_device *obd = ((struct seq_file *)file->private_data)->private;
+       int val, rc;
 
 
-        if (obd == NULL)
-                return 0;
+       if (obd == NULL)
+               return 0;
 
         rc = lprocfs_write_helper(buffer, count, &val);
         if (rc)
 
         rc = lprocfs_write_helper(buffer, count, &val);
         if (rc)
@@ -311,24 +312,24 @@ static int osc_wr_grant_shrink_interval(struct file *file, const char *buffer,
 
         return count;
 }
 
         return count;
 }
+LPROC_SEQ_FOPS(osc_grant_shrink_interval);
 
 
-static int osc_rd_checksum(char *page, char **start, off_t off, int count,
-                           int *eof, void *data)
+static int osc_checksum_seq_show(struct seq_file *m, void *v)
 {
 {
-        struct obd_device *obd = data;
+       struct obd_device *obd = m->private;
 
 
-        if (obd == NULL)
-                return 0;
+       if (obd == NULL)
+               return 0;
 
 
-        return snprintf(page, count, "%d\n",
-                        obd->u.cli.cl_checksum ? 1 : 0);
+       return seq_printf(m, "%d\n",
+                         obd->u.cli.cl_checksum ? 1 : 0);
 }
 
 }
 
-static int osc_wr_checksum(struct file *file, const char *buffer,
-                           unsigned long count, void *data)
+static ssize_t osc_checksum_seq_write(struct file *file, const char *buffer,
+                                     size_t count, loff_t *off)
 {
 {
-        struct obd_device *obd = data;
-        int val, rc;
+       struct obd_device *obd = ((struct seq_file *)file->private_data)->private;
+       int val, rc;
 
         if (obd == NULL)
                 return 0;
 
         if (obd == NULL)
                 return 0;
@@ -341,39 +342,36 @@ static int osc_wr_checksum(struct file *file, const char *buffer,
 
         return count;
 }
 
         return count;
 }
+LPROC_SEQ_FOPS(osc_checksum);
 
 
-static int osc_rd_checksum_type(char *page, char **start, off_t off, int count,
-                                int *eof, void *data)
+static int osc_checksum_type_seq_show(struct seq_file *m, void *v)
 {
 {
-        struct obd_device *obd = data;
-        int i, len =0;
-        DECLARE_CKSUM_NAME;
+       struct obd_device *obd = m->private;
+       int i;
+       DECLARE_CKSUM_NAME;
 
         if (obd == NULL)
                 return 0;
 
 
         if (obd == NULL)
                 return 0;
 
-        for (i = 0; i < ARRAY_SIZE(cksum_name) && len < count; i++) {
-                if (((1 << i) & obd->u.cli.cl_supp_cksum_types) == 0)
-                        continue;
-                if (obd->u.cli.cl_cksum_type == (1 << i))
-                        len += snprintf(page + len, count - len, "[%s] ",
-                                        cksum_name[i]);
-                else
-                        len += snprintf(page + len, count - len, "%s ",
-                                        cksum_name[i]);
-        }
-        if (len < count)
-                len += sprintf(page + len, "\n");
-        return len;
+       for (i = 0; i < ARRAY_SIZE(cksum_name); i++) {
+               if (((1 << i) & obd->u.cli.cl_supp_cksum_types) == 0)
+                       continue;
+               if (obd->u.cli.cl_cksum_type == (1 << i))
+                       seq_printf(m, "[%s] ", cksum_name[i]);
+               else
+                       seq_printf(m, "%s ", cksum_name[i]);
+       }
+       seq_printf(m, "\n");
+       return 0;
 }
 
 }
 
-static int osc_wd_checksum_type(struct file *file, const char *buffer,
-                                unsigned long count, void *data)
+static ssize_t osc_checksum_type_seq_write(struct file *file, const char *buffer,
+                                          size_t count, loff_t *off)
 {
 {
-        struct obd_device *obd = data;
-        int i;
-        DECLARE_CKSUM_NAME;
-        char kernbuf[10];
+       struct obd_device *obd = ((struct seq_file *)file->private_data)->private;
+       int i;
+       DECLARE_CKSUM_NAME;
+       char kernbuf[10];
 
         if (obd == NULL)
                 return 0;
 
         if (obd == NULL)
                 return 0;
@@ -397,21 +395,20 @@ static int osc_wd_checksum_type(struct file *file, const char *buffer,
         }
         return -EINVAL;
 }
         }
         return -EINVAL;
 }
+LPROC_SEQ_FOPS(osc_checksum_type);
 
 
-static int osc_rd_resend_count(char *page, char **start, off_t off, int count,
-                               int *eof, void *data)
+static int osc_resend_count_seq_show(struct seq_file *m, void *v)
 {
 {
-        struct obd_device *obd = data;
+       struct obd_device *obd = m->private;
 
 
-        return snprintf(page, count, "%u\n",
-                        cfs_atomic_read(&obd->u.cli.cl_resends));
+       return seq_printf(m, "%u\n", cfs_atomic_read(&obd->u.cli.cl_resends));
 }
 
 }
 
-static int osc_wr_resend_count(struct file *file, const char *buffer,
-                               unsigned long count, void *data)
+static ssize_t osc_resend_count_seq_write(struct file *file, const char *buffer,
+                                         size_t count, loff_t *off)
 {
 {
-        struct obd_device *obd = data;
-        int val, rc;
+       struct obd_device *obd = ((struct seq_file *)file->private_data)->private;
+       int val, rc;
 
         rc = lprocfs_write_helper(buffer, count, &val);
         if (rc)
 
         rc = lprocfs_write_helper(buffer, count, &val);
         if (rc)
@@ -424,57 +421,63 @@ static int osc_wr_resend_count(struct file *file, const char *buffer,
 
         return count;
 }
 
         return count;
 }
+LPROC_SEQ_FOPS(osc_resend_count);
 
 
-static int osc_rd_contention_seconds(char *page, char **start, off_t off,
-                                     int count, int *eof, void *data)
+static int osc_contention_seconds_seq_show(struct seq_file *m, void *v)
 {
 {
-        struct obd_device *obd = data;
-        struct osc_device *od  = obd2osc_dev(obd);
+       struct obd_device *obd = m->private;
+       struct osc_device *od  = obd2osc_dev(obd);
 
 
-        return snprintf(page, count, "%u\n", od->od_contention_time);
+       return seq_printf(m, "%u\n", od->od_contention_time);
 }
 
 }
 
-static int osc_wr_contention_seconds(struct file *file, const char *buffer,
-                                     unsigned long count, void *data)
+static ssize_t osc_contention_seconds_seq_write(struct file *file, const char *buffer,
+                                               size_t count, loff_t *off)
 {
 {
-        struct obd_device *obd = data;
-        struct osc_device *od  = obd2osc_dev(obd);
+       struct obd_device *obd = ((struct seq_file *)file->private_data)->private;
+       struct osc_device *od  = obd2osc_dev(obd);
 
 
-        return lprocfs_write_helper(buffer, count, &od->od_contention_time) ?:
-                count;
+       return lprocfs_write_helper(buffer, count, &od->od_contention_time) ?: count;
 }
 }
+LPROC_SEQ_FOPS(osc_contention_seconds);
 
 
-static int osc_rd_lockless_truncate(char *page, char **start, off_t off,
-                                    int count, int *eof, void *data)
+static int osc_lockless_truncate_seq_show(struct seq_file *m, void *v)
 {
 {
-        struct obd_device *obd = data;
-        struct osc_device *od  = obd2osc_dev(obd);
+       struct obd_device *obd = m->private;
+       struct osc_device *od  = obd2osc_dev(obd);
 
 
-        return snprintf(page, count, "%u\n", od->od_lockless_truncate);
+       return seq_printf(m, "%u\n", od->od_lockless_truncate);
 }
 
 }
 
-static int osc_wr_lockless_truncate(struct file *file, const char *buffer,
-                                    unsigned long count, void *data)
+static ssize_t osc_lockless_truncate_seq_write(struct file *file, const char *buffer,
+                                   size_t count, loff_t *off)
 {
 {
-        struct obd_device *obd = data;
+       struct obd_device *obd = ((struct seq_file *)file->private_data)->private;
         struct osc_device *od  = obd2osc_dev(obd);
 
         return lprocfs_write_helper(buffer, count, &od->od_lockless_truncate) ?:
                 count;
 }
         struct osc_device *od  = obd2osc_dev(obd);
 
         return lprocfs_write_helper(buffer, count, &od->od_lockless_truncate) ?:
                 count;
 }
+LPROC_SEQ_FOPS(osc_lockless_truncate);
 
 
-static int osc_rd_destroys_in_flight(char *page, char **start, off_t off,
-                                     int count, int *eof, void *data)
+static int osc_destroys_in_flight_seq_show(struct seq_file *m, void *v)
 {
 {
-        struct obd_device *obd = data;
-        return snprintf(page, count, "%u\n",
-                        cfs_atomic_read(&obd->u.cli.cl_destroy_in_flight));
+       struct obd_device *obd = m->private;
+       return seq_printf(m, "%u\n",
+                         cfs_atomic_read(&obd->u.cli.cl_destroy_in_flight));
 }
 }
+LPROC_SEQ_FOPS_RO(osc_destroys_in_flight);
 
 
-static int lprocfs_osc_wr_max_pages_per_rpc(struct file *file,
-       const char *buffer, unsigned long count, void *data)
+static int osc_obd_max_pages_per_rpc_seq_show(struct seq_file *m, void *v)
 {
 {
-       struct obd_device *dev = data;
+       return lprocfs_obd_max_pages_per_rpc_seq_show(m, m->private);
+}
+
+static ssize_t osc_obd_max_pages_per_rpc_seq_write(struct file *file,
+                                                  const char *buffer,
+                                                  size_t count, loff_t *off)
+{
+       struct obd_device *dev = ((struct seq_file *)file->private_data)->private;
        struct client_obd *cli = &dev->u.cli;
        struct obd_connect_data *ocd = &cli->cl_import->imp_connect_data;
        int chunk_mask, rc;
        struct client_obd *cli = &dev->u.cli;
        struct obd_connect_data *ocd = &cli->cl_import->imp_connect_data;
        int chunk_mask, rc;
@@ -504,71 +507,74 @@ static int lprocfs_osc_wr_max_pages_per_rpc(struct file *file,
        LPROCFS_CLIMP_EXIT(dev);
        return count;
 }
        LPROCFS_CLIMP_EXIT(dev);
        return count;
 }
+LPROC_SEQ_FOPS(osc_obd_max_pages_per_rpc);
 
 
-static int osc_rd_unstable_stats(char *page, char **start, off_t off,
-                               int count, int *eof, void *data)
+static int osc_unstable_stats_seq_show(struct seq_file *m, void *v)
 {
 {
-       struct obd_device *dev = data;
+       struct obd_device *dev = m->private;
        struct client_obd *cli = &dev->u.cli;
        int pages, mb;
 
        pages = cfs_atomic_read(&cli->cl_unstable_count);
        mb    = (pages * PAGE_CACHE_SIZE) >> 20;
 
        struct client_obd *cli = &dev->u.cli;
        int pages, mb;
 
        pages = cfs_atomic_read(&cli->cl_unstable_count);
        mb    = (pages * PAGE_CACHE_SIZE) >> 20;
 
-       return snprintf(page, count,
-                       "unstable_pages: %8d\n"
+       return seq_printf(m, "unstable_pages: %8d\n"
                        "unstable_mb:    %8d\n",
                        pages, mb);
 }
                        "unstable_mb:    %8d\n",
                        pages, mb);
 }
-
-static struct lprocfs_vars lprocfs_osc_obd_vars[] = {
-        { "uuid",            lprocfs_rd_uuid,        0, 0 },
-        { "ping",            0, lprocfs_wr_ping,     0, 0, 0222 },
-        { "connect_flags",   lprocfs_rd_connect_flags, 0, 0 },
-        { "blocksize",       lprocfs_rd_blksize,     0, 0 },
-        { "kbytestotal",     lprocfs_rd_kbytestotal, 0, 0 },
-        { "kbytesfree",      lprocfs_rd_kbytesfree,  0, 0 },
-        { "kbytesavail",     lprocfs_rd_kbytesavail, 0, 0 },
-        { "filestotal",      lprocfs_rd_filestotal,  0, 0 },
-        { "filesfree",       lprocfs_rd_filesfree,   0, 0 },
-        //{ "filegroups",      lprocfs_rd_filegroups,  0, 0 },
-        { "ost_server_uuid", lprocfs_rd_server_uuid, 0, 0 },
-        { "ost_conn_uuid",   lprocfs_rd_conn_uuid, 0, 0 },
-        { "active",          osc_rd_active,
-                             osc_wr_active, 0 },
-        { "max_pages_per_rpc", lprocfs_obd_rd_max_pages_per_rpc,
-                              lprocfs_osc_wr_max_pages_per_rpc, 0 },
-        { "max_rpcs_in_flight", osc_rd_max_rpcs_in_flight,
-                                osc_wr_max_rpcs_in_flight, 0 },
-        { "destroys_in_flight", osc_rd_destroys_in_flight, 0, 0 },
-        { "max_dirty_mb",    osc_rd_max_dirty_mb, osc_wr_max_dirty_mb, 0 },
-       { "osc_cached_mb",   osc_rd_cached_mb,     osc_wr_cached_mb, 0 },
-        { "cur_dirty_bytes", osc_rd_cur_dirty_bytes, 0, 0 },
-        { "cur_grant_bytes", osc_rd_cur_grant_bytes,
-                             osc_wr_cur_grant_bytes, 0 },
-        { "cur_lost_grant_bytes", osc_rd_cur_lost_grant_bytes, 0, 0},
-        { "grant_shrink_interval", osc_rd_grant_shrink_interval,
-                                   osc_wr_grant_shrink_interval, 0 },
-        { "checksums",       osc_rd_checksum, osc_wr_checksum, 0 },
-        { "checksum_type",   osc_rd_checksum_type, osc_wd_checksum_type, 0 },
-        { "resend_count",    osc_rd_resend_count, osc_wr_resend_count, 0},
-        { "timeouts",        lprocfs_rd_timeouts,      0, 0 },
-        { "contention_seconds", osc_rd_contention_seconds,
-                                osc_wr_contention_seconds, 0 },
-        { "lockless_truncate",  osc_rd_lockless_truncate,
-                                osc_wr_lockless_truncate, 0 },
-        { "import",          lprocfs_rd_import,        lprocfs_wr_import, 0 },
-        { "state",           lprocfs_rd_state,         0, 0 },
-        { "pinger_recov",    lprocfs_rd_pinger_recov,
-                             lprocfs_wr_pinger_recov,  0, 0 },
-        { "unstable_stats",  osc_rd_unstable_stats, 0, 0},
-
-        { 0 }
-};
-
-static struct lprocfs_vars lprocfs_osc_module_vars[] = {
-        { "num_refs",        lprocfs_rd_numrefs,     0, 0 },
-        { 0 }
+LPROC_SEQ_FOPS_RO(osc_unstable_stats);
+
+LPROC_SEQ_FOPS_RO_TYPE(osc, uuid);
+LPROC_SEQ_FOPS_RO_TYPE(osc, connect_flags);
+LPROC_SEQ_FOPS_RO_TYPE(osc, blksize);
+LPROC_SEQ_FOPS_RO_TYPE(osc, kbytestotal);
+LPROC_SEQ_FOPS_RO_TYPE(osc, kbytesfree);
+LPROC_SEQ_FOPS_RO_TYPE(osc, kbytesavail);
+LPROC_SEQ_FOPS_RO_TYPE(osc, filestotal);
+LPROC_SEQ_FOPS_RO_TYPE(osc, filesfree);
+LPROC_SEQ_FOPS_RO_TYPE(osc, server_uuid);
+LPROC_SEQ_FOPS_RO_TYPE(osc, conn_uuid);
+LPROC_SEQ_FOPS_RO_TYPE(osc, timeouts);
+LPROC_SEQ_FOPS_RO_TYPE(osc, state);
+
+LPROC_SEQ_FOPS_WO_TYPE(osc, ping);
+
+LPROC_SEQ_FOPS_RW_TYPE(osc, import);
+LPROC_SEQ_FOPS_RW_TYPE(osc, pinger_recov);
+
+struct lprocfs_seq_vars lprocfs_osc_obd_vars[] = {
+       { "uuid",               &osc_uuid_fops                  },
+       { "ping",               &osc_ping_fops,         0, 0222 },
+       { "connect_flags",      &osc_connect_flags_fops         },
+       { "blocksize",          &osc_blksize_fops               },
+       { "kbytestotal",        &osc_kbytestotal_fops           },
+       { "kbytesfree",         &osc_kbytesfree_fops            },
+       { "kbytesavail",        &osc_kbytesavail_fops           },
+       { "filestotal",         &osc_filestotal_fops            },
+       { "filesfree",          &osc_filesfree_fops             },
+       { "ost_server_uuid",    &osc_server_uuid_fops           },
+       { "ost_conn_uuid",      &osc_conn_uuid_fops             },
+       { "active",             &osc_active_fops                },
+       { "max_pages_per_rpc",  &osc_obd_max_pages_per_rpc_fops },
+       { "max_rpcs_in_flight", &osc_max_rpcs_in_flight_fops    },
+       { "destroys_in_flight", &osc_destroys_in_flight_fops    },
+       { "max_dirty_mb",       &osc_max_dirty_mb_fops          },
+       { "osc_cached_mb",      &osc_cached_mb_fops             },
+       { "cur_dirty_bytes",    &osc_cur_dirty_bytes_fops       },
+       { "cur_grant_bytes",    &osc_cur_grant_bytes_fops       },
+       { "cur_lost_grant_bytes",       &osc_cur_lost_grant_bytes_fops  },
+       { "grant_shrink_interval",      &osc_grant_shrink_interval_fops },
+       { "checksums",          &osc_checksum_fops              },
+       { "checksum_type",      &osc_checksum_type_fops         },
+       { "resend_count",       &osc_resend_count_fops          },
+       { "timeouts",           &osc_timeouts_fops              },
+       { "contention_seconds", &osc_contention_seconds_fops    },
+       { "lockless_truncate",  &osc_lockless_truncate_fops     },
+       { "import",             &osc_import_fops                },
+       { "state",              &osc_state_fops                 },
+       { "pinger_recov",       &osc_pinger_recov_fops          },
+       { "unstable_stats",     &osc_unstable_stats_fops        },
+       { 0 }
 };
 
 #define pct(a,b) (b ? a * 100 / b : 0)
 };
 
 #define pct(a,b) (b ? a * 100 / b : 0)
@@ -686,7 +692,6 @@ static ssize_t osc_rpc_stats_seq_write(struct file *file, const char *buf,
 
         return len;
 }
 
         return len;
 }
-
 LPROC_SEQ_FOPS(osc_rpc_stats);
 
 static int osc_stats_seq_show(struct seq_file *seq, void *v)
 LPROC_SEQ_FOPS(osc_rpc_stats);
 
 static int osc_stats_seq_show(struct seq_file *seq, void *v)
@@ -733,10 +738,4 @@ int lproc_osc_attach_seqstat(struct obd_device *dev)
 
        return rc;
 }
 
        return rc;
 }
-
-void lprocfs_osc_init_vars(struct lprocfs_static_vars *lvars)
-{
-        lvars->module_vars = lprocfs_osc_module_vars;
-        lvars->obd_vars    = lprocfs_osc_obd_vars;
-}
 #endif /* LPROCFS */
 #endif /* LPROCFS */
index 0772c2b..8378d0a 100644 (file)
@@ -146,14 +146,10 @@ int osc_cleanup(struct obd_device *obd);
 int osc_setup(struct obd_device *obd, struct lustre_cfg *lcfg);
 
 #ifdef LPROCFS
 int osc_setup(struct obd_device *obd, struct lustre_cfg *lcfg);
 
 #ifdef LPROCFS
+extern struct lprocfs_seq_vars lprocfs_osc_obd_vars[];
 int lproc_osc_attach_seqstat(struct obd_device *dev);
 int lproc_osc_attach_seqstat(struct obd_device *dev);
-void lprocfs_osc_init_vars(struct lprocfs_static_vars *lvars);
 #else
 static inline int lproc_osc_attach_seqstat(struct obd_device *dev) {return 0;}
 #else
 static inline int lproc_osc_attach_seqstat(struct obd_device *dev) {return 0;}
-static inline void lprocfs_osc_init_vars(struct lprocfs_static_vars *lvars)
-{
-        memset(lvars, 0, sizeof(*lvars));
-}
 #endif
 
 extern struct lu_device_type osc_device_type;
 #endif
 
 extern struct lu_device_type osc_device_type;
index 4cb6a05..09afa3c 100644 (file)
@@ -3519,7 +3519,6 @@ static int brw_queue_work(const struct lu_env *env, void *data)
 
 int osc_setup(struct obd_device *obd, struct lustre_cfg *lcfg)
 {
 
 int osc_setup(struct obd_device *obd, struct lustre_cfg *lcfg)
 {
-       struct lprocfs_static_vars lvars = { 0 };
        struct client_obd          *cli = &obd->u.cli;
        void                       *handler;
        int                        rc;
        struct client_obd          *cli = &obd->u.cli;
        void                       *handler;
        int                        rc;
@@ -3548,8 +3547,10 @@ int osc_setup(struct obd_device *obd, struct lustre_cfg *lcfg)
                GOTO(out_ptlrpcd_work, rc);
 
        cli->cl_grant_shrink_interval = GRANT_SHRINK_INTERVAL;
                GOTO(out_ptlrpcd_work, rc);
 
        cli->cl_grant_shrink_interval = GRANT_SHRINK_INTERVAL;
-       lprocfs_osc_init_vars(&lvars);
-       if (lprocfs_obd_setup(obd, lvars.obd_vars) == 0) {
+#ifdef LPROCFS
+       obd->obd_vars = lprocfs_osc_obd_vars;
+#endif
+       if (lprocfs_seq_obd_setup(obd) == 0) {
                lproc_osc_attach_seqstat(obd);
                sptlrpc_lprocfs_cliobd_attach(obd);
                ptlrpc_lprocfs_register_obd(obd);
                lproc_osc_attach_seqstat(obd);
                sptlrpc_lprocfs_cliobd_attach(obd);
                ptlrpc_lprocfs_register_obd(obd);
@@ -3663,21 +3664,9 @@ int osc_cleanup(struct obd_device *obd)
 
 int osc_process_config_base(struct obd_device *obd, struct lustre_cfg *lcfg)
 {
 
 int osc_process_config_base(struct obd_device *obd, struct lustre_cfg *lcfg)
 {
-        struct lprocfs_static_vars lvars = { 0 };
-        int rc = 0;
-
-        lprocfs_osc_init_vars(&lvars);
-
-        switch (lcfg->lcfg_command) {
-        default:
-                rc = class_process_proc_param(PARAM_OSC, lvars.obd_vars,
-                                              lcfg, obd);
-                if (rc > 0)
-                        rc = 0;
-                break;
-        }
-
-        return(rc);
+       int rc = class_process_proc_seq_param(PARAM_OSC, obd->obd_vars,
+                                             lcfg, obd);
+       return(rc > 0 ? 0: rc);
 }
 
 static int osc_process_config(struct obd_device *obd, obd_count len, void *buf)
 }
 
 static int osc_process_config(struct obd_device *obd, obd_count len, void *buf)
@@ -3730,7 +3719,6 @@ extern struct lock_class_key osc_ast_guard_class;
 
 int __init osc_init(void)
 {
 
 int __init osc_init(void)
 {
-        struct lprocfs_static_vars lvars = { 0 };
         int rc;
         ENTRY;
 
         int rc;
         ENTRY;
 
@@ -3743,11 +3731,9 @@ int __init osc_init(void)
        if (rc)
                RETURN(rc);
 
        if (rc)
                RETURN(rc);
 
-        lprocfs_osc_init_vars(&lvars);
-
        rc = class_register_type(&osc_obd_ops, NULL, NULL,
 #ifndef HAVE_ONLY_PROCFS_SEQ
        rc = class_register_type(&osc_obd_ops, NULL, NULL,
 #ifndef HAVE_ONLY_PROCFS_SEQ
-                               lvars.module_vars,
+                               NULL,
 #endif
                                LUSTRE_OSC_NAME, &osc_device_type);
         if (rc) {
 #endif
                                LUSTRE_OSC_NAME, &osc_device_type);
         if (rc) {