From: Greg Kroah-Hartman Date: Tue, 18 Jun 2019 15:45:49 +0000 (+0200) Subject: block: drbd: no need to check return value of debugfs_create functions X-Git-Url: http://git.cdn.openwrt.org/?a=commitdiff_plain;h=d27e84a305980ac61df0a6841059d0eb09b8283d;p=openwrt%2Fstaging%2Fblogic.git block: drbd: no need to check return value of debugfs_create functions 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 Cc: Lars Ellenberg Cc: Jens Axboe Cc: drbd-dev@lists.linbit.com Signed-off-by: Greg Kroah-Hartman Signed-off-by: Jens Axboe --- diff --git a/drivers/block/drbd/drbd_debugfs.c b/drivers/block/drbd/drbd_debugfs.c index f13b48ff5f43..b3b9cd5628fd 100644 --- a/drivers/block/drbd/drbd_debugfs.c +++ b/drivers/block/drbd/drbd_debugfs.c @@ -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; } diff --git a/drivers/block/drbd/drbd_debugfs.h b/drivers/block/drbd/drbd_debugfs.h index 4ecfbb3358d7..58e31cef0844 100644 --- a/drivers/block/drbd/drbd_debugfs.h +++ b/drivers/block/drbd/drbd_debugfs.h @@ -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) { } diff --git a/drivers/block/drbd/drbd_main.c b/drivers/block/drbd/drbd_main.c index 541b31fa42b3..40edaf87241c 100644 --- a/drivers/block/drbd/drbd_main.c +++ b/drivers/block/drbd/drbd_main.c @@ -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",