diff options
| author | Ming Lei <ming.lei@redhat.com> | 2025-12-31 11:00:56 +0800 |
|---|---|---|
| committer | Jens Axboe <axboe@kernel.dk> | 2026-01-07 08:06:33 -0700 |
| commit | 641864314866dff382f64cd8b52fd6bf4c4d84f6 (patch) | |
| tree | dcaade36021f6054742699b89e462157e6639250 /block | |
| parent | ee623c892aa59003fca173de0041abc2ccc2c72d (diff) | |
| download | linux-next-history-641864314866dff382f64cd8b52fd6bf4c4d84f6.tar.gz | |
block: don't initialize bi_vcnt for cloned bio in bio_iov_bvec_set()
bio_iov_bvec_set() creates a cloned bio that borrows a bvec array from
an iov_iter. For cloned bios, bi_vcnt is meaningless because iteration
is controlled entirely by bi_iter (bi_idx, bi_size, bi_bvec_done), not
by bi_vcnt. Remove the incorrect bi_vcnt assignment.
Explicitly initialize bi_iter.bi_idx to 0 to ensure iteration starts
at the first bvec. While bi_idx is typically already zero from bio
initialization, making this explicit improves clarity and correctness.
This change also avoids accessing iter->nr_segs, which is an iov_iter
implementation detail that block code should not depend on.
Signed-off-by: Ming Lei <ming.lei@redhat.com>
Reviewed-by: Nitesh Shetty <nj.shetty@samsung.com>
Signed-off-by: Jens Axboe <axboe@kernel.dk>
Diffstat (limited to 'block')
| -rw-r--r-- | block/bio.c | 2 |
1 files changed, 1 insertions, 1 deletions
diff --git a/block/bio.c b/block/bio.c index 0e936288034e3..2359c0723b88e 100644 --- a/block/bio.c +++ b/block/bio.c @@ -1165,8 +1165,8 @@ void bio_iov_bvec_set(struct bio *bio, const struct iov_iter *iter) { WARN_ON_ONCE(bio->bi_max_vecs); - bio->bi_vcnt = iter->nr_segs; bio->bi_io_vec = (struct bio_vec *)iter->bvec; + bio->bi_iter.bi_idx = 0; bio->bi_iter.bi_bvec_done = iter->iov_offset; bio->bi_iter.bi_size = iov_iter_count(iter); bio_set_flag(bio, BIO_CLONED); |
