Message ID | 20230817075509.1438569-1-fengli@smartx.com (mailing list archive) |
---|---|
State | New, archived |
Headers | show |
Series | block: fix unexpected split in bio_discard_limit | expand |
Ping… Thanks, Li > 2023年8月17日 下午3:55,Li Feng <fengli@smartx.com> 写道: > > 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 >
On Thu, Aug 17, 2023 at 3:42 PM Li Feng <fengli@smartx.com> wrote: > > bio_discard_limit() enforces discard boundaries within the range of 32-bit > unsigned integers, resulting in unexpected discard cut boundaries. Any bio size can't be bigger than UINT_MAX, see bio definition. > > 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. As mentioned, max bio size is 4GB, so there shouldn't be such issue. Thanks,
> 2023年8月22日 21:07,Ming Lei <ming.lei@redhat.com> 写道: > > On Thu, Aug 17, 2023 at 3:42 PM Li Feng <fengli@smartx.com> wrote: >> >> bio_discard_limit() enforces discard boundaries within the range of 32-bit >> unsigned integers, resulting in unexpected discard cut boundaries. > > Any bio size can't be bigger than UINT_MAX, see bio definition. > >> >> 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. > > As mentioned, max bio size is 4GB, so there shouldn't be such issue. > > Thanks, > Got it, many thanks.
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,
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(-)