lkml.org 
[lkml]   [2023]   [Aug]   [17]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
Patch in this message
/
From
Subject[PATCH] block: fix unexpected split in bio_discard_limit
Date
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@smartx.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
\
 
 \ /
  Last update: 2023-08-17 09:41    [W:0.059 / U:1.896 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site