Skip to contentSkip to conversation

block: map BLK_STS_ZONE_RESOURCE to errno

PATCH In review Keith Busch 3 participants 7 messages Sep 15, 2020 – Sep 17, 2020

Subsystems (2)
lore
Share & tools
lore

Keith Busch

author maintainer
#0 lore raw

PATCH v2 1/2 block: map BLK_STS_ZONE_RESOURCE to errno

A zoned device with limited resources to open zones for writing may return an error when the host exceeds those limits. Provide an appropriate errno for this condition for drivers that return the zone resource block status error when the device responds with these conditions.

---
v1->v2:

Pick an errno to map BLK_STS_ZONE_RESOURCE

 block/blk-core.c | 3 +++
 1 file changed, 3 insertions(+)
block/blk-core.c +3 -0
index 10c08ac50697..3594efe05117 100644
@@ -186,6 +186,9 @@ static const struct {
 	/* device mapper special case, should not leak out: */
 	[BLK_STS_DM_REQUEUE]	= { -EREMCHG, "dm internal retry" },
 
+	/* too many zone resources in use */
+	[BLK_STS_ZONE_RESOURCE]	= { -ETOOMANYREFS, "zone resource exceeded" },
+
 	/* everything else not covered above: */
 	[BLK_STS_IOERR]		= { -EIO,	"I/O" },
 };
Signature · 7 lines
2.24.1


_______________________________________________
Linux-nvme mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/linux-nvme
author maintainer
#1 lore raw

PATCH v2 2/2 nvme: translate zone resource errors

Translate zoned resource errors to the appropriate blk_status_t.

---
v1->v2:

Use BLK_STS_ZONE_RESOURCE instead of BLK_STS_DEV_RESOURCE

 drivers/nvme/host/core.c | 3 +++
 1 file changed, 3 insertions(+)
drivers/nvme/host/core.c +3 -0
index f3a61a24d45f..6d5c95a3e03c 100644
@@ -236,6 +236,9 @@ static blk_status_t nvme_error_status(u16 status)
 		return BLK_STS_NEXUS;
 	case NVME_SC_HOST_PATH_ERROR:
 		return BLK_STS_TRANSPORT;
+	case NVME_SC_ZONE_TOO_MANY_ACTIVE:
+	case NVME_SC_ZONE_TOO_MANY_OPEN:
+		return BLK_STS_ZONE_RESOURCE;
 	default:
 		return BLK_STS_IOERR;
 	}
Signature · 7 lines
2.24.1


_______________________________________________
Linux-nvme mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/linux-nvme
#2 lore raw

Re: [PATCHv2 2/2] nvme: translate zone resource errors

Quoted 16 lines · Keith Busch

Translate zoned resource errors to the appropriate blk_status_t.

---
v1->v2:

Use BLK_STS_ZONE_RESOURCE instead of BLK_STS_DEV_RESOURCE

 drivers/nvme/host/core.c | 3 +++
 1 file changed, 3 insertions(+)
drivers/nvme/host/core.c +0 -0
index f3a61a24d45f..6d5c95a3e03c 100644

drivers/nvme/host/core.c static blk_status_t nvme_error_status(u16 status) · line 241

Quoted 6 lines
drivers/nvme/host/core.c +3 -0
@@ -236,6 +236,9 @@ static blk_status_t nvme_error_status(u16 status)
 		return BLK_STS_NEXUS;
 	case NVME_SC_HOST_PATH_ERROR:
 		return BLK_STS_TRANSPORT;
+	case NVME_SC_ZONE_TOO_MANY_ACTIVE:
+	case NVME_SC_ZONE_TOO_MANY_OPEN:
+		return BLK_STS_ZONE_RESOURCE;

BLK_STS_ZONE_RESOURCE is used in the submission path to tell the block layer to "try again later because the target zone is locked". This is used by scsi for zone append emulation. So I think it may be better to define BLK_STS_DEV_ZONE_RESOURCE to avoid confusions, and that would also clearly indicate that the status comes from a command failed by the device, not the stack. Thoughts ?

Quoted 4 lines
drivers/nvme/host/core.c +0 -0
 	default:
 		return BLK_STS_IOERR;
 	}
Signature · 7 lines
Damien Le Moal
Western Digital Research

_______________________________________________
Linux-nvme mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/linux-nvme
#6 lore raw
In reply to Keith Busch
Quoted 20 lines · Keith Busch

A zoned device with limited resources to open zones for writing may return an error when the host exceeds those limits. Provide an appropriate errno for this condition for drivers that return the zone resource block status error when the device responds with these conditions.

---
v1->v2:

Pick an errno to map BLK_STS_ZONE_RESOURCE

 block/blk-core.c | 3 +++
 1 file changed, 3 insertions(+)
