diff options
author | Philipp Reisner <philipp.reisner@linbit.com> | 2022-11-09 14:34:52 +0100 |
---|---|---|
committer | Jens Axboe <axboe@kernel.dk> | 2022-11-09 12:40:36 -0700 |
commit | 21b87a7d7564751590e3a38dfb243f9a0bbedbd2 (patch) | |
tree | b6e3df2ccc8fc479cfaa30debbc7f72074323f7f /drivers/block | |
parent | 258bea6388ac93f34561fd91064232d14e174bff (diff) | |
download | linux-stable-21b87a7d7564751590e3a38dfb243f9a0bbedbd2.tar.gz linux-stable-21b87a7d7564751590e3a38dfb243f9a0bbedbd2.tar.bz2 linux-stable-21b87a7d7564751590e3a38dfb243f9a0bbedbd2.zip |
drbd: disable discard support if granularity > max
The discard_granularity describes the minimum unit of a discard.
If that is larger than the maximal discard size, we need to disable
discards completely.
Reviewed-by: Joel Colledge <joel.colledge@linbit.com>
Signed-off-by: Philipp Reisner <philipp.reisner@linbit.com>
Signed-off-by: Christoph Böhmwalder <christoph.boehmwalder@linbit.com>
Link: https://lore.kernel.org/r/20221109133453.51652-3-christoph.boehmwalder@linbit.com
Signed-off-by: Jens Axboe <axboe@kernel.dk>
Diffstat (limited to 'drivers/block')
-rw-r--r-- | drivers/block/drbd/drbd_nl.c | 13 |
1 files changed, 13 insertions, 0 deletions
diff --git a/drivers/block/drbd/drbd_nl.c b/drivers/block/drbd/drbd_nl.c index 249eba7d21c2..63f589926d85 100644 --- a/drivers/block/drbd/drbd_nl.c +++ b/drivers/block/drbd/drbd_nl.c @@ -1256,6 +1256,18 @@ static void fixup_write_zeroes(struct drbd_device *device, struct request_queue q->limits.max_write_zeroes_sectors = 0; } +static void fixup_discard_support(struct drbd_device *device, struct request_queue *q) +{ + unsigned int max_discard = device->rq_queue->limits.max_discard_sectors; + unsigned int discard_granularity = + device->rq_queue->limits.discard_granularity >> SECTOR_SHIFT; + + if (discard_granularity > max_discard) { + blk_queue_discard_granularity(q, 0); + blk_queue_max_discard_sectors(q, 0); + } +} + static void drbd_setup_queue_param(struct drbd_device *device, struct drbd_backing_dev *bdev, unsigned int max_bio_size, struct o_qlim *o) { @@ -1288,6 +1300,7 @@ static void drbd_setup_queue_param(struct drbd_device *device, struct drbd_backi disk_update_readahead(device->vdisk); } fixup_write_zeroes(device, q); + fixup_discard_support(device, q); } void drbd_reconsider_queue_parameters(struct drbd_device *device, struct drbd_backing_dev *bdev, struct o_qlim *o) |