From: Chaitanya Kulkarni <chaitanya.kulkarni@wdc.com>
To: linux-block@vger.kernel.org, linux-scsi@vger.kernel.org
Cc: axboe@kernel.dk, jejb@linux.ibm.com, dennis@kernel.org,
hare@suse.com, damien.lemoal@wdc.com, sagi@grimberg.me,
dennisszhou@gmail.com, jthumshirn@suse.de, osandov@fb.com,
ming.lei@redhat.com, tj@kernel.org, bvanassche@acm.org,
martin.petersen@oracle.com,
Chaitanya Kulkarni <chaitanya.kulkarni@wdc.com>
Subject: [PATCH 4/4] null_blk: implement REQ_OP_ZONE_RESET_ALL
Date: Wed, 31 Jul 2019 14:01:02 -0700 [thread overview]
Message-ID: <20190731210102.3472-5-chaitanya.kulkarni@wdc.com> (raw)
In-Reply-To: <20190731210102.3472-1-chaitanya.kulkarni@wdc.com>
This patch implements newly introduced zone reset all operation for
null_blk driver.
Signed-off-by: Chaitanya Kulkarni <chaitanya.kulkarni@wdc.com>
---
drivers/block/null_blk_main.c | 3 +++
drivers/block/null_blk_zoned.c | 28 ++++++++++++++++++++++------
2 files changed, 25 insertions(+), 6 deletions(-)
diff --git a/drivers/block/null_blk_main.c b/drivers/block/null_blk_main.c
index 99328ded60d1..99c56d72ff78 100644
--- a/drivers/block/null_blk_main.c
+++ b/drivers/block/null_blk_main.c
@@ -1214,6 +1214,8 @@ static blk_status_t null_handle_cmd(struct nullb_cmd *cmd)
null_zone_write(cmd, sector, nr_sectors);
else if (op == REQ_OP_ZONE_RESET)
null_zone_reset(cmd, sector);
+ else if (op == REQ_OP_ZONE_RESET_ALL)
+ null_zone_reset(cmd, 0);
}
out:
/* Complete IO by inline, softirq or timer */
@@ -1688,6 +1690,7 @@ static int null_add_dev(struct nullb_device *dev)
blk_queue_chunk_sectors(nullb->q, dev->zone_size_sects);
nullb->q->limits.zoned = BLK_ZONED_HM;
+ blk_queue_flag_set(QUEUE_FLAG_ZONE_RESETALL, nullb->q);
}
nullb->q->queuedata = nullb;
diff --git a/drivers/block/null_blk_zoned.c b/drivers/block/null_blk_zoned.c
index cb28d93f2bd1..8c7f5bf81975 100644
--- a/drivers/block/null_blk_zoned.c
+++ b/drivers/block/null_blk_zoned.c
@@ -125,12 +125,28 @@ void null_zone_reset(struct nullb_cmd *cmd, sector_t sector)
struct nullb_device *dev = cmd->nq->dev;
unsigned int zno = null_zone_no(dev, sector);
struct blk_zone *zone = &dev->zones[zno];
+ size_t i;
+
+ switch (req_op(cmd->rq)) {
+ case REQ_OP_ZONE_RESET_ALL:
+ for (i = 0; i < dev->nr_zones; i++) {
+ if (zone[i].type == BLK_ZONE_TYPE_CONVENTIONAL)
+ continue;
+ zone[i].cond = BLK_ZONE_COND_EMPTY;
+ zone[i].wp = zone[i].start;
+ }
+ break;
+ case REQ_OP_ZONE_RESET:
+ if (zone->type == BLK_ZONE_TYPE_CONVENTIONAL) {
+ cmd->error = BLK_STS_IOERR;
+ return;
+ }
- if (zone->type == BLK_ZONE_TYPE_CONVENTIONAL) {
- cmd->error = BLK_STS_IOERR;
- return;
+ zone->cond = BLK_ZONE_COND_EMPTY;
+ zone->wp = zone->start;
+ break;
+ default:
+ cmd->error = BLK_STS_NOTSUPP;
+ break;
}
-
- zone->cond = BLK_ZONE_COND_EMPTY;
- zone->wp = zone->start;
}
--
2.17.0
next prev parent reply other threads:[~2019-07-31 21:02 UTC|newest]
Thread overview: 11+ messages / expand[flat|nested] mbox.gz Atom feed top
2019-07-31 21:00 [PATCH 0/4] block: introduce REQ_OP_ZONE_RESET_ALL Chaitanya Kulkarni
2019-07-31 21:00 ` [PATCH 1/4] block: add req op to reset all zones and flag Chaitanya Kulkarni
2019-08-01 0:53 ` Damien Le Moal
2019-07-31 21:01 ` [PATCH 2/4] blk-zoned: implement REQ_OP_ZONE_RESET_ALL Chaitanya Kulkarni
2019-08-01 0:55 ` Damien Le Moal
2019-08-01 4:51 ` Chaitanya Kulkarni
2019-08-01 8:40 ` Damien Le Moal
2019-07-31 21:01 ` [PATCH 3/4] scsi: " Chaitanya Kulkarni
2019-08-01 1:00 ` Damien Le Moal
2019-07-31 21:01 ` Chaitanya Kulkarni [this message]
2019-08-01 1:03 ` [PATCH 4/4] null_blk: " Damien Le Moal
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=20190731210102.3472-5-chaitanya.kulkarni@wdc.com \
--to=chaitanya.kulkarni@wdc.com \
--cc=axboe@kernel.dk \
--cc=bvanassche@acm.org \
--cc=damien.lemoal@wdc.com \
--cc=dennis@kernel.org \
--cc=dennisszhou@gmail.com \
--cc=hare@suse.com \
--cc=jejb@linux.ibm.com \
--cc=jthumshirn@suse.de \
--cc=linux-block@vger.kernel.org \
--cc=linux-scsi@vger.kernel.org \
--cc=martin.petersen@oracle.com \
--cc=ming.lei@redhat.com \
--cc=osandov@fb.com \
--cc=sagi@grimberg.me \
--cc=tj@kernel.org \
/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 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).