gfs: no need to check return value of debugfs_create functions
authorGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Tue, 22 Jan 2019 15:21:51 +0000 (16:21 +0100)
committerAndreas Gruenbacher <agruenba@redhat.com>
Wed, 23 Jan 2019 11:30:34 +0000 (12:30 +0100)
When calling debugfs functions, there is no need to ever check the
return value.  The function can work or not, but the code logic should
never do something different based on this.

There is no need to save the dentries for the debugfs files, so drop
those variables to save a bit of space and make the code simpler.

Cc: Bob Peterson <rpeterso@redhat.com>
Cc: Andreas Gruenbacher <agruenba@redhat.com>
Cc: cluster-devel@redhat.com
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Signed-off-by: Andreas Gruenbacher <agruenba@redhat.com>
fs/gfs2/glock.c
fs/gfs2/glock.h
fs/gfs2/incore.h
fs/gfs2/main.c

index b92740e..f66773c 100644 (file)
@@ -2131,71 +2131,29 @@ static const struct file_operations gfs2_sbstats_fops = {
        .release = seq_release,
 };
 
-int gfs2_create_debugfs_file(struct gfs2_sbd *sdp)
-{
-       struct dentry *dent;
-
-       dent = debugfs_create_dir(sdp->sd_table_name, gfs2_root);
-       if (IS_ERR_OR_NULL(dent))
-               goto fail;
-       sdp->debugfs_dir = dent;
-
-       dent = debugfs_create_file("glocks",
-                                  S_IFREG | S_IRUGO,
-                                  sdp->debugfs_dir, sdp,
-                                  &gfs2_glocks_fops);
-       if (IS_ERR_OR_NULL(dent))
-               goto fail;
-       sdp->debugfs_dentry_glocks = dent;
-
-       dent = debugfs_create_file("glstats",
-                                  S_IFREG | S_IRUGO,
-                                  sdp->debugfs_dir, sdp,
-                                  &gfs2_glstats_fops);
-       if (IS_ERR_OR_NULL(dent))
-               goto fail;
-       sdp->debugfs_dentry_glstats = dent;
-
-       dent = debugfs_create_file("sbstats",
-                                  S_IFREG | S_IRUGO,
-                                  sdp->debugfs_dir, sdp,
-                                  &gfs2_sbstats_fops);
-       if (IS_ERR_OR_NULL(dent))
-               goto fail;
-       sdp->debugfs_dentry_sbstats = dent;
+void gfs2_create_debugfs_file(struct gfs2_sbd *sdp)
+{
+       sdp->debugfs_dir = debugfs_create_dir(sdp->sd_table_name, gfs2_root);
 
-       return 0;
-fail:
-       gfs2_delete_debugfs_file(sdp);
-       return dent ? PTR_ERR(dent) : -ENOMEM;
+       debugfs_create_file("glocks", S_IFREG | S_IRUGO, sdp->debugfs_dir, sdp,
+                           &gfs2_glocks_fops);
+
+       debugfs_create_file("glstats", S_IFREG | S_IRUGO, sdp->debugfs_dir, sdp,
+                           &gfs2_glstats_fops);
+
+       debugfs_create_file("sbstats", S_IFREG | S_IRUGO, sdp->debugfs_dir, sdp,
+                           &gfs2_sbstats_fops);
 }
 
 void gfs2_delete_debugfs_file(struct gfs2_sbd *sdp)
 {
-       if (sdp->debugfs_dir) {
-               if (sdp->debugfs_dentry_glocks) {
-                       debugfs_remove(sdp->debugfs_dentry_glocks);
-                       sdp->debugfs_dentry_glocks = NULL;
-               }
-               if (sdp->debugfs_dentry_glstats) {
-                       debugfs_remove(sdp->debugfs_dentry_glstats);
-                       sdp->debugfs_dentry_glstats = NULL;
-               }
-               if (sdp->debugfs_dentry_sbstats) {
-                       debugfs_remove(sdp->debugfs_dentry_sbstats);
-                       sdp->debugfs_dentry_sbstats = NULL;
-               }
-               debugfs_remove(sdp->debugfs_dir);
-               sdp->debugfs_dir = NULL;
-       }
+       debugfs_remove_recursive(sdp->debugfs_dir);
+       sdp->debugfs_dir = NULL;
 }
 
-int gfs2_register_debugfs(void)
+void gfs2_register_debugfs(void)
 {
        gfs2_root = debugfs_create_dir("gfs2", NULL);
-       if (IS_ERR(gfs2_root))
-               return PTR_ERR(gfs2_root);
-       return gfs2_root ? 0 : -ENOMEM;
 }
 
 void gfs2_unregister_debugfs(void)
index 8949bf2..936b329 100644 (file)
@@ -243,9 +243,9 @@ extern void gfs2_glock_free(struct gfs2_glock *gl);
 extern int __init gfs2_glock_init(void);
 extern void gfs2_glock_exit(void);
 
-extern int gfs2_create_debugfs_file(struct gfs2_sbd *sdp);
+extern void gfs2_create_debugfs_file(struct gfs2_sbd *sdp);
 extern void gfs2_delete_debugfs_file(struct gfs2_sbd *sdp);
-extern int gfs2_register_debugfs(void);
+extern void gfs2_register_debugfs(void);
 extern void gfs2_unregister_debugfs(void);
 
 extern const struct lm_lockops gfs2_dlm_ops;
index e10e0b0..cdf07b4 100644 (file)
@@ -853,9 +853,6 @@ struct gfs2_sbd {
 
        unsigned long sd_last_warning;
        struct dentry *debugfs_dir;    /* debugfs directory */
-       struct dentry *debugfs_dentry_glocks;
-       struct dentry *debugfs_dentry_glstats;
-       struct dentry *debugfs_dentry_sbstats;
 };
 
 static inline void gfs2_glstats_inc(struct gfs2_glock *gl, int which)
index c760306..136484e 100644 (file)
@@ -178,16 +178,12 @@ static int __init init_gfs2_fs(void)
        if (!gfs2_page_pool)
                goto fail_mempool;
 
-       error = gfs2_register_debugfs();
-       if (error)
-               goto fail_debugfs;
+       gfs2_register_debugfs();
 
        pr_info("GFS2 installed\n");
 
        return 0;
 
-fail_debugfs:
-       mempool_destroy(gfs2_page_pool);
 fail_mempool:
        destroy_workqueue(gfs2_freeze_wq);
 fail_wq3: