From: minwoo.im.dev@gmail.com (Minwoo Im)
Subject: [PATCH V6 6/6] fabrics: Return errno mapped for fabrics error status
Date: Wed, 5 Jun 2019 00:40:34 +0900 [thread overview]
Message-ID: <20190604154034.23386-7-minwoo.im.dev@gmail.com> (raw)
In-Reply-To: <20190604154034.23386-1-minwoo.im.dev@gmail.com>
If discover has been failed due to a nvme status, it will be returned to
main() with mapped value for fabrics get log page command.
Now connect command related status cannot be added in this patch because
kernel is not currently returning the nvme status, it's instead
returning -EIO if fails. errno for connect command can be added once
kernel is ready to return the proper value for nvme status.
Cc: Keith Busch <kbusch at kernel.org>
Cc: Chaitanya Kulkarni <chaitanya.Kulkarni at wdc.com>
Cc: Sagi Grimberg <sagi at grimberg.me>
Signed-off-by: Minwoo Im <minwoo.im.dev at gmail.com>
---
fabrics.c | 19 +++++++++++++------
1 file changed, 13 insertions(+), 6 deletions(-)
diff --git a/fabrics.c b/fabrics.c
index 7be7f59..81c2d9d 100644
--- a/fabrics.c
+++ b/fabrics.c
@@ -35,6 +35,7 @@
#include "parser.h"
#include "nvme-ioctl.h"
+#include "nvme-status.h"
#include "fabrics.h"
#include "nvme.h"
@@ -295,7 +296,7 @@ enum {
};
static int nvmf_get_log_page_discovery(const char *dev_path,
- struct nvmf_disc_rsp_page_hdr **logp, int *numrec)
+ struct nvmf_disc_rsp_page_hdr **logp, int *numrec, int *status)
{
struct nvmf_disc_rsp_page_hdr *log;
unsigned int hdr_size;
@@ -400,6 +401,7 @@ out_free_log:
out_close:
close(fd);
out:
+ *status = nvme_status_to_errno(error, true);
return error;
}
@@ -849,6 +851,7 @@ static int do_discover(char *argstr, bool connect)
struct nvmf_disc_rsp_page_hdr *log = NULL;
char *dev_name;
int instance, numrec = 0, ret, err;
+ int status = 0;
instance = add_ctrl(argstr);
if (instance < 0)
@@ -856,7 +859,7 @@ static int do_discover(char *argstr, bool connect)
if (asprintf(&dev_name, "/dev/nvme%d", instance) < 0)
return -errno;
- ret = nvmf_get_log_page_discovery(dev_name, &log, &numrec);
+ ret = nvmf_get_log_page_discovery(dev_name, &log, &numrec, &status);
free(dev_name);
err = remove_ctrl(instance);
if (err)
@@ -874,9 +877,11 @@ static int do_discover(char *argstr, bool connect)
case DISC_GET_NUMRECS:
fprintf(stderr,
"Get number of discovery log entries failed.\n");
+ ret = status;
break;
case DISC_GET_LOG:
fprintf(stderr, "Get discovery log entries failed.\n");
+ ret = status;
break;
case DISC_NO_LOG:
fprintf(stdout, "No discovery log entries to fetch.\n");
@@ -885,6 +890,7 @@ static int do_discover(char *argstr, bool connect)
case DISC_NOT_EQUAL:
fprintf(stderr,
"Numrec values of last two get discovery log page not equal\n");
+ ret = DISC_OK;
break;
default:
fprintf(stderr, "Get discovery log page failed: %d\n", ret);
@@ -1000,7 +1006,7 @@ int discover(const char *desc, int argc, char **argv, bool connect)
}
out:
- return ret;
+ return nvme_status_to_errno(ret, true);
}
int connect(const char *desc, int argc, char **argv)
@@ -1047,8 +1053,9 @@ int connect(const char *desc, int argc, char **argv)
instance = add_ctrl(argstr);
if (instance < 0)
ret = instance;
+
out:
- return ret;
+ return nvme_status_to_errno(ret, true);
}
static int scan_sys_nvme_filter(const struct dirent *d)
@@ -1181,7 +1188,7 @@ int disconnect(const char *desc, int argc, char **argv)
}
out:
- return ret;
+ return nvme_status_to_errno(ret, true);
}
int disconnect_all(const char *desc, int argc, char **argv)
@@ -1212,5 +1219,5 @@ int disconnect_all(const char *desc, int argc, char **argv)
}
}
out:
- return ret;
+ return nvme_status_to_errno(ret, true);
}
--
2.21.0
next prev parent reply other threads:[~2019-06-04 15:40 UTC|newest]
Thread overview: 22+ messages / expand[flat|nested] mbox.gz Atom feed top
2019-06-04 15:40 [PATCH V6 0/6] nvme-cli: Introduce nvme-status mapping with errno Minwoo Im
2019-06-04 15:40 ` [PATCH V6 1/6] nvme: Do not return in the middle of the subcommand Minwoo Im
2019-06-08 19:16 ` Chaitanya Kulkarni
2019-06-08 19:48 ` Minwoo Im
2019-06-08 20:00 ` Chaitanya Kulkarni
2019-06-04 15:40 ` [PATCH V6 2/6] fabrics: " Minwoo Im
2019-06-08 19:19 ` Chaitanya Kulkarni
2019-06-04 15:40 ` [PATCH V6 3/6] nvme: Return negative error value for internal errors Minwoo Im
2019-06-04 15:40 ` [PATCH V6 4/6] nvme-status: Introduce nvme status module to map errno Minwoo Im
2019-06-04 15:40 ` [PATCH V6 5/6] nvme: Return errno mapped for nvme error status Minwoo Im
2019-06-04 15:40 ` Minwoo Im [this message]
2019-06-08 19:36 ` [PATCH V6 6/6] fabrics: Return errno mapped for fabrics " Chaitanya Kulkarni
2019-06-08 20:01 ` Minwoo Im
2019-06-08 20:13 ` Chaitanya Kulkarni
2019-06-10 9:17 ` Minwoo Im
2019-06-10 9:26 ` Minwoo Im
2019-06-11 0:01 ` Sagi Grimberg
2019-06-11 5:13 ` Minwoo Im
2019-06-11 17:36 ` Sagi Grimberg
2019-06-12 12:26 ` Minwoo Im
2019-06-17 17:39 ` Sagi Grimberg
2019-06-18 4:17 ` Minwoo Im
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20190604154034.23386-7-minwoo.im.dev@gmail.com \
--to=minwoo.im.dev@gmail.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).