From 12212948153062facf7bfbeda27e0dca4f1dddb9 Mon Sep 17 00:00:00 2001 From: Chenggang Wang Date: Wed, 18 Nov 2020 20:45:16 +0800 Subject: [PATCH] UPSTREAM: block: fix get_max_io_size() commit e4b469c66f3cbb81c2e94d31123d7bcdf3c1dabd upstream. A previous commit aligning splits to physical block sizes inadvertently modified one return case such that that it now returns 0 length splits when the number of sectors doesn't exceed the physical offset. This later hits a BUG in bio_split(). Restore the previous working behavior. Bug: 173583534 Fixes: 9cc5169cd478b ("block: Improve physical block alignment of split bios") Reported-by: Eric Deal Signed-off-by: Keith Busch Cc: Bart Van Assche Cc: stable@vger.kernel.org Signed-off-by: Jens Axboe Signed-off-by: Greg Kroah-Hartman Bug: 173583534 (cherry picked from commit f09dbec9c0c68f354eef157c0fe7aa1c6704ecd2) Signed-off-by: Chenggang Wang Signed-off-by: Greg Kroah-Hartman Change-Id: I5f4708059f106b6ded162cbe096e45bae7a7fca4 --- block/blk-merge.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/block/blk-merge.c b/block/blk-merge.c index 8a226eb0c291..897169440a68 100644 --- a/block/blk-merge.c +++ b/block/blk-merge.c @@ -154,7 +154,7 @@ static inline unsigned get_max_io_size(struct request_queue *q, if (max_sectors > start_offset) return max_sectors - start_offset; - return sectors & (lbs - 1); + return sectors & ~(lbs - 1); } static inline unsigned get_max_segment_size(const struct request_queue *q,