diff options
author | Christoph Hellwig <hch@lst.de> | 2024-01-03 09:16:22 +0100 |
---|---|---|
committer | Jens Axboe <axboe@kernel.dk> | 2024-01-05 00:05:49 +0100 |
commit | 458aa1a09939a56e044768013c86b5ef06e1c4f1 (patch) | |
tree | d1d59ad9bd2b78e2dbe2a5ffd81e646a43511c0a /block | |
parent | mtd_blkdevs: use the default discard granularity (diff) | |
download | linux-458aa1a09939a56e044768013c86b5ef06e1c4f1.tar.xz linux-458aa1a09939a56e044768013c86b5ef06e1c4f1.zip |
block: floor the discard granularity to the physical block size
Discarding less than a physical block doesn't make sense. This fixes
the existing behavior for zram before the recent changes to default
the discard granularity to the logical block size, and is also a
generally useful sanity check.
Fixes: 3753039def5d ("zram: use the default discard granularity")
Reported-by: Sergey Senozhatsky <senozhatsky@chromium.org>
Signed-off-by: Christoph Hellwig <hch@lst.de>
Link: https://lore.kernel.org/r/20240103081622.508754-1-hch@lst.de
Signed-off-by: Jens Axboe <axboe@kernel.dk>
Diffstat (limited to 'block')
-rw-r--r-- | block/blk-settings.c | 3 |
1 files changed, 3 insertions, 0 deletions
diff --git a/block/blk-settings.c b/block/blk-settings.c index d993d20dab3c..06ea91e51b8b 100644 --- a/block/blk-settings.c +++ b/block/blk-settings.c @@ -342,6 +342,9 @@ void blk_queue_physical_block_size(struct request_queue *q, unsigned int size) if (q->limits.physical_block_size < q->limits.logical_block_size) q->limits.physical_block_size = q->limits.logical_block_size; + if (q->limits.discard_granularity < q->limits.physical_block_size) + q->limits.discard_granularity = q->limits.physical_block_size; + if (q->limits.io_min < q->limits.physical_block_size) q->limits.io_min = q->limits.physical_block_size; } |