Linux-NVME Archive on lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] nvme: fix command limits status code
@ 2025-05-20 20:20 Keith Busch
  2025-05-21  1:46 ` Chaitanya Kulkarni
  2025-05-21  6:14 ` Christoph Hellwig
  0 siblings, 2 replies; 4+ messages in thread
From: Keith Busch @ 2025-05-20 20:20 UTC (permalink / raw)
  To: linux-nvme, hch; +Cc: sagi, Keith Busch, Chaitanya Kulkarni

From: Keith Busch <kbusch@kernel.org>

The command specific status code, 0x183, was introduced in nvme 2.0
specification defined to "Command Size Limits Exceeded" and only ever
applied to DSM and Copy commands. Fix the name and remove the incorrect
special handling for it.

Fixes: 3b7c33b28a44d4 ("nvme.h: add Write Zeroes definitions")
Cc: Chaitanya Kulkarni <chaitanyak@nvidia.com>
Signed-off-by: Keith Busch <kbusch@kernel.org>
---
 drivers/nvme/host/constants.c     | 2 +-
 drivers/nvme/host/core.c          | 1 -
 drivers/nvme/host/pr.c            | 2 --
 drivers/nvme/target/core.c        | 9 +--------
 drivers/nvme/target/io-cmd-bdev.c | 9 +--------
 include/linux/nvme.h              | 2 +-
 6 files changed, 4 insertions(+), 21 deletions(-)

