Skip to content

Commit

Permalink
null_blk: Fix zone reset all tracing
Browse files Browse the repository at this point in the history
commit f9c9104 upstream.

In the cae of the REQ_OP_ZONE_RESET_ALL operation, the command sector is
ignored and the operation is applied to all sequential zones. For these
commands, tracing the effect of the command using the command sector to
determine the target zone is thus incorrect.

Fix null_zone_mgmt() zone condition tracing in the case of
REQ_OP_ZONE_RESET_ALL to apply tracing to all sequential zones that are
not already empty.

Fixes: 766c329 ("null_blk: add trace in null_blk_zoned.c")
Signed-off-by: Damien Le Moal <damien.lemoal@wdc.com>
Cc: stable@vger.kernel.org
Signed-off-by: Jens Axboe <axboe@kernel.dk>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
  • Loading branch information
damien-lemoal authored and gregkh committed Nov 5, 2020
1 parent 167ebb1 commit 02d74be
Showing 1 changed file with 8 additions and 6 deletions.
14 changes: 8 additions & 6 deletions drivers/block/null_blk_zoned.c
Expand Up @@ -230,13 +230,15 @@ static blk_status_t null_zone_mgmt(struct nullb_cmd *cmd, enum req_opf op,

switch (op) {
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;
for (i = dev->zone_nr_conv; i < dev->nr_zones; i++) {
zone = &dev->zones[i];
if (zone->cond != BLK_ZONE_COND_EMPTY) {
zone->cond = BLK_ZONE_COND_EMPTY;
zone->wp = zone->start;
trace_nullb_zone_op(cmd, i, zone->cond);
}
}
break;
return BLK_STS_OK;
case REQ_OP_ZONE_RESET:
if (zone->type == BLK_ZONE_TYPE_CONVENTIONAL)
return BLK_STS_IOERR;
Expand Down

0 comments on commit 02d74be

Please sign in to comment.