Skip to content

Commit db9f384

Browse files
committed
Merge tag 'block-5.7-2020-05-22' of git://git.kernel.dk/linux-block
Pull block fixes from Jens Axboe: "Two fixes for null_blk zone mode" * tag 'block-5.7-2020-05-22' of git://git.kernel.dk/linux-block: null_blk: don't allow discard for zoned mode null_blk: return error for invalid zone size
2 parents b09ca17 + 1592cd1 commit db9f384

File tree

2 files changed

+11
-0
lines changed

2 files changed

+11
-0
lines changed

drivers/block/null_blk_main.c

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1535,6 +1535,13 @@ static void null_config_discard(struct nullb *nullb)
15351535
{
15361536
if (nullb->dev->discard == false)
15371537
return;
1538+
1539+
if (nullb->dev->zoned) {
1540+
nullb->dev->discard = false;
1541+
pr_info("discard option is ignored in zoned mode\n");
1542+
return;
1543+
}
1544+
15381545
nullb->q->limits.discard_granularity = nullb->dev->blocksize;
15391546
nullb->q->limits.discard_alignment = nullb->dev->blocksize;
15401547
blk_queue_max_discard_sectors(nullb->q, UINT_MAX >> 9);

drivers/block/null_blk_zoned.c

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,10 @@ int null_init_zoned_dev(struct nullb_device *dev, struct request_queue *q)
2323
pr_err("zone_size must be power-of-two\n");
2424
return -EINVAL;
2525
}
26+
if (dev->zone_size > dev->size) {
27+
pr_err("Zone size larger than device capacity\n");
28+
return -EINVAL;
29+
}
2630

2731
dev->zone_size_sects = dev->zone_size << ZONE_SIZE_SHIFT;
2832
dev->nr_zones = dev_size >>

0 commit comments

Comments
 (0)