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 08/20] staging/lustre/obdclass: move sysctl timeout to sysfs
Date: Mon,  6 Jul 2015 12:48:46 -0400	[thread overview]
Message-ID: <1436201338-14263-9-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>

This is the first step of moving lustre sysctls from
/proc/sys/lustre to /sys/fs/lustre

Signed-off-by: Oleg Drokin <green@linuxhacker.ru>
---
 drivers/staging/lustre/lustre/include/obd_class.h  |  4 +-
 drivers/staging/lustre/lustre/obdclass/class_obd.c |  6 +-
 .../lustre/lustre/obdclass/linux/linux-sysctl.c    | 66 +++++++++++++++++-----
 drivers/staging/lustre/sysfs-fs-lustre             | 12 ++++
 4 files changed, 71 insertions(+), 17 deletions(-)

diff --git a/drivers/staging/lustre/lustre/include/obd_class.h b/drivers/staging/lustre/lustre/include/obd_class.h
index 36ed781..7dce4ee 100644
--- a/drivers/staging/lustre/lustre/include/obd_class.h
+++ b/drivers/staging/lustre/lustre/include/obd_class.h
@@ -1869,8 +1869,8 @@ extern int (*ptlrpc_put_connection_superhack)(struct ptlrpc_connection *c);
 /* obd_mount.c */
 
 /* sysctl.c */
-extern void obd_sysctl_init (void);
-extern void obd_sysctl_clean (void);
+extern int obd_sysctl_init(void);
+extern void obd_sysctl_clean(void);
 
 /* uuid.c  */
 typedef __u8 class_uuid_t[16];
diff --git a/drivers/staging/lustre/lustre/obdclass/class_obd.c b/drivers/staging/lustre/lustre/obdclass/class_obd.c
index df0063b..1f949dc 100644
--- a/drivers/staging/lustre/lustre/obdclass/class_obd.c
+++ b/drivers/staging/lustre/lustre/obdclass/class_obd.c
@@ -567,12 +567,14 @@ static int __init init_obdclass(void)
 	if (err)
 		return err;
 
-	obd_sysctl_init();
-
 	err = class_procfs_init();
 	if (err)
 		return err;
 
+	err = obd_sysctl_init();
+	if (err)
+		return err;
+
 	err = lu_global_init();
 	if (err)
 		return err;
diff --git a/drivers/staging/lustre/lustre/obdclass/linux/linux-sysctl.c b/drivers/staging/lustre/lustre/obdclass/linux/linux-sysctl.c
index eda5f30..3c8087b 100644
--- a/drivers/staging/lustre/lustre/obdclass/linux/linux-sysctl.c
+++ b/drivers/staging/lustre/lustre/obdclass/linux/linux-sysctl.c
@@ -54,16 +54,53 @@
 static struct ctl_table_header *obd_table_header;
 #endif
 
-#ifdef CONFIG_SYSCTL
-static int proc_set_timeout(struct ctl_table *table, int write,
-			void __user *buffer, size_t *lenp, loff_t *ppos)
+struct static_lustre_uintvalue_attr {
+	struct {
+		struct attribute attr;
+		ssize_t (*show)(struct kobject *kobj, struct attribute *attr,
+				char *buf);
+		ssize_t (*store)(struct kobject *kobj, struct attribute *attr,
+				 const char *buf, size_t len);
+	} u;
+	int *value;
+};
+
+static ssize_t static_uintvalue_show(struct kobject *kobj,
+				    struct attribute *attr,
+				    char *buf)
 {
+	struct static_lustre_uintvalue_attr *lattr = (void *)attr;
+
+	return sprintf(buf, "%d\n", *lattr->value);
+}
+
+static ssize_t static_uintvalue_store(struct kobject *kobj,
+				     struct attribute *attr,
+				     const char *buffer, size_t count)
+{
+	struct static_lustre_uintvalue_attr *lattr  = (void *)attr;
 	int rc;
+	unsigned int val;
 
-	rc = proc_dointvec(table, write, buffer, lenp, ppos);
-	return rc;
+	rc = kstrtouint(buffer, 10, &val);
+	if (rc)
+		return rc;
+
+	*lattr->value = val;
+
+	return count;
 }
 
+#define LUSTRE_STATIC_UINT_ATTR(name, value) \
+static struct static_lustre_uintvalue_attr lustre_sattr_##name =	\
+					{__ATTR(name, 0644,		\
+						static_uintvalue_show,	\
+						static_uintvalue_store),\
+					  value }
+
+LUSTRE_STATIC_UINT_ATTR(timeout, &obd_timeout);
+
+#ifdef CONFIG_SYSCTL
 static int proc_max_dirty_pages_in_mb(struct ctl_table *table, int write,
 			       void __user *buffer, size_t *lenp, loff_t *ppos)
 {
@@ -107,13 +144,6 @@ static int proc_max_dirty_pages_in_mb(struct ctl_table *table, int write,
 
 static struct ctl_table obd_table[] = {
 	{
-		.procname = "timeout",
-		.data     = &obd_timeout,
-		.maxlen   = sizeof(int),
-		.mode     = 0644,
-		.proc_handler = &proc_set_timeout
-	},
-	{
 		.procname = "debug_peer_on_timeout",
 		.data     = &obd_debug_peer_on_timeout,
 		.maxlen   = sizeof(int),
@@ -191,12 +221,22 @@ static struct ctl_table parent_table[] = {
 };
 #endif
 
-void obd_sysctl_init(void)
+static struct attribute *lustre_attrs[] = {
+	&lustre_sattr_timeout.u.attr,
+	NULL,
+};
+
+static struct attribute_group lustre_attr_group = {
+	.attrs = lustre_attrs,
+};
+
+int obd_sysctl_init(void)
 {
 #ifdef CONFIG_SYSCTL
 	if (!obd_table_header)
 		obd_table_header = register_sysctl_table(parent_table);
 #endif
+	return sysfs_create_group(lustre_kobj, &lustre_attr_group);
 }
 
 void obd_sysctl_clean(void)
diff --git a/drivers/staging/lustre/sysfs-fs-lustre b/drivers/staging/lustre/sysfs-fs-lustre
index 1e302e8..6dbad26 100644
--- a/drivers/staging/lustre/sysfs-fs-lustre
+++ b/drivers/staging/lustre/sysfs-fs-lustre
@@ -40,6 +40,18 @@ Description:
 			       e.g. dd.1253
 		nodelocal - use jobid_name value from above.
 
+What:		/sys/fs/lustre/timeout
+Date:		June 2015
+Contact:	"Oleg Drokin" <oleg.drokin@intel.com>
+Description:
+		Controls "lustre timeout" variable, also known as obd_timeout
+		in some old manual. In the past obd_timeout was of paramount
+		importance as the timeout value used everywhere and where
+		other timeouts were derived from. These days it's much less
+		important as network timeouts are mostly determined by
+		AT (adaptive timeouts).
+		Unit: seconds, default: 100
+
 What:		/sys/fs/lustre/llite/<fsname>-<uuid>/blocksize
 Date:		May 2015
 Contact:	"Oleg Drokin" <oleg.drokin@intel.com>
-- 
2.1.0


  parent reply	other threads:[~2015-07-06 16:53 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 ` green [this message]
2015-07-06 16:48 ` [PATCH 09/20] staging/lustre/obdclass: move max_dirty_mb from sysctl to sysfs 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 ` [PATCH 13/20] staging/lustre/libcfs: move /proc/sys/lnet to debugfs green
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-9-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.