OSDN Git Service

block: drbd: no need to check return value of debugfs_create functions
authorGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Tue, 18 Jun 2019 15:45:49 +0000 (17:45 +0200)
committerJens Axboe <axboe@kernel.dk>
Thu, 20 Jun 2019 09:28:16 +0000 (03:28 -0600)
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.

Cc: Philipp Reisner <philipp.reisner@linbit.com>
Cc: Lars Ellenberg <lars.ellenberg@linbit.com>
Cc: Jens Axboe <axboe@kernel.dk>
Cc: drbd-dev@lists.linbit.com
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Signed-off-by: Jens Axboe <axboe@kernel.dk>
drivers/block/drbd/drbd_debugfs.c
drivers/block/drbd/drbd_debugfs.h
drivers/block/drbd/drbd_main.c

index f13b48f..b3b9cd5 100644 (file)
@@ -465,35 +465,20 @@ static const struct file_operations in_flight_summary_fops = {
 void drbd_debugfs_resource_add(struct drbd_resource *resource)
 {
        struct dentry *dentry;
-       if (!drbd_debugfs_resources)
-               return;
 
        dentry = debugfs_create_dir(resource->name, drbd_debugfs_resources);
-       if (IS_ERR_OR_NULL(dentry))
-               goto fail;
        resource->debugfs_res = dentry;
 
        dentry = debugfs_create_dir("volumes", resource->debugfs_res);
-       if (IS_ERR_OR_NULL(dentry))
-               goto fail;
        resource->debugfs_res_volumes = dentry;
 
        dentry = debugfs_create_dir("connections", resource->debugfs_res);
-       if (IS_ERR_OR_NULL(dentry))
-               goto fail;
        resource->debugfs_res_connections = dentry;
 
        dentry = debugfs_create_file("in_flight_summary", 0440,
                                     resource->debugfs_res, resource,
                                     &in_flight_summary_fops);
-       if (IS_ERR_OR_NULL(dentry))
-               goto fail;
        resource->debugfs_res_in_flight_summary = dentry;
-       return;
-
-fail:
-       drbd_debugfs_resource_cleanup(resource);
-       drbd_err(resource, "failed to create debugfs dentry\n");
 }
 
 static void drbd_debugfs_remove(struct dentry **dp)
@@ -636,35 +621,22 @@ void drbd_debugfs_connection_add(struct drbd_connection *connection)
 {
        struct dentry *conns_dir = connection->resource->debugfs_res_connections;
        struct dentry *dentry;
-       if (!conns_dir)
-               return;
 
        /* Once we enable mutliple peers,
         * these connections will have descriptive names.
         * For now, it is just the one connection to the (only) "peer". */
        dentry = debugfs_create_dir("peer", conns_dir);
-       if (IS_ERR_OR_NULL(dentry))
-               goto fail;
        connection->debugfs_conn = dentry;
 
        dentry = debugfs_create_file("callback_history", 0440,
                                     connection->debugfs_conn, connection,
                                     &connection_callback_history_fops);
-       if (IS_ERR_OR_NULL(dentry))
-               goto fail;
        connection->debugfs_conn_callback_history = dentry;
 
        dentry = debugfs_create_file("oldest_requests", 0440,
                                     connection->debugfs_conn, connection,
                                     &connection_oldest_requests_fops);
-       if (IS_ERR_OR_NULL(dentry))
-               goto fail;
        connection->debugfs_conn_oldest_requests = dentry;
-       return;
-
-fail:
-       drbd_debugfs_connection_cleanup(connection);
-       drbd_err(connection, "failed to create debugfs dentry\n");
 }
 
 void drbd_debugfs_connection_cleanup(struct drbd_connection *connection)
@@ -809,8 +781,6 @@ void drbd_debugfs_device_add(struct drbd_device *device)
 
        snprintf(vnr_buf, sizeof(vnr_buf), "%u", device->vnr);
        dentry = debugfs_create_dir(vnr_buf, vols_dir);
-       if (IS_ERR_OR_NULL(dentry))
-               goto fail;
        device->debugfs_vol = dentry;
 
        snprintf(minor_buf, sizeof(minor_buf), "%u", device->minor);
@@ -819,18 +789,14 @@ void drbd_debugfs_device_add(struct drbd_device *device)
        if (!slink_name)
                goto fail;
        dentry = debugfs_create_symlink(minor_buf, drbd_debugfs_minors, slink_name);
+       device->debugfs_minor = dentry;
        kfree(slink_name);
        slink_name = NULL;
-       if (IS_ERR_OR_NULL(dentry))
-               goto fail;
-       device->debugfs_minor = dentry;
 
 #define DCF(name)      do {                                    \
        dentry = debugfs_create_file(#name, 0440,       \
                        device->debugfs_vol, device,            \
                        &device_ ## name ## _fops);             \
-       if (IS_ERR_OR_NULL(dentry))                             \
-               goto fail;                                      \
        device->debugfs_vol_ ## name = dentry;                  \
        } while (0)
 
@@ -864,19 +830,9 @@ void drbd_debugfs_peer_device_add(struct drbd_peer_device *peer_device)
        struct dentry *dentry;
        char vnr_buf[8];
 
-       if (!conn_dir)
-               return;
-
        snprintf(vnr_buf, sizeof(vnr_buf), "%u", peer_device->device->vnr);
        dentry = debugfs_create_dir(vnr_buf, conn_dir);
-       if (IS_ERR_OR_NULL(dentry))
-               goto fail;
        peer_device->debugfs_peer_dev = dentry;
-       return;
-
-fail:
-       drbd_debugfs_peer_device_cleanup(peer_device);
-       drbd_err(peer_device, "failed to create debugfs entries\n");
 }
 
 void drbd_debugfs_peer_device_cleanup(struct drbd_peer_device *peer_device)
