Whamcloud - gitweb
LU-5556 target: limit bulk transfer time
[fs/lustre-release.git] / lustre / obdclass / linux / linux-sysctl.c
index a28f17a..6a06687 100644 (file)
@@ -54,7 +54,7 @@
 #include <lprocfs_status.h>
 
 #ifdef CONFIG_SYSCTL
-cfs_sysctl_table_header_t *obd_table_header = NULL;
+struct ctl_table_header *obd_table_header = NULL;
 #endif
 
 #ifndef HAVE_SYSCTL_UNNUMBERED
@@ -79,6 +79,7 @@ enum {
         OBD_AT_EXTRA,
         OBD_AT_EARLY_MARGIN,
         OBD_AT_HISTORY,
+       OBD_BULK_TIMEOUT,       /* bulk transfer timeout */
 };
 
 #else
@@ -104,6 +105,7 @@ enum {
 #define OBD_AT_EXTRA            CTL_UNNUMBERED
 #define OBD_AT_EARLY_MARGIN     CTL_UNNUMBERED
 #define OBD_AT_HISTORY          CTL_UNNUMBERED
+#define OBD_BULK_TIMEOUT       CTL_UNNUMBERED
 
 #endif
 
@@ -134,7 +136,7 @@ int LL_PROC_PROTO(proc_memory_alloc)
         if (len > *lenp)
                 len = *lenp;
         buf[len] = '\0';
-        if (cfs_copy_to_user(buffer, buf, len))
+       if (copy_to_user(buffer, buf, len))
                 return -EFAULT;
         *lenp = len;
         *ppos += *lenp;
@@ -158,7 +160,7 @@ int LL_PROC_PROTO(proc_pages_alloc)
         if (len > *lenp)
                 len = *lenp;
         buf[len] = '\0';
-        if (cfs_copy_to_user(buffer, buf, len))
+       if (copy_to_user(buffer, buf, len))
                 return -EFAULT;
         *lenp = len;
         *ppos += *lenp;
@@ -182,7 +184,7 @@ int LL_PROC_PROTO(proc_mem_max)
         if (len > *lenp)
                 len = *lenp;
         buf[len] = '\0';
-        if (cfs_copy_to_user(buffer, buf, len))
+       if (copy_to_user(buffer, buf, len))
                 return -EFAULT;
         *lenp = len;
         *ppos += *lenp;
@@ -206,7 +208,7 @@ int LL_PROC_PROTO(proc_pages_max)
         if (len > *lenp)
                 len = *lenp;
         buf[len] = '\0';
-        if (cfs_copy_to_user(buffer, buf, len))
+       if (copy_to_user(buffer, buf, len))
                 return -EFAULT;
         *lenp = len;
         *ppos += *lenp;
@@ -215,44 +217,44 @@ int LL_PROC_PROTO(proc_pages_max)
 
 int LL_PROC_PROTO(proc_max_dirty_pages_in_mb)
 {
-        int rc = 0;
-        DECLARE_LL_PROC_PPOS_DECL;
-
-        if (!table->data || !table->maxlen || !*lenp || (*ppos && !write)) {
-                *lenp = 0;
-                return 0;
-        }
-        if (write) {
-                rc = lprocfs_write_frac_helper(buffer, *lenp,
-                                               (unsigned int*)table->data,
-                                               1 << (20 - CFS_PAGE_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 > ((cfs_num_physpages / 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,
-                               ((cfs_num_physpages / 10) * 9));
-                        obd_max_dirty_pages = ((cfs_num_physpages / 10) * 9);
-                } else if (obd_max_dirty_pages < 4 << (20 - CFS_PAGE_SHIFT)) {
-                        obd_max_dirty_pages = 4 << (20 - CFS_PAGE_SHIFT);
-                }
-        } else {
-                char buf[21];
-                int len;
-
-                len = lprocfs_read_frac_helper(buf, sizeof(buf),
-                                               *(unsigned int*)table->data,
-                                               1 << (20 - CFS_PAGE_SHIFT));
-                if (len > *lenp)
-                        len = *lenp;
-                buf[len] = '\0';
-                if (cfs_copy_to_user(buffer, buf, len))
-                        return -EFAULT;
-                *lenp = len;
-        }
-        *ppos += *lenp;
-        return rc;
+       int rc = 0;
+       DECLARE_LL_PROC_PPOS_DECL;
+
+       if (!table->data || !table->maxlen || !*lenp || (*ppos && !write)) {
+               *lenp = 0;
+               return 0;
+       }
+       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;
+       }
+       *ppos += *lenp;
+       return rc;
 }
 
 #ifdef RANDOM_FAIL_ALLOC
@@ -279,7 +281,7 @@ int LL_PROC_PROTO(proc_alloc_fail_rate)
                 if (len > *lenp)
                         len = *lenp;
                 buf[len] = '\0';
-                if (cfs_copy_to_user(buffer, buf, len))
+               if (copy_to_user(buffer, buf, len))
                         return -EFAULT;
                 *lenp = len;
         }
@@ -288,6 +290,10 @@ int LL_PROC_PROTO(proc_alloc_fail_rate)
 }
 #endif
 
+int LL_PROC_PROTO(proc_bulk_timeout)
+{
+       return proc_dointvec(table, write, buffer, lenp, ppos);
+}
 int LL_PROC_PROTO(proc_at_min)
 {
         return ll_proc_dointvec(table, write, filp, buffer, lenp, ppos);
@@ -310,7 +316,7 @@ int LL_PROC_PROTO(proc_at_history)
 }
 
 #ifdef CONFIG_SYSCTL
-static cfs_sysctl_table_t obd_table[] = {
+static struct ctl_table obd_table[] = {
         {
                 INIT_CTL_NAME(OBD_TIMEOUT)
                 .procname = "timeout",
@@ -401,6 +407,14 @@ static cfs_sysctl_table_t obd_table[] = {
                 .mode     = 0644,
                 .proc_handler = &proc_max_dirty_pages_in_mb
         },
+       {
+               INIT_CTL_NAME(OBD_BULK_TIMEOUT)
+               .procname       = "bulk_timeout",
+               .data           = &bulk_timeout,
+               .maxlen         = sizeof(int),
+               .mode           = 0644,
+               .proc_handler   = &proc_bulk_timeout
+       },
         {
                 INIT_CTL_NAME(OBD_AT_MIN)
                 .procname = "at_min",
@@ -444,7 +458,7 @@ static cfs_sysctl_table_t obd_table[] = {
         {       INIT_CTL_NAME(0)    }
 };
 
-static cfs_sysctl_table_t parent_table[] = {
+static struct ctl_table parent_table[] = {
         {
                 INIT_CTL_NAME(OBD_SYSCTL)
                 .procname = "lustre",
@@ -460,16 +474,16 @@ static cfs_sysctl_table_t parent_table[] = {
 void obd_sysctl_init (void)
 {
 #ifdef CONFIG_SYSCTL
-        if ( !obd_table_header )
-                obd_table_header = cfs_register_sysctl_table(parent_table, 0);
+       if ( !obd_table_header )
+               obd_table_header = register_sysctl_table(parent_table);
 #endif
 }
 
 void obd_sysctl_clean (void)
 {
 #ifdef CONFIG_SYSCTL
-        if ( obd_table_header )
-                cfs_unregister_sysctl_table(obd_table_header);
-        obd_table_header = NULL;
+       if ( obd_table_header )
+               unregister_sysctl_table(obd_table_header);
+       obd_table_header = NULL;
 #endif
 }