[<prev] [next>] [thread-next>] [day] [month] [year] [list]
Message-ID: <20230817075509.1438569-1-fengli@smartx.com>
Date: Thu, 17 Aug 2023 15:55:06 +0800
From: Li Feng <fengli@...rtx.com>
To: Jens Axboe <axboe@...nel.dk>,
linux-block@...r.kernel.org (open list:BLOCK LAYER),
linux-kernel@...r.kernel.org (open list)
Cc: lifeng1519@...il.com, Li Feng <fengli@...rtx.com>
Subject: [PATCH] block: fix unexpected split in bio_discard_limit
bio_discard_limit() enforces discard boundaries within the range of 32-bit
unsigned integers, resulting in unexpected discard cut boundaries.
For example, max discard size = 1MiB, discard_granularity = 512B, then the
discard lengths sent in the range [0,4G) are 1MiB, 1MiB... (1MiB-512).
The next discard offset from 4G is [4G-512, 4G-512+1MiB).
The discard of the 4G offset boundary does not comply with the optimal 1MiB
size.
Signed-off-by: Li Feng <fengli@...rtx.com>
---
block/blk-lib.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/block/blk-lib.c b/block/blk-lib.c
index e59c3069e835..ec95508c3593 100644
--- a/block/blk-lib.c
+++ b/block/blk-lib.c
@@ -32,7 +32,7 @@ static sector_t bio_discard_limit(struct block_device *bdev, sector_t sector)
* Align the bio size to the discard granularity to make splitting the bio
* at discard granularity boundaries easier in the driver if needed.
*/
- return round_down(UINT_MAX, discard_granularity) >> SECTOR_SHIFT;
+ return round_down(ULONG_MAX, discard_granularity) >> SECTOR_SHIFT;
}
int __blkdev_issue_discard(struct block_device *bdev, sector_t sector,
--
2.41.0
Powered by blists - more mailing lists