Whamcloud - gitweb
LU-3308 mdc: allow setting readdir RPC size parameter
[fs/lustre-release.git] / lustre / obdclass / lprocfs_status.c
index 7896dc5..eb46f76 100644 (file)
@@ -2288,31 +2288,58 @@ const struct sysfs_ops lustre_sysfs_ops = {
 };
 EXPORT_SYMBOL_GPL(lustre_sysfs_ops);
 
-int lprocfs_obd_rd_max_pages_per_rpc(char *page, char **start, off_t off,
-                                    int count, int *eof, void *data)
+int lprocfs_obd_max_pages_per_rpc_seq_show(struct seq_file *m, void *data)
 {
        struct obd_device *dev = data;
        struct client_obd *cli = &dev->u.cli;
-       int rc;
 
        spin_lock(&cli->cl_loi_list_lock);
-       rc = snprintf(page, count, "%d\n", cli->cl_max_pages_per_rpc);
+       seq_printf(m, "%d\n", cli->cl_max_pages_per_rpc);
        spin_unlock(&cli->cl_loi_list_lock);
-
-       return rc;
+       return 0;
 }
+EXPORT_SYMBOL(lprocfs_obd_max_pages_per_rpc_seq_show);
 
-int lprocfs_obd_max_pages_per_rpc_seq_show(struct seq_file *m, void *data)
+ssize_t lprocfs_obd_max_pages_per_rpc_seq_write(struct file *file,
+                                               const char __user *buffer,
+                                               size_t count, loff_t *off)
 {
-       struct obd_device *dev = data;
+       struct obd_device *dev =
+               ((struct seq_file *)file->private_data)->private;
        struct client_obd *cli = &dev->u.cli;
+       struct obd_connect_data *ocd = &cli->cl_import->imp_connect_data;
+       int chunk_mask, rc;
+       __s64 val;
+
+       rc = lprocfs_str_with_units_to_s64(buffer, count, &val, '1');
+       if (rc)
+               return rc;
+       if (val < 0)
+               return -ERANGE;
+
+       /* if the max_pages is specified in bytes, convert to pages */
+       if (val >= ONE_MB_BRW_SIZE)
+               val >>= PAGE_SHIFT;
 
+       LPROCFS_CLIMP_CHECK(dev);
+
+       chunk_mask = ~((1 << (cli->cl_chunkbits - PAGE_SHIFT)) - 1);
+       /* max_pages_per_rpc must be chunk aligned */
+       val = (val + ~chunk_mask) & chunk_mask;
+       if (val == 0 || (ocd->ocd_brw_size != 0 &&
+                        val > ocd->ocd_brw_size >> PAGE_SHIFT)) {
+               LPROCFS_CLIMP_EXIT(dev);
+               return -ERANGE;
+       }
        spin_lock(&cli->cl_loi_list_lock);
-       seq_printf(m, "%d\n", cli->cl_max_pages_per_rpc);
+       cli->cl_max_pages_per_rpc = val;
+       client_adjust_max_dirty(cli);
        spin_unlock(&cli->cl_loi_list_lock);
-       return 0;
+
+       LPROCFS_CLIMP_EXIT(dev);
+       return count;
 }
-EXPORT_SYMBOL(lprocfs_obd_max_pages_per_rpc_seq_show);
+EXPORT_SYMBOL(lprocfs_obd_max_pages_per_rpc_seq_write);
 
 int lprocfs_wr_root_squash(const char __user *buffer, unsigned long count,
                           struct root_squash_info *squash, char *name)