linux-nvme.lists.infradead.org archive mirror
 help / color / mirror / Atom feed
From: Sagi Grimberg <sagi@grimberg.me>
To: Marko Ahvenainen <marko.ahvenainen@helsinkimemorytech.com>,
	"hch@lst.de" <hch@lst.de>, "kch@nvidia.com" <kch@nvidia.com>
Cc: "linux-nvme@lists.infradead.org" <linux-nvme@lists.infradead.org>,
	"linux-kernel@vger.kernel.org" <linux-kernel@vger.kernel.org>
Subject: Re: [RFC PATCH] nvmet: passthru: use Invalid Field, not Invalid Opcode, for unhandled Get/Set Features FIDs
Date: Sun, 23 Aug 2026 00:53:05 +0300	[thread overview]
Message-ID: <4aa2e0d5-e519-4125-b537-e4b035d07847@grimberg.me> (raw)
In-Reply-To: <IA4P221MB1623401F07A6952EFC9895FDF4A32@IA4P221MB1623.NAMP221.PROD.OUTLOOK.COM>

Hey Marko,

> Hello all,
>
> My first kernel patch, be gentle ;)
>
> nvmet_passthru_get_set_features() rejects any FID that reaches its
> default case - whether intentionally blocked (IRQ_COALESCE,
> IRQ_CONFIG, HOST_MEM_BUF, SW_PROGRESS, RESV_MASK, RESV_PERSIST) or
> simply unlisted (e.g. FID 0, unassigned by the spec) - with
> NVME_SC_INVALID_OPCODE | NVME_STATUS_DNR. That's the wrong class: the
> Get/Set Features opcode is always valid here, it's the FID that's
> rejected, so NVME_SC_INVALID_FIELD is correct.
>
> This surfaced while debugging why nvme-cli's "dump all known
> features" mode (get-feature -f 0) completes against a native
> controller but aborts over nvmet passthru: natively, FID 0 gets a
> plain Invalid Field rejection (no DNR) that nvme-cli tolerates and
> continues past; nvmet's Invalid Opcode + DNR is not tolerated the
> same way.
>
> Verified with this fix applied: get-feature -f 0 now enumerates every
> FID over nvmet passthru (NVMe/TCP) without aborting early. The DNR
> flag was not the obstacle - only the status class was.
>
> This is a status-code fix only, not a policy change: Get/Set Features
> FIDs are still intercepted at more than one layer before reaching
> this function (nvmet_parse_admin_cmd()/nvmet_parse_passthru_admin_cmd()
> already service ASYNC_EVENT, KATO, NUM_QUEUES, HOST_ID and FDP with
> nvmet's own emulation), so native and passthru queries still won't
> return identical results for every FID - only this early-abort
> failure mode is fixed. I'd rather leave any broader forwarding-policy
> change to a separate discussion.
>
> Unrelated aside noticed while reading this code: the
> NVME_FEAT_ASYNC_EVENT case (and propably some other) inside this
> function is dead code, since the callers above already intercept
> that FID before it can be reached.
>
> Signed-off-by: Marko Ahvenainen <marko.ahvenainen@helsinkimemorytech.com>
> ---
>   drivers/nvme/target/passthru.c | 2 +-
>   1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/drivers/nvme/target/passthru.c b/drivers/nvme/target/passthru.c
> index e27f84e3cf2b..df1396081f87 100644
> --- a/drivers/nvme/target/passthru.c
> +++ b/drivers/nvme/target/passthru.c
> @@ -483,7 +483,7 @@ static u16 nvmet_passthru_get_set_features(struct nvmet_req *req)
>          case NVME_FEAT_RESV_PERSIST:
>                  /* No reservations, see nvmet_parse_passthru_io_cmd() */
>          default:
> -               return NVME_SC_INVALID_OPCODE | NVME_STATUS_DNR;
> +               return NVME_SC_INVALID_FIELD | NVME_STATUS_DNR;

I think you want to set the error_loc such that it can be viewed from 
the error log page.

>          }
>   }
>
> --
> 2.43.0

You should make it a proper (non-rfc) patch and send it.
The below should be removed from the actual submission.

>
> This e-mail and any attachments may contain privileged or confidential information and is for the sole use of the intended recipient(s). Any unauthorized use or disclosure of this communication is prohibited. If you believe that you have received this e-mail in error, please notify the sender immediately and destroy all copies.



  reply	other threads:[~2026-08-22 21:53 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-08-21  9:02 [RFC PATCH] nvmet: passthru: use Invalid Field, not Invalid Opcode, for unhandled Get/Set Features FIDs Marko Ahvenainen
2026-08-22 21:53 ` Sagi Grimberg [this message]
2026-08-25 12:30   ` Marko Ahvenainen

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=4aa2e0d5-e519-4125-b537-e4b035d07847@grimberg.me \
    --to=sagi@grimberg.me \
    --cc=hch@lst.de \
    --cc=kch@nvidia.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-nvme@lists.infradead.org \
    --cc=marko.ahvenainen@helsinkimemorytech.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).