From 0ff4dca9ceb2ecef8c3a03fc633b82b76bb67377 Mon Sep 17 00:00:00 2001 From: Mr NeilBrown Date: Thu, 27 Feb 2020 16:11:58 +1100 Subject: [PATCH] LU-6142 lustre: remove ldebugfs_register_stats() wrapper It was just calling debugfs_create_file() so unwind things and just call the real function instead. This ends up saving a number of lines as there was never any error handling happening anyway, so that all can be removed as well. Test-Parameters: trivial Signed-off-by: Greg Kroah-Hartman Signed-off-by: Mr NeilBrown Change-Id: I7e30139cc8e810ab4bc49ae9c298e6199c3f2942 Reviewed-on: https://review.whamcloud.com/37746 Reviewed-by: Andreas Dilger Reviewed-by: Shaun Tancheff Tested-by: jenkins Tested-by: Maloo Reviewed-by: James Simmons --- lustre/include/lprocfs_status.h | 3 +-- lustre/ldlm/ldlm_pool.c | 4 ++-- lustre/llite/lproc_llite.c | 12 ++++-------- lustre/obdclass/lprocfs_status.c | 19 ++----------------- lustre/ptlrpc/lproc_ptlrpc.c | 24 ++++++++++-------------- 5 files changed, 19 insertions(+), 43 deletions(-) diff --git a/lustre/include/lprocfs_status.h b/lustre/include/lprocfs_status.h index 485cab9..14a080f 100644 --- a/lustre/include/lprocfs_status.h +++ b/lustre/include/lprocfs_status.h @@ -516,8 +516,7 @@ lprocfs_nid_stats_clear_seq_write(struct file *file, const char __user *buffer, size_t count, loff_t *off); extern int lprocfs_nid_stats_clear_seq_show(struct seq_file *file, void *data); #endif -extern int ldebugfs_register_stats(struct dentry *parent, const char *name, - struct lprocfs_stats *stats); +extern const struct file_operations lprocfs_stats_seq_fops; extern int lprocfs_register_stats(struct proc_dir_entry *root, const char *name, struct lprocfs_stats *stats); diff --git a/lustre/ldlm/ldlm_pool.c b/lustre/ldlm/ldlm_pool.c index 3bb6fed..402d5e0 100644 --- a/lustre/ldlm/ldlm_pool.c +++ b/lustre/ldlm/ldlm_pool.c @@ -844,8 +844,8 @@ static int ldlm_pool_debugfs_init(struct ldlm_pool *pl) lprocfs_counter_init(pl->pl_stats, LDLM_POOL_TIMING_STAT, LPROCFS_CNTR_AVGMINMAX | LPROCFS_CNTR_STDDEV, "recalc_timing", "sec"); - rc = ldebugfs_register_stats(pl->pl_debugfs_entry, "stats", - pl->pl_stats); + debugfs_create_file("stats", 0644, pl->pl_debugfs_entry, + pl->pl_stats, &lprocfs_stats_seq_fops); EXIT; out: diff --git a/lustre/llite/lproc_llite.c b/lustre/llite/lproc_llite.c index d202ce0..3b7936e 100644 --- a/lustre/llite/lproc_llite.c +++ b/lustre/llite/lproc_llite.c @@ -1677,10 +1677,8 @@ int ll_debugfs_register_super(struct super_block *sb, const char *name) llite_opcode_table[id].opname, ptr); } - err = ldebugfs_register_stats(sbi->ll_debugfs_entry, "stats", - sbi->ll_stats); - if (err) - GOTO(out_stats, err); + debugfs_create_file("stats", 0644, sbi->ll_debugfs_entry, + sbi->ll_stats, &lprocfs_stats_seq_fops); sbi->ll_ra_stats = lprocfs_alloc_stats(ARRAY_SIZE(ra_stat_string), LPROCFS_STATS_FLAG_NONE); @@ -1691,10 +1689,8 @@ int ll_debugfs_register_super(struct super_block *sb, const char *name) lprocfs_counter_init(sbi->ll_ra_stats, id, 0, ra_stat_string[id], "pages"); - err = ldebugfs_register_stats(sbi->ll_debugfs_entry, "read_ahead_stats", - sbi->ll_ra_stats); - if (err) - GOTO(out_ra_stats, err); + debugfs_create_file("read_ahead_stats", 0644, sbi->ll_debugfs_entry, + sbi->ll_ra_stats, &lprocfs_stats_seq_fops); out_ll_kset: /* Yes we also register sysfs mount kset here as well */ diff --git a/lustre/obdclass/lprocfs_status.c b/lustre/obdclass/lprocfs_status.c index 2564467..780ab60 100644 --- a/lustre/obdclass/lprocfs_status.c +++ b/lustre/obdclass/lprocfs_status.c @@ -1415,7 +1415,7 @@ static int lprocfs_stats_seq_open(struct inode *inode, struct file *file) return 0; } -static const struct file_operations lprocfs_stats_seq_fops = { +const struct file_operations lprocfs_stats_seq_fops = { .owner = THIS_MODULE, .open = lprocfs_stats_seq_open, .read = seq_read, @@ -1423,22 +1423,7 @@ static const struct file_operations lprocfs_stats_seq_fops = { .llseek = seq_lseek, .release = lprocfs_seq_release, }; - -int ldebugfs_register_stats(struct dentry *parent, const char *name, - struct lprocfs_stats *stats) -{ - struct dentry *entry; - - LASSERT(!IS_ERR_OR_NULL(parent)); - - entry = debugfs_create_file(name, 0644, parent, stats, - &lprocfs_stats_seq_fops); - if (IS_ERR_OR_NULL(entry)) - return entry ? PTR_ERR(entry) : -ENOMEM; - - return 0; -} -EXPORT_SYMBOL_GPL(ldebugfs_register_stats); +EXPORT_SYMBOL(lprocfs_stats_seq_fops); int lprocfs_register_stats(struct proc_dir_entry *root, const char *name, struct lprocfs_stats *stats) diff --git a/lustre/ptlrpc/lproc_ptlrpc.c b/lustre/ptlrpc/lproc_ptlrpc.c index 8920d43..413128c 100644 --- a/lustre/ptlrpc/lproc_ptlrpc.c +++ b/lustre/ptlrpc/lproc_ptlrpc.c @@ -202,10 +202,10 @@ ptlrpc_ldebugfs_register(struct dentry *root, char *dir, char *name, struct lprocfs_stats **stats_ret) { struct dentry *svc_debugfs_entry; - struct lprocfs_stats *svc_stats; - int i, rc; - unsigned int svc_counter_config = LPROCFS_CNTR_AVGMINMAX | - LPROCFS_CNTR_STDDEV; + struct lprocfs_stats *svc_stats; + int i; + unsigned int svc_counter_config = LPROCFS_CNTR_AVGMINMAX | + LPROCFS_CNTR_STDDEV; LASSERT(!*debugfs_root_ret); LASSERT(!*stats_ret); @@ -253,16 +253,12 @@ ptlrpc_ldebugfs_register(struct dentry *root, char *dir, char *name, ll_opcode2str(opcode), "usec"); } - rc = ldebugfs_register_stats(svc_debugfs_entry, name, svc_stats); - if (rc < 0) { - if (dir) - debugfs_remove_recursive(svc_debugfs_entry); - lprocfs_free_stats(&svc_stats); - } else { - if (dir) - *debugfs_root_ret = svc_debugfs_entry; - *stats_ret = svc_stats; - } + debugfs_create_file(name, 0644, svc_debugfs_entry, svc_stats, + &lprocfs_stats_seq_fops); + + if (dir) + *debugfs_root_ret = svc_debugfs_entry; + *stats_ret = svc_stats; } static int -- 1.8.3.1