block/blk-core.c +0 -0
index 10c08ac50697..3594efe05117 100644

block/blk-core.c static const struct { · line 190

Quoted 5 lines
block/blk-core.c +2 -0
@@ -186,6 +186,9 @@ static const struct {
 	/* device mapper special case, should not leak out: */
 	[BLK_STS_DM_REQUEUE]	= { -EREMCHG, "dm internal retry" },
 
+	/* too many zone resources in use */
+	[BLK_STS_ZONE_RESOURCE]	= { -ETOOMANYREFS, "zone resource exceeded" },

OK. I think this is somewhat matching. The error message that strerrror() returns for this error will be somewhat obscure to users though. We need to document this.

Quoted 5 lines
block/blk-core.c +1 -0
+
 	/* everything else not covered above: */
 	[BLK_STS_IOERR]		= { -EIO,	"I/O" },
 };
Signature · 7 lines
Damien Le Moal
Western Digital Research

_______________________________________________
Linux-nvme mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/linux-nvme
author maintainer
#3 lore raw

Re: [PATCHv2 2/2] nvme: translate zone resource errors

In reply to Damien Le Moal
Quoted 22 lines · Damien Le Moal
Quoted 21 lines · Keith Busch

Translate zoned resource errors to the appropriate blk_status_t.

---
v1->v2:

Use BLK_STS_ZONE_RESOURCE instead of BLK_STS_DEV_RESOURCE

 drivers/nvme/host/core.c | 3 +++
 1 file changed, 3 insertions(+)
drivers/nvme/host/core.c +2 -0
index f3a61a24d45f..6d5c95a3e03c 100644
@@ -236,6 +236,9 @@ static blk_status_t nvme_error_status(u16 status)
 		return BLK_STS_NEXUS;
 	case NVME_SC_HOST_PATH_ERROR:
 		return BLK_STS_TRANSPORT;
+	case NVME_SC_ZONE_TOO_MANY_ACTIVE:
+	case NVME_SC_ZONE_TOO_MANY_OPEN:
Quoted 8 lines

drivers/nvme/host/core.c static blk_status_t nvme_error_status(u16 status) · line 241

Quoted 1 line
drivers/nvme/host/core.c +1 -0
+		return BLK_STS_ZONE_RESOURCE;

BLK_STS_ZONE_RESOURCE is used in the submission path to tell the block layer to "try again later because the target zone is locked". This is used by scsi for zone append emulation. So I think it may be better to define BLK_STS_DEV_ZONE_RESOURCE to avoid confusions, and that would also clearly indicate that the status comes from a command failed by the device, not the stack. Thoughts ?

I believe it's safe to use for the completion side since the special handling is only for submission errors. But I agree this type of double meaning could invite confusion. I'll send a v3 with your suggestion and we'll see how that goes.

_______________________________________________
Linux-nvme mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/linux-nvme

#4 lore raw

Re: [PATCHv2 2/2] nvme: translate zone resource errors

Quoted 4 lines · Keith Busch

I believe it's safe to use for the completion side since the special handling is only for submission errors. But I agree this type of double meaning could invite confusion. I'll send a v3 with your suggestion and we'll see how that goes.

Two remarks: Can you include the scsi patch for Damien so that ZNS and ZBC/ZAC are handled together? Should we use a separate status for active vs open zones?

_______________________________________________
Linux-nvme mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/linux-nvme

#5 lore raw

Re: [PATCHv2 2/2] nvme: translate zone resource errors

Quoted 9 lines · On 2020/09/17 14:48, [email protected] wrote:
Quoted 4 lines · Keith Busch

I believe it's safe to use for the completion side since the special handling is only for submission errors. But I agree this type of double meaning could invite confusion. I'll send a v3 with your suggestion and we'll see how that goes.

Two remarks: Can you include the scsi patch for Damien so that ZNS and ZBC/ZAC are handled together? Should we use a separate status for active vs open zones?

I did not think about that... It will not matter for ZBC/ZAC since there is no limit on active zones, but that indeed could be useful for ZNS. And with Johannes "explicit_open" series for zonefs, open() of a zonefs file would return different error codes to the application for max open exceeded vs max active exceeded. Same for raw block devices ioctls or write operations.

Hmm. So we need 2 BLK_STS and 2 errno. Not a big change but I am out of idea for the second errno... EOVERFLOW for max active error ?

Max open zones error: BLK_STS_ZONE_MOR -> ETOOMANYREFS Mac active zones error: BLK_STS_ZONE_MAR -> EOVERFLOW

May be.

Signature · 7 lines
Damien Le Moal
Western Digital Research

_______________________________________________
Linux-nvme mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/linux-nvme