All of lore.kernel.org
 help / color / mirror / Atom feed
From: Damien Le Moal <damien.lemoal@wdc.com>
To: linux-block@vger.kernel.org, Jens Axboe <axboe@kernel.dk>,
	linux-scsi@vger.kernel.org,
	"Martin K . Petersen" <martin.petersen@oracle.com>,
	dm-devel@redhat.com, Mike Snitzer <snitzer@redhat.com>
Cc: Ajay Joshi <ajay.joshi@wdc.com>,
	Matias Bjorling <matias.bjorling@wdc.com>,
	Hans Holmberg <Hans.Holmberg@wdc.com>,
	Dmitry Fomichev <dmitry.fomichev@wdc.com>,
	Keith Busch <kbusch@kernel.org>
Subject: [PATCH 8/8] null_blk: add zone open, close, and finish support
Date: Sun, 27 Oct 2019 23:05:49 +0900	[thread overview]
Message-ID: <20191027140549.26272-9-damien.lemoal@wdc.com> (raw)
In-Reply-To: <20191027140549.26272-1-damien.lemoal@wdc.com>

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


WARNING: multiple messages have this Message-ID (diff)
From: Damien Le Moal <damien.lemoal@wdc.com>
To: linux-block@vger.kernel.org, Jens Axboe <axboe@kernel.dk>,
	linux-scsi@vger.kernel.org,
	"Martin K . Petersen" <martin.petersen@oracle.com>,
	dm-devel@redhat.com, Mike Snitzer <snitzer@redhat.com>
Cc: Dmitry Fomichev <dmitry.fomichev@wdc.com>,
	Keith Busch <kbusch@kernel.org>,
	Hans Holmberg <Hans.Holmberg@wdc.com>,
	Ajay Joshi <ajay.joshi@wdc.com>,
	Matias Bjorling <matias.bjorling@wdc.com>
Subject: [PATCH 8/8] null_blk: add zone open, close, and finish support
Date: Sun, 27 Oct 2019 23:05:49 +0900	[thread overview]
Message-ID: <20191027140549.26272-9-damien.lemoal@wdc.com> (raw)
In-Reply-To: <20191027140549.26272-1-damien.lemoal@wdc.com>

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

  parent reply	other threads:[~2019-10-27 14:06 UTC|newest]

Thread overview: 62+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
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-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:50   ` Chaitanya Kulkarni
2019-10-28  7:50     ` Chaitanya Kulkarni
2019-10-29 12:13   ` Javier González
2019-10-29 12:13     ` Javier González
2019-11-07  9:50   ` Christoph Hellwig
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-27 14:05   ` Damien Le Moal
2019-10-28  7:49   ` Chaitanya Kulkarni
2019-10-28  7:49     ` Chaitanya Kulkarni
2019-10-28  7:54     ` Damien Le Moal
2019-10-28  7:54       ` Damien Le Moal
2019-10-28  8:37       ` Chaitanya Kulkarni
2019-10-28  8:37         ` Chaitanya Kulkarni
2019-11-07  9:51   ` Christoph Hellwig
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-10-27 14:05   ` Damien Le Moal
2019-11-02  0:42   ` Martin K. Petersen
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-27 14:05   ` Damien Le Moal
2019-10-29 12:23   ` Javier González
2019-10-29 12:23     ` Javier González
2019-11-07  9:52   ` Christoph Hellwig
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-27 14:05   ` Damien Le Moal
2019-10-29 12:23   ` Javier González
2019-10-29 12:23     ` Javier González
2019-11-07  9:52   ` Christoph Hellwig
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-10-27 14:05   ` Damien Le Moal
2019-11-02  0:43   ` Martin K. Petersen
2019-11-02  0:43     ` Martin K. Petersen
2019-11-07  9:53   ` Christoph Hellwig
2019-11-07  9:53     ` Christoph Hellwig
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-05 16:34   ` Mike Snitzer
2019-11-05 16:34     ` Mike Snitzer
2019-11-07  9:53   ` Christoph Hellwig
2019-11-07  9:53     ` Christoph Hellwig
2019-10-27 14:05 ` Damien Le Moal [this message]
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-07  9:54     ` Christoph Hellwig
2019-11-02  3:01 ` [PATCH 0/8] Zone management commands support Jens Axboe
2019-11-02  3:01   ` Jens Axboe
2019-11-03 23:41   ` Damien Le Moal
2019-11-03 23:41     ` Damien Le Moal
2019-11-05  4:51     ` Martin K. Petersen
2019-11-05  4:51       ` Martin K. Petersen
2019-11-05  5:08       ` Damien Le Moal
2019-11-05  5:08         ` Damien Le Moal
2019-11-07 13:40 ` Jens Axboe
2019-11-07 13:40   ` Jens Axboe

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20191027140549.26272-9-damien.lemoal@wdc.com \
    --to=damien.lemoal@wdc.com \
    --cc=Hans.Holmberg@wdc.com \
    --cc=ajay.joshi@wdc.com \
    --cc=axboe@kernel.dk \
    --cc=dm-devel@redhat.com \
    --cc=dmitry.fomichev@wdc.com \
    --cc=kbusch@kernel.org \
    --cc=linux-block@vger.kernel.org \
    --cc=linux-scsi@vger.kernel.org \
    --cc=martin.petersen@oracle.com \
    --cc=matias.bjorling@wdc.com \
    --cc=snitzer@redhat.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.