@@ -917,35 +873,19 @@ void drbd_debugfs_cleanup(void)
        drbd_debugfs_remove(&drbd_debugfs_root);
 }
 
-int __init drbd_debugfs_init(void)
+void __init drbd_debugfs_init(void)
 {
        struct dentry *dentry;
 
        dentry = debugfs_create_dir("drbd", NULL);
-       if (IS_ERR_OR_NULL(dentry))
-               goto fail;
        drbd_debugfs_root = dentry;
 
        dentry = debugfs_create_file("version", 0444, drbd_debugfs_root, NULL, &drbd_version_fops);
-       if (IS_ERR_OR_NULL(dentry))
-               goto fail;
        drbd_debugfs_version = dentry;
 
        dentry = debugfs_create_dir("resources", drbd_debugfs_root);
-       if (IS_ERR_OR_NULL(dentry))
-               goto fail;
        drbd_debugfs_resources = dentry;
 
        dentry = debugfs_create_dir("minors", drbd_debugfs_root);
-       if (IS_ERR_OR_NULL(dentry))
-               goto fail;
        drbd_debugfs_minors = dentry;
-       return 0;
-
-fail:
-       drbd_debugfs_cleanup();
-       if (dentry)
-               return PTR_ERR(dentry);
-       else
-               return -EINVAL;
 }
index 4ecfbb3..58e31ce 100644 (file)
@@ -6,7 +6,7 @@
 #include "drbd_int.h"
 
 #ifdef CONFIG_DEBUG_FS
-int __init drbd_debugfs_init(void);
+void __init drbd_debugfs_init(void);
 void drbd_debugfs_cleanup(void);
 
 void drbd_debugfs_resource_add(struct drbd_resource *resource);
@@ -22,7 +22,7 @@ void drbd_debugfs_peer_device_add(struct drbd_peer_device *peer_device);
 void drbd_debugfs_peer_device_cleanup(struct drbd_peer_device *peer_device);
 #else
 
-static inline int __init drbd_debugfs_init(void) { return -ENODEV; }
+static inline void __init drbd_debugfs_init(void) { }
 static inline void drbd_debugfs_cleanup(void) { }
 
 static inline void drbd_debugfs_resource_add(struct drbd_resource *resource) { }
index 541b31f..40edaf8 100644 (file)
@@ -3009,8 +3009,7 @@ static int __init drbd_init(void)
        spin_lock_init(&retry.lock);
        INIT_LIST_HEAD(&retry.writes);
 
-       if (drbd_debugfs_init())
-               pr_notice("failed to initialize debugfs -- will not be available\n");
+       drbd_debugfs_init();
 
        pr_info("initialized. "
               "Version: " REL_VERSION " (api:%d/proto:%d-%d)\n",