From 6cbb4aa65d9538814c0a761041ae34cbf1c3d524 Mon Sep 17 00:00:00 2001 From: James Simmons Date: Fri, 11 Oct 2024 14:22:23 -0400 Subject: [PATCH] LU-8066 sysfs: migrate pinger_recov to sys/fs tree The pinger_recov file is simple so the logical place is sys/fs which is accessible to everyone. Change-Id: I1117c4bd54aa4941f3ff66acfca422cc83a54088 Signed-off-by: James Simmons Reviewed-on: https://review.whamcloud.com/c/fs/lustre-release/+/56666 Tested-by: jenkins Tested-by: Maloo Reviewed-by: Andreas Dilger Reviewed-by: Arshad Hussain Reviewed-by: Oleg Drokin --- lustre/include/lprocfs_status.h | 22 ++++------------------ lustre/mdc/lproc_mdc.c | 5 ++--- lustre/osc/lproc_osc.c | 6 ++---- lustre/ptlrpc/lproc_ptlrpc.c | 24 +++++++++++++----------- 4 files changed, 21 insertions(+), 36 deletions(-) diff --git a/lustre/include/lprocfs_status.h b/lustre/include/lprocfs_status.h index a7ffce8..f7b9f6d 100644 --- a/lustre/include/lprocfs_status.h +++ b/lustre/include/lprocfs_status.h @@ -634,11 +634,10 @@ lprocfs_import_seq_write(struct file *file, const char __user *buffer, { return ldebugfs_import_seq_write(file, buffer, count, off); } - -extern int lprocfs_pinger_recov_seq_show(struct seq_file *m, void *data); -extern ssize_t -lprocfs_pinger_recov_seq_write(struct file *file, const char __user *buffer, - size_t count, loff_t *off); +ssize_t pinger_recov_show(struct kobject *kobj, struct attribute *attr, + char *buf); +ssize_t pinger_recov_store(struct kobject *kobj, struct attribute *attr, + const char *buffer, size_t count); int string_to_size(u64 *size, const char *buffer, size_t count); int sysfs_memparse_total(const char *buffer, size_t count, u64 *val, @@ -1173,19 +1172,6 @@ lprocfs_import_seq_write(struct file *file, const char __user *buffer, return 0; } -static inline int -lprocfs_pinger_recov_seq_show(struct seq_file *m, void *data) -{ - return 0; -} - -static inline ssize_t -lprocfs_pinger_recov_seq_write(struct file *file, const char __user *buffer, - size_t count, loff_t *off) -{ - return 0; -} - /* Statfs helpers */ static inline int lprocfs_blksize_seq_show(struct seq_file *m, void *data) diff --git a/lustre/mdc/lproc_mdc.c b/lustre/mdc/lproc_mdc.c index c7bcf03..035ff6b 100644 --- a/lustre/mdc/lproc_mdc.c +++ b/lustre/mdc/lproc_mdc.c @@ -306,6 +306,7 @@ LUSTRE_RW_ATTR(checksum_dump); LUSTRE_ATTR(mds_conn_uuid, 0444, conn_uuid_show, NULL); LUSTRE_RO_ATTR(conn_uuid); +LUSTRE_RW_ATTR(pinger_recov); LUSTRE_RW_ATTR(ping); static int mdc_cached_mb_seq_show(struct seq_file *m, void *v) @@ -633,7 +634,6 @@ 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, import); -LPROC_SEQ_FOPS_RW_TYPE(mdc, pinger_recov); struct lprocfs_vars lprocfs_mdc_obd_vars[] = { { .name = "connect_flags", @@ -652,8 +652,6 @@ struct lprocfs_vars lprocfs_mdc_obd_vars[] = { .fops = &mdc_import_fops }, { .name = "state", .fops = &mdc_state_fops }, - { .name = "pinger_recov", - .fops = &mdc_pinger_recov_fops }, { .name = "rpc_stats", .fops = &mdc_rpc_stats_fops }, { .name = "batch_stats", @@ -785,6 +783,7 @@ static struct attribute *mdc_attrs[] = { &lustre_attr_max_pages_per_rpc.attr, &lustre_attr_mds_conn_uuid.attr, &lustre_attr_conn_uuid.attr, + &lustre_attr_pinger_recov.attr, &lustre_attr_ping.attr, &lustre_attr_grant_shrink.attr, &lustre_attr_grant_shrink_interval.attr, diff --git a/lustre/osc/lproc_osc.c b/lustre/osc/lproc_osc.c index 5f64cdf..f5a829c 100644 --- a/lustre/osc/lproc_osc.c +++ b/lustre/osc/lproc_osc.c @@ -164,6 +164,7 @@ LUSTRE_RW_ATTR(max_dirty_mb); LUSTRE_ATTR(ost_conn_uuid, 0444, conn_uuid_show, NULL); LUSTRE_RO_ATTR(conn_uuid); +LUSTRE_RW_ATTR(pinger_recov); LUSTRE_RW_ATTR(ping); static int osc_cached_mb_seq_show(struct seq_file *m, void *v) @@ -732,9 +733,7 @@ LPROC_SEQ_FOPS_RO_TYPE(osc, connect_flags); LPROC_SEQ_FOPS_RO_TYPE(osc, server_uuid); LPROC_SEQ_FOPS_RO_TYPE(osc, timeouts); LPROC_SEQ_FOPS_RO_TYPE(osc, state); - LPROC_SEQ_FOPS_RW_TYPE(osc, import); -LPROC_SEQ_FOPS_RW_TYPE(osc, pinger_recov); struct lprocfs_vars lprocfs_osc_obd_vars[] = { { .name = "connect_flags", @@ -755,8 +754,6 @@ struct lprocfs_vars lprocfs_osc_obd_vars[] = { .fops = &osc_import_fops }, { .name = "state", .fops = &osc_state_fops }, - { .name = "pinger_recov", - .fops = &osc_pinger_recov_fops }, { .name = "unstable_stats", .fops = &osc_unstable_stats_fops }, { NULL } @@ -944,6 +941,7 @@ static struct attribute *osc_attrs[] = { &lustre_attr_resend_count.attr, &lustre_attr_ost_conn_uuid.attr, &lustre_attr_conn_uuid.attr, + &lustre_attr_pinger_recov.attr, &lustre_attr_ping.attr, &lustre_attr_idle_timeout.attr, &lustre_attr_idle_connect.attr, diff --git a/lustre/ptlrpc/lproc_ptlrpc.c b/lustre/ptlrpc/lproc_ptlrpc.c index 62f1a30..589dc89 100644 --- a/lustre/ptlrpc/lproc_ptlrpc.c +++ b/lustre/ptlrpc/lproc_ptlrpc.c @@ -1442,30 +1442,32 @@ out: } EXPORT_SYMBOL(ldebugfs_import_seq_write); -int lprocfs_pinger_recov_seq_show(struct seq_file *m, void *n) +ssize_t pinger_recov_show(struct kobject *kobj, struct attribute *attr, + char *buf) { - struct obd_device *obd = m->private; + struct obd_device *obd = container_of(kobj, struct obd_device, + obd_kset.kobj); struct obd_import *imp; int rc; with_imp_locked(obd, imp, rc) - seq_printf(m, "%d\n", !imp->imp_no_pinger_recover); + rc = scnprintf(buf, PAGE_SIZE, "%d\n", + !imp->imp_no_pinger_recover); return rc; } -EXPORT_SYMBOL(lprocfs_pinger_recov_seq_show); +EXPORT_SYMBOL(pinger_recov_show); -ssize_t -lprocfs_pinger_recov_seq_write(struct file *file, const char __user *buffer, - size_t count, loff_t *off) +ssize_t pinger_recov_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 obd_import *imp; bool val; int rc; - rc = kstrtobool_from_user(buffer, count, &val); + rc = kstrtobool(buffer, &val); if (rc < 0) return rc; @@ -1477,4 +1479,4 @@ lprocfs_pinger_recov_seq_write(struct file *file, const char __user *buffer, return rc ?: count; } -EXPORT_SYMBOL(lprocfs_pinger_recov_seq_write); +EXPORT_SYMBOL(pinger_recov_store); -- 1.8.3.1