staging/lustre/lnet: Reenable lnet router debugfs
authorOleg Drokin <green@linuxhacker.ru>
Mon, 14 Sep 2015 22:41:17 +0000 (18:41 -0400)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Tue, 15 Sep 2015 13:26:52 +0000 (06:26 -0700)
It looks like router proc files were defined out, so I missed them
during debugfs conversion.
Reenable the code and move all the variables to debugfs.

Signed-off-by: Oleg Drokin <green@linuxhacker.ru>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
drivers/staging/lustre/include/linux/libcfs/libcfs.h
drivers/staging/lustre/include/linux/lnet/lib-lnet.h
drivers/staging/lustre/lnet/lnet/api-ni.c
drivers/staging/lustre/lnet/lnet/router_proc.c
drivers/staging/lustre/lustre/libcfs/module.c

index 01961d9e6c363c25ba4764415f842dc3334c56ed..259a33658d3f1a438f5a4c52c5eb91ac1780db5e 100644 (file)
@@ -161,4 +161,12 @@ extern struct cfs_psdev_ops libcfs_psdev_ops;
 
 extern struct cfs_wi_sched *cfs_sched_rehash;
 
+struct lnet_debugfs_symlink_def {
+       char *name;
+       char *target;
+};
+
+void lustre_insert_debugfs(struct ctl_table *table,
+                          const struct lnet_debugfs_symlink_def *symlinks);
+
 #endif /* _LIBCFS_H */
index a9c9a077c77d3e12d10a6620a19866a40749e00d..22d54b2095282d10af250b58910a3fd46882a1ba 100644 (file)
@@ -443,8 +443,8 @@ int lnet_del_route(__u32 net, lnet_nid_t gw_nid);
 void lnet_destroy_routes(void);
 int lnet_get_route(int idx, __u32 *net, __u32 *hops,
                   lnet_nid_t *gateway, __u32 *alive, __u32 *priority);
-void lnet_proc_init(void);
-void lnet_proc_fini(void);
+void lnet_router_debugfs_init(void);
+void lnet_router_debugfs_fini(void);
 int  lnet_rtrpools_alloc(int im_a_router);
 void lnet_rtrpools_free(void);
 lnet_remotenet_t *lnet_find_net_locked(__u32 net);
index d14fe70a56dff99c469858c61530d4691e4024fa..7fab03bee1eaa4025e036877cbd1b3c90a60aaf3 100644 (file)
@@ -1262,7 +1262,7 @@ LNetNIInit(lnet_pid_t requested_pid)
        if (rc != 0)
                goto failed4;
 
-       lnet_proc_init();
+       lnet_router_debugfs_init();
        goto out;
 
  failed4:
