All the mail mirrored from lore.kernel.org
 help / color / mirror / Atom feed
From: green@linuxhacker.ru
To: Greg Kroah-Hartman <gregkh@linuxfoundation.org>,
	devel@driverdev.osuosl.org,
	Andreas Dilger <andreas.dilger@intel.com>
Cc: Linux Kernel Mailing List <linux-kernel@vger.kernel.org>,
	Oleg Drokin <green@linuxhacker.ru>
Subject: [PATCH 13/20] staging/lustre/libcfs: move /proc/sys/lnet to debugfs
Date: Mon,  6 Jul 2015 12:48:51 -0400	[thread overview]
Message-ID: <1436201338-14263-14-git-send-email-green@linuxhacker.ru> (raw)
In-Reply-To: <1436201338-14263-1-git-send-email-green@linuxhacker.ru>

From: Oleg Drokin <green@linuxhacker.ru>

Parameters in lnet sysctl are of debug quantity, so let's move them
to debugfs instead.

Signed-off-by: Oleg Drokin <green@linuxhacker.ru>
---
 drivers/staging/lustre/lustre/libcfs/module.c | 86 +++++++++++++++++----------
 1 file changed, 56 insertions(+), 30 deletions(-)

diff --git a/drivers/staging/lustre/lustre/libcfs/module.c b/drivers/staging/lustre/lustre/libcfs/module.c
index e60b2e9..bffde77 100644
--- a/drivers/staging/lustre/lustre/libcfs/module.c
+++ b/drivers/staging/lustre/lustre/libcfs/module.c
@@ -50,6 +50,7 @@
 #include <linux/list.h>
 
 #include <linux/sysctl.h>
+#include <linux/debugfs.h>
 
 # define DEBUG_SUBSYSTEM S_LNET
 
@@ -69,10 +70,10 @@ extern struct miscdevice libcfs_dev;
 extern struct cfs_wi_sched *cfs_sched_rehash;
 extern void libcfs_init_nidstrings(void);
 
-static int insert_proc(void);
-static void remove_proc(void);
+static void insert_debugfs(void);
+static void remove_debugfs(void);
 
-static struct ctl_table_header *lnet_table_header;
+static struct dentry *lnet_debugfs_root;
 extern char lnet_upcall[1024];
 /**
  * The path of debug log dump upcall script.
@@ -428,17 +429,10 @@ static int init_libcfs_module(void)
 		goto cleanup_wi;
 	}
 
-
-	rc = insert_proc();
-	if (rc) {
-		CERROR("insert_proc: error %d\n", rc);
-		goto cleanup_crypto;
-	}
+	insert_debugfs();
 
 	CDEBUG (D_OTHER, "portals setup OK\n");
 	return 0;
- cleanup_crypto:
-	cfs_crypto_unregister();
  cleanup_wi:
 	cfs_wi_shutdown();
  cleanup_deregister:
@@ -454,7 +448,7 @@ static void exit_libcfs_module(void)
 {
 	int rc;
 
-	remove_proc();
+	remove_debugfs();
 
 	CDEBUG(D_MALLOC, "before Portals cleanup: kmem %d\n",
 	       atomic_read(&libcfs_kmemory));
@@ -935,31 +929,63 @@ static struct ctl_table lnet_table[] = {
 	}
 };
 
-static struct ctl_table top_table[] = {
-	{
-		.procname = "lnet",
-		.mode     = 0555,
-		.data     = NULL,
-		.maxlen   = 0,
-		.child    = lnet_table,
-	},
-	{
-	}
+static ssize_t lnet_debugfs_read(struct file *filp, char __user *buf,
+				 size_t count, loff_t *ppos)
+{
+	struct ctl_table *table = filp->private_data;
+	int error;
+
+	error = table->proc_handler(table, 0, (void __user *)buf, &count, ppos);
+	if (!error)
+		error = count;
+
+	return error;
+}
+
+static ssize_t lnet_debugfs_write(struct file *filp, const char __user *buf,
+				  size_t count, loff_t *ppos)
+{
+	struct ctl_table *table = filp->private_data;
+	int error;
+
+	error = table->proc_handler(table, 1, (void __user *)buf, &count, ppos);
+	if (!error)
+		error = count;
+
+	return error;
+}
+
+static const struct file_operations lnet_debugfs_file_operations = {
+	.open		= simple_open,
+	.read		= lnet_debugfs_read,
+	.write		= lnet_debugfs_write,
+	.llseek		= default_llseek,
 };
 
-static int insert_proc(void)
+static void insert_debugfs(void)
 {
-	if (lnet_table_header == NULL)
-		lnet_table_header = register_sysctl_table(top_table);
-	return 0;
+	struct ctl_table *table;
+	struct dentry *entry;
+
+	if (lnet_debugfs_root == NULL)
+		lnet_debugfs_root = debugfs_create_dir("lnet", NULL);
+
+	/* Even if we cannot create, just ignore it altogether) */
+	if (IS_ERR_OR_NULL(lnet_debugfs_root))
+		return;
+
+	for (table = lnet_table; table->procname; table++)
+		entry = debugfs_create_file(table->procname, table->mode,
+					    lnet_debugfs_root, table,
+					    &lnet_debugfs_file_operations);
 }
 
