Commit 760a54a
block: account for bi_bvec_done in bio_may_need_split()
When checking if a bio fits in a single segment, bio_may_need_split()
compares bi_size against the current bvec's bv_len. However, for
partially consumed bvecs (bi_bvec_done > 0), such as in cloned or
split bios, the remaining bytes in the current bvec is actually
(bv_len - bi_bvec_done), not bv_len.
This could cause bio_may_need_split() to incorrectly return false,
leading to nr_phys_segments being set to 1 when the bio actually
spans multiple segments. This triggers the WARN_ON in __blk_rq_map_sg()
when the actual mapped segments exceed the expected count.
Fix by subtracting bi_bvec_done from bv_len in the comparison.
Reported-by: Venkat Rao Bagalkote <[email protected]>
Close: https://lore.kernel.org/linux-block/[email protected]/
Repored-and-bisected-by: Christoph Hellwig <[email protected]>
Tested-by: Venkat Rao Bagalkote <[email protected]>
Tested-by: Christoph Hellwig <[email protected]>
Fixes: ee623c8 ("block: use bvec iterator helper for bio_may_need_split()")
Cc: Nitesh Shetty <[email protected]>
Signed-off-by: Ming Lei <[email protected]>1 parent 2b94c1f commit 760a54a
1 file changed
+1
-1
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
380 | 380 | | |
381 | 381 | | |
382 | 382 | | |
383 | | - | |
| 383 | + | |
384 | 384 | | |
385 | 385 | | |
386 | 386 | | |
| |||
0 commit comments