Skip to contentSkip to conversation

nvme-cli: add ana-log page support

PATCH Superseded Chaitanya Kulkarni 2 participants 6 messages Aug 2, 2018 – Aug 3, 2018

Subsystems (2)

v3 of 4 Superseded Latest is v4 →

lore
Share & tools
lore
#0 lore raw

v3 cover nvme-cli: add ana-log page support

This patch series implements ANA-LOG-PAGE support for nvme-cli.

Regards,
Chaitanya

Changes since V2:-
1. Add CMIC and ANACAP decoding.
2. Incorporate comments from Hannes.

Changes since V1:-
1. Add JSON support.
2. Incorporate comments from Christoph.

Chaitanya Kulkarni (2):
nvme-cli: add minimal ana-log page support
nvme-cli: add ana-log documentation

 Documentation/nvme-ana-log.1    |  82 ++++
 Documentation/nvme-ana-log.html | 826 ++++++++++++++++++++++++++++++++
 Documentation/nvme-ana-log.txt  |  45 ++
 linux/nvme.h                    |  52 +-
 nvme-builtin.h                  |   1 +
 nvme-ioctl.c                    |   8 +
 nvme-ioctl.h                    |   1 +
 nvme-print.c                    | 170 ++++++-
 nvme-print.h                    |   2 +
 nvme.c                          |  77 +++
 10 files changed, 1257 insertions(+), 7 deletions(-)
 create mode 100644 Documentation/nvme-ana-log.1
 create mode 100644 Documentation/nvme-ana-log.html
 create mode 100644 Documentation/nvme-ana-log.txt
Signature · 1 line
2.17.0
#1 lore raw

PATCH v3 1/2 nvme-cli: add minimal ana-log page support

This patch adds a new command to retrieve the ANA Log page. We update identify ctrl/ns data structure to support this command. We also add ana based error codes and different identifiers to the linux/nvme.h header file in order to support this command.

Signed-off-by Chaitanya Kulkarni <chaitanya.kulkarni at wdc.com>
Signed-off-by Hannes Reinecke <hare at suse.com>
---
 linux/nvme.h   |  52 +++++++++++++--
 nvme-builtin.h |   1 +
 nvme-ioctl.c   |   8 +++
 nvme-ioctl.h   |   1 +
 nvme-print.c   | 170 ++++++++++++++++++++++++++++++++++++++++++++++++-
 nvme-print.h   |   2 +
 nvme.c         |  77 ++++++++++++++++++++++
 7 files changed, 304 insertions(+), 7 deletions(-)
