public inbox for linux-nvme@lists.infradead.org
 help / color / mirror / Atom feed
From: hch@lst.de (Christoph Hellwig)
Subject: [PATCH 1/2] nvme-cli: add minimal ana-log page support
Date: Wed, 25 Jul 2018 06:53:52 +0200	[thread overview]
Message-ID: <20180725045352.GA10905@lst.de> (raw)
In-Reply-To: <20180725001316.2714-1-chaitanya.kulkarni@wdc.com>

On Tue, Jul 24, 2018@05:13:15PM -0700, Chaitanya Kulkarni wrote:
> 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.

One thing I am a little concerned about here is that reading the
ANA log page may clear the ANA AEN.  This actually is the same for
other log pages that clear AENs, but for ANA the effects are much
worse.

Keith, wat do you think of always setting the RAE bit for log pages
associated with AENs?  The only real issue I can see is that the
bit is only defined for NVMe 1.3+ so we'd need to figure out the
version somehow.  Maybe with a new ioctl so that we don't have
to send an identify every time.

We also really need the RAE bit implemented in the Linux target.
This should be very simple but I haven't got to it yet.  Chaitanya,
do you want to give it a quick spin independent of this discussion?

And now some comments on the patch itself:

> +const char * nvme_ana_state_to_string(int state)

No space after the '*', please.  Also the type of state should be
'enum nvme_ana_state'.

> +{
> +	switch (state) {
> +	case NVME_ANA_OPTIMIZED:
> +		return "OPTIMIZED";
> +	case NVME_ANA_NONOPTIMIZED:
> +		return "NON-OPTIMIZED";
> +	case NVME_ANA_INACCESSIBLE:
> +		return "INACCESSIBLE";
> +	case NVME_ANA_PERSISTENT_LOSS:
> +		return "PERSISTENT-LOSS";
> +	case NVME_ANA_CHANGE:
> +		return "CHANGE";
> +	default:
> +		return "UNKNOWN";
> +	}
> +}

Is there precedene for SHOUTING elsewhere in nvme-clu?  Otherwise I'd
suggest to print these in lower case and match what is in the kernel
sysfs files.

> +void show_ana_log(struct nvme_ana_rsp_hdr *ana_log, const char *devname)

The devname argument seems unused.

> +{
> +	int offset = sizeof(struct nvme_ana_rsp_hdr);
> +	void *base = ana_log;
> +	struct nvme_ana_rsp_hdr *hdr = base;
> +	struct nvme_ana_group_desc *desc;
> +	size_t nsid_buf_size;
> +	__u32 nr_nsids;
> +	int i;
> +	int j;
> +
> +	printf("ANA LOG HEADER :-\n");
> +	printf("chgcnt	:	%"PRIu64"\n", (uint64_t)le64_to_cpu(hdr->chgcnt));
> +	printf("ngrps	:	%u\n", le16_to_cpu(hdr->ngrps));
> +	printf("ANA Log Desc :-\n");
> +
> +	for (i = 0; i < le16_to_cpu(ana_log->ngrps); i++) {
> +		desc = base + offset;
> +		nr_nsids = le32_to_cpu(desc->nnsids);
> +		nsid_buf_size = nr_nsids * sizeof(__le32);
> +
> +		offset += sizeof(*desc);
> +		printf("grpid	:	%u\n", le32_to_cpu(desc->grpid));
> +		printf("nnsids	:	%u\n", le32_to_cpu(desc->nnsids));
> +		printf("chgcnt	:	%llu\n", le64_to_cpu(desc->chgcnt));
> +		printf("state	:	%s\n", nvme_ana_state_to_string(desc->state));

I think we also need a json version of all this, don't we?

> +static int get_ana_log(int argc, char **argv, struct command *cmd, struct plugin *plugin)

Overly long line.

  parent reply	other threads:[~2018-07-25  4:53 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-07-25  0:13 [PATCH 1/2] nvme-cli: add minimal ana-log page support Chaitanya Kulkarni
2018-07-25  0:13 ` [PATCH 2/2] nvme-cli add ana-log documentation Chaitanya Kulkarni
2018-07-25  4:53 ` Christoph Hellwig [this message]
2018-07-25  6:43   ` [PATCH 1/2] nvme-cli: add minimal ana-log page support Chaitanya Kulkarni
2018-07-25 14:48   ` Keith Busch
2018-07-26  9:24     ` Christoph Hellwig
2018-07-26 14:29       ` Keith Busch

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=20180725045352.GA10905@lst.de \
    --to=hch@lst.de \
    /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