Commit a61dbfb1 authored by Chaitanya Kulkarni's avatar Chaitanya Kulkarni Committed by Jens Axboe

null_blk: implement REQ_OP_ZONE_RESET_ALL

This patch implements newly introduced zone reset all operation for
null_blk driver.
Reviewed-by: default avatarDamien Le Moal <damien.lemoal@wdc.com>
Reviewed-by: default avatarHannes Reinecke <hare@suse.com>
Signed-off-by: default avatarChaitanya Kulkarni <chaitanya.kulkarni@wdc.com>
Signed-off-by: default avatarJens Axboe <axboe@kernel.dk>
parent d81e9d49
...@@ -1214,6 +1214,8 @@ static blk_status_t null_handle_cmd(struct nullb_cmd *cmd) ...@@ -1214,6 +1214,8 @@ static blk_status_t null_handle_cmd(struct nullb_cmd *cmd)
null_zone_write(cmd, sector, nr_sectors); null_zone_write(cmd, sector, nr_sectors);
else if (op == REQ_OP_ZONE_RESET) else if (op == REQ_OP_ZONE_RESET)
null_zone_reset(cmd, sector); null_zone_reset(cmd, sector);
else if (op == REQ_OP_ZONE_RESET_ALL)
null_zone_reset(cmd, 0);
} }
out: out:
/* Complete IO by inline, softirq or timer */ /* Complete IO by inline, softirq or timer */
...@@ -1688,6 +1690,7 @@ static int null_add_dev(struct nullb_device *dev) ...@@ -1688,6 +1690,7 @@ static int null_add_dev(struct nullb_device *dev)
blk_queue_chunk_sectors(nullb->q, dev->zone_size_sects); blk_queue_chunk_sectors(nullb->q, dev->zone_size_sects);
nullb->q->limits.zoned = BLK_ZONED_HM; nullb->q->limits.zoned = BLK_ZONED_HM;
blk_queue_flag_set(QUEUE_FLAG_ZONE_RESETALL, nullb->q);
} }
nullb->q->queuedata = nullb; nullb->q->queuedata = nullb;
......
...@@ -125,12 +125,28 @@ void null_zone_reset(struct nullb_cmd *cmd, sector_t sector) ...@@ -125,12 +125,28 @@ void null_zone_reset(struct nullb_cmd *cmd, sector_t sector)
struct nullb_device *dev = cmd->nq->dev; struct nullb_device *dev = cmd->nq->dev;
unsigned int zno = null_zone_no(dev, sector); unsigned int zno = null_zone_no(dev, sector);
struct blk_zone *zone = &dev->zones[zno]; 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) { zone->cond = BLK_ZONE_COND_EMPTY;
cmd->error = BLK_STS_IOERR; zone->wp = zone->start;
return; break;
default:
cmd->error = BLK_STS_NOTSUPP;
break;
} }
zone->cond = BLK_ZONE_COND_EMPTY;
zone->wp = zone->start;
} }
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment