Whamcloud - gitweb
LU-6142 lustre: remove ldebugfs_register_stats() wrapper 46/37746/6
authorMr NeilBrown <neilb@suse.de>
Thu, 27 Feb 2020 05:11:58 +0000 (16:11 +1100)
committerOleg Drokin <green@whamcloud.com>
Tue, 14 Apr 2020 08:09:31 +0000 (08:09 +0000)
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 <gregkh@linuxfoundation.org>
Signed-off-by: Mr NeilBrown <neilb@suse.de>
Change-Id: I7e30139cc8e810ab4bc49ae9c298e6199c3f2942
Reviewed-on: https://review.whamcloud.com/37746
Reviewed-by: Andreas Dilger <adilger@whamcloud.com>
Reviewed-by: Shaun Tancheff <shaun.tancheff@hpe.com>
Tested-by: jenkins <devops@whamcloud.com>
Tested-by: Maloo <maloo@whamcloud.com>
Reviewed-by: James Simmons <jsimmons@infradead.org>
lustre/include/lprocfs_status.h
lustre/ldlm/ldlm_pool.c
lustre/llite/lproc_llite.c
lustre/obdclass/lprocfs_status.c
lustre/ptlrpc/lproc_ptlrpc.c

index 485cab9..14a080f 100644 (file)
@@ -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);
 
index 3bb6fed..402d5e0 100644 (file)
@@ -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:
index d202ce0..3b7936e 100644 (file)
@@ -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 */
index 2564467..780ab60 100644 (file)
@@ -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)
index 8920d43..413128c 100644 (file)
@@ -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