block: move the bi_size overflow check in __bio_try_merge_page
authorChristoph Hellwig <hch@lst.de>
Mon, 24 Jul 2023 16:54:30 +0000 (09:54 -0700)
committerJens Axboe <axboe@kernel.dk>
Tue, 25 Jul 2023 01:55:16 +0000 (19:55 -0600)
commit613699050a49760f1d70c74f71bd0b013ca3c356
tree1117f66979ad0ad87e929850920077c7debf8eaa
parent0eca8b6f97ac705c5806f7d062207379094fb114
block: move the bi_size overflow check in __bio_try_merge_page

Checking for availability in bi_size in a function that attempts to
merge into an existing segment is a bit odd, as the limit also applies
when adding a new segment.  This code works fine as we always call
__bio_try_merge_page, but contributes to sub-optimal calling conventions
and doesn't lead to clear code.

Move it to two of the callers instead, the third one already has a more
strict check that includes max_hw_segments anyway.

Signed-off-by: Christoph Hellwig <hch@lst.de>
Reviewed-by: Jinyoung Choi <j-young.choi@samsung.com>
Reviewed-by: Johannes Thumshirn <johannes.thumshirn@wdc.com>
Link: https://lore.kernel.org/r/20230724165433.117645-6-hch@lst.de
Signed-off-by: Jens Axboe <axboe@kernel.dk>
block/bio.c