File 0032-nvme-cli-Add-rae-argument-to-nvme_get_log.patch of Package nvme-cli.10193
From d729874ac26aea5be18d8f98feaf839b2092045e Mon Sep 17 00:00:00 2001
From: Hannes Reinecke <hare@suse.de>
Date: Thu, 20 Sep 2018 11:09:38 +0200
Subject: nvme-cli: Add 'rae' argument to nvme_get_log()
Git-commit: 181c469e27cf95bf0a71a7cddbf4b176127f52c0
References: bsc#1076004
We should be setting the 'rae' bit when sending a log page; we don't
want to accidentally overwriting any outstanding AENs when calling
nvme-cli.
Signed-off-by: Hannes Reinecke <hare@suse.com>
---
intel-nvme.c | 12 ++++++++----
memblaze-nvme.c | 3 ++-
nvme-ioctl.c | 16 ++++++++++------
nvme-ioctl.h | 3 ++-
wdc-nvme.c | 2 +-
5 files changed, 23 insertions(+), 13 deletions(-)
diff --git a/intel-nvme.c b/intel-nvme.c
index 7bc06e4..57c7479 100644
--- a/intel-nvme.c
+++ b/intel-nvme.c
@@ -161,7 +161,8 @@ static int get_additional_smart_log(int argc, char **argv, struct command *cmd,
fd = parse_and_open(argc, argv, desc, command_line_options, &cfg, sizeof(cfg));
- err = nvme_get_log(fd, cfg.namespace_id, 0xca, sizeof(smart_log), &smart_log);
+ err = nvme_get_log(fd, cfg.namespace_id, 0xca, false,
+ sizeof(smart_log), &smart_log);
if (!err) {
if (!cfg.raw_binary)
show_intel_smart_log(&smart_log, cfg.namespace_id, devicename);
@@ -195,7 +196,8 @@ static int get_market_log(int argc, char **argv, struct command *cmd, struct plu
fd = parse_and_open(argc, argv, desc, command_line_options, &cfg, sizeof(cfg));
- err = nvme_get_log(fd, NVME_NSID_ALL, 0xdd, sizeof(log), log);
+ err = nvme_get_log(fd, NVME_NSID_ALL, 0xdd, false,
+ sizeof(log), log);
if (!err) {
if (!cfg.raw_binary)
printf("Intel Marketing Name Log:\n%s\n", log);
@@ -255,7 +257,8 @@ static int get_temp_stats_log(int argc, char **argv, struct command *cmd, struct
fd = parse_and_open(argc, argv, desc, command_line_options, &cfg, sizeof(cfg));
- err = nvme_get_log(fd, NVME_NSID_ALL, 0xc5, sizeof(stats), &stats);
+ err = nvme_get_log(fd, NVME_NSID_ALL, 0xc5, false,
+ sizeof(stats), &stats);
if (!err) {
if (!cfg.raw_binary)
show_temp_stats(&stats);
@@ -321,7 +324,8 @@ static int get_lat_stats_log(int argc, char **argv, struct command *cmd, struct
fd = parse_and_open(argc, argv, desc, command_line_options, &cfg, sizeof(cfg));
- err = nvme_get_log(fd, NVME_NSID_ALL, cfg.write ? 0xc2 : 0xc1, sizeof(stats), &stats);
+ err = nvme_get_log(fd, NVME_NSID_ALL, cfg.write ? 0xc2 : 0xc1,
+ false, sizeof(stats), &stats);
if (!err) {
if (!cfg.raw_binary)
show_lat_stats(&stats, cfg.write);
diff --git a/memblaze-nvme.c b/memblaze-nvme.c
index 1e092db..fb371f3 100644
--- a/memblaze-nvme.c
+++ b/memblaze-nvme.c
@@ -223,7 +223,8 @@ static int get_additional_smart_log(int argc, char **argv, struct command *cmd,
fd = parse_and_open(argc, argv, desc, command_line_options, &cfg, sizeof(cfg));
- err = nvme_get_log(fd, cfg.namespace_id, 0xca, sizeof(smart_log), &smart_log);
+ err = nvme_get_log(fd, cfg.namespace_id, 0xca, false,
+ sizeof(smart_log), &smart_log);
if (!err) {
if (!cfg.raw_binary)
err = show_memblaze_smart_log(fd, cfg.namespace_id, devicename, &smart_log);
diff --git a/nvme-ioctl.c b/nvme-ioctl.c
index 11e81d1..7b05a17 100644
--- a/nvme-ioctl.c
+++ b/nvme-ioctl.c
@@ -394,7 +394,8 @@ int nvme_get_log13(int fd, __u32 nsid, __u8 log_id, __u8 lsp, __u64 lpo,
}
-int nvme_get_log(int fd, __u32 nsid, __u8 log_id, __u32 data_len, void *data)
+int nvme_get_log(int fd, __u32 nsid, __u8 log_id, bool rae,
+ __u32 data_len, void *data)
{
void *ptr = data;
__u32 offset = 0, xfer_len = data_len;
@@ -411,7 +412,7 @@ int nvme_get_log(int fd, __u32 nsid, __u8 log_id, __u32 data_len, void *data)
xfer_len = 4096;
ret = nvme_get_log13(fd, nsid, log_id, NVME_NO_LOG_LSP,
- offset, 0, false, xfer_len, ptr);
+ offset, 0, rae, xfer_len, ptr);
if (ret)
return ret;
@@ -424,22 +425,25 @@ int nvme_get_log(int fd, __u32 nsid, __u8 log_id, __u32 data_len, void *data)
int nvme_fw_log(int fd, struct nvme_firmware_log_page *fw_log)
{
- return nvme_get_log(fd, NVME_NSID_ALL, NVME_LOG_FW_SLOT, sizeof(*fw_log), fw_log);
+ return nvme_get_log(fd, NVME_NSID_ALL, NVME_LOG_FW_SLOT, true,
+ sizeof(*fw_log), fw_log);
}
int nvme_error_log(int fd, int entries, struct nvme_error_log_page *err_log)
{
- return nvme_get_log(fd, NVME_NSID_ALL, NVME_LOG_ERROR, entries * sizeof(*err_log), err_log);
+ return nvme_get_log(fd, NVME_NSID_ALL, NVME_LOG_ERROR, false,
+ entries * sizeof(*err_log), err_log);
}
int nvme_smart_log(int fd, __u32 nsid, struct nvme_smart_log *smart_log)
{
- return nvme_get_log(fd, nsid, NVME_LOG_SMART, sizeof(*smart_log), smart_log);
+ return nvme_get_log(fd, nsid, NVME_LOG_SMART, false,
+ sizeof(*smart_log), smart_log);
}
int nvme_discovery_log(int fd, struct nvmf_disc_rsp_page_hdr *log, __u32 size)
{
- return nvme_get_log(fd, 0, NVME_LOG_DISC, size, log);
+ return nvme_get_log(fd, 0, NVME_LOG_DISC, true, size, log);
}
int nvme_feature(int fd, __u8 opcode, __u32 nsid, __u32 cdw10, __u32 cdw11,
diff --git a/nvme-ioctl.h b/nvme-ioctl.h
index e86a577..94e93f8 100644
--- a/nvme-ioctl.h
+++ b/nvme-ioctl.h
@@ -80,7 +80,8 @@ int nvme_identify_ctrl_list(int fd, __u32 nsid, __u16 cntid, void *data);
int nvme_identify_ns_descs(int fd, __u32 nsid, void *data);
int nvme_get_log13(int fd, __u32 nsid, __u8 log_id, __u8 lsp, __u64 lpo,
__u16 group_id, bool rae, __u32 data_len, void *data);
-int nvme_get_log(int fd, __u32 nsid, __u8 log_id, __u32 data_len, void *data);
+int nvme_get_log(int fd, __u32 nsid, __u8 log_id, bool rae,
+ __u32 data_len, void *data);
int nvme_fw_log(int fd, struct nvme_firmware_log_page *fw_log);
diff --git a/wdc-nvme.c b/wdc-nvme.c
index 6baf857..87acc63 100644
--- a/wdc-nvme.c
+++ b/wdc-nvme.c
@@ -873,7 +873,7 @@ static int wdc_smart_log_add(int argc, char **argv, struct command *command,
memset(data, 0, sizeof (__u8) * WDC_ADD_LOG_BUF_LEN);
ret = nvme_get_log(fd, 0x01, WDC_NVME_ADD_LOG_OPCODE,
- WDC_ADD_LOG_BUF_LEN, data);
+ false, WDC_ADD_LOG_BUF_LEN, data);
fprintf(stderr, "NVMe Status:%s(%x)\n", nvme_status_to_string(ret), ret);
if (ret == 0) {
l = (struct wdc_log_page_header*)data;
--
2.13.7