linux-block.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH 0/8] Zone management commands support
@ 2019-10-27 14:05 Damien Le Moal
  2019-10-27 14:05 ` [PATCH 1/8] block: Remove REQ_OP_ZONE_RESET plugging Damien Le Moal
                   ` (9 more replies)
  0 siblings, 10 replies; 31+ messages in thread
From: Damien Le Moal @ 2019-10-27 14:05 UTC (permalink / raw)
  To: linux-block, Jens Axboe, linux-scsi, Martin K . Petersen,
	dm-devel, Mike Snitzer
  Cc: Ajay Joshi, Matias Bjorling, Hans Holmberg, Dmitry Fomichev, Keith Busch

This series implements a few improvements and cleanups to zone block
device zone reset operations with the first three patches.

The remaining of the series patches introduce zone open, close and
finish support, allowing users of zoned block devices to explicitly
control the condition (state) of zones.

While these operations are not stricktly necessary for the correct
operation of zoned block devices, the open and close operations can
improve performance for some device implementations of the ZBC and ZAC
standards under write workloads. The finish zone operation, which
transition a zone to the full state, can also be useful to protect a
zone data by preventing further zone writes.

These operations are implemented by introducing the new
REQ_OP_ZONE_OPEN, REQ_OP_ZONE_CLOSE and REQ_OP_ZONE_FINISH request codes
and the function blkdev_zone_mgmt() to issue these requests. This new
function also replaces the former blkdev_reset_zones() function to reset
zones write pointer.

The new ioctls BLKOPENZONE, BLKCLOSEZONE and BLKFINISHZONE are also
defined to allow applications to issue these new requests without
resorting to a device passthrough interface (e.g. SG_IO).

Support for these operations is added to the SCSI sd driver, to the dm
infrastructure (dm-linear and dm-flakey targets) and to the null_blk
driver.

Ajay Joshi (5):
  block: add zone open, close and finish operations
  block: add zone open, close and finish ioctl support
  scsi: sd_zbc: add zone open, close, and finish support
  dm: add zone open, close and finish support
  null_blk: add zone open, close, and finish support

Damien Le Moal (3):
  block: Remove REQ_OP_ZONE_RESET plugging
  block: Simplify REQ_OP_ZONE_RESET_ALL handling
  scsi: sd_zbc: Fix sd_zbc_complete()

 block/blk-core.c               | 12 +++--
 block/blk-zoned.c              | 99 ++++++++++++++++++----------------
 block/ioctl.c                  |  5 +-
 drivers/block/null_blk_zoned.c | 33 ++++++++++--
 drivers/md/dm-flakey.c         |  7 ++-
 drivers/md/dm-linear.c         |  2 +-
 drivers/md/dm-zoned-metadata.c |  6 +--
 drivers/md/dm.c                |  5 +-
 drivers/scsi/sd.c              | 15 +++++-
 drivers/scsi/sd.h              |  8 +--
 drivers/scsi/sd_zbc.c          | 43 +++++++--------
 fs/f2fs/segment.c              |  3 +-
 include/linux/blk_types.h      | 25 +++++++++
 include/linux/blkdev.h         | 15 +++---
 include/uapi/linux/blkzoned.h  | 17 ++++--
 15 files changed, 192 insertions(+), 103 deletions(-)

-- 
2.21.0


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

* [PATCH 1/8] block: Remove REQ_OP_ZONE_RESET plugging
  2019-10-27 14:05 [PATCH 0/8] Zone management commands support Damien Le Moal
@ 2019-10-27 14:05 ` Damien Le Moal
  2019-10-28  7:50   ` Chaitanya Kulkarni
                     ` (2 more replies)
  2019-10-27 14:05 ` [PATCH 2/8] block: Simplify REQ_OP_ZONE_RESET_ALL handling Damien Le Moal
                   ` (8 subsequent siblings)
  9 siblings, 3 replies; 31+ messages in thread
From: Damien Le Moal @ 2019-10-27 14:05 UTC (permalink / raw)
  To: linux-block, Jens Axboe, linux-scsi, Martin K . Petersen,
	dm-devel, Mike Snitzer
  Cc: Ajay Joshi, Matias Bjorling, Hans Holmberg, Dmitry Fomichev, Keith Busch

REQ_OP_ZONE_RESET operations cannot be merged as these bios and requests
do not have a size and are never sequential due to the zone start sector
position required for their execution. As a result, there is no point in
using a plug around blkdev_reset_zones() bio issuing loop. This patch
removes this unnecessary plugging.

Signed-off-by: Damien Le Moal <damien.lemoal@wdc.com>
---
 block/blk-zoned.c | 4 ----
 1 file changed, 4 deletions(-)

diff --git a/block/blk-zoned.c b/block/blk-zoned.c
index 4bc5f260248a..7fe376eede86 100644
--- a/block/blk-zoned.c
+++ b/block/blk-zoned.c
@@ -258,7 +258,6 @@ int blkdev_reset_zones(struct block_device *bdev,
 	sector_t zone_sectors;
 	sector_t end_sector = sector + nr_sectors;
 	struct bio *bio = NULL;
-	struct blk_plug plug;
 	int ret;
 
 	if (!blk_queue_is_zoned(q))
@@ -283,7 +282,6 @@ int blkdev_reset_zones(struct block_device *bdev,
 	    end_sector != bdev->bd_part->nr_sects)
 		return -EINVAL;
 
-	blk_start_plug(&plug);
 	while (sector < end_sector) {
 
 		bio = blk_next_bio(bio, 0, gfp_mask);
@@ -301,8 +299,6 @@ int blkdev_reset_zones(struct block_device *bdev,
 	ret = submit_bio_wait(bio);
 	bio_put(bio);
 
-	blk_finish_plug(&plug);
-
 	return ret;
 }
 EXPORT_SYMBOL_GPL(blkdev_reset_zones);
-- 
2.21.0


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

* [PATCH 2/8] block: Simplify REQ_OP_ZONE_RESET_ALL handling
  2019-10-27 14:05 [PATCH 0/8] Zone management commands support Damien Le Moal
  2019-10-27 14:05 ` [PATCH 1/8] block: Remove REQ_OP_ZONE_RESET plugging Damien Le Moal
@ 2019-10-27 14:05 ` Damien Le Moal
  2019-10-28  7:49   ` Chaitanya Kulkarni
  2019-11-07  9:51   ` Christoph Hellwig
  2019-10-27 14:05 ` [PATCH 3/8] scsi: sd_zbc: Fix sd_zbc_complete() Damien Le Moal
                   ` (7 subsequent siblings)
  9 siblings, 2 replies; 31+ messages in thread
From: Damien Le Moal @ 2019-10-27 14:05 UTC (permalink / raw)
  To: linux-block, Jens Axboe, linux-scsi, Martin K . Petersen,
	dm-devel, Mike Snitzer
  Cc: Ajay Joshi, Matias Bjorling, Hans Holmberg, Dmitry Fomichev, Keith Busch

There is no need for the function __blkdev_reset_all_zones() as
REQ_OP_ZONE_RESET_ALL can be handled directly in blkdev_reset_zones()
bio loop with an early break from the loop. This patch removes this
function and modifies blkdev_reset_zones(), simplifying the code.

Signed-off-by: Damien Le Moal <damien.lemoal@wdc.com>
---
 block/blk-zoned.c | 40 +++++++++++++---------------------------
 1 file changed, 13 insertions(+), 27 deletions(-)

diff --git a/block/blk-zoned.c b/block/blk-zoned.c
index 7fe376eede86..14785011e798 100644
--- a/block/blk-zoned.c
+++ b/block/blk-zoned.c
@@ -202,32 +202,14 @@ int blkdev_report_zones(struct block_device *bdev, sector_t sector,
 }
 EXPORT_SYMBOL_GPL(blkdev_report_zones);
 
-/*
- * Special case of zone reset operation to reset all zones in one command,
- * useful for applications like mkfs.
- */
-static int __blkdev_reset_all_zones(struct block_device *bdev, gfp_t gfp_mask)
-{
-	struct bio *bio = bio_alloc(gfp_mask, 0);
-	int ret;
-
-	/* across the zones operations, don't need any sectors */
-	bio_set_dev(bio, bdev);
-	bio_set_op_attrs(bio, REQ_OP_ZONE_RESET_ALL, 0);
-
-	ret = submit_bio_wait(bio);
-	bio_put(bio);
-
-	return ret;
-}
-
 static inline bool blkdev_allow_reset_all_zones(struct block_device *bdev,
+						sector_t sector,
 						sector_t nr_sectors)
 {
 	if (!blk_queue_zone_resetall(bdev_get_queue(bdev)))
 		return false;
 
-	if (nr_sectors != part_nr_sects_read(bdev->bd_part))
+	if (sector || nr_sectors != part_nr_sects_read(bdev->bd_part))
 		return false;
 	/*
 	 * REQ_OP_ZONE_RESET_ALL can be executed only if the block device is
@@ -270,9 +252,6 @@ int blkdev_reset_zones(struct block_device *bdev,
 		/* Out of range */
 		return -EINVAL;
 
-	if (blkdev_allow_reset_all_zones(bdev, nr_sectors))
-		return  __blkdev_reset_all_zones(bdev, gfp_mask);
-
 	/* Check alignment (handle eventual smaller last zone) */
 	zone_sectors = blk_queue_zone_sectors(q);
 	if (sector & (zone_sectors - 1))
@@ -283,17 +262,24 @@ int blkdev_reset_zones(struct block_device *bdev,
 		return -EINVAL;
 
 	while (sector < end_sector) {
-
 		bio = blk_next_bio(bio, 0, gfp_mask);
-		bio->bi_iter.bi_sector = sector;
 		bio_set_dev(bio, bdev);
-		bio_set_op_attrs(bio, REQ_OP_ZONE_RESET, 0);
 
+		/*
+		 * Special case for the zone reset operation that reset all
+		 * zones, this is useful for applications like mkfs.
+		 */
+		if (blkdev_allow_reset_all_zones(bdev, sector, nr_sectors)) {
+			bio->bi_opf = REQ_OP_ZONE_RESET_ALL;
+			break;
+		}
+
+		bio->bi_opf = REQ_OP_ZONE_RESET;
+		bio->bi_iter.bi_sector = sector;
 		sector += zone_sectors;
 
 		/* This may take a while, so be nice to others */
 		cond_resched();
-
 	}
 
 	ret = submit_bio_wait(bio);
-- 
2.21.0


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

* [PATCH 3/8] scsi: sd_zbc: Fix sd_zbc_complete()
  2019-10-27 14:05 [PATCH 0/8] Zone management commands support Damien Le Moal
  2019-10-27 14:05 ` [PATCH 1/8] block: Remove REQ_OP_ZONE_RESET plugging Damien Le Moal
  2019-10-27 14:05 ` [PATCH 2/8] block: Simplify REQ_OP_ZONE_RESET_ALL handling Damien Le Moal
@ 2019-10-27 14:05 ` Damien Le Moal
  2019-11-02  0:42   ` Martin K. Petersen
  2019-10-27 14:05 ` [PATCH 4/8] block: add zone open, close and finish operations Damien Le Moal
                   ` (6 subsequent siblings)
  9 siblings, 1 reply; 31+ messages in thread
From: Damien Le Moal @ 2019-10-27 14:05 UTC (permalink / raw)
  To: linux-block, Jens Axboe, linux-scsi, Martin K . Petersen,
	dm-devel, Mike Snitzer
  Cc: Ajay Joshi, Matias Bjorling, Hans Holmberg, Dmitry Fomichev, Keith Busch

The ILLEGAL REQUEST/INVALID FIELD IN CDB error generated by an attempt
to reset a conventional zone does not apply to the reset write pointer
command with the ALL bit set, that is, to REQ_OP_ZONE_RESET_ALL
requests. Fix sd_zbc_complete() to be quiet only in the case of
REQ_OP_ZONE_RESET, excluding REQ_OP_ZONE_RESET_ALL.

Since REQ_OP_ZONE_RESET is the only request handled by
sd_zbc_complete(), also simplify the code using a simple if statement.

Fixes: d81e9d494354 ("scsi: implement REQ_OP_ZONE_RESET_ALL")
Cc: stable@vger.kernel.org
Signed-off-by: Damien Le Moal <damien.lemoal@wdc.com>
---
 drivers/scsi/sd_zbc.c | 29 ++++++++++-------------------
 1 file changed, 10 insertions(+), 19 deletions(-)

diff --git a/drivers/scsi/sd_zbc.c b/drivers/scsi/sd_zbc.c
index de4019dc0f0b..1efc69e194f8 100644
--- a/drivers/scsi/sd_zbc.c
+++ b/drivers/scsi/sd_zbc.c
@@ -263,25 +263,16 @@ void sd_zbc_complete(struct scsi_cmnd *cmd, unsigned int good_bytes,
 	int result = cmd->result;
 	struct request *rq = cmd->request;
 
-	switch (req_op(rq)) {
-	case REQ_OP_ZONE_RESET:
-	case REQ_OP_ZONE_RESET_ALL:
-
-		if (result &&
-		    sshdr->sense_key == ILLEGAL_REQUEST &&
-		    sshdr->asc == 0x24)
-			/*
-			 * INVALID FIELD IN CDB error: reset of a conventional
-			 * zone was attempted. Nothing to worry about, so be
-			 * quiet about the error.
-			 */
-			rq->rq_flags |= RQF_QUIET;
-		break;
-
-	case REQ_OP_WRITE:
-	case REQ_OP_WRITE_ZEROES:
-	case REQ_OP_WRITE_SAME:
-		break;
+	if (req_op(rq) == REQ_OP_ZONE_RESET &&
+	    result &&
+	    sshdr->sense_key == ILLEGAL_REQUEST &&
+	    sshdr->asc == 0x24) {
+		/*
+		 * INVALID FIELD IN CDB error: reset of a conventional
+		 * zone was attempted. Nothing to worry about, so be
+		 * quiet about the error.
+		 */
+		rq->rq_flags |= RQF_QUIET;
 	}
 }
 
-- 
2.21.0


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

* [PATCH 4/8] block: add zone open, close and finish operations
  2019-10-27 14:05 [PATCH 0/8] Zone management commands support Damien Le Moal
                   ` (2 preceding siblings ...)
  2019-10-27 14:05 ` [PATCH 3/8] scsi: sd_zbc: Fix sd_zbc_complete() Damien Le Moal
@ 2019-10-27 14:05 ` Damien Le Moal
  2019-10-29 12:23   ` Javier González
  2019-11-07  9:52   ` Christoph Hellwig
  2019-10-27 14:05 ` [PATCH 5/8] block: add zone open, close and finish ioctl support Damien Le Moal
                   ` (5 subsequent siblings)
  9 siblings, 2 replies; 31+ messages in thread
