Whamcloud - gitweb
LU-8066 sysfs: migrate max_pages_per_rpc to sysfs tree 65/56665/2
authorJames Simmons <jsimmons@infradead.org>
Fri, 11 Oct 2024 14:24:00 +0000 (08:24 -0600)
committerOleg Drokin <green@whamcloud.com>
Mon, 16 Dec 2024 08:15:14 +0000 (08:15 +0000)
Both the osc and mdc layer place max_pages_per_rpc in the proc
tree. We can move it to the sysfs tree. This is a simple sysfs
file so no root only issues for this tunable.

Change-Id: Ib4c9bd5e3b6a56c489149779208a1461692538ac
Signed-off-by: James Simmons <jsimmons@infradead.org>
Reviewed-on: https://review.whamcloud.com/c/fs/lustre-release/+/56665
Tested-by: jenkins <devops@whamcloud.com>
Tested-by: Maloo <maloo@whamcloud.com>
Reviewed-by: Andreas Dilger <adilger@whamcloud.com>
Reviewed-by: Arshad Hussain <arshad.hussain@aeoncomputing.com>
Reviewed-by: Oleg Drokin <green@whamcloud.com>
lustre/include/lprocfs_status.h
lustre/mdc/lproc_mdc.c
lustre/obdclass/lprocfs_status.c
lustre/osc/lproc_osc.c

index 8dbf4cf..a7ffce8 100644 (file)
@@ -922,10 +922,10 @@ ssize_t instance_show(struct kobject *kobj, struct attribute *attr,
                      char *buf);
 #endif
 /* lproc_status.c */
