public inbox for io-uring@vger.kernel.org
 help / color / mirror / Atom feed
* [PATCH V2 0/3] block: avoid to use bi_vcnt in bio_may_need_split()
@ 2025-12-31  3:00 Ming Lei
  2025-12-31  3:00 ` [PATCH V2 1/3] block: use bvec iterator helper for bio_may_need_split() Ming Lei
                   ` (4 more replies)
  0 siblings, 5 replies; 9+ messages in thread
From: Ming Lei @ 2025-12-31  3:00 UTC (permalink / raw)
  To: Jens Axboe, linux-block
  Cc: io-uring, Caleb Sander Mateos, Nitesh Shetty, Ming Lei

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(-)

-- 
2.47.0


^ permalink raw reply	[flat|nested] 9+ messages in thread

end of thread, other threads:[~2026-01-07 15:08 UTC | newest]

Thread overview: 9+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2025-12-31  3:00 [PATCH V2 0/3] block: avoid to use bi_vcnt in bio_may_need_split() Ming Lei
2025-12-31  3:00 ` [PATCH V2 1/3] block: use bvec iterator helper for bio_may_need_split() Ming Lei
2026-01-07 10:38   ` Nitesh Shetty
2025-12-31  3:00 ` [PATCH V2 2/3] block: don't initialize bi_vcnt for cloned bio in bio_iov_bvec_set() Ming Lei
2026-01-07 10:39   ` Nitesh Shetty
2025-12-31  3:00 ` [PATCH V2 3/3] io_uring: remove nr_segs recalculation in io_import_kbuf() Ming Lei
2026-01-07 10:40   ` Nitesh Shetty
2026-01-07  4:11 ` [PATCH V2 0/3] block: avoid to use bi_vcnt in bio_may_need_split() Ming Lei
2026-01-07 15:08 ` Jens Axboe

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox