Skip to content

Commit 3c407dc

Browse files
Christoph Hellwigaxboe
authored andcommitted
block: default the discard granularity to sector size
Current the discard granularity defaults to 0 and must be initialized by any driver that wants to support discard. Default to the sector size instead, which is the smallest possible value, and a very useful default. Signed-off-by: Christoph Hellwig <hch@lst.de> Link: https://lore.kernel.org/r/20231228075545.362768-4-hch@lst.de Signed-off-by: Jens Axboe <axboe@kernel.dk>
1 parent 5e7169e commit 3c407dc

1 file changed

Lines changed: 4 additions & 1 deletion

File tree

block/blk-settings.c

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@ void blk_set_default_limits(struct queue_limits *lim)
4848
lim->max_discard_sectors = 0;
4949
lim->max_hw_discard_sectors = 0;
5050
lim->max_secure_erase_sectors = 0;
51-
lim->discard_granularity = 0;
51+
lim->discard_granularity = 512;
5252
lim->discard_alignment = 0;
5353
lim->discard_misaligned = 0;
5454
lim->logical_block_size = lim->physical_block_size = lim->io_min = 512;
@@ -309,6 +309,9 @@ void blk_queue_logical_block_size(struct request_queue *q, unsigned int size)
309309

310310
limits->logical_block_size = size;
311311

312+
if (limits->discard_granularity < limits->logical_block_size)
313+
limits->discard_granularity = limits->logical_block_size;
314+
312315
if (limits->physical_block_size < size)
313316
limits->physical_block_size = size;
314317

0 commit comments

Comments
 (0)