@@ -1305,7 +1305,7 @@ LNetNIFini(void)
        } else {
                LASSERT(!the_lnet.ln_niinit_self);
 
-               lnet_proc_fini();
+               lnet_router_debugfs_fini();
                lnet_router_checker_stop();
                lnet_ping_target_fini();
 
index 40f418b82960746b5cde2324a7a40d57ae43c775..a9f4cbf2fcfe8b7bc1c22e265e0df5f7c0209021 100644 (file)
 #include "../../include/linux/libcfs/libcfs.h"
 #include "../../include/linux/lnet/lib-lnet.h"
 
-#if  defined(LNET_ROUTER)
-
 /* This is really lnet_proc.c. You might need to update sanity test 215
  * if any file format is changed. */
 
-static struct ctl_table_header *lnet_table_header;
-
 #define LNET_LOFFT_BITS                (sizeof(loff_t) * 8)
 /*
  * NB: max allowed LNET_CPT_BITS is 8 on 64-bit system and 2 on 32-bit system
@@ -914,44 +910,11 @@ static struct ctl_table lnet_table[] = {
        }
 };
 
-static struct ctl_table top_table[] = {
-       {
-               .procname = "lnet",
-               .mode     = 0555,
-               .data     = NULL,
-               .maxlen   = 0,
-               .child    = lnet_table,
-       },
-       {
-       }
-};
-
-void
-lnet_proc_init(void)
+void lnet_router_debugfs_init(void)
 {
-       if (lnet_table_header == NULL)
-               lnet_table_header = register_sysctl_table(top_table);
+       lustre_insert_debugfs(lnet_table, NULL);
 }
 
-void
-lnet_proc_fini(void)
+void lnet_router_debugfs_fini(void)
 {
-       if (lnet_table_header != NULL)
-               unregister_sysctl_table(lnet_table_header);
-
-       lnet_table_header = NULL;
 }
-
-#else
-
-void
-lnet_proc_init(void)
-{
-}
-
-void
-lnet_proc_fini(void)
-{
-}
-
-#endif
index 806f9747a3a299ead2f07d18da2a38c9aadff88a..a19f5796b64240051a54442773693f1c06c41179 100644 (file)
@@ -66,9 +66,6 @@ MODULE_AUTHOR("Peter J. Braam <braam@clusterfs.com>");
 MODULE_DESCRIPTION("Portals v3.1");
 MODULE_LICENSE("GPL");
 
-static void insert_debugfs(void);
-static void remove_debugfs(void);
-
 static struct dentry *lnet_debugfs_root;
 
 static void kportal_memhog_free(struct libcfs_device_userstate *ldu)
@@ -349,90 +346,6 @@ struct cfs_psdev_ops libcfs_psdev_ops = {
        libcfs_ioctl
 };
 
-static int init_libcfs_module(void)
-{
-       int rc;
-
-       libcfs_arch_init();
-       libcfs_init_nidstrings();
-
-       rc = libcfs_debug_init(5 * 1024 * 1024);
-       if (rc < 0) {
-               pr_err("LustreError: libcfs_debug_init: %d\n", rc);
-               return rc;
-       }
-
-       rc = cfs_cpu_init();
-       if (rc != 0)
-               goto cleanup_debug;
-
-       rc = misc_register(&libcfs_dev);
-       if (rc) {
-               CERROR("misc_register: error %d\n", rc);
-               goto cleanup_cpu;
-       }
-
-       rc = cfs_wi_startup();
-       if (rc) {
-               CERROR("initialize workitem: error %d\n", rc);
-               goto cleanup_deregister;
-       }
-
-       /* max to 4 threads, should be enough for rehash */
-       rc = min(cfs_cpt_weight(cfs_cpt_table, CFS_CPT_ANY), 4);
-       rc = cfs_wi_sched_create("cfs_rh", cfs_cpt_table, CFS_CPT_ANY,
-                                rc, &cfs_sched_rehash);
-       if (rc != 0) {
-               CERROR("Startup workitem scheduler: error: %d\n", rc);
-               goto cleanup_deregister;
-       }
-
-       rc = cfs_crypto_register();
-       if (rc) {
-               CERROR("cfs_crypto_register: error %d\n", rc);
-               goto cleanup_wi;
-       }
-
-       insert_debugfs();
-
-       CDEBUG(D_OTHER, "portals setup OK\n");
-       return 0;
- cleanup_wi:
-       cfs_wi_shutdown();
- cleanup_deregister:
-       misc_deregister(&libcfs_dev);
-cleanup_cpu:
-       cfs_cpu_fini();
- cleanup_debug:
-       libcfs_debug_cleanup();
-       return rc;
-}
-
-static void exit_libcfs_module(void)
-{
-       int rc;
-
-       remove_debugfs();
-
-       if (cfs_sched_rehash != NULL) {
-               cfs_wi_sched_destroy(cfs_sched_rehash);
-               cfs_sched_rehash = NULL;
-       }
-
-       cfs_crypto_unregister();
-       cfs_wi_shutdown();
-
-       misc_deregister(&libcfs_dev);
-
-       cfs_cpu_fini();
-
-       rc = libcfs_debug_cleanup();
-       if (rc)
-               pr_err("LustreError: libcfs_debug_cleanup: %d\n", rc);
-
-       libcfs_arch_cleanup();
-}
-
 static int proc_call_handler(void *data, int write, loff_t *ppos,
                void __user *buffer, size_t *lenp,
                int (*handler)(void *data, int write,
@@ -700,11 +613,6 @@ static struct ctl_table lnet_table[] = {
        }
 };
 
-struct lnet_debugfs_symlink_def {
-       char *name;
-       char *target;
-};
-
 static const struct lnet_debugfs_symlink_def lnet_debugfs_symlinks[] = {
        { "console_ratelimit",
          "/sys/module/libcfs/parameters/libcfs_console_ratelimit"},
@@ -756,11 +664,10 @@ static const struct file_operations lnet_debugfs_file_operations = {
        .llseek         = default_llseek,
 };
 
-static void insert_debugfs(void)
+void lustre_insert_debugfs(struct ctl_table *table,
+                          const struct lnet_debugfs_symlink_def *symlinks)
 {
-       struct ctl_table *table;
        struct dentry *entry;
-       const struct lnet_debugfs_symlink_def *symlinks;
 
        if (lnet_debugfs_root == NULL)
                lnet_debugfs_root = debugfs_create_dir("lnet", NULL);
@@ -769,19 +676,20 @@ static void insert_debugfs(void)
        if (IS_ERR_OR_NULL(lnet_debugfs_root))
                return;
 
-       for (table = lnet_table; table->procname; table++)
+       for (; table->procname; table++)
                entry = debugfs_create_file(table->procname, table->mode,
                                            lnet_debugfs_root, table,
                                            &lnet_debugfs_file_operations);
 
-       for (symlinks = lnet_debugfs_symlinks; symlinks->name; symlinks++)
+       for (; symlinks && symlinks->name; symlinks++)
                entry = debugfs_create_symlink(symlinks->name,
                                               lnet_debugfs_root,
                                               symlinks->target);
 
 }
+EXPORT_SYMBOL_GPL(lustre_insert_debugfs);
 
-static void remove_debugfs(void)
+static void lustre_remove_debugfs(void)
 {
        if (lnet_debugfs_root != NULL)
                debugfs_remove_recursive(lnet_debugfs_root);
@@ -789,6 +697,90 @@ static void remove_debugfs(void)
        lnet_debugfs_root = NULL;
 }
 
+static int init_libcfs_module(void)
+{
+       int rc;
+
+       libcfs_arch_init();
+       libcfs_init_nidstrings();
+
+       rc = libcfs_debug_init(5 * 1024 * 1024);
+       if (rc < 0) {
+               pr_err("LustreError: libcfs_debug_init: %d\n", rc);
+               return rc;
+       }
+
+       rc = cfs_cpu_init();
+       if (rc != 0)
+               goto cleanup_debug;
+
+       rc = misc_register(&libcfs_dev);
+       if (rc) {
+               CERROR("misc_register: error %d\n", rc);
+               goto cleanup_cpu;
+       }
+
+       rc = cfs_wi_startup();
+       if (rc) {
+               CERROR("initialize workitem: error %d\n", rc);
+               goto cleanup_deregister;
+       }
+
+       /* max to 4 threads, should be enough for rehash */
+       rc = min(cfs_cpt_weight(cfs_cpt_table, CFS_CPT_ANY), 4);
+       rc = cfs_wi_sched_create("cfs_rh", cfs_cpt_table, CFS_CPT_ANY,
+                                rc, &cfs_sched_rehash);
+       if (rc != 0) {
+               CERROR("Startup workitem scheduler: error: %d\n", rc);
+               goto cleanup_deregister;
+       }
+
+       rc = cfs_crypto_register();
+       if (rc) {
+               CERROR("cfs_crypto_register: error %d\n", rc);
+               goto cleanup_wi;
+       }
+
+       lustre_insert_debugfs(lnet_table, lnet_debugfs_symlinks);
+
+       CDEBUG(D_OTHER, "portals setup OK\n");
+       return 0;
+ cleanup_wi:
+       cfs_wi_shutdown();
+ cleanup_deregister:
+       misc_deregister(&libcfs_dev);
+cleanup_cpu:
+       cfs_cpu_fini();
+ cleanup_debug:
+       libcfs_debug_cleanup();
+       return rc;
+}
+
+static void exit_libcfs_module(void)
+{
+       int rc;
+
+       lustre_remove_debugfs();
+
+       if (cfs_sched_rehash) {
+               cfs_wi_sched_destroy(cfs_sched_rehash);
+               cfs_sched_rehash = NULL;
+       }
+
+       cfs_crypto_unregister();
+       cfs_wi_shutdown();
+
+       misc_deregister(&libcfs_dev);
+
+       cfs_cpu_fini();
+
+       rc = libcfs_debug_cleanup();
+       if (rc)
+               pr_err("LustreError: libcfs_debug_cleanup: %d\n", rc);
+
+       libcfs_arch_cleanup();
+}
+
 MODULE_VERSION("1.0.0");
 
 module_init(init_libcfs_module);