]> www.infradead.org Git - users/sagi/nvme-cli.git/commitdiff
fabrics: do not report error when no modules are loaded when disconnecting
authorDaniel Wagner <dwagner@suse.de>
Fri, 26 Jul 2024 12:20:09 +0000 (14:20 +0200)
committerDaniel Wagner <wagi@monom.org>
Mon, 29 Jul 2024 08:35:59 +0000 (10:35 +0200)
Do not report an error when the libnvme reports that the subsystem is
not available when the user tries to disconnect. This allows the user to
call disconnect without filtering this special case. The result is the
same, after this call the host is not connected anymore.

Signed-off-by: Daniel Wagner <dwagner@suse.de>
fabrics.c

index e52fcd0ab6b808ded44933fa1689bd2a6bb28c30..6e27ee3e9f5a18a6ef7a06b1cfa40aa038ba5a64 100644 (file)
--- a/fabrics.c
+++ b/fabrics.c
@@ -1106,6 +1106,14 @@ int nvmf_disconnect(const char *desc, int argc, char **argv)
        nvme_root_skip_namespaces(r);
        ret = nvme_scan_topology(r, NULL, NULL);
        if (ret < 0) {
+               /*
+                * Do not report an error when the modules are not
+                * loaded, this allows the user to unconditionally call
+                * disconnect.
+                */
+               if (errno == ENOENT)
+                       return 0;
+
                fprintf(stderr, "Failed to scan topology: %s\n",
                        nvme_strerror(errno));
                return -errno;
@@ -1174,9 +1182,16 @@ int nvmf_disconnect_all(const char *desc, int argc, char **argv)
        nvme_root_skip_namespaces(r);
        ret = nvme_scan_topology(r, NULL, NULL);
        if (ret < 0) {
-               if (errno != ENOENT)
-                       fprintf(stderr, "Failed to scan topology: %s\n",
-                               nvme_strerror(errno));
+               /*
+                * Do not report an error when the modules are not
+                * loaded, this allows the user to unconditionally call
+                * disconnect.
+                */
+               if (errno == ENOENT)
+                       return 0;
+
+               fprintf(stderr, "Failed to scan topology: %s\n",
+                       nvme_strerror(errno));
                return -errno;
        }