Skip to content

block: avoid to use bi_vcnt in bio_may_need_split()

Ming Lei io-uring linux-block 1 version Applied

Status from this message: Applied, thanks!

Get series with b4
b4 am [email protected]

Versions newest first

  1. v2 Latest3 patches 5 repliesApplied

Changes in v2 from the cover letter

- improve bio layout by putting bi_iter and bi_io_vec together
- improve commit log

Patches in v2 Applied

#Subject and filesSizeRepliesApplied
1/3block: use bvec iterator helper for bio_may_need_split()block/bio.c block/blk.h include/linux/blk_types.h+14 -51 reply
2/3block: don't initialize bi_vcnt for cloned bio in bio_iov_bvec_set()block/bio.c+1 -11 reply
3/3io_uring: remove nr_segs recalculation in io_import_kbuf()io_uring/rsrc.c+0 -111 reply

Reviews trailers per patch

All 3 patches have a Reviewed-by or Acked-by.

PatchNitesh Shetty
1/3R-b
2/3R-b
3/3R-b

Trailers given in replies are filled; those carried in the patches from earlier versions are outlined with dashes.

Read the v2 thread

Cover letter [PATCH V2 0/3] block: avoid to use bi_vcnt in bio_may_need_split()

This series cleans up bio handling to use bi_iter consistently for both cloned and non-cloned bios, removing the reliance on bi_vcnt which is only meaningful for non-cloned bios.

Currently, bio_may_need_split() uses bi_vcnt to check if a bio has a single segment. While this works, it's inconsistent with how cloned bios operate - they use bi_iter for iteration, not bi_vcnt. This inconsistency led to io_uring needing to recalculate iov_iter.nr_segs to ensure bi_vcnt gets a correct value when copied.

This series unifies the approach:

1. Make bio_may_need_split() use bi_iter instead of bi_vcnt. This handles both cloned and non-cloned bios in a consistent way. Also move bi_io_vec adjacent to bi_iter in struct bio since they're commonly accessed together.

2. Stop copying iov_iter.nr_segs to bi_vcnt in bio_iov_bvec_set(), since cloned bios should rely on bi_iter, not bi_vcnt.

3. Remove the nr_segs recalculation in io_uring, which was only needed to provide an accurate bi_vcnt value.

Nitesh verified no performance regression on NVMe 512-byte fio/t/io_uring workloads.

V2:
- improve bio layout by putting bi_iter and bi_io_vec together
- improve commit log

Ming Lei (3):
block: use bvec iterator helper for bio_may_need_split()
block: don't initialize bi_vcnt for cloned bio in bio_iov_bvec_set()
io_uring: remove nr_segs recalculation in io_import_kbuf()

 block/bio.c               |  5 ++++-
 block/blk.h               | 12 +++++++++---
 include/linux/blk_types.h |  4 ++--
 io_uring/rsrc.c           | 11 -----------
 4 files changed, 15 insertions(+), 17 deletions(-)
Signature · 1 line
2.47.0