From: "Matias Bjørling" <mb@lightnvm.io>
To: Damien Le Moal <Damien.LeMoal@wdc.com>,
"axboe@fb.com" <axboe@fb.com>, "hch@lst.de" <hch@lst.de>,
Chaitanya Kulkarni <Chaitanya.Kulkarni@wdc.com>,
Dmitry Fomichev <Dmitry.Fomichev@wdc.com>,
Ajay Joshi <Ajay.Joshi@wdc.com>,
Aravind Ramesh <Aravind.Ramesh@wdc.com>,
"martin.petersen@oracle.com" <martin.petersen@oracle.com>,
"James.Bottomley@HansenPartnership.com"
<James.Bottomley@HansenPartnership.com>,
"agk@redhat.com" <agk@redhat.com>,
"snitzer@redhat.com" <snitzer@redhat.com>
Cc: "linux-block@vger.kernel.org" <linux-block@vger.kernel.org>,
"linux-kernel@vger.kernel.org" <linux-kernel@vger.kernel.org>,
"linux-scsi@vger.kernel.org" <linux-scsi@vger.kernel.org>,
"dm-devel@redhat.com" <dm-devel@redhat.com>,
Matias Bjorling <Matias.Bjorling@wdc.com>
Subject: Re: [PATCH 2/4] null_blk: add zone open, close, and finish support
Date: Tue, 25 Jun 2019 13:06:33 +0200 [thread overview]
Message-ID: <1aa6552c-ecf9-a168-df75-ec8c52ddbea6@lightnvm.io> (raw)
In-Reply-To: <BYAPR04MB5816D471063D970DDCF9AEC7E7E60@BYAPR04MB5816.namprd04.prod.outlook.com>
On 6/22/19 3:02 AM, Damien Le Moal wrote:
> On 2019/06/21 22:07, Matias Bjørling 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.
>>
>> Signed-off-by: Ajay Joshi <ajay.joshi@wdc.com>
>> Signed-off-by: Matias Bjørling <matias.bjorling@wdc.com>
>> ---
>> drivers/block/null_blk.h | 4 ++--
>> drivers/block/null_blk_main.c | 13 ++++++++++---
>> drivers/block/null_blk_zoned.c | 33 ++++++++++++++++++++++++++++++---
>> 3 files changed, 42 insertions(+), 8 deletions(-)
>>
>> diff --git a/drivers/block/null_blk.h b/drivers/block/null_blk.h
>> index 34b22d6523ba..62ef65cb0f3e 100644
>> --- a/drivers/block/null_blk.h
>> +++ b/drivers/block/null_blk.h
>> @@ -93,7 +93,7 @@ int null_zone_report(struct gendisk *disk, sector_t sector,
>> gfp_t gfp_mask);
>> void null_zone_write(struct nullb_cmd *cmd, sector_t sector,
>> unsigned int nr_sectors);
>> -void null_zone_reset(struct nullb_cmd *cmd, sector_t sector);
>> +void null_zone_mgmt_op(struct nullb_cmd *cmd, sector_t sector);
>> #else
>> static inline int null_zone_init(struct nullb_device *dev)
>> {
>> @@ -111,6 +111,6 @@ static inline void null_zone_write(struct nullb_cmd *cmd, sector_t sector,
>> unsigned int nr_sectors)
>> {
>> }
>> -static inline void null_zone_reset(struct nullb_cmd *cmd, sector_t sector) {}
>> +static inline void null_zone_mgmt_op(struct nullb_cmd *cmd, sector_t sector) {}
>> #endif /* CONFIG_BLK_DEV_ZONED */
>> #endif /* __NULL_BLK_H */
>> diff --git a/drivers/block/null_blk_main.c b/drivers/block/null_blk_main.c
>> index 447d635c79a2..5058fb980c9c 100644
>> --- a/drivers/block/null_blk_main.c
>> +++ b/drivers/block/null_blk_main.c
>> @@ -1209,10 +1209,17 @@ static blk_status_t null_handle_cmd(struct nullb_cmd *cmd)
>> nr_sectors = blk_rq_sectors(cmd->rq);
>> }
>>
>> - if (op == REQ_OP_WRITE)
>> + switch (op) {
>> + case REQ_OP_WRITE:
>> null_zone_write(cmd, sector, nr_sectors);
>> - else if (op == REQ_OP_ZONE_RESET)
>> - null_zone_reset(cmd, sector);
>> + break;
>> + case REQ_OP_ZONE_RESET:
>> + case REQ_OP_ZONE_OPEN:
>> + case REQ_OP_ZONE_CLOSE:
>> + case REQ_OP_ZONE_FINISH:
>> + null_zone_mgmt_op(cmd, sector);
>> + break;
>> + }
>> }
>> out:
>> /* Complete IO by inline, softirq or timer */
>> diff --git a/drivers/block/null_blk_zoned.c b/drivers/block/null_blk_zoned.c
>> index fca0c97ff1aa..47d956b2e148 100644
>> --- a/drivers/block/null_blk_zoned.c
>> +++ b/drivers/block/null_blk_zoned.c
>> @@ -121,17 +121,44 @@ void null_zone_write(struct nullb_cmd *cmd, sector_t sector,
>> }
>> }
>>
>> -void null_zone_reset(struct nullb_cmd *cmd, sector_t sector)
>> +void null_zone_mgmt_op(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];
>> + enum req_opf op = req_op(cmd->rq);
>>
>> if (zone->type == BLK_ZONE_TYPE_CONVENTIONAL) {
>> cmd->error = BLK_STS_IOERR;
>> return;
>> }
>>
>> - zone->cond = BLK_ZONE_COND_EMPTY;
>> - zone->wp = zone->start;
>> + switch (op) {
>> + case REQ_OP_ZONE_RESET:
>> + zone->cond = BLK_ZONE_COND_EMPTY;
>> + zone->wp = zone->start;
>> + return;
>> + case REQ_OP_ZONE_OPEN:
>> + if (zone->cond == BLK_ZONE_COND_FULL) {
>> + cmd->error = BLK_STS_IOERR;
>> + return;
>> + }
>> + zone->cond = BLK_ZONE_COND_EXP_OPEN;
>
>
> With ZBC, open of a full zone is a "nop". No error. So I would rather have this as:
>
> if (zone->cond != BLK_ZONE_COND_FULL)
> zone->cond = BLK_ZONE_COND_EXP_OPEN;
>
Is this only ZBC? I can't find a reference to it in ZAC. I think it
should fail. One is trying to open a zone that is full, one can't open
it again. It's done for this round.
>
>> + return;
>> + case REQ_OP_ZONE_CLOSE:
>> + if (zone->cond == BLK_ZONE_COND_FULL) {
>> + cmd->error = BLK_STS_IOERR;
>> + return;
>> + }
>> + zone->cond = BLK_ZONE_COND_CLOSED;
>
> Sam as for open. Closing a full zone on ZBC is a nop.
I think this should cause error.
And the code above would
> also set an empty zone to closed. Finally, if the zone is open but nothing was
> written to it, it must be returned to empty condition, not closed.
Only on a reset event right? In general, if I do a expl. open, close it,
it should not go to empty.
So something
> like this is needed.
>
> switch (zone->cond) {
> case BLK_ZONE_COND_FULL:
> case BLK_ZONE_COND_EMPTY:
> break;
> case BLK_ZONE_COND_EXP_OPEN:
> if (zone->wp == zone->start) {
> zone->cond = BLK_ZONE_COND_EMPTY;
> break;
> }
> /* fallthrough */
> default:
> zone->cond = BLK_ZONE_COND_CLOSED;
> }
>
>> + return;
>> + case REQ_OP_ZONE_FINISH:
>> + zone->cond = BLK_ZONE_COND_FULL;
>> + zone->wp = zone->start + zone->len;
>> + return;
>> + default:
>> + /* Invalid zone condition */
>> + cmd->error = BLK_STS_IOERR;
>> + return;
>> + }
>> }
>>
>
>
next prev parent reply other threads:[~2019-06-25 11:06 UTC|newest]
Thread overview: 25+ messages / expand[flat|nested] mbox.gz Atom feed top
2019-06-21 13:07 [PATCH 0/4] open, close, finish zone support Matias Bjørling
2019-06-21 13:07 ` [PATCH 1/4] block: add zone open, close and finish support Matias Bjørling
2019-06-22 0:51 ` Damien Le Moal
2019-06-24 10:36 ` Matias Bjørling
2019-06-22 6:04 ` Minwoo Im
2019-06-24 19:43 ` Bart Van Assche
2019-06-24 22:27 ` Chaitanya Kulkarni
2019-06-25 10:35 ` Matias Bjørling
2019-06-25 15:55 ` Bart Van Assche
2019-06-25 16:30 ` Javier González
2019-06-25 16:51 ` Chaitanya Kulkarni
2019-06-25 16:53 ` Matias Bjørling
2019-06-26 0:44 ` Damien Le Moal
2019-06-26 0:42 ` Damien Le Moal
2019-06-21 13:07 ` [PATCH 2/4] null_blk: add zone open, close, " Matias Bjørling
2019-06-22 1:02 ` Damien Le Moal
2019-06-25 11:06 ` Matias Bjørling [this message]
2019-06-25 12:36 ` Damien Le Moal
2019-06-25 13:03 ` Matias Bjørling
2019-06-21 13:07 ` [PATCH 3/4] scsi: sd_zbc: " Matias Bjørling
2019-06-22 1:12 ` Damien Le Moal
2019-06-24 19:46 ` Bart Van Assche
2019-06-25 10:32 ` Matias Bjørling
2019-06-21 13:07 ` [PATCH 4/4] dm: add zone open, close " Matias Bjørling
2019-06-22 1:15 ` 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=1aa6552c-ecf9-a168-df75-ec8c52ddbea6@lightnvm.io \
--to=mb@lightnvm.io \
--cc=Ajay.Joshi@wdc.com \
--cc=Aravind.Ramesh@wdc.com \
--cc=Chaitanya.Kulkarni@wdc.com \
--cc=Damien.LeMoal@wdc.com \
--cc=Dmitry.Fomichev@wdc.com \
--cc=James.Bottomley@HansenPartnership.com \
--cc=Matias.Bjorling@wdc.com \
--cc=agk@redhat.com \
--cc=axboe@fb.com \
--cc=dm-devel@redhat.com \
--cc=hch@lst.de \
--cc=linux-block@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-scsi@vger.kernel.org \
--cc=martin.petersen@oracle.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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®