linux-block.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] block: floor the discard granularity to the physical block size
@ 2024-01-03  8:16 Christoph Hellwig
  2024-01-04 23:10 ` Jens Axboe
  2024-01-06  1:31 ` Sergey Senozhatsky
  0 siblings, 2 replies; 3+ messages in thread
From: Christoph Hellwig @ 2024-01-03  8:16 UTC (permalink / raw)
  To: axboe; +Cc: linux-block, Sergey Senozhatsky

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>
---
 block/blk-settings.c | 3 +++
 1 file changed, 3 insertions(+)

diff --git a/block/blk-settings.c b/block/blk-settings.c
index d993d20dab3c6d..06ea91e51b8b2e 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;
 }
-- 
2.39.2


^ permalink raw reply related	[flat|nested] 3+ messages in thread

* Re: [PATCH] block: floor the discard granularity to the physical block size
  2024-01-03  8:16 [PATCH] block: floor the discard granularity to the physical block size Christoph Hellwig
@ 2024-01-04 23:10 ` Jens Axboe
  2024-01-06  1:31 ` Sergey Senozhatsky
  1 sibling, 0 replies; 3+ messages in thread
From: Jens Axboe @ 2024-01-04 23:10 UTC (permalink / raw)
  To: Christoph Hellwig; +Cc: linux-block, Sergey Senozhatsky


On Wed, 03 Jan 2024 08:16:22 +0000, Christoph Hellwig wrote:
> 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,
-- 
Jens Axboe




^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [PATCH] block: floor the discard granularity to the physical block size
  2024-01-03  8:16 [PATCH] block: floor the discard granularity to the physical block size Christoph Hellwig
  2024-01-04 23:10 ` Jens Axboe
@ 2024-01-06  1:31 ` Sergey Senozhatsky
  1 sibling, 0 replies; 3+ messages in thread
From: Sergey Senozhatsky @ 2024-01-06  1:31 UTC (permalink / raw)
  To: Christoph Hellwig; +Cc: axboe, linux-block, Sergey Senozhatsky

On (24/01/03 08:16), Christoph Hellwig wrote:
> 
> 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>

FWIW,
Reviewed-by: Sergey Senozhatsky <senozhatsky@chromium.org>

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2024-01-06  1:31 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2024-01-03  8:16 [PATCH] block: floor the discard granularity to the physical block size Christoph Hellwig
2024-01-04 23:10 ` Jens Axboe
2024-01-06  1:31 ` Sergey Senozhatsky

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).