From: minwoo.im.dev@gmail.com (Minwoo Im)
Subject: [PATCH V4 2/3] nvme: Return errno mapped for nvme error status
Date: Wed, 22 May 2019 01:36:58 +0900 [thread overview]
Message-ID: <20190521163659.24577-3-minwoo.im.dev@gmail.com> (raw)
In-Reply-To: <20190521163659.24577-1-minwoo.im.dev@gmail.com>
If ioctl module has returned a nvme error status, it will be returned
by being converted to a mapped errno value which has been provided by
previous commits.
Cc: Keith Busch <keith.busch at intel.com>
Cc: Chaitanya Kulkarni <chaitanya.Kulkarni at wdc.com>
Signed-off-by: Minwoo Im <minwoo.im.dev at gmail.com>
---
nvme.c | 108 +++++++++++++++++++++++----------------------------------
1 file changed, 43 insertions(+), 65 deletions(-)
diff --git a/nvme.c b/nvme.c
index 9819fcb..b81b8e1 100644
--- a/nvme.c
+++ b/nvme.c
@@ -48,6 +48,7 @@
#include "common.h"
#include "nvme-print.h"
#include "nvme-ioctl.h"
+#include "nvme-status.h"
#include "nvme-lightnvm.h"
#include "plugin.h"
@@ -220,7 +221,7 @@ static int get_smart_log(int argc, char **argv, struct command *cmd, struct plug
close_fd:
close(fd);
- return err;
+ return nvme_status_to_errno(err, false);
}
static int get_ana_log(int argc, char **argv, struct command *cmd,
@@ -292,7 +293,7 @@ static int get_ana_log(int argc, char **argv, struct command *cmd,
free(ana_log);
close_fd:
close(fd);
- return err;
+ return nvme_status_to_errno(err, false);
}
static int get_telemetry_log(int argc, char **argv, struct command *cmd, struct plugin *plugin)
@@ -419,7 +420,7 @@ static int get_telemetry_log(int argc, char **argv, struct command *cmd, struct
free(page_log);
close_fd:
close(fd);
- return err;
+ return nvme_status_to_errno(err, false);
}
static int get_endurance_log(int argc, char **argv, struct command *cmd, struct plugin *plugin)
@@ -473,7 +474,7 @@ static int get_endurance_log(int argc, char **argv, struct command *cmd, struct
close_fd:
close(fd);
- return err;
+ return nvme_status_to_errno(err, false);
}
static int get_effects_log(int argc, char **argv, struct command *cmd, struct plugin *plugin)
@@ -535,7 +536,7 @@ static int get_effects_log(int argc, char **argv, struct command *cmd, struct pl
close_fd:
close(fd);
- return err;
+ return nvme_status_to_errno(err, false);
}
static int get_error_log(int argc, char **argv, struct command *cmd, struct plugin *plugin)
@@ -619,7 +620,7 @@ static int get_error_log(int argc, char **argv, struct command *cmd, struct plug
close_fd:
close(fd);
- return err;
+ return nvme_status_to_errno(err, false);
}
static int get_fw_log(int argc, char **argv, struct command *cmd, struct plugin *plugin)
@@ -673,7 +674,7 @@ static int get_fw_log(int argc, char **argv, struct command *cmd, struct plugin
close_fd:
close(fd);
- return err;
+ return nvme_status_to_errno(err, false);
}
static int get_changed_ns_list_log(int argc, char **argv, struct command *cmd, struct plugin *plugin)
@@ -728,8 +729,7 @@ static int get_changed_ns_list_log(int argc, char **argv, struct command *cmd, s
close_fd:
close(fd);
-
- return err;
+ return nvme_status_to_errno(err, false);
}
static int get_log(int argc, char **argv, struct command *cmd, struct plugin *plugin)
@@ -828,7 +828,7 @@ static int get_log(int argc, char **argv, struct command *cmd, struct plugin *pl
close_fd:
close(fd);
- return err;
+ return nvme_status_to_errno(err, false);
}
static int sanitize_log(int argc, char **argv, struct command *command, struct plugin *plugin)
@@ -890,8 +890,7 @@ static int sanitize_log(int argc, char **argv, struct command *command, struct p
close_fd:
close(fd);
-
- return ret;
+ return nvme_status_to_errno(ret, false);
}
static int list_ctrl(int argc, char **argv, struct command *cmd, struct plugin *plugin)
@@ -941,11 +940,9 @@ static int list_ctrl(int argc, char **argv, struct command *cmd, struct plugin *
perror("id controller list");
free(cntlist);
-
close_fd:
close(fd);
-
- return err;
+ return nvme_status_to_errno(err, false);
}
static int list_ns(int argc, char **argv, struct command *cmd, struct plugin *plugin)
@@ -988,8 +985,7 @@ static int list_ns(int argc, char **argv, struct command *cmd, struct plugin *pl
perror("id namespace list");
close(fd);
-
- return err;
+ return nvme_status_to_errno(err, false);
}
static int get_nsid(int fd)
@@ -1060,8 +1056,7 @@ static int delete_ns(int argc, char **argv, struct command *cmd, struct plugin *
close_fd:
close(fd);
-
- return err;
+ return nvme_status_to_errno(err, false);
}
static int nvme_attach_ns(int argc, char **argv, int attach, const char *desc, struct command *cmd)
@@ -1125,8 +1120,7 @@ static int nvme_attach_ns(int argc, char **argv, int attach, const char *desc, s
close_fd:
close(fd);
-
- return err;
+ return nvme_status_to_errno(err, false);
}
static int attach_ns(int argc, char **argv, struct command *cmd, struct plugin *plugin)
@@ -1253,8 +1247,7 @@ static int create_ns(int argc, char **argv, struct command *cmd, struct plugin *
close_fd:
close(fd);
-
- return err;
+ return nvme_status_to_errno(err, false);
}
char *nvme_char_from_block(char *block)
@@ -1867,8 +1860,7 @@ static int list(int argc, char **argv, struct command *cmd, struct plugin *plugi
for (i = 0; i < n; i++)
free(devices[i]);
free(devices);
-
- return ret;
+ return nvme_status_to_errno(ret, false);
}
int __id_ctrl(int argc, char **argv, struct command *cmd, struct plugin *plugin, void (*vs)(__u8 *vs, struct json_object *root))
@@ -1941,8 +1933,7 @@ int __id_ctrl(int argc, char **argv, struct command *cmd, struct plugin *plugin,
close_fd:
close(fd);
-
- return err;
+ return nvme_status_to_errno(err, false);
}
static int id_ctrl(int argc, char **argv, struct command *cmd, struct plugin *plugin)
@@ -2022,8 +2013,7 @@ static int ns_descs(int argc, char **argv, struct command *cmd, struct plugin *p
close_fd:
close(fd);
-
- return err;
+ return nvme_status_to_errno(err, false);
}
static int id_ns(int argc, char **argv, struct command *cmd, struct plugin *plugin)
@@ -2109,8 +2099,7 @@ static int id_ns(int argc, char **argv, struct command *cmd, struct plugin *plug
close_fd:
close(fd);
-
- return err;
+ return nvme_status_to_errno(err, false);
}
static int id_nvmset(int argc, char **argv, struct command *cmd, struct plugin *plugin)
@@ -2167,8 +2156,7 @@ static int id_nvmset(int argc, char **argv, struct command *cmd, struct plugin *
close_fd:
close(fd);
-
- return err;
+ return nvme_status_to_errno(err, false);
}
static int get_ns_id(int argc, char **argv, struct command *cmd, struct plugin *plugin)
@@ -2256,8 +2244,7 @@ static int virtual_mgmt(int argc, char **argv, struct command *cmd, struct plugi
perror("virt-mgmt");
close(fd);
- return err;
-
+ return nvme_status_to_errno(err, false);
}
static int list_secondary_ctrl(int argc, char **argv, struct command *cmd, struct plugin *plugin)
@@ -2381,7 +2368,7 @@ static int device_self_test(int argc, char **argv, struct command *cmd, struct p
perror("Device self-test");
close(fd);
- return err;
+ return nvme_status_to_errno(err, false);
}
static int self_test_log(int argc, char **argv, struct command *cmd, struct plugin *plugin)
@@ -2436,8 +2423,7 @@ static int self_test_log(int argc, char **argv, struct command *cmd, struct plug
close_fd:
close(fd);
-
- return err;
+ return nvme_status_to_errno(err, false);
}
static int get_feature(int argc, char **argv, struct command *cmd, struct plugin *plugin)
@@ -2567,8 +2553,7 @@ static int get_feature(int argc, char **argv, struct command *cmd, struct plugin
close_fd:
close(fd);
-
- return err;
+ return nvme_status_to_errno(err, false);
}
static int fw_download(int argc, char **argv, struct command *cmd, struct plugin *plugin)
@@ -2672,8 +2657,7 @@ static int fw_download(int argc, char **argv, struct command *cmd, struct plugin
close(fw_fd);
close_fd:
close(fd);
-
- return err;
+ return nvme_status_to_errno(err, false);
}
static char *nvme_fw_status_reset_type(__u32 status)
@@ -2765,8 +2749,7 @@ static int fw_commit(int argc, char **argv, struct command *cmd, struct plugin *
close_fd:
close(fd);
-
- return err;
+ return nvme_status_to_errno(err, false);
}
static int subsystem_reset(int argc, char **argv, struct command *cmd, struct plugin *plugin)
@@ -2933,8 +2916,7 @@ static int sanitize(int argc, char **argv, struct command *cmd, struct plugin *p
close_fd:
close(fd);
-
- return ret;
+ return nvme_status_to_errno(ret, false);
}
static int show_registers(int argc, char **argv, struct command *cmd, struct plugin *plugin)
@@ -3058,8 +3040,7 @@ static int get_property(int argc, char **argv, struct command *cmd, struct plugi
close_fd:
close(fd);
-
- return err;
+ return nvme_status_to_errno(err, false);
}
static int set_property(int argc, char **argv, struct command *cmd, struct plugin *plugin)
@@ -3113,8 +3094,7 @@ static int set_property(int argc, char **argv, struct command *cmd, struct plugi
close_fd:
close(fd);
-
- return err;
+ return nvme_status_to_errno(err, false);
}
static int format(int argc, char **argv, struct command *cmd, struct plugin *plugin)
@@ -3274,8 +3254,7 @@ static int format(int argc, char **argv, struct command *cmd, struct plugin *plu
close_fd:
close(fd);
-
- return err;
+ return nvme_status_to_errno(err, false);
}
static int set_feature(int argc, char **argv, struct command *cmd, struct plugin *plugin)
@@ -3394,7 +3373,7 @@ static int set_feature(int argc, char **argv, struct command *cmd, struct plugin
free(buf);
close_fd:
close(fd);
- return err;
+ return nvme_status_to_errno(err, false);
}
static int sec_send(int argc, char **argv, struct command *cmd, struct plugin *plugin)
@@ -3641,7 +3620,7 @@ free:
free(buf);
close_fd:
close(fd);
- return err;
+ return nvme_status_to_errno(err, false);
}
static int write_uncor(int argc, char **argv, struct command *cmd, struct plugin *plugin)
@@ -3695,8 +3674,7 @@ static int write_uncor(int argc, char **argv, struct command *cmd, struct plugin
close_fd:
close(fd);
-
- return err;
+ return nvme_status_to_errno(err, false);
}
static int write_zeroes(int argc, char **argv, struct command *cmd, struct plugin *plugin)
@@ -3787,7 +3765,7 @@ static int write_zeroes(int argc, char **argv, struct command *cmd, struct plugi
close_fd:
close(fd);
- return err;
+ return nvme_status_to_errno(err, false);
}
static int dsm(int argc, char **argv, struct command *cmd, struct plugin *plugin)
@@ -3887,7 +3865,7 @@ static int dsm(int argc, char **argv, struct command *cmd, struct plugin *plugin
close_fd:
close(fd);
- return err;
+ return nvme_status_to_errno(err, false);
}
static int flush(int argc, char **argv, struct command *cmd, struct plugin *plugin)
@@ -3934,7 +3912,7 @@ static int flush(int argc, char **argv, struct command *cmd, struct plugin *plug
printf("NVMe Flush: success\n");
close_fd:
close(fd);
- return err;
+ return nvme_status_to_errno(err, false);
}
static int resv_acquire(int argc, char **argv, struct command *cmd, struct plugin *plugin)
@@ -4008,7 +3986,7 @@ static int resv_acquire(int argc, char **argv, struct command *cmd, struct plugi
close_fd:
close(fd);
- return err;
+ return nvme_status_to_errno(err, false);
}
static int resv_register(int argc, char **argv, struct command *cmd, struct plugin *plugin)
@@ -4085,7 +4063,7 @@ static int resv_register(int argc, char **argv, struct command *cmd, struct plug
close_fd:
close(fd);
- return err;
+ return nvme_status_to_errno(err, false);
}
static int resv_release(int argc, char **argv, struct command *cmd, struct plugin *plugin)
@@ -4158,7 +4136,7 @@ static int resv_release(int argc, char **argv, struct command *cmd, struct plugi
close_fd:
close(fd);
- return err;
+ return nvme_status_to_errno(err, false);
}
static int resv_report(int argc, char **argv, struct command *cmd, struct plugin *plugin)
@@ -4497,7 +4475,7 @@ static int submit_io(int opcode, char *command, const char *desc,
close(dfd);
close_fd:
close(fd);
- return err;
+ return nvme_status_to_errno(err, false);
}
static int compare(int argc, char **argv, struct command *cmd, struct plugin *plugin)
@@ -4733,7 +4711,7 @@ free:
free(buf);
close_fd:
close(fd);
- return err;
+ return nvme_status_to_errno(err, false);
}
static int passthru(int argc, char **argv, int ioctl_cmd, const char *desc, struct command *cmd)
@@ -4933,7 +4911,7 @@ static int passthru(int argc, char **argv, int ioctl_cmd, const char *desc, stru
close(wfd);
close_fd:
close(fd);
- return err;
+ return nvme_status_to_errno(err, false);
}
static int io_passthru(int argc, char **argv, struct command *cmd, struct plugin *plugin)
--
2.21.0
next prev parent reply other threads:[~2019-05-21 16:36 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
[not found] <CGME20190521163721epcas4p4d6e9ae0a49fde40f38fa770406538335@epcms2p6>
2019-05-21 16:36 ` [PATCH V4 0/3] nvme-cli: Introduce nvme-status mapping with errno Minwoo Im
2019-05-21 16:36 ` [PATCH V4 1/3] nvme-status: Introduce nvme status module to map errno Minwoo Im
2019-05-21 16:36 ` Minwoo Im [this message]
2019-05-21 16:36 ` [PATCH V4 3/3] fabrics: Return errno mapped for fabrics error status Minwoo Im
2019-05-23 4:25 ` [PATCH V4 0/3] nvme-cli: Introduce nvme-status mapping with errno 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=20190521163659.24577-3-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