Skip to contentSkip to conversation

block: floor the discard granularity to the physical block size

PATCH Applied Christoph Hellwig 3 participants 3 messages Jan 3, 2024 – Jan 6, 2024 Block layer

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 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")
---
 block/blk-settings.c | 3 +++
 1 file changed, 3 insertions(+)
block/blk-settings.c +3 -0
index d993d20dab3c6d..06ea91e51b8b2e 100644
@@ -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;
 }
Signature · 1 line
2.39.2
maintainer Applied
#1 lore raw
Quoted 6 lines · Christoph Hellwig

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.

Applied, thanks!

[1/1] block: floor the discard granularity to the physical block size

      commit: 458aa1a09939a56e044768013c86b5ef06e1c4f1

Best regards,

Signature · 1 line
Jens Axboe
Reviewed-by on v1 1/1
#2 lore raw
In reply to Christoph Hellwig
Quoted 9 lines · Christoph Hellwig

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")

FWIW,