linux/nvme.h +48 -4
index dc8ea89..ee6bcc6 100644
@@ -241,7 +241,12 @@ struct nvme_id_ctrl {
 	__le32			hmminds;
 	__le16			hmmaxd;
 	__le16			nsetidmax;
-	__u8			rsvd340[172];
+	__u8			rsvd340[2];
+	__u8			anatt;
+	__u8			anacap;
+	__le32			anagrpmax;
+	__le32			nanagrpid;
+	__u8			rsvd352[160];
 	__u8			sqes;
 	__u8			cqes;
 	__le16			maxcmd;
@@ -257,7 +262,8 @@ struct nvme_id_ctrl {
 	__le16			acwu;
 	__u8			rsvd534[2];
 	__le32			sgls;
-	__u8			rsvd540[228];
+	__le32			mnan;
+	__u8			rsvd544[224];
 	char			subnqn[256];
 	__u8			rsvd1024[768];
 	__le32			ioccsz;
@@ -317,7 +323,9 @@ struct nvme_id_ns {
 	__le16			nabspf;
 	__le16			noiob;
 	__u8			nvmcap[16];
-	__u8			rsvd64[36];
+	__u8			rsvd64[28];
+	__le32			anagrpid;
+	__u8			rsvd96[4];
 	__le16			nvmsetid;
 	__le16			endgid;
 	__u8			nguid[16];
@@ -516,6 +524,32 @@ struct nvme_effects_log {
 	__u8   resv[2048];
 };
 
+enum nvme_ana_state {
+	NVME_ANA_OPTIMIZED		= 0x01,
+	NVME_ANA_NONOPTIMIZED		= 0x02,
+	NVME_ANA_INACCESSIBLE		= 0x03,
+	NVME_ANA_PERSISTENT_LOSS	= 0x04,
+	NVME_ANA_CHANGE			= 0x0f,
+};
+
+struct nvme_ana_group_desc {
+	__le32  grpid;
+	__le32  nnsids;
+	__le64  chgcnt;
+	__u8    state;
+	__u8    rsvd17[7];
+	__le32  nsids[];
+};
+
+/* flag for the log specific field of the ANA log */
+#define NVME_ANA_LOG_RGO   (1 << 0)
+
+struct nvme_ana_rsp_hdr {
+	__le64  chgcnt;
+	__le16  ngrps;
+	__le16  rsvd10[3];
+};
+
 enum {
 	NVME_SMART_CRIT_SPARE		= 1 << 0,
 	NVME_SMART_CRIT_TEMPERATURE	= 1 << 1,
@@ -531,6 +565,7 @@ enum {
 	NVME_AER_VS			= 7,
 	NVME_AER_NOTICE_NS_CHANGED	= 0x0002,
 	NVME_AER_NOTICE_FW_ACT_STARTING = 0x0102,
+	NVME_AER_NOTICE_ANA		= 0x03,
 };
 
 struct nvme_lba_range_type {
@@ -881,6 +916,7 @@ enum {
 	NVME_LOG_TELEMETRY_HOST = 0x07,
 	NVME_LOG_TELEMETRY_CTRL = 0x08,
 	NVME_LOG_ENDURANCE_GROUP = 0x09,
+	NVME_LOG_ANA		= 0x0c,
 	NVME_LOG_DISC		= 0x70,
 	NVME_LOG_RESERVATION	= 0x80,
 	NVME_LOG_SANITIZE	= 0x81,
@@ -892,6 +928,7 @@ enum {
 enum {
 	NVME_NO_LOG_LSP       = 0x0,
 	NVME_NO_LOG_LPO       = 0x0,
+	NVME_LOG_ANA_LSP_RGO  = 0x1,
 	NVME_TELEM_LSP_CREATE = 0x1,
 };
 
@@ -1040,7 +1077,7 @@ struct nvme_get_log_page_command {
 	__u64			rsvd2[2];
 	union nvme_data_ptr	dptr;
 	__u8			lid;
-	__u8			rsvd10;
+	__u8			lsp;
 	__le16			numdl;
 	__le16			numdu;
 	__u16			rsvd11;
@@ -1354,6 +1391,13 @@ enum {
 	NVME_SC_ACCESS_DENIED		= 0x286,
 	NVME_SC_UNWRITTEN_BLOCK		= 0x287,
 
+	/*
+	 * Path-related Errors:
+	 */
+	NVME_SC_ANA_PERSISTENT_LOSS	= 0x301,
+	NVME_SC_ANA_INACCESSIBLE	= 0x302,
+	NVME_SC_ANA_TRANSITION		= 0x303,
+
 	NVME_SC_DNR			= 0x4000,
 };
 
nvme-builtin.h +1 -0
index 2c26d57..f9e47b3 100644
@@ -25,6 +25,7 @@ COMMAND_LIST(
 	ENTRY("fw-log", "Retrieve FW Log, show it", get_fw_log)
 	ENTRY("changed-ns-list-log", "Retrieve Changed Namespace List, show it", get_changed_ns_list_log)
 	ENTRY("smart-log", "Retrieve SMART Log, show it", get_smart_log)
+	ENTRY("ana-log", "Retrieve ANA Log, show it", get_ana_log)
 	ENTRY("error-log", "Retrieve Error Log, show it", get_error_log)
 	ENTRY("effects-log", "Retrieve Command Effects Log, show it", get_effects_log)
 	ENTRY("endurance-log", "Retrieve Endurance Group Log, show it", get_endurance_log)
nvme-ioctl.c +8 -0
index 9cf2a33..d63c863 100644
@@ -467,6 +467,14 @@ 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);
 }
 
+int nvme_ana_log(int fd, void *ana_log, size_t ana_log_len, int rgo)
+{
+	__u64 lpo = 0;
+
+	return nvme_get_log13(fd, NVME_NSID_ALL, NVME_LOG_ANA, rgo, lpo, 0,
+			true, ana_log_len, ana_log);
+}
+
 int nvme_self_test_log(int fd, struct nvme_self_test_log *self_test_log)
 {
 	return nvme_get_log(fd, NVME_NSID_ALL, NVME_LOG_DEVICE_SELF_TEST,
nvme-ioctl.h +1 -0
index b34f5de..d3823a4 100644
@@ -92,6 +92,7 @@ int nvme_changed_ns_list_log(int fd,
 		struct nvme_changed_ns_list_log *changed_ns_list_log);
 int nvme_error_log(int fd, int entries, struct nvme_error_log_page *err_log);
 int nvme_smart_log(int fd, __u32 nsid, struct nvme_smart_log *smart_log);
+int nvme_ana_log(int fd, void *ana_log, size_t ana_log_len, int rgo);
 int nvme_effects_log(int fd, struct nvme_effects_log_page *effects_log);
 int nvme_discovery_log(int fd, struct nvmf_disc_rsp_page_hdr *log, __u32 size);
 int nvme_sanitize_log(int fd, struct nvme_sanitize_log_page *sanitize_log);
nvme-print.c +167 -3

246 lines not on this page · raw message

nvme-print.h +2 -0
index da287c2..367347c 100644
@@ -24,6 +24,7 @@ void show_nvme_resv_report(struct nvme_reservation_status *status, int bytes, __
 void show_lba_range(struct nvme_lba_range_type *lbrt, int nr_ranges);
 void show_error_log(struct nvme_error_log_page *err_log, int entries, const char *devname);
 void show_smart_log(struct nvme_smart_log *smart, unsigned int nsid, const char *devname);
+void show_ana_log(struct nvme_ana_rsp_hdr *ana_log, const char *devname);
 void show_self_test_log(struct nvme_self_test_log *self_test, const char *devname);
 void show_fw_log(struct nvme_firmware_log_page *fw_log, const char *devname);
 void show_effects_log(struct nvme_effects_log_page *effects, unsigned int flags);
@@ -50,6 +51,7 @@ void json_nvme_id_ns(struct nvme_id_ns *ns, unsigned int flags);
 void json_nvme_resv_report(struct nvme_reservation_status *status, int bytes, __u32 cdw11);
 void json_error_log(struct nvme_error_log_page *err_log, int entries, const char *devname);
 void json_smart_log(struct nvme_smart_log *smart, unsigned int nsid, const char *devname);
+void json_ana_log(struct nvme_ana_rsp_hdr *ana_log, const char *devname);
 void json_effects_log(struct nvme_effects_log_page *effects_log, const char *devname);
 void json_sanitize_log(struct nvme_sanitize_log_page *sanitize_log, const char *devname);
 void json_fw_log(struct nvme_firmware_log_page *fw_log, const char *devname);
nvme.c +77 -0

84 lines not on this page · raw message

Signature · 1 line
2.17.0
#2 lore raw

PATCH v3 1/2 nvme-cli: add minimal ana-log page support

Hi Chaitanya,

Quoted 19 lines · Chaitanya Kulkarni
(quoted diff) +1 -1
@@ -1550,7 +1647,7 @@ char *nvme_status_to_string(__u32 status)
 ?	case NVME_SC_SANITIZE_IN_PROGRESS:	return "SANITIZE_IN_PROGRESS: The requested function is prohibited while a sanitize operation is in progress";
 ?	case NVME_SC_LBA_RANGE:			return "LBA_RANGE: The command references a LBA that exceeds the size of the namespace";
 ?	case NVME_SC_CAP_EXCEEDED:		return "CAP_EXCEEDED: The execution of the command has caused the capacity of the namespace to be exceeded";
-	case NVME_SC_NS_NOT_READY:		return "NS_NOT_READY: The namespace is not ready to be accessed";
+	case NVME_SC_NS_NOT_READY:		return "NS_NOT_READY: The namespace is not ready to be accessed as a result of a condition other than a condition that is
 reported as an Asymmetric Namespace Access condition";
 ?	case NVME_SC_RESERVATION_CONFLICT:	return "RESERVATION_CONFLICT: The command was aborted due to a conflict with a reservation held on the accessed namespace";
 ?	case NVME_SC_CQ_INVALID:		return "CQ_INVALID: The Completion Queue identifier specified in the command does not exist";

? case NVME_SC_QID_INVALID: return "QID_INVALID: The creation of the I/O Completion Queue failed due to an invalid queue identifier specified as part of the
command. An invalid queue identifier is one that is currently in use or one that is outside the range supported by the controller";

(quoted diff) +0 -0
@@ -1590,6 +1687,9 @@ char *nvme_status_to_string(__u32 status)
 ?	case NVME_SC_COMPARE_FAILED:		return "COMPARE_FAILED: The command failed due to a miscompare during a Compare command";
 ?	case NVME_SC_ACCESS_DENIED:		return "ACCESS_DENIED: Access to the namespace and/or LBA range is denied due to lack of access rights";

? case NVME_SC_UNWRITTEN_BLOCK: return "UNWRITTEN_BLOCK: The command failed due to an attempt to read from an LBA range containing a deallocated or
unwritten logical block";

nvme-print.c +3 -0
+	case NVME_SC_ANA_PERSISTENT_LOSS:	return "Asymmetric Namespace Access Persistent Loss";
+	case NVME_SC_ANA_INACCESSIBLE:		return "Asymmetric Namespace Access Inaccessible";
+	case NVME_SC_ANA_TRANSITION:		return "Asymmetric Namespace Access Transition";
Quoted 3 lines

? default: return "Unknown";
? }
?}

If possible, can we change the descriptions to something like TP 4004 just like the others or shorten descriptions? ?All the other state strings are having statements from the doc.

Thanks,
????????Minwoo Im

#3 lore raw

PATCH v3 1/2 nvme-cli: add minimal ana-log page support

In reply to Chaitanya Kulkarni

Hi Chaitanya,

One more trivial comment on this patch.

Quoted 27 lines · Chaitanya Kulkarni

This patch adds a new command to retrieve the ANA Log page. We update identify ctrl/ns data structure to support this command. We also add ana based error codes and different identifiers to the linux/nvme.h header file in order to support this command. ?
Signed-off-by: Chaitanya Kulkarni <chaitanya.kulkarni at wdc.com>
Signed-off-by: Hannes Reinecke <hare at suse.com>
---

nvme.c +18 -0
+static int get_ana_log(int argc, char **argv, struct command *cmd,
+		struct plugin *plugin)
+{
+	const char *desc = "Retrieve ANA log for the given device" \
+			"in either decoded format "\
+			"(default) or binary.";
+	const char *raw = "output in binary format";
+	void *ana_log;
+	int err, fmt, fd;
+	int groups = 0; /* Right now get all the per ANA group NSIDS */
+	size_t ana_log_len;
+	struct nvme_id_ctrl ctrl;
+
+	struct config {
+		int???raw_binary;
+		char *output_format;
+	};
+

nvme.c static int get_smart_log(int argc, char **argv, struct command *cmd, struct plug · line 257

Quoted 10 lines
nvme.c +10 -0
+	struct config cfg = {
+		.output_format = "normal",
+	};
+
+	const struct argconfig_commandline_options command_line_options[] = {
+		{"output-format", 'o', "FMT", CFG_STRING,???&cfg.output_format, required_argument, output_format },
+		{"raw-binary",????'b', "",????CFG_NONE,?????&cfg.raw_binary,????no_argument,???????raw},
+		{NULL}
+	};
+

There was a discussion about the '--raw-binary' option to deprecate it because '--output-format=binary' or '-o binary' will make a same result.

You can find the discussion on the Github PR #342 in following link:
????https://github.com/linux-nvme/nvme-cli/pull/342

For the newly added subcommand, it doesn't need to support the '--raw-binary' option anymore.

Thanks,

Minwoo Im

#4 lore raw

PATCH v3 2/2 nvme-cli: add ana-log documentation

In reply to Chaitanya Kulkarni
Signed-off-by Chaitanya Kulkarni <chaitanya.kulkarni at wdc.com>
Reviewed-by Hannes Reinecke <hare at suse.com>
---
 Documentation/nvme-ana-log.1    |  82 ++++
 Documentation/nvme-ana-log.html | 826 ++++++++++++++++++++++++++++++++
 Documentation/nvme-ana-log.txt  |  45 ++
 3 files changed, 953 insertions(+)
 create mode 100644 Documentation/nvme-ana-log.1
 create mode 100644 Documentation/nvme-ana-log.html
 create mode 100644 Documentation/nvme-ana-log.txt
Documentation/nvme-ana-log.1 new file +82 -0
new file mode 100644
index 0000000..6baea09
@@ -0,0 +1,82 @@
+'\" t
+.\"     Title: nvme-ana-log
+.\"    Author: [FIXME: author] [see http://docbook.sf.net/el/author]
+.\" Generator: DocBook XSL Stylesheets v1.78.1 <http://docbook.sf.net/>
+.\"      Date: 07/25/2018
+.\"    Manual: NVMe Manual
+.\"    Source: NVMe
+.\"  Language: English
+.\"
+.TH "NVME\-ANA\-LOG" "1" "07/25/2018" "NVMe" "NVMe Manual"
+.\" -----------------------------------------------------------------
+.\" * Define some portability stuff
+.\" -----------------------------------------------------------------
+.\" ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+.\" http://bugs.debian.org/507673
+.\" http://lists.gnu.org/archive/html/groff/2009-02/msg00013.html
+.\" ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+.ie \n(.g .ds Aq \(aq
+.el       .ds Aq '
+.\" -----------------------------------------------------------------
+.\" * set default formatting
+.\" -----------------------------------------------------------------
+.\" disable hyphenation
+.nh
+.\" disable justification (adjust text to left margin only)
+.ad l
+.\" -----------------------------------------------------------------
+.\" * MAIN CONTENT STARTS HERE *
+.\" -----------------------------------------------------------------
+.SH "NAME"
+nvme-ana-log \- Send NVMe ANA log page request, returns result and log
+.SH "SYNOPSIS"
+.sp
+.nf
+\fInvme ana\-log\fR <device>
+.fi
+.SH "DESCRIPTION"
+.sp
+Retrieves the NVMe Asymmetric Namespace Access log page from an NVMe device and provides the returned structure\&.
+.sp
+The <device> parameter is mandatory NVMe character device (ex: /dev/nvme0)\&.
+.sp
+On success, the returned ANA log structure may be returned in one of several ways depending on the option flags; the structure may parsed by the program and printed in a readable format or the raw buffer may be printed to stdout for another program to parse\&.
+.SH "OPTIONS"
+.PP
+\-b, \-\-raw\-binary
+.RS 4
+Print the raw ANA log buffer to stdout\&.
+.RE
+.PP
+\-o <format>, \-\-output\-format=<format>
+.RS 4
+Set the reporting format to
+\fInormal\fR,
+\fIjson\fR, or
+\fIbinary\fR\&. Only one output format can be used at a time\&.
+.RE
+.SH "EXAMPLES"
+.sp
+.RS 4
+.ie n \{\
+\h'-04'\(bu\h'+03'\c
+.\}
+.el \{\
+.sp -1
+.IP \(bu 2.3
+.\}
+Print the ANA log page in a human readable format:
+.RE
+.sp
+.if n \{\
+.RS 4
+.\}
+.nf
+# nvme ana\-log /dev/nvme0
+.fi
+.if n \{\
+.RE
+.\}
+.SH "NVME"
+.sp
+Part of the nvme\-user suite
Documentation/nvme-ana-log.html new file +826 -0

826 lines not on this page · raw message

Documentation/nvme-ana-log.txt new file +45 -0

45 lines not on this page · raw message

Signature · 1 line
2.17.0
#5 lore raw

PATCH v3 2/2 nvme-cli: add ana-log documentation

Hi Chaitanya,

Here's my review on this doc.

Quoted 10 lines · Chaitanya Kulkarni
Signed-off-by Chaitanya Kulkarni <chaitanya.kulkarni at wdc.com>
Reviewed-by Hannes Reinecke <hare at suse.com>

---

Documentation/nvme-ana-log.txt new file +1 -0
new file mode 100644
index 0000000..3514504
@@ -0,0 +1,45 @@
+nvme-ana-log(1)

Documentation/nvme-ana-log.txt line 11

Quoted 10 lines
Documentation/nvme-ana-log.txt new file +10 -0
+===============
+
+NAME
+----
+nvme-ana-log - Send NVMe ANA log page request, returns result and log
+
+SYNOPSIS
+--------
+[verse]
+'nvme ana-log' <device>

This verse can have argument options like all the other docs. 'nvme ana-log' <device> [-o <fmt> | --output-format=<fmt>]

Quoted 9 lines
Documentation/nvme-ana-log.txt new file +9 -0
+
+DESCRIPTION
+-----------
+Retrieves the NVMe Asymmetric Namespace Access log page from an NVMe device
+and provides the returned structure.
+
+The <device> parameter is mandatory NVMe character device (ex: /dev/nvme0).
+
+On success, the returned ANA log structure may be returned in one of

Documentation/nvme-ana-log.txt line 30

Quoted 10 lines
Documentation/nvme-ana-log.txt new file +10 -0
+several ways depending on the option flags; the structure may parsed by
+the program and printed in a readable format or the raw buffer may be
+printed to stdout for another program to parse.
+
+OPTIONS
+-------
+-b::
+--raw-binary::
+	Print the raw ANA log buffer to stdout.
+

It can be deprecated due to a reason mentioned in the first patch comment.

Quoted 16 lines
Documentation/nvme-ana-log.txt new file +15 -1
+-o <format>::
+--output-format=<format>::
+??????????????Set the reporting format to 'normal', 'json', or
+??????????????'binary'. Only one output format can be used at a time.
+
+EXAMPLES
+--------
+* Print the ANA log page in a human readable format:
+------------
+# nvme ana-log /dev/nvme0
+------------
+
+NVME
+----
+Part of the nvme-user suite
--?
Quoted 1 line

2.17.0

Thanks,

Minwoo Im