diff --git a/drivers/nvme/host/constants.c b/drivers/nvme/host/constants.c
index 2b9e6cfaf2a80..1a0058be58210 100644
--- a/drivers/nvme/host/constants.c
+++ b/drivers/nvme/host/constants.c
@@ -145,7 +145,7 @@ static const char * const nvme_statuses[] = {
 	[NVME_SC_BAD_ATTRIBUTES] = "Conflicting Attributes",
 	[NVME_SC_INVALID_PI] = "Invalid Protection Information",
 	[NVME_SC_READ_ONLY] = "Attempted Write to Read Only Range",
-	[NVME_SC_ONCS_NOT_SUPPORTED] = "ONCS Not Supported",
+	[NVME_SC_CMD_SIZE_LIM_EXCEEDED	] = "Command Size Limits Exceeded",
 	[NVME_SC_ZONE_BOUNDARY_ERROR] = "Zoned Boundary Error",
 	[NVME_SC_ZONE_FULL] = "Zone Is Full",
 	[NVME_SC_ZONE_READ_ONLY] = "Zone Is Read Only",
diff --git a/drivers/nvme/host/core.c b/drivers/nvme/host/core.c
index cdb806b2c89c7..05445217dd6ed 100644
--- a/drivers/nvme/host/core.c
+++ b/drivers/nvme/host/core.c
@@ -290,7 +290,6 @@ static blk_status_t nvme_error_status(u16 status)
 	case NVME_SC_NS_NOT_READY:
 		return BLK_STS_TARGET;
 	case NVME_SC_BAD_ATTRIBUTES:
-	case NVME_SC_ONCS_NOT_SUPPORTED:
 	case NVME_SC_INVALID_OPCODE:
 	case NVME_SC_INVALID_FIELD:
 	case NVME_SC_INVALID_NS:
diff --git a/drivers/nvme/host/pr.c b/drivers/nvme/host/pr.c
index cf2d2c5039ddb..ca6a74607b139 100644
--- a/drivers/nvme/host/pr.c
+++ b/drivers/nvme/host/pr.c
@@ -82,8 +82,6 @@ static int nvme_status_to_pr_err(int status)
 		return PR_STS_SUCCESS;
 	case NVME_SC_RESERVATION_CONFLICT:
 		return PR_STS_RESERVATION_CONFLICT;
-	case NVME_SC_ONCS_NOT_SUPPORTED:
-		return -EOPNOTSUPP;
 	case NVME_SC_BAD_ATTRIBUTES:
 	case NVME_SC_INVALID_OPCODE:
 	case NVME_SC_INVALID_FIELD:
diff --git a/drivers/nvme/target/core.c b/drivers/nvme/target/core.c
index db7b17d1094e8..e824f149746a7 100644
--- a/drivers/nvme/target/core.c
+++ b/drivers/nvme/target/core.c
@@ -62,14 +62,7 @@ inline u16 errno_to_nvme_status(struct nvmet_req *req, int errno)
 		return  NVME_SC_LBA_RANGE | NVME_STATUS_DNR;
 	case -EOPNOTSUPP:
 		req->error_loc = offsetof(struct nvme_common_command, opcode);
-		switch (req->cmd->common.opcode) {
-		case nvme_cmd_dsm:
-		case nvme_cmd_write_zeroes:
-			return NVME_SC_ONCS_NOT_SUPPORTED | NVME_STATUS_DNR;
-		default:
-			return NVME_SC_INVALID_OPCODE | NVME_STATUS_DNR;
-		}
-		break;
+		return NVME_SC_INVALID_OPCODE | NVME_STATUS_DNR;
 	case -ENODATA:
 		req->error_loc = offsetof(struct nvme_rw_command, nsid);
 		return NVME_SC_ACCESS_DENIED;
diff --git a/drivers/nvme/target/io-cmd-bdev.c b/drivers/nvme/target/io-cmd-bdev.c
index 83be0657e6df4..1cfa13d029bfa 100644
--- a/drivers/nvme/target/io-cmd-bdev.c
+++ b/drivers/nvme/target/io-cmd-bdev.c
@@ -145,15 +145,8 @@ u16 blk_to_nvme_status(struct nvmet_req *req, blk_status_t blk_sts)
 		req->error_loc = offsetof(struct nvme_rw_command, slba);
 		break;
 	case BLK_STS_NOTSUPP:
+		status = NVME_SC_INVALID_OPCODE | NVME_STATUS_DNR;
 		req->error_loc = offsetof(struct nvme_common_command, opcode);
-		switch (req->cmd->common.opcode) {
-		case nvme_cmd_dsm:
-		case nvme_cmd_write_zeroes:
-			status = NVME_SC_ONCS_NOT_SUPPORTED | NVME_STATUS_DNR;
-			break;
-		default:
-			status = NVME_SC_INVALID_OPCODE | NVME_STATUS_DNR;
-		}
 		break;
 	case BLK_STS_MEDIUM:
 		status = NVME_SC_ACCESS_DENIED;
diff --git a/include/linux/nvme.h b/include/linux/nvme.h
index 51308f65b72fd..b65a1b9f2116c 100644
--- a/include/linux/nvme.h
+++ b/include/linux/nvme.h
@@ -2171,7 +2171,7 @@ enum {
 	NVME_SC_BAD_ATTRIBUTES		= 0x180,
 	NVME_SC_INVALID_PI		= 0x181,
 	NVME_SC_READ_ONLY		= 0x182,
-	NVME_SC_ONCS_NOT_SUPPORTED	= 0x183,
+	NVME_SC_CMD_SIZE_LIM_EXCEEDED	= 0x183,
 
 	/*
 	 * I/O Command Set Specific - Fabrics commands:
-- 
2.47.1



^ permalink raw reply related	[flat|nested] 4+ messages in thread

* Re: [PATCH] nvme: fix command limits status code
  2025-05-20 20:20 [PATCH] nvme: fix command limits status code Keith Busch
@ 2025-05-21  1:46 ` Chaitanya Kulkarni
  2025-05-21  6:14 ` Christoph Hellwig
  1 sibling, 0 replies; 4+ messages in thread
From: Chaitanya Kulkarni @ 2025-05-21  1:46 UTC (permalink / raw)
  To: Keith Busch, linux-nvme@lists.infradead.org, hch@lst.de
  Cc: sagi@grimberg.me, Keith Busch

On 5/20/25 13:20, Keith Busch wrote:
> From: Keith Busch<kbusch@kernel.org>
>
> The command specific status code, 0x183, was introduced in nvme 2.0
> specification defined to "Command Size Limits Exceeded" and only ever
> applied to DSM and Copy commands. Fix the name and remove the incorrect
> special handling for it.
>
> Fixes: 3b7c33b28a44d4 ("nvme.h: add Write Zeroes definitions")
> Cc: Chaitanya Kulkarni<chaitanyak@nvidia.com>
> Signed-off-by: Keith Busch<kbusch@kernel.org>

Thanks a lot for the fix, looks good.

Reviewed-by: Chaitanya Kulkarni <kch@nvidia.com>

-ck



^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [PATCH] nvme: fix command limits status code
  2025-05-20 20:20 [PATCH] nvme: fix command limits status code Keith Busch
  2025-05-21  1:46 ` Chaitanya Kulkarni
@ 2025-05-21  6:14 ` Christoph Hellwig
  2025-05-21 14:24   ` Keith Busch
  1 sibling, 1 reply; 4+ messages in thread
From: Christoph Hellwig @ 2025-05-21  6:14 UTC (permalink / raw)
  To: Keith Busch; +Cc: linux-nvme, hch, sagi, Keith Busch, Chaitanya Kulkarni

On Tue, May 20, 2025 at 01:20:37PM -0700, Keith Busch wrote:
> From: Keith Busch <kbusch@kernel.org>
> 
> The command specific status code, 0x183, was introduced in nvme 2.0
> specification defined to "Command Size Limits Exceeded" and only ever
> applied to DSM and Copy commands.

Yeah, that's weird.  Chaitanya, did you implement this off an early
draft?

> Fix the name and remove the incorrect
> special handling for it.

Where the incorrect handling is the mappings in nvme_error_status
and nvme_status_to_pr_err?  Yes, limit exceed should not be a not
supported, so this looks fine.  But it would be good to actually
spell that out in the commit message.  I'll fix it up if you don't
object.



^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [PATCH] nvme: fix command limits status code
  2025-05-21  6:14 ` Christoph Hellwig
@ 2025-05-21 14:24   ` Keith Busch
  0 siblings, 0 replies; 4+ messages in thread
From: Keith Busch @ 2025-05-21 14:24 UTC (permalink / raw)
  To: Christoph Hellwig; +Cc: Keith Busch, linux-nvme, sagi, Chaitanya Kulkarni

On Wed, May 21, 2025 at 08:14:00AM +0200, Christoph Hellwig wrote:
> On Tue, May 20, 2025 at 01:20:37PM -0700, Keith Busch wrote:
> 
> > Fix the name and remove the incorrect
> > special handling for it.
> 
> Where the incorrect handling is the mappings in nvme_error_status
> and nvme_status_to_pr_err?  Yes, limit exceed should not be a not
> supported, so this looks fine.  But it would be good to actually
> spell that out in the commit message.  I'll fix it up if you don't
> object.

Yes, those two error mappings on the host side, and the target side use
of the misnamed status code too.


^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2025-05-21 14:34 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2025-05-20 20:20 [PATCH] nvme: fix command limits status code Keith Busch
2025-05-21  1:46 ` Chaitanya Kulkarni
2025-05-21  6:14 ` Christoph Hellwig
2025-05-21 14:24   ` Keith Busch

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox