Linux-Block Archive on lore.kernel.org
 help / color / Atom feed
* [PATCHv4 0/3] zoned block device specific errors
@ 2020-09-24 20:53 Keith Busch
  2020-09-24 20:53 ` [PATCHv4 1/3] block: add zone specific block statuses Keith Busch
                   ` (2 more replies)
  0 siblings, 3 replies; 10+ messages in thread
From: Keith Busch @ 2020-09-24 20:53 UTC (permalink / raw)
  To: axboe; +Cc: linux-nvme, linux-block, linux-scsi, hch, Keith Busch

Zone block devices may have some limits that require special handling.
This series provides a way for drivers to notify of these conditions.

v3 -> v4:

Added reviews/acks/sobs

Dropped unintended patch

Damien Le Moal (1):
  scsi: handle zone resources errors

Keith Busch (2):
  block: add zone specific block statuses
  nvme: translate zone resource errors

 Documentation/block/queue-sysfs.rst |  8 ++++++++
 block/blk-core.c                    |  4 ++++
 drivers/nvme/host/core.c            |  4 ++++
 drivers/scsi/scsi_lib.c             |  9 +++++++++
 include/linux/blk_types.h           | 18 ++++++++++++++++++
 5 files changed, 43 insertions(+)

-- 
2.24.1


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

* [PATCHv4 1/3] block: add zone specific block statuses
  2020-09-24 20:53 [PATCHv4 0/3] zoned block device specific errors Keith Busch
@ 2020-09-24 20:53 ` Keith Busch
  2020-10-01 21:35   ` Keith Busch
  2020-10-09 15:29   ` Keith Busch
  2020-09-24 20:53 ` [PATCHv4 2/3] nvme: translate zone resource errors Keith Busch
  2020-09-24 20:53 ` [PATCHv4 3/3] scsi: handle zone resources errors Keith Busch
  2 siblings, 2 replies; 10+ messages in thread
From: Keith Busch @ 2020-09-24 20:53 UTC (permalink / raw)
  To: axboe
  Cc: linux-nvme, linux-block, linux-scsi, hch, Keith Busch, linux-api,
	Niklas Cassel, Damien Le Moal, Johannes Thumshirn,
	Martin K . Petersen

A zoned device with limited resources to open or activate zones may
return an error when the host exceeds those limits. The same command may
be successful if retried later, but the host needs to wait for specific
zone states before it should expect a retry to succeed. Have the block
layer provide an appropriate status for these conditions so applications
can distinuguish this error for special handling.

Cc: linux-api@vger.kernel.org
Cc: Niklas Cassel <niklas.cassel@wdc.com>
Reviewed-by: Christoph Hellwig <hch@lst.de>
Reviewed-by: Damien Le Moal <damien.lemoal@wdc.com>
Reviewed-by: Johannes Thumshirn <johannes.thumshirn@wdc.com>
Reviewed-by: Martin K. Petersen <martin.petersen@oracle.com>
Signed-off-by: Keith Busch <kbusch@kernel.org>
---
 Documentation/block/queue-sysfs.rst |  8 ++++++++
 block/blk-core.c                    |  4 ++++
 include/linux/blk_types.h           | 18 ++++++++++++++++++
 3 files changed, 30 insertions(+)

diff --git a/Documentation/block/queue-sysfs.rst b/Documentation/block/queue-sysfs.rst
index f261a5c84170..2638d3446b79 100644
--- a/Documentation/block/queue-sysfs.rst
+++ b/Documentation/block/queue-sysfs.rst
@@ -124,6 +124,10 @@ For zoned block devices (zoned attribute indicating "host-managed" or
 EXPLICIT OPEN, IMPLICIT OPEN or CLOSED, is limited by this value.
 If this value is 0, there is no limit.
 
+If the host attempts to exceed this limit, the driver should report this error
+with BLK_STS_ZONE_ACTIVE_RESOURCE, which user space may see as the EOVERFLOW
+errno.
+
 max_open_zones (RO)
 -------------------
 For zoned block devices (zoned attribute indicating "host-managed" or
@@ -131,6 +135,10 @@ For zoned block devices (zoned attribute indicating "host-managed" or
 EXPLICIT OPEN or IMPLICIT OPEN, is limited by this value.
 If this value is 0, there is no limit.
 
+If the host attempts to exceed this limit, the driver should report this error
+with BLK_STS_ZONE_OPEN_RESOURCE, which user space may see as the ETOOMANYREFS
+errno.
+
 max_sectors_kb (RW)
 -------------------
 This is the maximum number of kilobytes that the block layer will allow
diff --git a/block/blk-core.c b/block/blk-core.c
index 10c08ac50697..8bffc7732e37 100644
--- a/block/blk-core.c
+++ b/block/blk-core.c
@@ -186,6 +186,10 @@ static const struct {
 	/* device mapper special case, should not leak out: */
 	[BLK_STS_DM_REQUEUE]	= { -EREMCHG, "dm internal retry" },
 
+	/* zone device specific errors */
+	[BLK_STS_ZONE_OPEN_RESOURCE]	= { -ETOOMANYREFS, "open zones exceeded" },
+	[BLK_STS_ZONE_ACTIVE_RESOURCE]	= { -EOVERFLOW, "active zones exceeded" },
+
 	/* everything else not covered above: */
 	[BLK_STS_IOERR]		= { -EIO,	"I/O" },
 };
diff --git a/include/linux/blk_types.h b/include/linux/blk_types.h
index 4ecf4fed171f..8603fc5f86a3 100644
--- a/include/linux/blk_types.h
+++ b/include/linux/blk_types.h
@@ -103,6 +103,24 @@ typedef u8 __bitwise blk_status_t;
  */
 #define BLK_STS_ZONE_RESOURCE	((__force blk_status_t)14)
 
+/*
+ * BLK_STS_ZONE_OPEN_RESOURCE is returned from the driver in the completion
+ * path if the device returns a status indicating that too many zone resources
+ * are currently open. The same command should be successful if resubmitted
+ * after the number of open zones decreases below the device's limits, which is
+ * reported in the request_queue's max_open_zones.
+ */
+#define BLK_STS_ZONE_OPEN_RESOURCE	((__force blk_status_t)15)
+
+/*
+ * BLK_STS_ZONE_ACTIVE_RESOURCE is returned from the driver in the completion
+ * path if the device returns a status indicating that too many zone resources
+ * are currently active. The same command should be successful if resubmitted
+ * after the number of active zones decreases below the device's limits, which
+ * is reported in the request_queue's max_active_zones.
+ */
+#define BLK_STS_ZONE_ACTIVE_RESOURCE	((__force blk_status_t)16)
+
 /**
  * blk_path_error - returns true if error may be path related
  * @error: status the request was completed with
-- 
2.24.1


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

* [PATCHv4 2/3] nvme: translate zone resource errors
  2020-09-24 20:53 [PATCHv4 0/3] zoned block device specific errors Keith Busch
  2020-09-24 20:53 ` [PATCHv4 1/3] block: add zone specific block statuses Keith Busch
@ 2020-09-24 20:53 ` Keith Busch
  2020-09-24 20:53 ` [PATCHv4 3/3] scsi: handle zone resources errors Keith Busch
  2 siblings, 0 replies; 10+ messages in thread
From: Keith Busch @ 2020-09-24 20:53 UTC (permalink / raw)
  To: axboe
  Cc: linux-nvme, linux-block, linux-scsi, hch, Keith Busch,
	Damien Le Moal, Johannes Thumshirn, Martin K . Petersen

Translate zoned resource errors to the appropriate blk_status_t.

Reviewed-by: Christoph Hellwig <hch@lst.de>
Reviewed-by: Damien Le Moal <damien.lemoal@wdc.com>
Reviewed-by: Johannes Thumshirn <johannes.thumshirn@wdc.com>
Reviewed-by: Martin K. Petersen <martin.petersen@oracle.com>
Signed-off-by: Keith Busch <kbusch@kernel.org>
---
 drivers/nvme/host/core.c | 4 ++++
 1 file changed, 4 insertions(+)

diff --git a/drivers/nvme/host/core.c b/drivers/nvme/host/core.c
index 614cd455836b..a0d26fcbf923 100644
--- a/drivers/nvme/host/core.c
+++ b/drivers/nvme/host/core.c
@@ -236,6 +236,10 @@ 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:
+		return BLK_STS_ZONE_ACTIVE_RESOURCE;
+	case NVME_SC_ZONE_TOO_MANY_OPEN:
+		return BLK_STS_ZONE_OPEN_RESOURCE;
 	default:
 		return BLK_STS_IOERR;
 	}
-- 
2.24.1


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

* [PATCHv4 3/3] scsi: handle zone resources errors
  2020-09-24 20:53 [PATCHv4 0/3] zoned block device specific errors Keith Busch
  2020-09-24 20:53 ` [PATCHv4 1/3] block: add zone specific block statuses Keith Busch
  2020-09-24 20:53 ` [PATCHv4 2/3] nvme: translate zone resource errors Keith Busch
@ 2020-09-24 20:53 ` Keith Busch
  2020-09-28  8:26   ` Johannes Thumshirn
  2 siblings, 1 reply; 10+ messages in thread
From: Keith Busch @ 2020-09-24 20:53 UTC (permalink / raw)
  To: axboe
  Cc: linux-nvme, linux-block, linux-scsi, hch, Damien Le Moal,
	Martin K . Petersen, Keith Busch

From: Damien Le Moal <damien.lemoal@wdc.com>

ZBC or ZAC disks that have a limit on the number of open zones may fail
a zone open command or a write to a zone that is not already implicitly
or explicitly open if the total number of open zones is already at the
maximum allowed.

For these operations, instead of returning the generic BLK_STS_IOERR,
return BLK_STS_ZONE_OPEN_RESOURCE which is returned as -ETOOMANYREFS to
the I/O issuer, allowing the device user to act appropriately on these
relatively benign zone resource errors.

Acked-by: Martin K. Petersen <martin.petersen@oracle.com>
Reviewed-by: Christoph Hellwig <hch@lst.de>
Signed-off-by: Damien Le Moal <damien.lemoal@wdc.com>
Signed-off-by: Keith Busch <kbusch@kernel.org>
---
 drivers/scsi/scsi_lib.c | 9 +++++++++
 1 file changed, 9 insertions(+)

diff --git a/drivers/scsi/scsi_lib.c b/drivers/scsi/scsi_lib.c
index 7affaaf8b98e..c129ac6666da 100644
--- a/drivers/scsi/scsi_lib.c
+++ b/drivers/scsi/scsi_lib.c
@@ -758,6 +758,15 @@ static void scsi_io_completion_action(struct scsi_cmnd *cmd, int result)
 			/* See SSC3rXX or current. */
 			action = ACTION_FAIL;
 			break;
+		case DATA_PROTECT:
+			action = ACTION_FAIL;
+			if ((sshdr.asc == 0x0C && sshdr.ascq == 0x12) ||
+			    (sshdr.asc == 0x55 &&
+			     (sshdr.ascq == 0x0E || sshdr.ascq == 0x0F))) {
+				/* Insufficient zone resources */
+				blk_stat = BLK_STS_ZONE_OPEN_RESOURCE;
+			}
+			break;
 		default:
 			action = ACTION_FAIL;
 			break;
-- 
2.24.1


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

* Re: [PATCHv4 3/3] scsi: handle zone resources errors
  2020-09-24 20:53 ` [PATCHv4 3/3] scsi: handle zone resources errors Keith Busch
@ 2020-09-28  8:26   ` Johannes Thumshirn
  0 siblings, 0 replies; 10+ messages in thread
From: Johannes Thumshirn @ 2020-09-28  8:26 UTC (permalink / raw)
  To: Keith Busch, axboe
  Cc: linux-nvme, linux-block, linux-scsi, hch, Damien Le Moal,
	Martin K . Petersen

Looks good,
Reviewed-by: Johannes Thumshirn <johannes.thumshirn@wdc.com>

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

* Re: [PATCHv4 1/3] block: add zone specific block statuses
  2020-09-24 20:53 ` [PATCHv4 1/3] block: add zone specific block statuses Keith Busch
@ 2020-10-01 21:35   ` Keith Busch
  2020-10-09 15:29   ` Keith Busch
  1 sibling, 0 replies; 10+ messages in thread
From: Keith Busch @ 2020-10-01 21:35 UTC (permalink / raw)
  To: axboe
  Cc: linux-nvme, linux-block, linux-scsi, hch, linux-api,
	Niklas Cassel, Damien Le Moal, Johannes Thumshirn,
	Martin K . Petersen

On Thu, Sep 24, 2020 at 01:53:28PM -0700, Keith Busch wrote:
> A zoned device with limited resources to open or activate zones may
> return an error when the host exceeds those limits. The same command may
> be successful if retried later, but the host needs to wait for specific
> zone states before it should expect a retry to succeed. Have the block
> layer provide an appropriate status for these conditions so applications
> can distinuguish this error for special handling.

Hi Jens,

Just checking in -- do you have any thoughts on this, or should I just
wait a bit more?

thx,
Keith

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

* Re: [PATCHv4 1/3] block: add zone specific block statuses
  2020-09-24 20:53 ` [PATCHv4 1/3] block: add zone specific block statuses Keith Busch
  2020-10-01 21:35   ` Keith Busch
@ 2020-10-09 15:29   ` Keith Busch
  2020-10-13 17:16     ` Keith Busch
  1 sibling, 1 reply; 10+ messages in thread
From: Keith Busch @ 2020-10-09 15:29 UTC (permalink / raw)
  To: axboe
  Cc: linux-nvme, linux-block, linux-scsi, hch, linux-api,
	Niklas Cassel, Damien Le Moal, Johannes Thumshirn,
	Martin K . Petersen

On Thu, Sep 24, 2020 at 01:53:28PM -0700, Keith Busch wrote:
> A zoned device with limited resources to open or activate zones may
> return an error when the host exceeds those limits. The same command may
> be successful if retried later, but the host needs to wait for specific
> zone states before it should expect a retry to succeed. Have the block
> layer provide an appropriate status for these conditions so applications
> can distinuguish this error for special handling.

Hi Jens,

Can be considered for inclusion? The series still applies cleanly to
block for-next.

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

* Re: [PATCHv4 1/3] block: add zone specific block statuses
  2020-10-09 15:29   ` Keith Busch
@ 2020-10-13 17:16     ` Keith Busch
  2020-10-13 19:25       ` Jens Axboe
  0 siblings, 1 reply; 10+ messages in thread
From: Keith Busch @ 2020-10-13 17:16 UTC (permalink / raw)
  To: axboe
  Cc: linux-nvme, linux-block, linux-scsi, hch, linux-api,
	Niklas Cassel, Damien Le Moal, Johannes Thumshirn,
	Martin K . Petersen

Hi Jens,

I'm going to try one more time in the hope you've just been too busy to
notice these patches. The series has been unchanged for a month now, and
has reviews from all the right people. Can this be considered for
inclusion?

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

* Re: [PATCHv4 1/3] block: add zone specific block statuses
  2020-10-13 17:16     ` Keith Busch
@ 2020-10-13 19:25       ` Jens Axboe
  0 siblings, 0 replies; 10+ messages in thread
From: Jens Axboe @ 2020-10-13 19:25 UTC (permalink / raw)
  To: Keith Busch
  Cc: linux-nvme, linux-block, linux-scsi, hch, linux-api,
	Niklas Cassel, Damien Le Moal, Johannes Thumshirn,
	Martin K . Petersen

On 10/13/20 11:16 AM, Keith Busch wrote:
> Hi Jens,
> 
> I'm going to try one more time in the hope you've just been too busy to
> notice these patches. The series has been unchanged for a month now, and
> has reviews from all the right people. Can this be considered for
> inclusion?

Thanks for the pings, finally got them picked up. Sorry about the
delay!

-- 
Jens Axboe


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

* [PATCHv4 1/3] block: add zone specific block statuses
  2020-09-25  1:28 [PATCHv4 0/3] zoned block device specific errors Keith Busch
@ 2020-09-25  1:28 ` Keith Busch
  0 siblings, 0 replies; 10+ messages in thread
From: Keith Busch @ 2020-09-25  1:28 UTC (permalink / raw)
  To: axboe
  Cc: linux-nvme, linux-block, linux-scsi, hch, Keith Busch, linux-api,
	Niklas Cassel, Damien Le Moal, Johannes Thumshirn,
	Martin K . Petersen

A zoned device with limited resources to open or activate zones may
return an error when the host exceeds those limits. The same command may
be successful if retried later, but the host needs to wait for specific
zone states before it should expect a retry to succeed. Have the block
layer provide an appropriate status for these conditions so applications
can distinuguish this error for special handling.

Cc: linux-api@vger.kernel.org
Cc: Niklas Cassel <niklas.cassel@wdc.com>
Reviewed-by: Christoph Hellwig <hch@lst.de>
Reviewed-by: Damien Le Moal <damien.lemoal@wdc.com>
Reviewed-by: Johannes Thumshirn <johannes.thumshirn@wdc.com>
Reviewed-by: Martin K. Petersen <martin.petersen@oracle.com>
Signed-off-by: Keith Busch <kbusch@kernel.org>
---
 Documentation/block/queue-sysfs.rst |  8 ++++++++
 block/blk-core.c                    |  4 ++++
 include/linux/blk_types.h           | 18 ++++++++++++++++++
 3 files changed, 30 insertions(+)

diff --git a/Documentation/block/queue-sysfs.rst b/Documentation/block/queue-sysfs.rst
index f261a5c84170..2638d3446b79 100644
--- a/Documentation/block/queue-sysfs.rst
+++ b/Documentation/block/queue-sysfs.rst
@@ -124,6 +124,10 @@ For zoned block devices (zoned attribute indicating "host-managed" or
 EXPLICIT OPEN, IMPLICIT OPEN or CLOSED, is limited by this value.
 If this value is 0, there is no limit.
 
+If the host attempts to exceed this limit, the driver should report this error
+with BLK_STS_ZONE_ACTIVE_RESOURCE, which user space may see as the EOVERFLOW
+errno.
+
 max_open_zones (RO)
 -------------------
 For zoned block devices (zoned attribute indicating "host-managed" or
@@ -131,6 +135,10 @@ For zoned block devices (zoned attribute indicating "host-managed" or
 EXPLICIT OPEN or IMPLICIT OPEN, is limited by this value.
 If this value is 0, there is no limit.
 
+If the host attempts to exceed this limit, the driver should report this error
+with BLK_STS_ZONE_OPEN_RESOURCE, which user space may see as the ETOOMANYREFS
+errno.
+
 max_sectors_kb (RW)
 -------------------
 This is the maximum number of kilobytes that the block layer will allow
diff --git a/block/blk-core.c b/block/blk-core.c
index 10c08ac50697..8bffc7732e37 100644
--- a/block/blk-core.c
+++ b/block/blk-core.c
@@ -186,6 +186,10 @@ static const struct {
 	/* device mapper special case, should not leak out: */
 	[BLK_STS_DM_REQUEUE]	= { -EREMCHG, "dm internal retry" },
 
+	/* zone device specific errors */
+	[BLK_STS_ZONE_OPEN_RESOURCE]	= { -ETOOMANYREFS, "open zones exceeded" },
+	[BLK_STS_ZONE_ACTIVE_RESOURCE]	= { -EOVERFLOW, "active zones exceeded" },
+
 	/* everything else not covered above: */
 	[BLK_STS_IOERR]		= { -EIO,	"I/O" },
 };
diff --git a/include/linux/blk_types.h b/include/linux/blk_types.h
index 4ecf4fed171f..8603fc5f86a3 100644
--- a/include/linux/blk_types.h
+++ b/include/linux/blk_types.h
@@ -103,6 +103,24 @@ typedef u8 __bitwise blk_status_t;
  */
 #define BLK_STS_ZONE_RESOURCE	((__force blk_status_t)14)
 
+/*
+ * BLK_STS_ZONE_OPEN_RESOURCE is returned from the driver in the completion
+ * path if the device returns a status indicating that too many zone resources
+ * are currently open. The same command should be successful if resubmitted
+ * after the number of open zones decreases below the device's limits, which is
+ * reported in the request_queue's max_open_zones.
+ */
+#define BLK_STS_ZONE_OPEN_RESOURCE	((__force blk_status_t)15)
+
+/*
+ * BLK_STS_ZONE_ACTIVE_RESOURCE is returned from the driver in the completion
+ * path if the device returns a status indicating that too many zone resources
+ * are currently active. The same command should be successful if resubmitted
+ * after the number of active zones decreases below the device's limits, which
+ * is reported in the request_queue's max_active_zones.
+ */
+#define BLK_STS_ZONE_ACTIVE_RESOURCE	((__force blk_status_t)16)
+
 /**
  * blk_path_error - returns true if error may be path related
  * @error: status the request was completed with
-- 
2.24.1


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

end of thread, back to index

Thread overview: 10+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-09-24 20:53 [PATCHv4 0/3] zoned block device specific errors Keith Busch
2020-09-24 20:53 ` [PATCHv4 1/3] block: add zone specific block statuses Keith Busch
2020-10-01 21:35   ` Keith Busch
2020-10-09 15:29   ` Keith Busch
2020-10-13 17:16     ` Keith Busch
2020-10-13 19:25       ` Jens Axboe
2020-09-24 20:53 ` [PATCHv4 2/3] nvme: translate zone resource errors Keith Busch
2020-09-24 20:53 ` [PATCHv4 3/3] scsi: handle zone resources errors Keith Busch
2020-09-28  8:26   ` Johannes Thumshirn
2020-09-25  1:28 [PATCHv4 0/3] zoned block device specific errors Keith Busch
2020-09-25  1:28 ` [PATCHv4 1/3] block: add zone specific block statuses Keith Busch

Linux-Block Archive on lore.kernel.org

Archives are clonable:
	git clone --mirror https://lore.kernel.org/linux-block/0 linux-block/git/0.git

	# If you have public-inbox 1.1+ installed, you may
	# initialize and index your mirror using the following commands:
	public-inbox-init -V2 linux-block linux-block/ https://lore.kernel.org/linux-block \
		linux-block@vger.kernel.org
	public-inbox-index linux-block

Example config snippet for mirrors

Newsgroup available over NNTP:
	nntp://nntp.lore.kernel.org/org.kernel.vger.linux-block


AGPL code for this site: git clone https://public-inbox.org/public-inbox.git