-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);
+ssize_t max_pages_per_rpc_show(struct kobject *kobj, struct attribute *attr,
+                              char *buf);
+ssize_t max_pages_per_rpc_store(struct kobject *kobj, struct attribute *attr,
+                               const char *buffer, size_t count);
 ssize_t short_io_bytes_show(struct kobject *kobj, struct attribute *attr,
                            char *buf);
 ssize_t short_io_bytes_store(struct kobject *kobj, struct attribute *attr,
index 1396c12..c7bcf03 100644 (file)
@@ -133,6 +133,8 @@ static ssize_t max_mod_rpcs_in_flight_store(struct kobject *kobj,
 }
 LUSTRE_RW_ATTR(max_mod_rpcs_in_flight);
 
+LUSTRE_RW_ATTR(max_pages_per_rpc);
+
 static int mdc_max_dirty_mb_seq_show(struct seq_file *m, void *v)
 {
        struct obd_device *obd = m->private;
@@ -630,7 +632,6 @@ LPROC_SEQ_FOPS_RO_TYPE(mdc, connect_flags);
 LPROC_SEQ_FOPS_RO_TYPE(mdc, server_uuid);
 LPROC_SEQ_FOPS_RO_TYPE(mdc, timeouts);
 LPROC_SEQ_FOPS_RO_TYPE(mdc, state);
-LPROC_SEQ_FOPS_RW_TYPE(mdc, obd_max_pages_per_rpc);
 LPROC_SEQ_FOPS_RW_TYPE(mdc, import);
 LPROC_SEQ_FOPS_RW_TYPE(mdc, pinger_recov);
 
@@ -639,8 +640,6 @@ struct lprocfs_vars lprocfs_mdc_obd_vars[] = {
          .fops =       &mdc_connect_flags_fops },
        { .name =       "mds_server_uuid",
          .fops =       &mdc_server_uuid_fops   },
-       { .name =       "max_pages_per_rpc",
-         .fops =       &mdc_obd_max_pages_per_rpc_fops },
        { .name =       "max_dirty_mb",
          .fops =       &mdc_max_dirty_mb_fops          },
        { .name =       "mdc_cached_mb",
@@ -783,6 +782,7 @@ static struct attribute *mdc_attrs[] = {
        &lustre_attr_checksum_dump.attr,
        &lustre_attr_max_rpcs_in_flight.attr,
        &lustre_attr_max_mod_rpcs_in_flight.attr,
+       &lustre_attr_max_pages_per_rpc.attr,
        &lustre_attr_mds_conn_uuid.attr,
        &lustre_attr_conn_uuid.attr,
        &lustre_attr_ping.attr,
index 6b90f7f..ce38c21 100644 (file)
@@ -2456,40 +2456,33 @@ const struct sysfs_ops lustre_sysfs_ops = {
 };
 EXPORT_SYMBOL_GPL(lustre_sysfs_ops);
 
-int lprocfs_obd_max_pages_per_rpc_seq_show(struct seq_file *m, void *data)
+ssize_t max_pages_per_rpc_show(struct kobject *kobj, struct attribute *attr,
+                              char *buf)
 {
-       struct obd_device *obd = data;
+       struct obd_device *obd = container_of(kobj, struct obd_device,
+                                             obd_kset.kobj);
        struct client_obd *cli = &obd->u.cli;
+       int rc;
 
        spin_lock(&cli->cl_loi_list_lock);
-       seq_printf(m, "%d\n", cli->cl_max_pages_per_rpc);
+       rc = scnprintf(buf, PAGE_SIZE, "%u\n", cli->cl_max_pages_per_rpc);
        spin_unlock(&cli->cl_loi_list_lock);
-       return 0;
+       return rc;
 }
-EXPORT_SYMBOL(lprocfs_obd_max_pages_per_rpc_seq_show);
+EXPORT_SYMBOL(max_pages_per_rpc_show);
 
-ssize_t lprocfs_obd_max_pages_per_rpc_seq_write(struct file *file,
-                                               const char __user *buffer,
-                                               size_t count, loff_t *off)
+ssize_t max_pages_per_rpc_store(struct kobject *kobj, struct attribute *attr,
+                               const char *buffer, size_t count)
 {
-       struct seq_file *m = file->private_data;
-       struct obd_device *obd = m->private;
+       struct obd_device *obd = container_of(kobj, struct obd_device,
+                                             obd_kset.kobj);
        struct client_obd *cli = &obd->u.cli;
        struct obd_import *imp;
        struct obd_connect_data *ocd;
        int chunk_mask, rc;
-       char kernbuf[22];
        u64 val;
 
-       if (count > sizeof(kernbuf) - 1)
-               return -EINVAL;
-
-       if (copy_from_user(kernbuf, buffer, count))
-               return -EFAULT;
-
-       kernbuf[count] = '\0';
-
-       rc = sysfs_memparse(kernbuf, count, &val, "B");
+       rc = sysfs_memparse(buffer, count, &val, "B");
        if (rc)
                return rc;
 
@@ -2515,7 +2508,7 @@ ssize_t lprocfs_obd_max_pages_per_rpc_seq_write(struct file *file,
 
        return rc ?: count;
 }
-EXPORT_SYMBOL(lprocfs_obd_max_pages_per_rpc_seq_write);
+EXPORT_SYMBOL(max_pages_per_rpc_store);
 
 ssize_t short_io_bytes_show(struct kobject *kobj, struct attribute *attr,
                            char *buf)
index dbe715d..5f64cdf 100644 (file)
@@ -586,8 +586,7 @@ static ssize_t destroys_in_flight_show(struct kobject *kobj,
 }
 LUSTRE_RO_ATTR(destroys_in_flight);
 
-LPROC_SEQ_FOPS_RW_TYPE(osc, obd_max_pages_per_rpc);
-
+LUSTRE_RW_ATTR(max_pages_per_rpc);
 LUSTRE_RW_ATTR(short_io_bytes);
 
 #ifdef CONFIG_PROC_FS
@@ -742,8 +741,6 @@ struct lprocfs_vars lprocfs_osc_obd_vars[] = {
          .fops =       &osc_connect_flags_fops         },
        { .name =       "ost_server_uuid",
          .fops =       &osc_server_uuid_fops           },
-       { .name =       "max_pages_per_rpc",
-         .fops =       &osc_obd_max_pages_per_rpc_fops },
        { .name =       "osc_cached_mb",
          .fops =       &osc_cached_mb_fops             },
        { .name =       "osc_unevict_cached_mb",
@@ -941,6 +938,7 @@ static struct attribute *osc_attrs[] = {
        &lustre_attr_destroys_in_flight.attr,
        &lustre_attr_grant_shrink_interval.attr,
        &lustre_attr_max_dirty_mb.attr,
+       &lustre_attr_max_pages_per_rpc.attr,
        &lustre_attr_max_rpcs_in_flight.attr,
        &lustre_attr_short_io_bytes.attr,
        &lustre_attr_resend_count.attr,