]> git.karo-electronics.de Git - linux-beck.git/commitdiff
staging/lustre/obdclass: move max_dirty_mb from sysctl to sysfs
authorOleg Drokin <green@linuxhacker.ru>
Mon, 6 Jul 2015 16:48:47 +0000 (12:48 -0400)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Tue, 14 Jul 2015 02:47:20 +0000 (19:47 -0700)
max_dirty_mb is now a parameter in /sys/fs/lustre/

Signed-off-by: Oleg Drokin <green@linuxhacker.ru>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
drivers/staging/lustre/lustre/obdclass/linux/linux-sysctl.c
drivers/staging/lustre/sysfs-fs-lustre

index 3c8087b5cf4b87aa1fa437a4df6912fcc6170b79..bb55a07b6c511b0c17e88fdbb9b75399aff0fbc0 100644 (file)
@@ -100,48 +100,42 @@ static struct static_lustre_uintvalue_attr lustre_sattr_##name =  \
 
 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)
+static ssize_t max_dirty_mb_show(struct kobject *kobj, struct attribute *attr,
+                                char *buf)
 {
-       int rc = 0;
+       return sprintf(buf, "%ul\n",
+                       obd_max_dirty_pages / (1 << (20 - PAGE_CACHE_SHIFT)));
+}
+
+static ssize_t max_dirty_mb_store(struct kobject *kobj, struct attribute *attr,
+                                 const char *buffer, size_t count)
+{
+       int rc;
+       unsigned long val;
+
+       rc = kstrtoul(buffer, 10, &val);
+       if (rc)
+               return rc;
+
+       val *= 1 << (20 - PAGE_CACHE_SHIFT); /* convert to pages */
 
-       if (!table->data || !table->maxlen || !*lenp || (*ppos && !write)) {
-               *lenp = 0;
-               return 0;
+       if (val > ((totalram_pages / 10) * 9)) {
+               /* Somebody wants to assign too much memory to dirty pages */
+               return -EINVAL;
        }
-       if (write) {
-               rc = lprocfs_write_frac_helper(buffer, *lenp,
-                                              (unsigned int *)table->data,
-                                              1 << (20 - PAGE_CACHE_SHIFT));
-               /* Don't allow them to let dirty pages exceed 90% of system
-                * memory and set a hard minimum of 4MB. */
-               if (obd_max_dirty_pages > ((totalram_pages / 10) * 9)) {
-                       CERROR("Refusing to set max dirty pages to %u, which is more than 90%% of available RAM; setting to %lu\n",
-                              obd_max_dirty_pages,
-                              ((totalram_pages / 10) * 9));
-                       obd_max_dirty_pages = (totalram_pages / 10) * 9;
-               } else if (obd_max_dirty_pages < 4 << (20 - PAGE_CACHE_SHIFT)) {
-                       obd_max_dirty_pages = 4 << (20 - PAGE_CACHE_SHIFT);
-               }
-       } else {
-               char buf[21];
-               int len;
-
-               len = lprocfs_read_frac_helper(buf, sizeof(buf),
-                                              *(unsigned int *)table->data,
-                                              1 << (20 - PAGE_CACHE_SHIFT));
-               if (len > *lenp)
-                       len = *lenp;
-               buf[len] = '\0';
-               if (copy_to_user(buffer, buf, len))
-                       return -EFAULT;
-               *lenp = len;
+
+       if (val < 4 << (20 - PAGE_CACHE_SHIFT)) {
+               /* Less than 4 Mb for dirty cache is also bad */
+               return -EINVAL;
        }
-       *ppos += *lenp;
-       return rc;
+
+       obd_max_dirty_pages = val;
+
+       return count;
 }
+LUSTRE_RW_ATTR(max_dirty_mb);
 
+#ifdef CONFIG_SYSCTL
 static struct ctl_table obd_table[] = {
        {
                .procname = "debug_peer_on_timeout",
@@ -164,13 +158,6 @@ static struct ctl_table obd_table[] = {
                .mode     = 0644,
                .proc_handler = &proc_dointvec
        },
-       {
-               .procname = "max_dirty_mb",
-               .data     = &obd_max_dirty_pages,
-               .maxlen   = sizeof(int),
-               .mode     = 0644,
-               .proc_handler = &proc_max_dirty_pages_in_mb
-       },
        {
                .procname = "at_min",
                .data     = &at_min,
@@ -223,6 +210,7 @@ static struct ctl_table parent_table[] = {
 
 static struct attribute *lustre_attrs[] = {
        &lustre_sattr_timeout.u.attr,
+       &lustre_attr_max_dirty_mb.attr,
        NULL,
 };
 
index 6dbad260fa7d78e14a292a015101aec54e0ba35d..38d1adcd233517700b02f5b5101d1ed577bd2c5f 100644 (file)
@@ -52,6 +52,18 @@ Description:
                AT (adaptive timeouts).
                Unit: seconds, default: 100
 
+What:          /sys/fs/lustre/max_dirty_mb
+Date:          June 2015
+Contact:       "Oleg Drokin" <oleg.drokin@intel.com>
+Description:
+               Controls total number of dirty cache (in megabytes) allowed
+               across all mounted lustre filesystems.
+               Since writeout of dirty pages in Lustre is somewhat expensive,
+               when you allow to many dirty pages, this might lead to
+               performance degradations as kernel tries to desperately
+               find some pages to free/writeout.
+               Default 1/2 RAM. Min value 4, max value 9/10 of RAM.
+
 What:          /sys/fs/lustre/llite/<fsname>-<uuid>/blocksize
 Date:          May 2015
 Contact:       "Oleg Drokin" <oleg.drokin@intel.com>