From: Damien Le Moal @ 2019-10-27 14:05 UTC (permalink / raw)
  To: linux-block, Jens Axboe, linux-scsi, Martin K . Petersen,
	dm-devel, Mike Snitzer
  Cc: Ajay Joshi, Matias Bjorling, Hans Holmberg, Dmitry Fomichev, Keith Busch

From: Ajay Joshi <ajay.joshi@wdc.com>

Zoned block devices (ZBC and ZAC devices) allow an explicit control
over the condition (state) of zones. The operations allowed are:
* Open a zone: Transition to open condition to indicate that a zone will
  actively be written
* Close a zone: Transition to closed condition to release the drive
  resources used for writing to a zone
* Finish a zone: Transition an open or closed zone to the full
  condition to prevent write operations

To enable this control for in-kernel zoned block device users, define
the new request operations REQ_OP_ZONE_OPEN, REQ_OP_ZONE_CLOSE
and REQ_OP_ZONE_FINISH as well as the generic function
blkdev_zone_mgmt() for submitting these operations on a range of zones.
This results in blkdev_reset_zones() removal and replacement with this
new zone magement function. Users of blkdev_reset_zones() (f2fs and
dm-zoned) are updated accordingly.

Contains contributions from Matias Bjorling, Hans Holmberg,
Dmitry Fomichev, Keith Busch, Damien Le Moal and Christoph Hellwig.

Signed-off-by: Ajay Joshi <ajay.joshi@wdc.com>
Signed-off-by: Matias Bjorling <matias.bjorling@wdc.com>
Signed-off-by: Hans Holmberg <hans.holmberg@wdc.com>
Signed-off-by: Dmitry Fomichev <dmitry.fomichev@wdc.com>
Signed-off-by: Keith Busch <kbusch@kernel.org>
Signed-off-by: Damien Le Moal <damien.lemoal@wdc.com>
---
 block/blk-core.c               | 12 +++++++++---
 block/blk-zoned.c              | 35 ++++++++++++++++++++--------------
 drivers/md/dm-zoned-metadata.c |  6 +++---
 fs/f2fs/segment.c              |  3 ++-
 include/linux/blk_types.h      | 25 ++++++++++++++++++++++++
 include/linux/blkdev.h         |  5 +++--
 6 files changed, 63 insertions(+), 23 deletions(-)