-static void remove_proc(void)
+static void remove_debugfs(void)
 {
-	if (lnet_table_header != NULL)
-		unregister_sysctl_table(lnet_table_header);
+	if (lnet_debugfs_root != NULL)
+		debugfs_remove_recursive(lnet_debugfs_root);
 
-	lnet_table_header = NULL;
+	lnet_debugfs_root = NULL;
 }
 
 MODULE_VERSION("1.0.0");
-- 
2.1.0


  parent reply	other threads:[~2015-07-06 16:49 UTC|newest]

Thread overview: 33+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-07-06 16:48 [PATCH 00/20] Lustre: final procfs bits removal green
2015-07-06 16:48 ` [PATCH 01/20] staging/lustre/lov: Move target sysfs symlink removal to object freeing green
2015-07-06 16:48 ` [PATCH 02/20] staging/lustre: make ldebugfs_remove recursive green
2015-07-06 16:48 ` [PATCH 03/20] staging/lustre/ldlm: In ldlm_pools_fini make sure there was init first green
2015-07-06 16:48 ` [PATCH 04/20] staging/lustre/obdclass: fix class_procfs_init error return value green
2015-07-06 16:48 ` [PATCH 05/20] staging/lustre: remove alloc_fail_rate sysctl green
2015-07-06 16:48 ` [PATCH 06/20] staging/lustre: Remove now obsolete memory tracking sysctls green
2015-07-06 16:48 ` [PATCH 07/20] staging/lustre: Remove unneeded ldlm_timeout control green
2015-07-06 16:48 ` [PATCH 08/20] staging/lustre/obdclass: move sysctl timeout to sysfs green
2015-07-06 16:48 ` [PATCH 09/20] staging/lustre/obdclass: move max_dirty_mb from sysctl " green
2015-07-06 16:48 ` [PATCH 10/20] staging/lustre/obdclass: move debug controls " green
2015-07-06 16:48 ` [PATCH 11/20] staging/lustre/obdclass: Move AT controls from sysctl " green
2015-07-06 16:48 ` [PATCH 12/20] staging/lustre: Get rid of remaining /proc/sys/lustre plumbing green
2015-07-06 16:48 ` green [this message]
2015-07-06 16:48 ` [PATCH 14/20] staging/lustre/libcfs: Remove redundant lnet debugfs variables green
2015-07-06 16:48 ` [PATCH 15/20] staging/lustre/libcfs: get rid of debugfs/lnet/console_backoff green
2015-07-08  8:28   ` Dan Carpenter
2015-07-08  8:30     ` Dan Carpenter
2015-07-08 13:43     ` Oleg Drokin
2015-07-06 16:48 ` [PATCH 16/20] staging/lustre/libcfs: Remove redundant enums and sysctl moduleparams green
2015-07-06 16:48 ` [PATCH 17/20] staging/lustre/libcfs: Remove unneeded lnet watchdog_ratelimit sysctl green
2015-07-06 16:48 ` [PATCH 18/20] staging/lustre/libcfs: get rid of debugfs/lnet/debug_mb green
2015-07-08  8:45   ` Dan Carpenter
2015-07-14  2:43     ` Greg Kroah-Hartman
2015-07-14  2:45       ` Oleg Drokin
2015-07-14  3:04         ` Greg Kroah-Hartman
2015-07-14  2:46   ` Greg Kroah-Hartman
2015-07-14  2:51     ` Oleg Drokin
2015-07-14  3:52       ` Greg Kroah-Hartman
2015-07-14  2:49   ` Greg Kroah-Hartman
2015-07-14  2:52     ` Oleg Drokin
2015-07-06 16:48 ` [PATCH 19/20] staging/lustre/libcfs: get rid of debugfs/lnet/console_{min,max}_delay_centisecs green
2015-07-06 16:48 ` [PATCH 20/20] staging/lustre/libcfs: remove unused portal_enter_debugger variable green

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1436201338-14263-14-git-send-email-green@linuxhacker.ru \
    --to=green@linuxhacker.ru \
    --cc=andreas.dilger@intel.com \
    --cc=devel@driverdev.osuosl.org \
    --cc=gregkh@linuxfoundation.org \
    --cc=linux-kernel@vger.kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.