summaryrefslogtreecommitdiffstats
path: root/drivers/block
diff options
context:
space:
mode:
authorChristoph Hellwig <hch@lst.de>2019-12-03 10:39:08 +0100
committerJens Axboe <axboe@kernel.dk>2019-12-03 18:18:22 +0100
commit6c6b3549142255c3fe4bab5560efdf8391c8d858 (patch)
tree0a738d6947054942fedcd44f532d6579976c1c28 /drivers/block
parentblock: don't handle bio based drivers in blk_revalidate_disk_zones (diff)
downloadlinux-6c6b3549142255c3fe4bab5560efdf8391c8d858.tar.xz
linux-6c6b3549142255c3fe4bab5560efdf8391c8d858.zip
block: set the zone size in blk_revalidate_disk_zones atomically
The current zone revalidation code has a major problem in that it doesn't update the zone size and q->nr_zones atomically, leading to a short window where an out of bounds access to the zone arrays is possible. To fix this move the setting of the zone size into the crticial sections blk_revalidate_disk_zones so that it gets updated together with the zone bitmaps and q->nr_zones. This also slightly simplifies the caller as it deducts the zone size from the report_zones. This change also allows to check for a power of two zone size in generic code. Reported-by: Hans Holmberg <hans@owltronix.com> Reviewed-by: Javier González <javier@javigon.com> Signed-off-by: Christoph Hellwig <hch@lst.de> Signed-off-by: Jens Axboe <axboe@kernel.dk>
Diffstat (limited to 'drivers/block')
-rw-r--r--drivers/block/null_blk_main.c3
1 files changed, 2 insertions, 1 deletions
diff --git a/drivers/block/null_blk_main.c b/drivers/block/null_blk_main.c
index 068cd0ae6e2c..997b7dc095b9 100644
--- a/drivers/block/null_blk_main.c
+++ b/drivers/block/null_blk_main.c
@@ -1583,6 +1583,8 @@ static int null_gendisk_register(struct nullb *nullb)
if (ret)
return ret;
} else {
+ blk_queue_chunk_sectors(nullb->q,
+ nullb->dev->zone_size_sects);
nullb->q->nr_zones = blkdev_nr_zones(disk);
}
}
@@ -1746,7 +1748,6 @@ static int null_add_dev(struct nullb_device *dev)
if (rv)
goto out_cleanup_blk_queue;
- blk_queue_chunk_sectors(nullb->q, dev->zone_size_sects);
nullb->q->limits.zoned = BLK_ZONED_HM;
blk_queue_flag_set(QUEUE_FLAG_ZONE_RESETALL, nullb->q);
blk_queue_required_elevator_features(nullb->q,