Skip to content

Commit

Permalink
null_blk: don't allow discard for zoned mode
Browse files Browse the repository at this point in the history
Zoned block device specification do not define the behavior of
discard/trim command as this command is generally replaced by the reset
write pointer (zone reset) command. Emulate this in null_blk by making
zoned and discard options mutually exclusive.

Suggested-by: Damien Le Moal <damien.lemoal@wdc.com>
Signed-off-by: Chaitanya Kulkarni <chaitanya.kulkarni@wdc.com>
Signed-off-by: Jens Axboe <axboe@kernel.dk>
  • Loading branch information
Chaitanya Kulkarni authored and Jens Axboe committed May 21, 2020
1 parent e274832 commit 1592cd1
Showing 1 changed file with 7 additions and 0 deletions.
7 changes: 7 additions & 0 deletions drivers/block/null_blk_main.c
Original file line number Diff line number Diff line change
Expand Up @@ -1535,6 +1535,13 @@ static void null_config_discard(struct nullb *nullb)
{
if (nullb->dev->discard == false)
return;

if (nullb->dev->zoned) {
nullb->dev->discard = false;
pr_info("discard option is ignored in zoned mode\n");
return;
}

nullb->q->limits.discard_granularity = nullb->dev->blocksize;
nullb->q->limits.discard_alignment = nullb->dev->blocksize;
blk_queue_max_discard_sectors(nullb->q, UINT_MAX >> 9);
Expand Down

0 comments on commit 1592cd1

Please sign in to comment.