Skip to content

Commit 458aa1a

Browse files
Christoph Hellwigaxboe
authored andcommitted
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: 3753039 ("zram: use the default discard granularity") Reported-by: Sergey Senozhatsky <[email protected]> Signed-off-by: Christoph Hellwig <[email protected]> Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Jens Axboe <[email protected]>
1 parent 31e4fac commit 458aa1a

File tree

1 file changed

+3
-0
lines changed

1 file changed

+3
-0
lines changed

block/blk-settings.c

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -342,6 +342,9 @@ void blk_queue_physical_block_size(struct request_queue *q, unsigned int size)
342342
if (q->limits.physical_block_size < q->limits.logical_block_size)
343343
q->limits.physical_block_size = q->limits.logical_block_size;
344344

345+
if (q->limits.discard_granularity < q->limits.physical_block_size)
346+
q->limits.discard_granularity = q->limits.physical_block_size;
347+
345348
if (q->limits.io_min < q->limits.physical_block_size)
346349
q->limits.io_min = q->limits.physical_block_size;
347350
}

0 commit comments

Comments
 (0)