diff --git a/block/blk-core.c b/block/blk-core.c
index d5e668ec751b..3306a3c5bed6 100644
--- a/block/blk-core.c
+++ b/block/blk-core.c
@@ -132,6 +132,9 @@ static const char *const blk_op_name[] = {
 	REQ_OP_NAME(SECURE_ERASE),
 	REQ_OP_NAME(ZONE_RESET),
 	REQ_OP_NAME(ZONE_RESET_ALL),
+	REQ_OP_NAME(ZONE_OPEN),
+	REQ_OP_NAME(ZONE_CLOSE),
+	REQ_OP_NAME(ZONE_FINISH),
 	REQ_OP_NAME(WRITE_SAME),
 	REQ_OP_NAME(WRITE_ZEROES),
 	REQ_OP_NAME(SCSI_IN),
@@ -849,10 +852,10 @@ static inline int blk_partition_remap(struct bio *bio)
 		goto out;
 
 	/*
-	 * Zone reset does not include bi_size so bio_sectors() is always 0.
-	 * Include a test for the reset op code and perform the remap if needed.
+	 * Zone management bios do not have a sector count but they do have
+	 * a start sector filled out and need to be remapped.
 	 */
-	if (bio_sectors(bio) || bio_op(bio) == REQ_OP_ZONE_RESET) {
+	if (bio_sectors(bio) || op_is_zone_mgmt(bio_op(bio))) {
 		if (bio_check_eod(bio, part_nr_sects_read(p)))
 			goto out;
 		bio->bi_iter.bi_sector += p->start_sect;
@@ -936,6 +939,9 @@ generic_make_request_checks(struct bio *bio)
 			goto not_supported;
 		break;
 	case REQ_OP_ZONE_RESET:
+	case REQ_OP_ZONE_OPEN:
+	case REQ_OP_ZONE_CLOSE:
+	case REQ_OP_ZONE_FINISH:
 		if (!blk_queue_is_zoned(q))
 			goto not_supported;
 		break;
diff --git a/block/blk-zoned.c b/block/blk-zoned.c
index 14785011e798..dab34dc48fb6 100644
--- a/block/blk-zoned.c
+++ b/block/blk-zoned.c
@@ -221,23 +221,27 @@ static inline bool blkdev_allow_reset_all_zones(struct block_device *bdev,
 }
 
 /**
- * blkdev_reset_zones - Reset zones write pointer
+ * blkdev_zone_mgmt - Execute a zone management operation on a range of zones
  * @bdev:	Target block device
- * @sector:	Start sector of the first zone to reset
- * @nr_sectors:	Number of sectors, at least the length of one zone
+ * @op:		Operation to be performed on the zones
+ * @sector:	Start sector of the first zone to operate on
+ * @nr_sectors:	Number of sectors, should be at least the length of one zone and
+ *		must be zone size aligned.
  * @gfp_mask:	Memory allocation flags (for bio_alloc)
  *
  * Description:
- *    Reset the write pointer of the zones contained in the range
+ *    Perform the specified operation on the range of zones specified by
  *    @sector..@sector+@nr_sectors. Specifying the entire disk sector range
  *    is valid, but the specified range should not contain conventional zones.
+ *    The operation to execute on each zone can be a zone reset, open, close
+ *    or finish request.
  */
-int blkdev_reset_zones(struct block_device *bdev,
-		       sector_t sector, sector_t nr_sectors,
-		       gfp_t gfp_mask)
+int blkdev_zone_mgmt(struct block_device *bdev, enum req_opf op,
+		     sector_t sector, sector_t nr_sectors,
+		     gfp_t gfp_mask)
 {
 	struct request_queue *q = bdev_get_queue(bdev);
-	sector_t zone_sectors;
+	sector_t zone_sectors = blk_queue_zone_sectors(q);
 	sector_t end_sector = sector + nr_sectors;
 	struct bio *bio = NULL;
 	int ret;
@@ -248,12 +252,14 @@ int blkdev_reset_zones(struct block_device *bdev,
 	if (bdev_read_only(bdev))
 		return -EPERM;
 
+	if (!op_is_zone_mgmt(op))
+		return -EOPNOTSUPP;
+
 	if (!nr_sectors || end_sector > bdev->bd_part->nr_sects)
 		/* Out of range */
 		return -EINVAL;
 
 	/* Check alignment (handle eventual smaller last zone) */
-	zone_sectors = blk_queue_zone_sectors(q);
 	if (sector & (zone_sectors - 1))
 		return -EINVAL;
 
@@ -269,12 +275,13 @@ int blkdev_reset_zones(struct block_device *bdev,
 		 * Special case for the zone reset operation that reset all
 		 * zones, this is useful for applications like mkfs.
 		 */
-		if (blkdev_allow_reset_all_zones(bdev, sector, nr_sectors)) {
+		if (op == REQ_OP_ZONE_RESET &&
+		    blkdev_allow_reset_all_zones(bdev, sector, nr_sectors)) {
 			bio->bi_opf = REQ_OP_ZONE_RESET_ALL;
 			break;
 		}
 
-		bio->bi_opf = REQ_OP_ZONE_RESET;
+		bio->bi_opf = op;
 		bio->bi_iter.bi_sector = sector;
 		sector += zone_sectors;
 
@@ -287,7 +294,7 @@ int blkdev_reset_zones(struct block_device *bdev,
 
 	return ret;
 }
-EXPORT_SYMBOL_GPL(blkdev_reset_zones);
+EXPORT_SYMBOL_GPL(blkdev_zone_mgmt);
 
 /*
  * BLKREPORTZONE ioctl processing.
@@ -379,8 +386,8 @@ int blkdev_reset_zones_ioctl(struct block_device *bdev, fmode_t mode,
 	if (copy_from_user(&zrange, argp, sizeof(struct blk_zone_range)))
 		return -EFAULT;
 
-	return blkdev_reset_zones(bdev, zrange.sector, zrange.nr_sectors,
-				  GFP_KERNEL);
+	return blkdev_zone_mgmt(bdev, REQ_OP_ZONE_RESET,
+				zrange.sector, zrange.nr_sectors, GFP_KERNEL);
 }
 
 static inline unsigned long *blk_alloc_zone_bitmap(int node,
diff --git a/drivers/md/dm-zoned-metadata.c b/drivers/md/dm-zoned-metadata.c
index 595a73110e17..feb4718ce6a6 100644
--- a/drivers/md/dm-zoned-metadata.c
+++ b/drivers/md/dm-zoned-metadata.c
@@ -1312,9 +1312,9 @@ static int dmz_reset_zone(struct dmz_metadata *zmd, struct dm_zone *zone)
 	if (!dmz_is_empty(zone) || dmz_seq_write_err(zone)) {
 		struct dmz_dev *dev = zmd->dev;
 
-		ret = blkdev_reset_zones(dev->bdev,
-					 dmz_start_sect(zmd, zone),
-					 dev->zone_nr_sectors, GFP_NOIO);
+		ret = blkdev_zone_mgmt(dev->bdev, REQ_OP_ZONE_RESET,
+				       dmz_start_sect(zmd, zone),
+				       dev->zone_nr_sectors, GFP_NOIO);
 		if (ret) {
 			dmz_dev_err(dev, "Reset zone %u failed %d",
 				    dmz_id(zmd, zone), ret);
diff --git a/fs/f2fs/segment.c b/fs/f2fs/segment.c
index 808709581481..2c997f94a3b2 100644
--- a/fs/f2fs/segment.c
+++ b/fs/f2fs/segment.c
@@ -1771,7 +1771,8 @@ static int __f2fs_issue_discard_zone(struct f2fs_sb_info *sbi,
 			return -EIO;
 		}
 		trace_f2fs_issue_reset_zone(bdev, blkstart);
-		return blkdev_reset_zones(bdev, sector, nr_sects, GFP_NOFS);
+		return blkdev_zone_mgmt(bdev, REQ_OP_ZONE_RESET,
+					sector, nr_sects, GFP_NOFS);
 	}
 
 	/* For conventional zones, use regular discard if supported */
diff --git a/include/linux/blk_types.h b/include/linux/blk_types.h
index d688b96d1d63..805d0efa2997 100644
--- a/include/linux/blk_types.h
+++ b/include/linux/blk_types.h
@@ -290,6 +290,12 @@ enum req_opf {
 	REQ_OP_ZONE_RESET_ALL	= 8,
 	/* write the zero filled sector many times */
 	REQ_OP_WRITE_ZEROES	= 9,
+	/* Open a zone */
+	REQ_OP_ZONE_OPEN	= 10,
+	/* Close a zone */
+	REQ_OP_ZONE_CLOSE	= 11,
+	/* Transition a zone to full */
+	REQ_OP_ZONE_FINISH	= 12,
 
 	/* SCSI passthrough using struct scsi_request */
 	REQ_OP_SCSI_IN		= 32,
@@ -417,6 +423,25 @@ static inline bool op_is_discard(unsigned int op)
 	return (op & REQ_OP_MASK) == REQ_OP_DISCARD;
 }
 
+/*
+ * Check if a bio or request operation is a zone management operation, with
+ * the exception of REQ_OP_ZONE_RESET_ALL which is treated as a special case
+ * due to its different handling in the block layer and device response in
+ * case of command failure.
+ */
+static inline bool op_is_zone_mgmt(enum req_opf op)
+{
+	switch (op & REQ_OP_MASK) {
+	case REQ_OP_ZONE_RESET:
+	case REQ_OP_ZONE_OPEN:
+	case REQ_OP_ZONE_CLOSE:
+	case REQ_OP_ZONE_FINISH:
+		return true;
+	default:
+		return false;
+	}
+}
+
 static inline int op_stat_group(unsigned int op)
 {
 	if (op_is_discard(op))
diff --git a/include/linux/blkdev.h b/include/linux/blkdev.h
index f3ea78b0c91c..bf797a63388c 100644
--- a/include/linux/blkdev.h
+++ b/include/linux/blkdev.h
@@ -360,8 +360,9 @@ extern unsigned int blkdev_nr_zones(struct block_device *bdev);
 extern int blkdev_report_zones(struct block_device *bdev,
 			       sector_t sector, struct blk_zone *zones,
 			       unsigned int *nr_zones);
-extern int blkdev_reset_zones(struct block_device *bdev, sector_t sectors,
-			      sector_t nr_sectors, gfp_t gfp_mask);
+extern int blkdev_zone_mgmt(struct block_device *bdev, enum req_opf op,
+			    sector_t sectors, sector_t nr_sectors,
+			    gfp_t gfp_mask);
 extern int blk_revalidate_disk_zones(struct gendisk *disk);
 
 extern int blkdev_report_zones_ioctl(struct block_device *bdev, fmode_t mode,
-- 
2.21.0


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

* [PATCH 5/8] block: add zone open, close and finish ioctl support
  2019-10-27 14:05 [PATCH 0/8] Zone management commands support Damien Le Moal
                   ` (3 preceding siblings ...)
  2019-10-27 14:05 ` [PATCH 4/8] block: add zone open, close and finish operations Damien Le Moal
@ 2019-10-27 14:05 ` Damien Le Moal
  2019-10-29 12:23   ` Javier González
  2019-11-07  9:52   ` Christoph Hellwig
  2019-10-27 14:05 ` [PATCH 6/8] scsi: sd_zbc: add zone open, close, and finish support Damien Le Moal
                   ` (4 subsequent siblings)
  9 siblings, 2 replies; 31+ messages in thread
From: Damien Le Moal @ 2019-10-27 14:05 UTC (permalink / raw)
  To: linux-block, Jens Axboe, linux-scsi, Martin K . Petersen,
	dm-devel, Mike Snitzer
  Cc: Ajay Joshi, Matias Bjorling, Hans Holmberg, Dmitry Fomichev, Keith Busch

From: Ajay Joshi <ajay.joshi@wdc.com>

Introduce three new ioctl commands BLKOPENZONE, BLKCLOSEZONE and
BLKFINISHZONE to allow applications to control the condition of zones
on a zoned block device through the execution of the REQ_OP_ZONE_OPEN,
REQ_OP_ZONE_CLOSE and REQ_OP_ZONE_FINISH operations.

Contains contributions from Matias Bjorling, Hans Holmberg,
Dmitry Fomichev, Keith Busch, Damien Le Moal and Christoph Hellwig.

Signed-off-by: Ajay Joshi <ajay.joshi@wdc.com>
Signed-off-by: Matias Bjorling <matias.bjorling@wdc.com>
Signed-off-by: Hans Holmberg <hans.holmberg@wdc.com>
Signed-off-by: Dmitry Fomichev <dmitry.fomichev@wdc.com>
Signed-off-by: Keith Busch <kbusch@kernel.org>
Signed-off-by: Damien Le Moal <damien.lemoal@wdc.com>
---
 block/blk-zoned.c             | 28 +++++++++++++++++++++++-----
 block/ioctl.c                 |  5 ++++-
 include/linux/blkdev.h        | 10 +++++-----
 include/uapi/linux/blkzoned.h | 17 ++++++++++++++---
 4 files changed, 46 insertions(+), 14 deletions(-)

diff --git a/block/blk-zoned.c b/block/blk-zoned.c
index dab34dc48fb6..481eaf7d04d4 100644
--- a/block/blk-zoned.c
+++ b/block/blk-zoned.c
@@ -357,15 +357,16 @@ int blkdev_report_zones_ioctl(struct block_device *bdev, fmode_t mode,
 }
 
 /*
- * BLKRESETZONE ioctl processing.
+ * BLKRESETZONE, BLKOPENZONE, BLKCLOSEZONE and BLKFINISHZONE ioctl processing.
  * Called from blkdev_ioctl.
  */
-int blkdev_reset_zones_ioctl(struct block_device *bdev, fmode_t mode,
-			     unsigned int cmd, unsigned long arg)
+int blkdev_zone_mgmt_ioctl(struct block_device *bdev, fmode_t mode,
+			   unsigned int cmd, unsigned long arg)
 {
 	void __user *argp = (void __user *)arg;
 	struct request_queue *q;
 	struct blk_zone_range zrange;
+	enum req_opf op;
 
 	if (!argp)
 		return -EINVAL;
@@ -386,8 +387,25 @@ int blkdev_reset_zones_ioctl(struct block_device *bdev, fmode_t mode,
 	if (copy_from_user(&zrange, argp, sizeof(struct blk_zone_range)))
 		return -EFAULT;
 
-	return blkdev_zone_mgmt(bdev, REQ_OP_ZONE_RESET,
-				zrange.sector, zrange.nr_sectors, GFP_KERNEL);
+	switch (cmd) {
+	case BLKRESETZONE:
+		op = REQ_OP_ZONE_RESET;
+		break;
+	case BLKOPENZONE:
+		op = REQ_OP_ZONE_OPEN;
+		break;
+	case BLKCLOSEZONE:
+		op = REQ_OP_ZONE_CLOSE;
+		break;
+	case BLKFINISHZONE:
+		op = REQ_OP_ZONE_FINISH;
+		break;
+	default:
+		return -ENOTTY;
+	}
+
+	return blkdev_zone_mgmt(bdev, op, zrange.sector, zrange.nr_sectors,
+				GFP_KERNEL);
 }
 
 static inline unsigned long *blk_alloc_zone_bitmap(int node,
diff --git a/block/ioctl.c b/block/ioctl.c
index 15a0eb80ada9..8756efb1419e 100644
--- a/block/ioctl.c
+++ b/block/ioctl.c
@@ -532,7 +532,10 @@ int blkdev_ioctl(struct block_device *bdev, fmode_t mode, unsigned cmd,
 	case BLKREPORTZONE:
 		return blkdev_report_zones_ioctl(bdev, mode, cmd, arg);
 	case BLKRESETZONE:
-		return blkdev_reset_zones_ioctl(bdev, mode, cmd, arg);
+	case BLKOPENZONE:
+	case BLKCLOSEZONE:
+	case BLKFINISHZONE:
+		return blkdev_zone_mgmt_ioctl(bdev, mode, cmd, arg);
 	case BLKGETZONESZ:
 		return put_uint(arg, bdev_zone_sectors(bdev));
 	case BLKGETNRZONES:
diff --git a/include/linux/blkdev.h b/include/linux/blkdev.h
index bf797a63388c..dbef541c2530 100644
--- a/include/linux/blkdev.h
+++ b/include/linux/blkdev.h
@@ -367,8 +367,8 @@ extern int blk_revalidate_disk_zones(struct gendisk *disk);
 
 extern int blkdev_report_zones_ioctl(struct block_device *bdev, fmode_t mode,
 				     unsigned int cmd, unsigned long arg);
-extern int blkdev_reset_zones_ioctl(struct block_device *bdev, fmode_t mode,
-				    unsigned int cmd, unsigned long arg);
+extern int blkdev_zone_mgmt_ioctl(struct block_device *bdev, fmode_t mode,
+				  unsigned int cmd, unsigned long arg);
 
 #else /* CONFIG_BLK_DEV_ZONED */
 
@@ -389,9 +389,9 @@ static inline int blkdev_report_zones_ioctl(struct block_device *bdev,
 	return -ENOTTY;
 }
 
-static inline int blkdev_reset_zones_ioctl(struct block_device *bdev,
-					   fmode_t mode, unsigned int cmd,
-					   unsigned long arg)
+static inline int blkdev_zone_mgmt_ioctl(struct block_device *bdev,
+					 fmode_t mode, unsigned int cmd,
+					 unsigned long arg)
 {
 	return -ENOTTY;
 }
diff --git a/include/uapi/linux/blkzoned.h b/include/uapi/linux/blkzoned.h
index 498eec813494..0cdef67135f0 100644
--- a/include/uapi/linux/blkzoned.h
+++ b/include/uapi/linux/blkzoned.h
@@ -120,9 +120,11 @@ struct blk_zone_report {
 };
 
 /**
- * struct blk_zone_range - BLKRESETZONE ioctl request
- * @sector: starting sector of the first zone to issue reset write pointer
- * @nr_sectors: Total number of sectors of 1 or more zones to reset
+ * struct blk_zone_range - BLKRESETZONE/BLKOPENZONE/
+ *                         BLKCLOSEZONE/BLKFINISHZONE ioctl
+ *                         requests
+ * @sector: Starting sector of the first zone to operate on.
+ * @nr_sectors: Total number of sectors of all zones to operate on.
  */
 struct blk_zone_range {
 	__u64		sector;
@@ -139,10 +141,19 @@ struct blk_zone_range {
  *                sector range. The sector range must be zone aligned.
  * @BLKGETZONESZ: Get the device zone size in number of 512 B sectors.
  * @BLKGETNRZONES: Get the total number of zones of the device.
+ * @BLKOPENZONE: Open the zones in the specified sector range.
+ *               The 512 B sector range must be zone aligned.
+ * @BLKCLOSEZONE: Close the zones in the specified sector range.
+ *                The 512 B sector range must be zone aligned.
+ * @BLKFINISHZONE: Mark the zones as full in the specified sector range.
+ *                 The 512 B sector range must be zone aligned.
  */
 #define BLKREPORTZONE	_IOWR(0x12, 130, struct blk_zone_report)
 #define BLKRESETZONE	_IOW(0x12, 131, struct blk_zone_range)
 #define BLKGETZONESZ	_IOR(0x12, 132, __u32)
 #define BLKGETNRZONES	_IOR(0x12, 133, __u32)
+#define BLKOPENZONE	_IOW(0x12, 134, struct blk_zone_range)
+#define BLKCLOSEZONE	_IOW(0x12, 135, struct blk_zone_range)
+#define BLKFINISHZONE	_IOW(0x12, 136, struct blk_zone_range)
 
 #endif /* _UAPI_BLKZONED_H */
-- 
2.21.0


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

* [PATCH 6/8] scsi: sd_zbc: add zone open, close, and finish support
  2019-10-27 14:05 [PATCH 0/8] Zone management commands support Damien Le Moal
                   ` (4 preceding siblings ...)
  2019-10-27 14:05 ` [PATCH 5/8] block: add zone open, close and finish ioctl support Damien Le Moal
@ 2019-10-27 14:05 ` Damien Le Moal
  2019-11-02  0:43   ` Martin K. Petersen
  2019-11-07  9:53   ` Christoph Hellwig
  2019-10-27 14:05 ` [PATCH 7/8] dm: add zone open, close " Damien Le Moal
                   ` (3 subsequent siblings)
  9 siblings, 2 replies; 31+ messages in thread
From: Damien Le Moal @ 2019-10-27 14:05 UTC (permalink / raw)
  To: linux-block, Jens Axboe, linux-scsi, Martin K . Petersen,
	dm-devel, Mike Snitzer
  Cc: Ajay Joshi, Matias Bjorling, Hans Holmberg, Dmitry Fomichev, Keith Busch

From: Ajay Joshi <ajay.joshi@wdc.com>

Implement REQ_OP_ZONE_OPEN, REQ_OP_ZONE_CLOSE and REQ_OP_ZONE_FINISH
support to allow explicit control of zone states.

Contains contributions from Matias Bjorling, Hans Holmberg,
Keith Busch and Damien Le Moal.

Signed-off-by: Ajay Joshi <ajay.joshi@wdc.com>
Signed-off-by: Matias Bjorling <matias.bjorling@wdc.com>
Signed-off-by: Hans Holmberg <hans.holmberg@wdc.com>
Signed-off-by: Keith Busch <kbusch@kernel.org>
Signed-off-by: Damien Le Moal <damien.lemoal@wdc.com>
---
 drivers/scsi/sd.c     | 15 +++++++++++++--
 drivers/scsi/sd.h     |  8 +++++---
 drivers/scsi/sd_zbc.c | 22 +++++++++++++---------
 3 files changed, 31 insertions(+), 14 deletions(-)

diff --git a/drivers/scsi/sd.c b/drivers/scsi/sd.c
index 03163ac5fe95..ff0a22e2a34e 100644
--- a/drivers/scsi/sd.c
+++ b/drivers/scsi/sd.c
@@ -1290,9 +1290,17 @@ static blk_status_t sd_init_command(struct scsi_cmnd *cmd)
 	case REQ_OP_WRITE:
 		return sd_setup_read_write_cmnd(cmd);
 	case REQ_OP_ZONE_RESET:
-		return sd_zbc_setup_reset_cmnd(cmd, false);
+		return sd_zbc_setup_zone_mgmt_cmnd(cmd, ZO_RESET_WRITE_POINTER,
+						   false);
 	case REQ_OP_ZONE_RESET_ALL:
-		return sd_zbc_setup_reset_cmnd(cmd, true);
+		return sd_zbc_setup_zone_mgmt_cmnd(cmd, ZO_RESET_WRITE_POINTER,
+						   true);
+	case REQ_OP_ZONE_OPEN:
+		return sd_zbc_setup_zone_mgmt_cmnd(cmd, ZO_OPEN_ZONE, false);
+	case REQ_OP_ZONE_CLOSE:
+		return sd_zbc_setup_zone_mgmt_cmnd(cmd, ZO_CLOSE_ZONE, false);
+	case REQ_OP_ZONE_FINISH:
+		return sd_zbc_setup_zone_mgmt_cmnd(cmd, ZO_FINISH_ZONE, false);
 	default:
 		WARN_ON_ONCE(1);
 		return BLK_STS_NOTSUPP;
@@ -1960,6 +1968,9 @@ static int sd_done(struct scsi_cmnd *SCpnt)
 	case REQ_OP_WRITE_SAME:
 	case REQ_OP_ZONE_RESET:
 	case REQ_OP_ZONE_RESET_ALL:
+	case REQ_OP_ZONE_OPEN:
+	case REQ_OP_ZONE_CLOSE:
+	case REQ_OP_ZONE_FINISH:
 		if (!result) {
 			good_bytes = blk_rq_bytes(req);
 			scsi_set_resid(SCpnt, 0);
diff --git a/drivers/scsi/sd.h b/drivers/scsi/sd.h
index 1eab779f812b..bf2102a749bc 100644
--- a/drivers/scsi/sd.h
+++ b/drivers/scsi/sd.h
@@ -209,7 +209,8 @@ static inline int sd_is_zoned(struct scsi_disk *sdkp)
 
 extern int sd_zbc_read_zones(struct scsi_disk *sdkp, unsigned char *buffer);
 extern void sd_zbc_print_zones(struct scsi_disk *sdkp);
-extern blk_status_t sd_zbc_setup_reset_cmnd(struct scsi_cmnd *cmd, bool all);
+blk_status_t sd_zbc_setup_zone_mgmt_cmnd(struct scsi_cmnd *cmd,
+					 unsigned char op, bool all);
 extern void sd_zbc_complete(struct scsi_cmnd *cmd, unsigned int good_bytes,
 			    struct scsi_sense_hdr *sshdr);
 extern int sd_zbc_report_zones(struct gendisk *disk, sector_t sector,
@@ -225,8 +226,9 @@ static inline int sd_zbc_read_zones(struct scsi_disk *sdkp,
 
 static inline void sd_zbc_print_zones(struct scsi_disk *sdkp) {}
 
-static inline blk_status_t sd_zbc_setup_reset_cmnd(struct scsi_cmnd *cmd,
-						   bool all)
+static inline blk_status_t sd_zbc_setup_zone_mgmt_cmnd(struct scsi_cmnd *cmd,
+						       unsigned char op,
+						       bool all)
 {
 	return BLK_STS_TARGET;
 }
diff --git a/drivers/scsi/sd_zbc.c b/drivers/scsi/sd_zbc.c
index 1efc69e194f8..39f10ec0dfcf 100644
--- a/drivers/scsi/sd_zbc.c
+++ b/drivers/scsi/sd_zbc.c
@@ -207,13 +207,17 @@ static inline sector_t sd_zbc_zone_sectors(struct scsi_disk *sdkp)
 }
 
 /**
- * sd_zbc_setup_reset_cmnd - Prepare a RESET WRITE POINTER scsi command.
+ * sd_zbc_setup_zone_mgmt_cmnd - Prepare a zone ZBC_OUT command. The operations
+ *			can be RESET WRITE POINTER, OPEN, CLOSE or FINISH.
  * @cmd: the command to setup
- * @all: Reset all zones control.
+ * @op: Operation to be performed
+ * @all: All zones control
  *
- * Called from sd_init_command() for a REQ_OP_ZONE_RESET request.
+ * Called from sd_init_command() for REQ_OP_ZONE_RESET, REQ_OP_ZONE_RESET_ALL,
+ * REQ_OP_ZONE_OPEN, REQ_OP_ZONE_CLOSE or REQ_OP_ZONE_FINISH requests.
  */
-blk_status_t sd_zbc_setup_reset_cmnd(struct scsi_cmnd *cmd, bool all)
+blk_status_t sd_zbc_setup_zone_mgmt_cmnd(struct scsi_cmnd *cmd,
+					 unsigned char op, bool all)
 {
 	struct request *rq = cmd->request;
 	struct scsi_disk *sdkp = scsi_disk(rq->rq_disk);
@@ -234,7 +238,7 @@ blk_status_t sd_zbc_setup_reset_cmnd(struct scsi_cmnd *cmd, bool all)
 	cmd->cmd_len = 16;
 	memset(cmd->cmnd, 0, cmd->cmd_len);
 	cmd->cmnd[0] = ZBC_OUT;
-	cmd->cmnd[1] = ZO_RESET_WRITE_POINTER;
+	cmd->cmnd[1] = op;
 	if (all)
 		cmd->cmnd[14] = 0x1;
 	else
@@ -263,14 +267,14 @@ void sd_zbc_complete(struct scsi_cmnd *cmd, unsigned int good_bytes,
 	int result = cmd->result;
 	struct request *rq = cmd->request;
 
-	if (req_op(rq) == REQ_OP_ZONE_RESET &&
+	if (op_is_zone_mgmt(req_op(rq)) &&
 	    result &&
 	    sshdr->sense_key == ILLEGAL_REQUEST &&
 	    sshdr->asc == 0x24) {
 		/*
-		 * INVALID FIELD IN CDB error: reset of a conventional
-		 * zone was attempted. Nothing to worry about, so be
-		 * quiet about the error.
+		 * INVALID FIELD IN CDB error: a zone management command was
+		 * attempted on a conventional zone. Nothing to worry about,
+		 * so be quiet about the error.
 		 */
 		rq->rq_flags |= RQF_QUIET;
 	}
-- 
2.21.0


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

* [PATCH 7/8] dm: add zone open, close and finish support
  2019-10-27 14:05 [PATCH 0/8] Zone management commands support Damien Le Moal
                   ` (5 preceding siblings ...)
  2019-10-27 14:05 ` [PATCH 6/8] scsi: sd_zbc: add zone open, close, and finish support Damien Le Moal
@ 2019-10-27 14:05 ` Damien Le Moal
  2019-11-05 16:34   ` Mike Snitzer
  2019-11-07  9:53   ` Christoph Hellwig
  2019-10-27 14:05 ` [PATCH 8/8] null_blk: add zone open, close, " Damien Le Moal
                   ` (2 subsequent siblings)
  9 siblings, 2 replies; 31+ messages in thread
From: Damien Le Moal @ 2019-10-27 14:05 UTC (permalink / raw)
  To: linux-block, Jens Axboe, linux-scsi, Martin K . Petersen,
	dm-devel, Mike Snitzer
  Cc: Ajay Joshi, Matias Bjorling, Hans Holmberg, Dmitry Fomichev, Keith Busch

From: Ajay Joshi <ajay.joshi@wdc.com>

Implement REQ_OP_ZONE_OPEN, REQ_OP_ZONE_CLOSE and REQ_OP_ZONE_FINISH
support to allow explicit control of zone states.

Contains contributions from Matias Bjorling, Hans Holmberg and
Damien Le Moal.

Signed-off-by: Ajay Joshi <ajay.joshi@wdc.com>
Signed-off-by: Matias Bjorling <matias.bjorling@wdc.com>
Signed-off-by: Hans Holmberg <hans.holmberg@wdc.com>
Signed-off-by: Damien Le Moal <damien.lemoal@wdc.com>
---
 drivers/md/dm-flakey.c | 7 +++----
 drivers/md/dm-linear.c | 2 +-
 drivers/md/dm.c        | 5 +++--
 3 files changed, 7 insertions(+), 7 deletions(-)

diff --git a/drivers/md/dm-flakey.c b/drivers/md/dm-flakey.c
index 2900fbde89b3..76587e9af0ef 100644
--- a/drivers/md/dm-flakey.c
+++ b/drivers/md/dm-flakey.c
@@ -280,7 +280,7 @@ static void flakey_map_bio(struct dm_target *ti, struct bio *bio)
 	struct flakey_c *fc = ti->private;
 
 	bio_set_dev(bio, fc->dev->bdev);
-	if (bio_sectors(bio) || bio_op(bio) == REQ_OP_ZONE_RESET)
+	if (bio_sectors(bio) || op_is_zone_mgmt(bio_op(bio)))
 		bio->bi_iter.bi_sector =
 			flakey_map_sector(ti, bio->bi_iter.bi_sector);
 }
@@ -322,8 +322,7 @@ static int flakey_map(struct dm_target *ti, struct bio *bio)
 	struct per_bio_data *pb = dm_per_bio_data(bio, sizeof(struct per_bio_data));
 	pb->bio_submitted = false;
 
-	/* Do not fail reset zone */
-	if (bio_op(bio) == REQ_OP_ZONE_RESET)
+	if (op_is_zone_mgmt(bio_op(bio)))
 		goto map_bio;
 
 	/* Are we alive ? */
@@ -384,7 +383,7 @@ static int flakey_end_io(struct dm_target *ti, struct bio *bio,
 	struct flakey_c *fc = ti->private;
 	struct per_bio_data *pb = dm_per_bio_data(bio, sizeof(struct per_bio_data));
 
-	if (bio_op(bio) == REQ_OP_ZONE_RESET)
+	if (op_is_zone_mgmt(bio_op(bio)))
 		return DM_ENDIO_DONE;
 
 	if (!*error && pb->bio_submitted && (bio_data_dir(bio) == READ)) {
diff --git a/drivers/md/dm-linear.c b/drivers/md/dm-linear.c
index ecefe6703736..97acafd48c85 100644
--- a/drivers/md/dm-linear.c
+++ b/drivers/md/dm-linear.c
@@ -90,7 +90,7 @@ static void linear_map_bio(struct dm_target *ti, struct bio *bio)
 	struct linear_c *lc = ti->private;
 
 	bio_set_dev(bio, lc->dev->bdev);
-	if (bio_sectors(bio) || bio_op(bio) == REQ_OP_ZONE_RESET)
+	if (bio_sectors(bio) || op_is_zone_mgmt(bio_op(bio)))
 		bio->bi_iter.bi_sector =
 			linear_map_sector(ti, bio->bi_iter.bi_sector);
 }
diff --git a/drivers/md/dm.c b/drivers/md/dm.c
index 1a5e328c443a..bc143c1b2333 100644
--- a/drivers/md/dm.c
+++ b/drivers/md/dm.c
@@ -1174,7 +1174,8 @@ static size_t dm_dax_copy_to_iter(struct dax_device *dax_dev, pgoff_t pgoff,
 
 /*
  * A target may call dm_accept_partial_bio only from the map routine.  It is
- * allowed for all bio types except REQ_PREFLUSH and REQ_OP_ZONE_RESET.
+ * allowed for all bio types except REQ_PREFLUSH, REQ_OP_ZONE_RESET,
+ * REQ_OP_ZONE_OPEN, REQ_OP_ZONE_CLOSE and REQ_OP_ZONE_FINISH.
  *
  * dm_accept_partial_bio informs the dm that the target only wants to process
  * additional n_sectors sectors of the bio and the rest of the data should be
@@ -1627,7 +1628,7 @@ static blk_qc_t __split_and_process_bio(struct mapped_device *md,
 		ci.sector_count = 0;
 		error = __send_empty_flush(&ci);
 		/* dec_pending submits any data associated with flush */
-	} else if (bio_op(bio) == REQ_OP_ZONE_RESET) {
+	} else if (op_is_zone_mgmt(bio_op(bio))) {
 		ci.bio = bio;
 		ci.sector_count = 0;
 		error = __split_and_process_non_flush(&ci);
-- 
2.21.0


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

* [PATCH 8/8] null_blk: add zone open, close, and finish support
  2019-10-27 14:05 [PATCH 0/8] Zone management commands support Damien Le Moal
                   ` (6 preceding siblings ...)
  2019-10-27 14:05 ` [PATCH 7/8] dm: add zone open, close " Damien Le Moal
@ 2019-10-27 14:05 ` Damien Le Moal
  2019-11-07  9:54   ` Christoph Hellwig
  2019-11-02  3:01 ` [PATCH 0/8] Zone management commands support Jens Axboe
  2019-11-07 13:40 ` Jens Axboe
  9 siblings, 1 reply; 31+ messages in thread
From: Damien Le Moal @ 2019-10-27 14:05 UTC (permalink / raw)
  To: linux-block, Jens Axboe, linux-scsi, Martin K . Petersen,
	dm-devel, Mike Snitzer
  Cc: Ajay Joshi, Matias Bjorling, Hans Holmberg, Dmitry Fomichev, Keith Busch

From: Ajay Joshi <ajay.joshi@wdc.com>

Implement REQ_OP_ZONE_OPEN, REQ_OP_ZONE_CLOSE and REQ_OP_ZONE_FINISH
support to allow explicit control of zone states.

Contains contributions from Matias Bjorling, Hans Holmberg,
Keith Busch and Damien Le Moal.

Signed-off-by: Ajay Joshi <ajay.joshi@wdc.com>
Signed-off-by: Matias Bjorling <matias.bjorling@wdc.com>
Signed-off-by: Hans Holmberg <hans.holmberg@wdc.com>
Signed-off-by: Keith Busch <kbusch@kernel.org>
Signed-off-by: Damien Le Moal <damien.lemoal@wdc.com>
---
 drivers/block/null_blk_zoned.c | 33 ++++++++++++++++++++++++++++++---
 1 file changed, 30 insertions(+), 3 deletions(-)

diff --git a/drivers/block/null_blk_zoned.c b/drivers/block/null_blk_zoned.c
index 4e56b17ed3ef..02f41a3bc4cb 100644
--- a/drivers/block/null_blk_zoned.c
+++ b/drivers/block/null_blk_zoned.c
@@ -136,13 +136,14 @@ static blk_status_t null_zone_write(struct nullb_cmd *cmd, sector_t sector,
 	return BLK_STS_OK;
 }
 
-static blk_status_t null_zone_reset(struct nullb_cmd *cmd, sector_t sector)
+static blk_status_t null_zone_mgmt(struct nullb_cmd *cmd, enum req_opf op,
+				   sector_t sector)
 {
 	struct nullb_device *dev = cmd->nq->dev;
 	struct blk_zone *zone = &dev->zones[null_zone_no(dev, sector)];
 	size_t i;
 
-	switch (req_op(cmd->rq)) {
+	switch (op) {
 	case REQ_OP_ZONE_RESET_ALL:
 		for (i = 0; i < dev->nr_zones; i++) {
 			if (zone[i].type == BLK_ZONE_TYPE_CONVENTIONAL)
@@ -158,6 +159,29 @@ static blk_status_t null_zone_reset(struct nullb_cmd *cmd, sector_t sector)
 		zone->cond = BLK_ZONE_COND_EMPTY;
 		zone->wp = zone->start;
 		break;
+	case REQ_OP_ZONE_OPEN:
+		if (zone->type == BLK_ZONE_TYPE_CONVENTIONAL)
+			return BLK_STS_IOERR;
+		if (zone->cond == BLK_ZONE_COND_FULL)
+			return BLK_STS_IOERR;
+
+		zone->cond = BLK_ZONE_COND_EXP_OPEN;
+		break;
+	case REQ_OP_ZONE_CLOSE:
+		if (zone->type == BLK_ZONE_TYPE_CONVENTIONAL)
+			return BLK_STS_IOERR;
+		if (zone->cond == BLK_ZONE_COND_FULL)
+			return BLK_STS_IOERR;
+
+		zone->cond = BLK_ZONE_COND_CLOSED;
+		break;
+	case REQ_OP_ZONE_FINISH:
+		if (zone->type == BLK_ZONE_TYPE_CONVENTIONAL)
+			return BLK_STS_IOERR;
+
+		zone->cond = BLK_ZONE_COND_FULL;
+		zone->wp = zone->start + zone->len;
+		break;
 	default:
 		return BLK_STS_NOTSUPP;
 	}
@@ -172,7 +196,10 @@ blk_status_t null_handle_zoned(struct nullb_cmd *cmd, enum req_opf op,
 		return null_zone_write(cmd, sector, nr_sectors);
 	case REQ_OP_ZONE_RESET:
 	case REQ_OP_ZONE_RESET_ALL:
-		return null_zone_reset(cmd, sector);
+	case REQ_OP_ZONE_OPEN:
+	case REQ_OP_ZONE_CLOSE:
+	case REQ_OP_ZONE_FINISH:
+		return null_zone_mgmt(cmd, op, sector);
 	default:
 		return BLK_STS_OK;
 	}
-- 
2.21.0


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

* Re: [PATCH 2/8] block: Simplify REQ_OP_ZONE_RESET_ALL handling
  2019-10-27 14:05 ` [PATCH 2/8] block: Simplify REQ_OP_ZONE_RESET_ALL handling Damien Le Moal
@ 2019-10-28  7:49   ` Chaitanya Kulkarni
  2019-10-28  7:54     ` Damien Le Moal
  2019-11-07  9:51   ` Christoph Hellwig
  1 sibling, 1 reply; 31+ messages in thread
From: Chaitanya Kulkarni @ 2019-10-28  7:49 UTC (permalink / raw)
  To: Damien Le Moal, linux-block, Jens Axboe, linux-scsi,
	Martin K . Petersen, dm-devel, Mike Snitzer
  Cc: Ajay Joshi, Matias Bjorling, Hans Holmberg, Dmitry Fomichev, Keith Busch

The reason code for REQ_OP_RESET_ALL is kept in a different function so
we can clearly differentiate between REQ_OP_RESET and REQ_OP_RESET_ALL
when we add new tracepoints with blktrace framework.

But if that is acceptable, then,

Reviewed-by: Chaitanya Kulkarni <chaitanya.kulkarni@wdc.com>

On 10/27/19 7:06 AM, Damien Le Moal wrote:
> There is no need for the function __blkdev_reset_all_zones() as
> REQ_OP_ZONE_RESET_ALL can be handled directly in blkdev_reset_zones()
> bio loop with an early break from the loop. This patch removes this
> function and modifies blkdev_reset_zones(), simplifying the code.
> 
> Signed-off-by: Damien Le Moal<damien.lemoal@wdc.com>


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

* Re: [PATCH 1/8] block: Remove REQ_OP_ZONE_RESET plugging
  2019-10-27 14:05 ` [PATCH 1/8] block: Remove REQ_OP_ZONE_RESET plugging Damien Le Moal
@ 2019-10-28  7:50   ` Chaitanya Kulkarni
  2019-10-29 12:13   ` Javier González
  2019-11-07  9:50   ` Christoph Hellwig
  2 siblings, 0 replies; 31+ messages in thread
From: Chaitanya Kulkarni @ 2019-10-28  7:50 UTC (permalink / raw)
  To: Damien Le Moal, linux-block, Jens Axboe, linux-scsi,
	Martin K . Petersen, dm-devel, Mike Snitzer
  Cc: Ajay Joshi, Matias Bjorling, Hans Holmberg, Dmitry Fomichev, Keith Busch

Looks good,

Reviewed-by: Chaitanya Kulkarni <chaitanya.kulkarni@wdc.com>

On 10/27/19 7:06 AM, Damien Le Moal wrote:
> REQ_OP_ZONE_RESET operations cannot be merged as these bios and requests
> do not have a size and are never sequential due to the zone start sector
> position required for their execution. As a result, there is no point in
> using a plug around blkdev_reset_zones() bio issuing loop. This patch
> removes this unnecessary plugging.
> 
> Signed-off-by: Damien Le Moal <damien.lemoal@wdc.com>
> ---
>   block/blk-zoned.c | 4 ----
>   1 file changed, 4 deletions(-)
> 
> diff --git a/block/blk-zoned.c b/block/blk-zoned.c
> index 4bc5f260248a..7fe376eede86 100644
> --- a/block/blk-zoned.c
> +++ b/block/blk-zoned.c
> @@ -258,7 +258,6 @@ int blkdev_reset_zones(struct block_device *bdev,
>   	sector_t zone_sectors;
>   	sector_t end_sector = sector + nr_sectors;
>   	struct bio *bio = NULL;
> -	struct blk_plug plug;
>   	int ret;
>   
>   	if (!blk_queue_is_zoned(q))
> @@ -283,7 +282,6 @@ int blkdev_reset_zones(struct block_device *bdev,
>   	    end_sector != bdev->bd_part->nr_sects)
>   		return -EINVAL;
>   
> -	blk_start_plug(&plug);
>   	while (sector < end_sector) {
>   
>   		bio = blk_next_bio(bio, 0, gfp_mask);
> @@ -301,8 +299,6 @@ int blkdev_reset_zones(struct block_device *bdev,
>   	ret = submit_bio_wait(bio);
>   	bio_put(bio);
>   
> -	blk_finish_plug(&plug);
> -
>   	return ret;
>   }
>   EXPORT_SYMBOL_GPL(blkdev_reset_zones);
> 


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

* Re: [PATCH 2/8] block: Simplify REQ_OP_ZONE_RESET_ALL handling
  2019-10-28  7:49   ` Chaitanya Kulkarni
@ 2019-10-28  7:54     ` Damien Le Moal
  2019-10-28  8:37       ` Chaitanya Kulkarni
  0 siblings, 1 reply; 31+ messages in thread
From: Damien Le Moal @ 2019-10-28  7:54 UTC (permalink / raw)
  To: Chaitanya Kulkarni, linux-block, Jens Axboe, linux-scsi,
	Martin K . Petersen, dm-devel, Mike Snitzer
  Cc: Ajay Joshi, Matias Bjorling, Hans Holmberg, Dmitry Fomichev, Keith Busch

On 2019/10/28 8:49, Chaitanya Kulkarni wrote:
> The reason code for REQ_OP_RESET_ALL is kept in a different function so
> we can clearly differentiate between REQ_OP_RESET and REQ_OP_RESET_ALL
> when we add new tracepoints with blktrace framework.

Isn't the trace point under submit_bio() in
generic_make_request_checks() ? So removing the function is not a
problem for tracing as far as I can tell. Am I missing something ?

> 
> But if that is acceptable, then,
> 
> Reviewed-by: Chaitanya Kulkarni <chaitanya.kulkarni@wdc.com>
> 
> On 10/27/19 7:06 AM, Damien Le Moal wrote:
>> There is no need for the function __blkdev_reset_all_zones() as
>> REQ_OP_ZONE_RESET_ALL can be handled directly in blkdev_reset_zones()
>> bio loop with an early break from the loop. This patch removes this
>> function and modifies blkdev_reset_zones(), simplifying the code.
>>
>> Signed-off-by: Damien Le Moal<damien.lemoal@wdc.com>
> 
> 


-- 
Damien Le Moal
Western Digital Research

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

* Re: [PATCH 2/8] block: Simplify REQ_OP_ZONE_RESET_ALL handling
  2019-10-28  7:54     ` Damien Le Moal
@ 2019-10-28  8:37       ` Chaitanya Kulkarni
  0 siblings, 0 replies; 31+ messages in thread
From: Chaitanya Kulkarni @ 2019-10-28  8:37 UTC (permalink / raw)
  To: Damien Le Moal, linux-block, Jens Axboe, linux-scsi,
	Martin K . Petersen, dm-devel, Mike Snitzer
  Cc: Ajay Joshi, Matias Bjorling, Hans Holmberg, Dmitry Fomichev, Keith Busch

On 10/28/19 12:54 AM, Damien Le Moal wrote:
> Isn't the trace point under submit_bio() in
> generic_make_request_checks() ? So removing the function is not a
> problem for tracing as far as I can tell. Am I missing something ?

Yes you are right, I completely missed that.

Sorry I've created confusion with block_dump and tracepoint.

Block trace code is fine.

The block_dump code under the submit_bio() is only dumps the bios with
the data:-


1171                 if (unlikely(block_dump)) {
1172                         char b[BDEVNAME_SIZE];
1173                         printk(KERN_DEBUG "%s(%d): %s block %Lu on 
%s (%u sectors)\n",
1174                         current->comm, task_pid_nr(current),
1175                                 op_is_write(bio_op(bio)) ? "WRITE" 
: "READ",
1176                                 (unsigned long 
long)bio->bi_iter.bi_sector,
1177                                 bio_devname(bio, b), count);
1178                 }


I've posted patch-series [1] in the past to move that code out but it 
didn't go anywhere in anticipation of more data less requests.

Since it is taking longer to have blktrace extensions RFC to move 
forward and [1] didn't go anywhere I wanted to use block_dump
parameter in the blk-zoned.c (not an ideal situation) so that we can 
have atleast minimal debug support for the new REQ_OP_ZONE_XXX 
operations until we get block trace extensions in the kernel.

Nonetheless, I'll just a send a patch on the top of this which will
make discussion much easier.


[1] :- 
https://lore.kernel.org/linux-block/DM6PR04MB57546ECC4CFDDB5535E3382586FB0@DM6PR04MB5754.namprd04.prod.outlook.com/T/

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

* Re: [PATCH 1/8] block: Remove REQ_OP_ZONE_RESET plugging
  2019-10-27 14:05 ` [PATCH 1/8] block: Remove REQ_OP_ZONE_RESET plugging Damien Le Moal
  2019-10-28  7:50   ` Chaitanya Kulkarni
@ 2019-10-29 12:13   ` Javier González
  2019-11-07  9:50   ` Christoph Hellwig
  2 siblings, 0 replies; 31+ messages in thread
From: Javier González @ 2019-10-29 12:13 UTC (permalink / raw)
  To: Damien Le Moal
  Cc: linux-block, Jens Axboe, linux-scsi, Martin K . Petersen,
	dm-devel, Mike Snitzer, Ajay Joshi, Matias Bjorling,
	Hans Holmberg, Dmitry Fomichev, Keith Busch

On 27.10.2019 23:05, Damien Le Moal wrote:
>REQ_OP_ZONE_RESET operations cannot be merged as these bios and requests
>do not have a size and are never sequential due to the zone start sector
>position required for their execution. As a result, there is no point in
>using a plug around blkdev_reset_zones() bio issuing loop. This patch
>removes this unnecessary plugging.
>
>Signed-off-by: Damien Le Moal <damien.lemoal@wdc.com>
>---
> block/blk-zoned.c | 4 ----
> 1 file changed, 4 deletions(-)
>
>diff --git a/block/blk-zoned.c b/block/blk-zoned.c
>index 4bc5f260248a..7fe376eede86 100644
>--- a/block/blk-zoned.c
>+++ b/block/blk-zoned.c
>@@ -258,7 +258,6 @@ int blkdev_reset_zones(struct block_device *bdev,
> 	sector_t zone_sectors;
> 	sector_t end_sector = sector + nr_sectors;
> 	struct bio *bio = NULL;
>-	struct blk_plug plug;
> 	int ret;
>
> 	if (!blk_queue_is_zoned(q))
>@@ -283,7 +282,6 @@ int blkdev_reset_zones(struct block_device *bdev,
> 	    end_sector != bdev->bd_part->nr_sects)
> 		return -EINVAL;
>
>-	blk_start_plug(&plug);
> 	while (sector < end_sector) {
>
> 		bio = blk_next_bio(bio, 0, gfp_mask);
>@@ -301,8 +299,6 @@ int blkdev_reset_zones(struct block_device *bdev,
> 	ret = submit_bio_wait(bio);
> 	bio_put(bio);
>
>-	blk_finish_plug(&plug);
>-
> 	return ret;
> }
> EXPORT_SYMBOL_GPL(blkdev_reset_zones);
>-- 
>2.21.0
>

Looks good to me.

Reviewed-by: Javier González <javier@javigon.com>

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

* Re: [PATCH 5/8] block: add zone open, close and finish ioctl support
  2019-10-27 14:05 ` [PATCH 5/8] block: add zone open, close and finish ioctl support Damien Le Moal
@ 2019-10-29 12:23   ` Javier González
  2019-11-07  9:52   ` Christoph Hellwig
  1 sibling, 0 replies; 31+ messages in thread
From: Javier González @ 2019-10-29 12:23 UTC (permalink / raw)
  To: Damien Le Moal
  Cc: linux-block, Jens Axboe, linux-scsi, Martin K . Petersen,
	dm-devel, Mike Snitzer, Ajay Joshi, Matias Bjorling,
	Hans Holmberg, Dmitry Fomichev, Keith Busch

On 27.10.2019 23:05, Damien Le Moal wrote:
>From: Ajay Joshi <ajay.joshi@wdc.com>
>
>Introduce three new ioctl commands BLKOPENZONE, BLKCLOSEZONE and
>BLKFINISHZONE to allow applications to control the condition of zones
>on a zoned block device through the execution of the REQ_OP_ZONE_OPEN,
>REQ_OP_ZONE_CLOSE and REQ_OP_ZONE_FINISH operations.
>
>Contains contributions from Matias Bjorling, Hans Holmberg,
>Dmitry Fomichev, Keith Busch, Damien Le Moal and Christoph Hellwig.
>
>Signed-off-by: Ajay Joshi <ajay.joshi@wdc.com>
>Signed-off-by: Matias Bjorling <matias.bjorling@wdc.com>
>Signed-off-by: Hans Holmberg <hans.holmberg@wdc.com>
>Signed-off-by: Dmitry Fomichev <dmitry.fomichev@wdc.com>
>Signed-off-by: Keith Busch <kbusch@kernel.org>
>Signed-off-by: Damien Le Moal <damien.lemoal@wdc.com>
>---
> block/blk-zoned.c             | 28 +++++++++++++++++++++++-----
> block/ioctl.c                 |  5 ++++-
> include/linux/blkdev.h        | 10 +++++-----
> include/uapi/linux/blkzoned.h | 17 ++++++++++++++---
> 4 files changed, 46 insertions(+), 14 deletions(-)
>
>diff --git a/block/blk-zoned.c b/block/blk-zoned.c
>index dab34dc48fb6..481eaf7d04d4 100644
>--- a/block/blk-zoned.c
>+++ b/block/blk-zoned.c
>@@ -357,15 +357,16 @@ int blkdev_report_zones_ioctl(struct block_device *bdev, fmode_t mode,
> }
>
> /*
>- * BLKRESETZONE ioctl processing.
>+ * BLKRESETZONE, BLKOPENZONE, BLKCLOSEZONE and BLKFINISHZONE ioctl processing.
>  * Called from blkdev_ioctl.
>  */
>-int blkdev_reset_zones_ioctl(struct block_device *bdev, fmode_t mode,
>-			     unsigned int cmd, unsigned long arg)
>+int blkdev_zone_mgmt_ioctl(struct block_device *bdev, fmode_t mode,
>+			   unsigned int cmd, unsigned long arg)
> {
> 	void __user *argp = (void __user *)arg;
> 	struct request_queue *q;
> 	struct blk_zone_range zrange;
>+	enum req_opf op;
>
> 	if (!argp)
> 		return -EINVAL;
>@@ -386,8 +387,25 @@ int blkdev_reset_zones_ioctl(struct block_device *bdev, fmode_t mode,
> 	if (copy_from_user(&zrange, argp, sizeof(struct blk_zone_range)))
> 		return -EFAULT;
>
>-	return blkdev_zone_mgmt(bdev, REQ_OP_ZONE_RESET,
>-				zrange.sector, zrange.nr_sectors, GFP_KERNEL);
>+	switch (cmd) {
>+	case BLKRESETZONE:
>+		op = REQ_OP_ZONE_RESET;
>+		break;
>+	case BLKOPENZONE:
>+		op = REQ_OP_ZONE_OPEN;
>+		break;
>+	case BLKCLOSEZONE:
>+		op = REQ_OP_ZONE_CLOSE;
>+		break;
>+	case BLKFINISHZONE:
>+		op = REQ_OP_ZONE_FINISH;
>+		break;
>+	default:
>+		return -ENOTTY;
>+	}
>+
>+	return blkdev_zone_mgmt(bdev, op, zrange.sector, zrange.nr_sectors,
>+				GFP_KERNEL);
> }
>
> static inline unsigned long *blk_alloc_zone_bitmap(int node,
>diff --git a/block/ioctl.c b/block/ioctl.c
>index 15a0eb80ada9..8756efb1419e 100644
>--- a/block/ioctl.c
>+++ b/block/ioctl.c
>@@ -532,7 +532,10 @@ int blkdev_ioctl(struct block_device *bdev, fmode_t mode, unsigned cmd,
> 	case BLKREPORTZONE:
> 		return blkdev_report_zones_ioctl(bdev, mode, cmd, arg);
> 	case BLKRESETZONE:
>-		return blkdev_reset_zones_ioctl(bdev, mode, cmd, arg);
>+	case BLKOPENZONE:
>+	case BLKCLOSEZONE:
>+	case BLKFINISHZONE:
>+		return blkdev_zone_mgmt_ioctl(bdev, mode, cmd, arg);
> 	case BLKGETZONESZ:
> 		return put_uint(arg, bdev_zone_sectors(bdev));
> 	case BLKGETNRZONES:
>diff --git a/include/linux/blkdev.h b/include/linux/blkdev.h
>index bf797a63388c..dbef541c2530 100644
>--- a/include/linux/blkdev.h
>+++ b/include/linux/blkdev.h
>@@ -367,8 +367,8 @@ extern int blk_revalidate_disk_zones(struct gendisk *disk);
>
> extern int blkdev_report_zones_ioctl(struct block_device *bdev, fmode_t mode,
> 				     unsigned int cmd, unsigned long arg);
>-extern int blkdev_reset_zones_ioctl(struct block_device *bdev, fmode_t mode,
>-				    unsigned int cmd, unsigned long arg);
>+extern int blkdev_zone_mgmt_ioctl(struct block_device *bdev, fmode_t mode,
>+				  unsigned int cmd, unsigned long arg);
>
> #else /* CONFIG_BLK_DEV_ZONED */
>
>@@ -389,9 +389,9 @@ static inline int blkdev_report_zones_ioctl(struct block_device *bdev,
> 	return -ENOTTY;
> }
>
>-static inline int blkdev_reset_zones_ioctl(struct block_device *bdev,
>-					   fmode_t mode, unsigned int cmd,
>-					   unsigned long arg)
>+static inline int blkdev_zone_mgmt_ioctl(struct block_device *bdev,
>+					 fmode_t mode, unsigned int cmd,
>+					 unsigned long arg)
> {
> 	return -ENOTTY;
> }
>diff --git a/include/uapi/linux/blkzoned.h b/include/uapi/linux/blkzoned.h
>index 498eec813494..0cdef67135f0 100644
>--- a/include/uapi/linux/blkzoned.h
>+++ b/include/uapi/linux/blkzoned.h
>@@ -120,9 +120,11 @@ struct blk_zone_report {
> };
>
> /**
>- * struct blk_zone_range - BLKRESETZONE ioctl request
>- * @sector: starting sector of the first zone to issue reset write pointer
>- * @nr_sectors: Total number of sectors of 1 or more zones to reset
>+ * struct blk_zone_range - BLKRESETZONE/BLKOPENZONE/
>+ *                         BLKCLOSEZONE/BLKFINISHZONE ioctl
>+ *                         requests
>+ * @sector: Starting sector of the first zone to operate on.
>+ * @nr_sectors: Total number of sectors of all zones to operate on.
>  */
> struct blk_zone_range {
> 	__u64		sector;
>@@ -139,10 +141,19 @@ struct blk_zone_range {
>  *                sector range. The sector range must be zone aligned.
>  * @BLKGETZONESZ: Get the device zone size in number of 512 B sectors.
>  * @BLKGETNRZONES: Get the total number of zones of the device.
>+ * @BLKOPENZONE: Open the zones in the specified sector range.
>+ *               The 512 B sector range must be zone aligned.
>+ * @BLKCLOSEZONE: Close the zones in the specified sector range.
>+ *                The 512 B sector range must be zone aligned.
>+ * @BLKFINISHZONE: Mark the zones as full in the specified sector range.
>+ *                 The 512 B sector range must be zone aligned.
>  */
> #define BLKREPORTZONE	_IOWR(0x12, 130, struct blk_zone_report)
> #define BLKRESETZONE	_IOW(0x12, 131, struct blk_zone_range)
> #define BLKGETZONESZ	_IOR(0x12, 132, __u32)
> #define BLKGETNRZONES	_IOR(0x12, 133, __u32)
>+#define BLKOPENZONE	_IOW(0x12, 134, struct blk_zone_range)
>+#define BLKCLOSEZONE	_IOW(0x12, 135, struct blk_zone_range)
>+#define BLKFINISHZONE	_IOW(0x12, 136, struct blk_zone_range)
>
> #endif /* _UAPI_BLKZONED_H */
>-- 
>2.21.0
>

Looks good.

Reviewed-by: Javier González <javier@javigon.com>

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

* Re: [PATCH 4/8] block: add zone open, close and finish operations
  2019-10-27 14:05 ` [PATCH 4/8] block: add zone open, close and finish operations Damien Le Moal
@ 2019-10-29 12:23   ` Javier González
  2019-11-07  9:52   ` Christoph Hellwig
  1 sibling, 0 replies; 31+ messages in thread
From: Javier González @ 2019-10-29 12:23 UTC (permalink / raw)
  To: Damien Le Moal
  Cc: linux-block, Jens Axboe, linux-scsi, Martin K . Petersen,
	dm-devel, Mike Snitzer, Ajay Joshi, Matias Bjorling,
	Hans Holmberg, Dmitry Fomichev, Keith Busch

On 27.10.2019 23:05, Damien Le Moal wrote:
>From: Ajay Joshi <ajay.joshi@wdc.com>
>
>Zoned block devices (ZBC and ZAC devices) allow an explicit control
>over the condition (state) of zones. The operations allowed are:
>* Open a zone: Transition to open condition to indicate that a zone will
>  actively be written
>* Close a zone: Transition to closed condition to release the drive
>  resources used for writing to a zone
>* Finish a zone: Transition an open or closed zone to the full
>  condition to prevent write operations
>
>To enable this control for in-kernel zoned block device users, define
>the new request operations REQ_OP_ZONE_OPEN, REQ_OP_ZONE_CLOSE
>and REQ_OP_ZONE_FINISH as well as the generic function
>blkdev_zone_mgmt() for submitting these operations on a range of zones.
>This results in blkdev_reset_zones() removal and replacement with this
>new zone magement function. Users of blkdev_reset_zones() (f2fs and
>dm-zoned) are updated accordingly.
>
>Contains contributions from Matias Bjorling, Hans Holmberg,
>Dmitry Fomichev, Keith Busch, Damien Le Moal and Christoph Hellwig.
>
>Signed-off-by: Ajay Joshi <ajay.joshi@wdc.com>
>Signed-off-by: Matias Bjorling <matias.bjorling@wdc.com>
>Signed-off-by: Hans Holmberg <hans.holmberg@wdc.com>
>Signed-off-by: Dmitry Fomichev <dmitry.fomichev@wdc.com>
>Signed-off-by: Keith Busch <kbusch@kernel.org>
>Signed-off-by: Damien Le Moal <damien.lemoal@wdc.com>
>---
> block/blk-core.c               | 12 +++++++++---
> block/blk-zoned.c              | 35 ++++++++++++++++++++--------------
> drivers/md/dm-zoned-metadata.c |  6 +++---
> fs/f2fs/segment.c              |  3 ++-
> include/linux/blk_types.h      | 25 ++++++++++++++++++++++++
> include/linux/blkdev.h         |  5 +++--
> 6 files changed, 63 insertions(+), 23 deletions(-)
>
>diff --git a/block/blk-core.c b/block/blk-core.c
>index d5e668ec751b..3306a3c5bed6 100644
>--- a/block/blk-core.c
>+++ b/block/blk-core.c
>@@ -132,6 +132,9 @@ static const char *const blk_op_name[] = {
> 	REQ_OP_NAME(SECURE_ERASE),
> 	REQ_OP_NAME(ZONE_RESET),
> 	REQ_OP_NAME(ZONE_RESET_ALL),
>+	REQ_OP_NAME(ZONE_OPEN),
>+	REQ_OP_NAME(ZONE_CLOSE),
>+	REQ_OP_NAME(ZONE_FINISH),
> 	REQ_OP_NAME(WRITE_SAME),
> 	REQ_OP_NAME(WRITE_ZEROES),
> 	REQ_OP_NAME(SCSI_IN),
>@@ -849,10 +852,10 @@ static inline int blk_partition_remap(struct bio *bio)
> 		goto out;
>
> 	/*
>-	 * Zone reset does not include bi_size so bio_sectors() is always 0.
>-	 * Include a test for the reset op code and perform the remap if needed.
>+	 * Zone management bios do not have a sector count but they do have
>+	 * a start sector filled out and need to be remapped.
> 	 */
>-	if (bio_sectors(bio) || bio_op(bio) == REQ_OP_ZONE_RESET) {
>+	if (bio_sectors(bio) || op_is_zone_mgmt(bio_op(bio))) {
> 		if (bio_check_eod(bio, part_nr_sects_read(p)))
> 			goto out;
> 		bio->bi_iter.bi_sector += p->start_sect;
>@@ -936,6 +939,9 @@ generic_make_request_checks(struct bio *bio)
> 			goto not_supported;
> 		break;
> 	case REQ_OP_ZONE_RESET:
>+	case REQ_OP_ZONE_OPEN:
>+	case REQ_OP_ZONE_CLOSE:
>+	case REQ_OP_ZONE_FINISH:
> 		if (!blk_queue_is_zoned(q))
> 			goto not_supported;
> 		break;
>diff --git a/block/blk-zoned.c b/block/blk-zoned.c
>index 14785011e798..dab34dc48fb6 100644
>--- a/block/blk-zoned.c
>+++ b/block/blk-zoned.c
>@@ -221,23 +221,27 @@ static inline bool blkdev_allow_reset_all_zones(struct block_device *bdev,
> }
>
> /**
>- * blkdev_reset_zones - Reset zones write pointer
>+ * blkdev_zone_mgmt - Execute a zone management operation on a range of zones
>  * @bdev:	Target block device
>- * @sector:	Start sector of the first zone to reset
>- * @nr_sectors:	Number of sectors, at least the length of one zone
>+ * @op:		Operation to be performed on the zones
>+ * @sector:	Start sector of the first zone to operate on
>+ * @nr_sectors:	Number of sectors, should be at least the length of one zone and
>+ *		must be zone size aligned.
>  * @gfp_mask:	Memory allocation flags (for bio_alloc)
>  *
>  * Description:
>- *    Reset the write pointer of the zones contained in the range
>+ *    Perform the specified operation on the range of zones specified by
>  *    @sector..@sector+@nr_sectors. Specifying the entire disk sector range
>  *    is valid, but the specified range should not contain conventional zones.
>+ *    The operation to execute on each zone can be a zone reset, open, close
>+ *    or finish request.
>  */
>-int blkdev_reset_zones(struct block_device *bdev,
>-		       sector_t sector, sector_t nr_sectors,
>-		       gfp_t gfp_mask)
>+int blkdev_zone_mgmt(struct block_device *bdev, enum req_opf op,
>+		     sector_t sector, sector_t nr_sectors,
>+		     gfp_t gfp_mask)
> {
> 	struct request_queue *q = bdev_get_queue(bdev);
>-	sector_t zone_sectors;
>+	sector_t zone_sectors = blk_queue_zone_sectors(q);
> 	sector_t end_sector = sector + nr_sectors;
> 	struct bio *bio = NULL;
> 	int ret;
>@@ -248,12 +252,14 @@ int blkdev_reset_zones(struct block_device *bdev,
> 	if (bdev_read_only(bdev))
> 		return -EPERM;
>
>+	if (!op_is_zone_mgmt(op))
>+		return -EOPNOTSUPP;
>+
> 	if (!nr_sectors || end_sector > bdev->bd_part->nr_sects)
> 		/* Out of range */
> 		return -EINVAL;
>
> 	/* Check alignment (handle eventual smaller last zone) */
>-	zone_sectors = blk_queue_zone_sectors(q);
> 	if (sector & (zone_sectors - 1))
> 		return -EINVAL;
>
>@@ -269,12 +275,13 @@ int blkdev_reset_zones(struct block_device *bdev,
> 		 * Special case for the zone reset operation that reset all
> 		 * zones, this is useful for applications like mkfs.
> 		 */
>-		if (blkdev_allow_reset_all_zones(bdev, sector, nr_sectors)) {
>+		if (op == REQ_OP_ZONE_RESET &&
>+		    blkdev_allow_reset_all_zones(bdev, sector, nr_sectors)) {
> 			bio->bi_opf = REQ_OP_ZONE_RESET_ALL;
> 			break;
> 		}
>
>-		bio->bi_opf = REQ_OP_ZONE_RESET;
>+		bio->bi_opf = op;
> 		bio->bi_iter.bi_sector = sector;
> 		sector += zone_sectors;
>
>@@ -287,7 +294,7 @@ int blkdev_reset_zones(struct block_device *bdev,
>
> 	return ret;
> }
>-EXPORT_SYMBOL_GPL(blkdev_reset_zones);
>+EXPORT_SYMBOL_GPL(blkdev_zone_mgmt);
>
> /*
>  * BLKREPORTZONE ioctl processing.
>@@ -379,8 +386,8 @@ int blkdev_reset_zones_ioctl(struct block_device *bdev, fmode_t mode,
> 	if (copy_from_user(&zrange, argp, sizeof(struct blk_zone_range)))
> 		return -EFAULT;
>
>-	return blkdev_reset_zones(bdev, zrange.sector, zrange.nr_sectors,
>-				  GFP_KERNEL);
>+	return blkdev_zone_mgmt(bdev, REQ_OP_ZONE_RESET,
>+				zrange.sector, zrange.nr_sectors, GFP_KERNEL);
> }
>
> static inline unsigned long *blk_alloc_zone_bitmap(int node,
>diff --git a/drivers/md/dm-zoned-metadata.c b/drivers/md/dm-zoned-metadata.c
>index 595a73110e17..feb4718ce6a6 100644
>--- a/drivers/md/dm-zoned-metadata.c
>+++ b/drivers/md/dm-zoned-metadata.c
>@@ -1312,9 +1312,9 @@ static int dmz_reset_zone(struct dmz_metadata *zmd, struct dm_zone *zone)
> 	if (!dmz_is_empty(zone) || dmz_seq_write_err(zone)) {
> 		struct dmz_dev *dev = zmd->dev;
>
>-		ret = blkdev_reset_zones(dev->bdev,
>-					 dmz_start_sect(zmd, zone),
>-					 dev->zone_nr_sectors, GFP_NOIO);
>+		ret = blkdev_zone_mgmt(dev->bdev, REQ_OP_ZONE_RESET,
>+				       dmz_start_sect(zmd, zone),
>+				       dev->zone_nr_sectors, GFP_NOIO);
> 		if (ret) {
> 			dmz_dev_err(dev, "Reset zone %u failed %d",
> 				    dmz_id(zmd, zone), ret);
>diff --git a/fs/f2fs/segment.c b/fs/f2fs/segment.c
>index 808709581481..2c997f94a3b2 100644
>--- a/fs/f2fs/segment.c
>+++ b/fs/f2fs/segment.c
>@@ -1771,7 +1771,8 @@ static int __f2fs_issue_discard_zone(struct f2fs_sb_info *sbi,
> 			return -EIO;
> 		}
> 		trace_f2fs_issue_reset_zone(bdev, blkstart);
>-		return blkdev_reset_zones(bdev, sector, nr_sects, GFP_NOFS);
>+		return blkdev_zone_mgmt(bdev, REQ_OP_ZONE_RESET,
>+					sector, nr_sects, GFP_NOFS);
> 	}
>
> 	/* For conventional zones, use regular discard if supported */
>diff --git a/include/linux/blk_types.h b/include/linux/blk_types.h
>index d688b96d1d63..805d0efa2997 100644
>--- a/include/linux/blk_types.h
>+++ b/include/linux/blk_types.h
>@@ -290,6 +290,12 @@ enum req_opf {
> 	REQ_OP_ZONE_RESET_ALL	= 8,
> 	/* write the zero filled sector many times */
> 	REQ_OP_WRITE_ZEROES	= 9,
>+	/* Open a zone */
>+	REQ_OP_ZONE_OPEN	= 10,
>+	/* Close a zone */
>+	REQ_OP_ZONE_CLOSE	= 11,
>+	/* Transition a zone to full */
>+	REQ_OP_ZONE_FINISH	= 12,
>
> 	/* SCSI passthrough using struct scsi_request */
> 	REQ_OP_SCSI_IN		= 32,
>@@ -417,6 +423,25 @@ static inline bool op_is_discard(unsigned int op)
> 	return (op & REQ_OP_MASK) == REQ_OP_DISCARD;
> }
>
>+/*
>+ * Check if a bio or request operation is a zone management operation, with
>+ * the exception of REQ_OP_ZONE_RESET_ALL which is treated as a special case
>+ * due to its different handling in the block layer and device response in
>+ * case of command failure.
>+ */
>+static inline bool op_is_zone_mgmt(enum req_opf op)
>+{
>+	switch (op & REQ_OP_MASK) {
>+	case REQ_OP_ZONE_RESET:
>+	case REQ_OP_ZONE_OPEN:
>+	case REQ_OP_ZONE_CLOSE:
>+	case REQ_OP_ZONE_FINISH:
>+		return true;
>+	default:
>+		return false;
>+	}
>+}
>+
> static inline int op_stat_group(unsigned int op)
> {
> 	if (op_is_discard(op))
>diff --git a/include/linux/blkdev.h b/include/linux/blkdev.h
>index f3ea78b0c91c..bf797a63388c 100644
>--- a/include/linux/blkdev.h
>+++ b/include/linux/blkdev.h
>@@ -360,8 +360,9 @@ extern unsigned int blkdev_nr_zones(struct block_device *bdev);
> extern int blkdev_report_zones(struct block_device *bdev,
> 			       sector_t sector, struct blk_zone *zones,
> 			       unsigned int *nr_zones);
>-extern int blkdev_reset_zones(struct block_device *bdev, sector_t sectors,
>-			      sector_t nr_sectors, gfp_t gfp_mask);
>+extern int blkdev_zone_mgmt(struct block_device *bdev, enum req_opf op,
>+			    sector_t sectors, sector_t nr_sectors,
>+			    gfp_t gfp_mask);
> extern int blk_revalidate_disk_zones(struct gendisk *disk);
>
> extern int blkdev_report_zones_ioctl(struct block_device *bdev, fmode_t mode,
>-- 
>2.21.0
>

Looks good.

Reviewed-by: Javier González <javier@javigon.com>

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

* Re: [PATCH 3/8] scsi: sd_zbc: Fix sd_zbc_complete()
  2019-10-27 14:05 ` [PATCH 3/8] scsi: sd_zbc: Fix sd_zbc_complete() Damien Le Moal
@ 2019-11-02  0:42   ` Martin K. Petersen
  0 siblings, 0 replies; 31+ messages in thread
From: Martin K. Petersen @ 2019-11-02  0:42 UTC (permalink / raw)
  To: Damien Le Moal
  Cc: linux-block, Jens Axboe, linux-scsi, Martin K . Petersen,
	dm-devel, Mike Snitzer, Ajay Joshi, Matias Bjorling,
	Hans Holmberg, Dmitry Fomichev, Keith Busch


Damien,

> The ILLEGAL REQUEST/INVALID FIELD IN CDB error generated by an attempt
> to reset a conventional zone does not apply to the reset write pointer
> command with the ALL bit set, that is, to REQ_OP_ZONE_RESET_ALL
> requests. Fix sd_zbc_complete() to be quiet only in the case of
> REQ_OP_ZONE_RESET, excluding REQ_OP_ZONE_RESET_ALL.
>
> Since REQ_OP_ZONE_RESET is the only request handled by
> sd_zbc_complete(), also simplify the code using a simple if statement.

Reviewed-by: Martin K. Petersen <martin.petersen@oracle.com>

-- 
Martin K. Petersen	Oracle Linux Engineering

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

* Re: [PATCH 6/8] scsi: sd_zbc: add zone open, close, and finish support
  2019-10-27 14:05 ` [PATCH 6/8] scsi: sd_zbc: add zone open, close, and finish support Damien Le Moal
@ 2019-11-02  0:43   ` Martin K. Petersen
  2019-11-07  9:53   ` Christoph Hellwig
  1 sibling, 0 replies; 31+ messages in thread
From: Martin K. Petersen @ 2019-11-02  0:43 UTC (permalink / raw)
  To: Damien Le Moal
  Cc: linux-block, Jens Axboe, linux-scsi, Martin K . Petersen,
	dm-devel, Mike Snitzer, Ajay Joshi, Matias Bjorling,
	Hans Holmberg, Dmitry Fomichev, Keith Busch


Damien,

> Implement REQ_OP_ZONE_OPEN, REQ_OP_ZONE_CLOSE and REQ_OP_ZONE_FINISH
> support to allow explicit control of zone states.
>
> Contains contributions from Matias Bjorling, Hans Holmberg,
> Keith Busch and Damien Le Moal.

Looks fine.

Reviewed-by: Martin K. Petersen <martin.petersen@oracle.com>

-- 
Martin K. Petersen	Oracle Linux Engineering

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

* Re: [PATCH 0/8] Zone management commands support
  2019-10-27 14:05 [PATCH 0/8] Zone management commands support Damien Le Moal
                   ` (7 preceding siblings ...)
  2019-10-27 14:05 ` [PATCH 8/8] null_blk: add zone open, close, " Damien Le Moal
@ 2019-11-02  3:01 ` Jens Axboe
  2019-11-03 23:41   ` Damien Le Moal
  2019-11-07 13:40 ` Jens Axboe
  9 siblings, 1 reply; 31+ messages in thread
From: Jens Axboe @ 2019-11-02  3:01 UTC (permalink / raw)
  To: Damien Le Moal, linux-block, linux-scsi, Martin K . Petersen,
	dm-devel, Mike Snitzer
  Cc: Ajay Joshi, Matias Bjorling, Hans Holmberg, Dmitry Fomichev, Keith Busch

On 10/27/19 8:05 AM, Damien Le Moal wrote:
> This series implements a few improvements and cleanups to zone block
> device zone reset operations with the first three patches.
> 
> The remaining of the series patches introduce zone open, close and
> finish support, allowing users of zoned block devices to explicitly
> control the condition (state) of zones.
> 
> While these operations are not stricktly necessary for the correct
> operation of zoned block devices, the open and close operations can
> improve performance for some device implementations of the ZBC and ZAC
> standards under write workloads. The finish zone operation, which
> transition a zone to the full state, can also be useful to protect a
> zone data by preventing further zone writes.
> 
> These operations are implemented by introducing the new
> REQ_OP_ZONE_OPEN, REQ_OP_ZONE_CLOSE and REQ_OP_ZONE_FINISH request codes
> and the function blkdev_zone_mgmt() to issue these requests. This new
> function also replaces the former blkdev_reset_zones() function to reset
> zones write pointer.
> 
> The new ioctls BLKOPENZONE, BLKCLOSEZONE and BLKFINISHZONE are also
> defined to allow applications to issue these new requests without
> resorting to a device passthrough interface (e.g. SG_IO).
> 
> Support for these operations is added to the SCSI sd driver, to the dm
> infrastructure (dm-linear and dm-flakey targets) and to the null_blk
> driver.

Can patch 3 go in separately, doesn't look like we need it in this
series?

Also need the DM folks to review/sign off on patch 7. Mike?

-- 
Jens Axboe


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

* Re: [PATCH 0/8] Zone management commands support
  2019-11-02  3:01 ` [PATCH 0/8] Zone management commands support Jens Axboe
@ 2019-11-03 23:41   ` Damien Le Moal
  2019-11-05  4:51     ` Martin K. Petersen
  0 siblings, 1 reply; 31+ messages in thread
From: Damien Le Moal @ 2019-11-03 23:41 UTC (permalink / raw)
  To: Jens Axboe, linux-block, linux-scsi, Martin K . Petersen,
	dm-devel, Mike Snitzer
  Cc: Ajay Joshi, Matias Bjorling, Hans Holmberg, Dmitry Fomichev, Keith Busch

On 2019/11/02 4:01, Jens Axboe wrote:
> On 10/27/19 8:05 AM, Damien Le Moal wrote:
>> This series implements a few improvements and cleanups to zone block
>> device zone reset operations with the first three patches.
>>
>> The remaining of the series patches introduce zone open, close and
>> finish support, allowing users of zoned block devices to explicitly
>> control the condition (state) of zones.
>>
>> While these operations are not stricktly necessary for the correct
>> operation of zoned block devices, the open and close operations can
>> improve performance for some device implementations of the ZBC and ZAC
>> standards under write workloads. The finish zone operation, which
>> transition a zone to the full state, can also be useful to protect a
>> zone data by preventing further zone writes.
>>
>> These operations are implemented by introducing the new
>> REQ_OP_ZONE_OPEN, REQ_OP_ZONE_CLOSE and REQ_OP_ZONE_FINISH request codes
>> and the function blkdev_zone_mgmt() to issue these requests. This new
>> function also replaces the former blkdev_reset_zones() function to reset
>> zones write pointer.
>>
>> The new ioctls BLKOPENZONE, BLKCLOSEZONE and BLKFINISHZONE are also
>> defined to allow applications to issue these new requests without
>> resorting to a device passthrough interface (e.g. SG_IO).
>>
>> Support for these operations is added to the SCSI sd driver, to the dm
>> infrastructure (dm-linear and dm-flakey targets) and to the null_blk
>> driver.
> 
> Can patch 3 go in separately, doesn't look like we need it in this
> series?

Yes, I think it can go in now in 5.4-rc if Martin is willing to take it.
That will create a small conflict in your tree for patch 6 though.

Martin,

Can you take patch 3 now ?

> 
> Also need the DM folks to review/sign off on patch 7. Mike?
> 


-- 
Damien Le Moal
Western Digital Research

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

* Re: [PATCH 0/8] Zone management commands support
  2019-11-03 23:41   ` Damien Le Moal
@ 2019-11-05  4:51     ` Martin K. Petersen
  2019-11-05  5:08       ` Damien Le Moal
  0 siblings, 1 reply; 31+ messages in thread
From: Martin K. Petersen @ 2019-11-05  4:51 UTC (permalink / raw)
  To: Damien Le Moal
  Cc: Jens Axboe, linux-block, linux-scsi, Martin K . Petersen,
	dm-devel, Mike Snitzer, Ajay Joshi, Matias Bjorling,
	Hans Holmberg, Dmitry Fomichev, Keith Busch


Damien,

> Can you take patch 3 now ?

Yep. Applied to 5.4/scsi-fixes.

-- 
Martin K. Petersen	Oracle Linux Engineering

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

* Re: [PATCH 0/8] Zone management commands support
  2019-11-05  4:51     ` Martin K. Petersen
@ 2019-11-05  5:08       ` Damien Le Moal
  0 siblings, 0 replies; 31+ messages in thread
From: Damien Le Moal @ 2019-11-05  5:08 UTC (permalink / raw)
  To: Martin K. Petersen
  Cc: Jens Axboe, linux-block, linux-scsi, dm-devel, Mike Snitzer,
	Ajay Joshi, Matias Bjorling, Hans Holmberg, Dmitry Fomichev,
	Keith Busch

On 2019/11/05 13:53, Martin K. Petersen wrote:
> 
> Damien,
> 
>> Can you take patch 3 now ?
> 
> Yep. Applied to 5.4/scsi-fixes.

Thanks !


-- 
Damien Le Moal
Western Digital Research

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

* Re: [PATCH 7/8] dm: add zone open, close and finish support
  2019-10-27 14:05 ` [PATCH 7/8] dm: add zone open, close " Damien Le Moal
@ 2019-11-05 16:34   ` Mike Snitzer
  2019-11-07  9:53   ` Christoph Hellwig
  1 sibling, 0 replies; 31+ messages in thread
From: Mike Snitzer @ 2019-11-05 16:34 UTC (permalink / raw)
  To: Damien Le Moal
  Cc: linux-block, Jens Axboe, linux-scsi, Martin K . Petersen,
	dm-devel, Ajay Joshi, Matias Bjorling, Hans Holmberg,
	Dmitry Fomichev, Keith Busch

On Sun, Oct 27 2019 at 10:05am -0400,
Damien Le Moal <damien.lemoal@wdc.com> wrote:

> From: Ajay Joshi <ajay.joshi@wdc.com>
> 
> Implement REQ_OP_ZONE_OPEN, REQ_OP_ZONE_CLOSE and REQ_OP_ZONE_FINISH
> support to allow explicit control of zone states.
> 
> Contains contributions from Matias Bjorling, Hans Holmberg and
> Damien Le Moal.
> 
> Signed-off-by: Ajay Joshi <ajay.joshi@wdc.com>
> Signed-off-by: Matias Bjorling <matias.bjorling@wdc.com>
> Signed-off-by: Hans Holmberg <hans.holmberg@wdc.com>
> Signed-off-by: Damien Le Moal <damien.lemoal@wdc.com>

Acked-by: Mike Snitzer <snitzer@redhat.com>


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

* Re: [PATCH 1/8] block: Remove REQ_OP_ZONE_RESET plugging
  2019-10-27 14:05 ` [PATCH 1/8] block: Remove REQ_OP_ZONE_RESET plugging Damien Le Moal
  2019-10-28  7:50   ` Chaitanya Kulkarni
  2019-10-29 12:13   ` Javier González
@ 2019-11-07  9:50   ` Christoph Hellwig
  2 siblings, 0 replies; 31+ messages in thread
From: Christoph Hellwig @ 2019-11-07  9:50 UTC (permalink / raw)
  To: Damien Le Moal
  Cc: linux-block, Jens Axboe, linux-scsi, Martin K . Petersen,
	dm-devel, Mike Snitzer, Ajay Joshi, Matias Bjorling,
	Hans Holmberg, Dmitry Fomichev, Keith Busch

Looks good,

Reviewed-by: Christoph Hellwig <hch@lst.de>

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

* Re: [PATCH 2/8] block: Simplify REQ_OP_ZONE_RESET_ALL handling
  2019-10-27 14:05 ` [PATCH 2/8] block: Simplify REQ_OP_ZONE_RESET_ALL handling Damien Le Moal
  2019-10-28  7:49   ` Chaitanya Kulkarni
@ 2019-11-07  9:51   ` Christoph Hellwig
  1 sibling, 0 replies; 31+ messages in thread
From: Christoph Hellwig @ 2019-11-07  9:51 UTC (permalink / raw)
  To: Damien Le Moal
  Cc: linux-block, Jens Axboe, linux-scsi, Martin K . Petersen,
	dm-devel, Mike Snitzer, Ajay Joshi, Matias Bjorling,
	Hans Holmberg, Dmitry Fomichev, Keith Busch

Looks good,

Reviewed-by: Christoph Hellwig <hch@lst.de>

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

* Re: [PATCH 4/8] block: add zone open, close and finish operations
  2019-10-27 14:05 ` [PATCH 4/8] block: add zone open, close and finish operations Damien Le Moal
  2019-10-29 12:23   ` Javier González
@ 2019-11-07  9:52   ` Christoph Hellwig
  1 sibling, 0 replies; 31+ messages in thread
From: Christoph Hellwig @ 2019-11-07  9:52 UTC (permalink / raw)
  To: Damien Le Moal
  Cc: linux-block, Jens Axboe, linux-scsi, Martin K . Petersen,
	dm-devel, Mike Snitzer, Ajay Joshi, Matias Bjorling,
	Hans Holmberg, Dmitry Fomichev, Keith Busch

Looks good,

Reviewed-by: Christoph Hellwig <hch@lst.de>

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

* Re: [PATCH 5/8] block: add zone open, close and finish ioctl support
  2019-10-27 14:05 ` [PATCH 5/8] block: add zone open, close and finish ioctl support Damien Le Moal
  2019-10-29 12:23   ` Javier González
@ 2019-11-07  9:52   ` Christoph Hellwig
  1 sibling, 0 replies; 31+ messages in thread
From: Christoph Hellwig @ 2019-11-07  9:52 UTC (permalink / raw)
  To: Damien Le Moal
  Cc: linux-block, Jens Axboe, linux-scsi, Martin K . Petersen,
	dm-devel, Mike Snitzer, Ajay Joshi, Matias Bjorling,
	Hans Holmberg, Dmitry Fomichev, Keith Busch

Looks good,

Reviewed-by: Christoph Hellwig <hch@lst.de>

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

* Re: [PATCH 6/8] scsi: sd_zbc: add zone open, close, and finish support
  2019-10-27 14:05 ` [PATCH 6/8] scsi: sd_zbc: add zone open, close, and finish support Damien Le Moal
  2019-11-02  0:43   ` Martin K. Petersen
@ 2019-11-07  9:53   ` Christoph Hellwig
  1 sibling, 0 replies; 31+ messages in thread
From: Christoph Hellwig @ 2019-11-07  9:53 UTC (permalink / raw)
  To: Damien Le Moal
  Cc: linux-block, Jens Axboe, linux-scsi, Martin K . Petersen,
	dm-devel, Mike Snitzer, Ajay Joshi, Matias Bjorling,
	Hans Holmberg, Dmitry Fomichev, Keith Busch

Looks good,

Reviewed-by: Christoph Hellwig <hch@lst.de>

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

* Re: [PATCH 7/8] dm: add zone open, close and finish support
  2019-10-27 14:05 ` [PATCH 7/8] dm: add zone open, close " Damien Le Moal
  2019-11-05 16:34   ` Mike Snitzer
@ 2019-11-07  9:53   ` Christoph Hellwig
  1 sibling, 0 replies; 31+ messages in thread
From: Christoph Hellwig @ 2019-11-07  9:53 UTC (permalink / raw)
  To: Damien Le Moal
  Cc: linux-block, Jens Axboe, linux-scsi, Martin K . Petersen,
	dm-devel, Mike Snitzer, Ajay Joshi, Matias Bjorling,
	Hans Holmberg, Dmitry Fomichev, Keith Busch

Looks good,

Reviewed-by: Christoph Hellwig <hch@lst.de>

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

* Re: [PATCH 8/8] null_blk: add zone open, close, and finish support
  2019-10-27 14:05 ` [PATCH 8/8] null_blk: add zone open, close, " Damien Le Moal
@ 2019-11-07  9:54   ` Christoph Hellwig
  0 siblings, 0 replies; 31+ messages in thread
From: Christoph Hellwig @ 2019-11-07  9:54 UTC (permalink / raw)
  To: Damien Le Moal
  Cc: linux-block, Jens Axboe, linux-scsi, Martin K . Petersen,
	dm-devel, Mike Snitzer, Ajay Joshi, Matias Bjorling,
	Hans Holmberg, Dmitry Fomichev, Keith Busch

Looks good,

Reviewed-by: Christoph Hellwig <hch@lst.de>

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

* Re: [PATCH 0/8] Zone management commands support
  2019-10-27 14:05 [PATCH 0/8] Zone management commands support Damien Le Moal
                   ` (8 preceding siblings ...)
  2019-11-02  3:01 ` [PATCH 0/8] Zone management commands support Jens Axboe
@ 2019-11-07 13:40 ` Jens Axboe
  9 siblings, 0 replies; 31+ messages in thread
From: Jens Axboe @ 2019-11-07 13:40 UTC (permalink / raw)
  To: Damien Le Moal, linux-block, linux-scsi, Martin K . Petersen,
	dm-devel, Mike Snitzer
  Cc: Ajay Joshi, Matias Bjorling, Hans Holmberg, Dmitry Fomichev, Keith Busch

On 10/27/19 8:05 AM, Damien Le Moal wrote:
> This series implements a few improvements and cleanups to zone block
> device zone reset operations with the first three patches.
> 
> The remaining of the series patches introduce zone open, close and
> finish support, allowing users of zoned block devices to explicitly
> control the condition (state) of zones.
> 
> While these operations are not stricktly necessary for the correct
> operation of zoned block devices, the open and close operations can
> improve performance for some device implementations of the ZBC and ZAC
> standards under write workloads. The finish zone operation, which
> transition a zone to the full state, can also be useful to protect a
> zone data by preventing further zone writes.
> 
> These operations are implemented by introducing the new
> REQ_OP_ZONE_OPEN, REQ_OP_ZONE_CLOSE and REQ_OP_ZONE_FINISH request codes
> and the function blkdev_zone_mgmt() to issue these requests. This new
> function also replaces the former blkdev_reset_zones() function to reset
> zones write pointer.
> 
> The new ioctls BLKOPENZONE, BLKCLOSEZONE and BLKFINISHZONE are also
> defined to allow applications to issue these new requests without
> resorting to a device passthrough interface (e.g. SG_IO).
> 
> Support for these operations is added to the SCSI sd driver, to the dm
> infrastructure (dm-linear and dm-flakey targets) and to the null_blk
> driver.

Applied for 5.5, thanks. I've got the last sd patch pending, the conflict
is rather ugly. I'll setup a post branch for drivers with this in, once
the dependent fix has landed in Linus's tree.

-- 
Jens Axboe


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

end of thread, other threads:[~2019-11-07 13:40 UTC | newest]

Thread overview: 31+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2019-10-27 14:05 [PATCH 0/8] Zone management commands support Damien Le Moal
2019-10-27 14:05 ` [PATCH 1/8] block: Remove REQ_OP_ZONE_RESET plugging Damien Le Moal
2019-10-28  7:50   ` Chaitanya Kulkarni
2019-10-29 12:13   ` Javier González
2019-11-07  9:50   ` Christoph Hellwig
2019-10-27 14:05 ` [PATCH 2/8] block: Simplify REQ_OP_ZONE_RESET_ALL handling Damien Le Moal
2019-10-28  7:49   ` Chaitanya Kulkarni
2019-10-28  7:54     ` Damien Le Moal
2019-10-28  8:37       ` Chaitanya Kulkarni
2019-11-07  9:51   ` Christoph Hellwig
2019-10-27 14:05 ` [PATCH 3/8] scsi: sd_zbc: Fix sd_zbc_complete() Damien Le Moal
2019-11-02  0:42   ` Martin K. Petersen
2019-10-27 14:05 ` [PATCH 4/8] block: add zone open, close and finish operations Damien Le Moal
2019-10-29 12:23   ` Javier González
2019-11-07  9:52   ` Christoph Hellwig
2019-10-27 14:05 ` [PATCH 5/8] block: add zone open, close and finish ioctl support Damien Le Moal
2019-10-29 12:23   ` Javier González
2019-11-07  9:52   ` Christoph Hellwig
2019-10-27 14:05 ` [PATCH 6/8] scsi: sd_zbc: add zone open, close, and finish support Damien Le Moal
2019-11-02  0:43   ` Martin K. Petersen
2019-11-07  9:53   ` Christoph Hellwig
2019-10-27 14:05 ` [PATCH 7/8] dm: add zone open, close " Damien Le Moal
2019-11-05 16:34   ` Mike Snitzer
2019-11-07  9:53   ` Christoph Hellwig
2019-10-27 14:05 ` [PATCH 8/8] null_blk: add zone open, close, " Damien Le Moal
2019-11-07  9:54   ` Christoph Hellwig
2019-11-02  3:01 ` [PATCH 0/8] Zone management commands support Jens Axboe
2019-11-03 23:41   ` Damien Le Moal
2019-11-05  4:51     ` Martin K. Petersen
2019-11-05  5:08       ` Damien Le Moal
2019-11-07 13:40 ` Jens Axboe

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).