From a25c846ebf39ef3b316c80aa1ec75224fdb9df39 Mon Sep 17 00:00:00 2001 From: James Simmons Date: Fri, 11 Oct 2024 08:24:00 -0600 Subject: [PATCH] LU-8066 sysfs: migrate max_pages_per_rpc to sysfs tree 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 Reviewed-on: https://review.whamcloud.com/c/fs/lustre-release/+/56665 Tested-by: jenkins Tested-by: Maloo Reviewed-by: Andreas Dilger Reviewed-by: Arshad Hussain Reviewed-by: Oleg Drokin --- lustre/include/lprocfs_status.h | 8 ++++---- lustre/mdc/lproc_mdc.c | 6 +++--- lustre/obdclass/lprocfs_status.c | 35 ++++++++++++++--------------------- lustre/osc/lproc_osc.c | 6 ++---- 4 files changed, 23 insertions(+), 32 deletions(-) diff --git a/lustre/include/lprocfs_status.h b/lustre/include/lprocfs_status.h index 8dbf4cf..a7ffce8 100644 --- a/lustre/include/lprocfs_status.h +++ b/lustre/include/lprocfs_status.h @@ -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, diff --git a/lustre/mdc/lproc_mdc.c b/lustre/mdc/lproc_mdc.c index 1396c12..c7bcf03 100644 --- a/lustre/mdc/lproc_mdc.c +++ b/lustre/mdc/lproc_mdc.c @@ -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, diff --git a/lustre/obdclass/lprocfs_status.c b/lustre/obdclass/lprocfs_status.c index 6b90f7f..ce38c21 100644 --- a/lustre/obdclass/lprocfs_status.c +++ b/lustre/obdclass/lprocfs_status.c @@ -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) diff --git a/lustre/osc/lproc_osc.c b/lustre/osc/lproc_osc.c index dbe715d..5f64cdf 100644 --- a/lustre/osc/lproc_osc.c +++ b/lustre/osc/lproc_osc.c @@ -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, -- 1.8.3.1