[PATCH for-4.4] block: split bios to max possible length
Keith Busch
keith.busch at intel.com
Wed Jan 6 08:21:17 PST 2016
On Wed, Jan 06, 2016 at 11:43:45PM +0800, Ming Lei wrote:
> Please see the 1st line code of __blk_segment_map_sg(), in which only
> one whole bvec is handled, and partial bvec can't be figured out there.
>
> Think of it further, drivers often use bv.bv_len directly in the
> iterator, for example:
>
> bio_for_each_segment(bvec, bio, iter)
> memcpy(page_address(bvec.bv_page) +
> bvec.bv_offset, addr +
> offset, bvec.bv_len);
>
> So your patch will break these drivers, won't it?
CC'ing Kent in hopes he will clarify what happens on a split.
The bio_advance() code comments say it's handled:
"
* This updates bi_sector, bi_size and bi_idx; if the number of bytes to
* complete doesn't align with a bvec boundary, then bv_len and bv_offset will
* be updated on the last bvec as well.
"
I admit I'm having a hard time seeing where bv_len and bv_offset updated
in this path. It was obviously handled after 054bdf646e then changed
with 4550dd6c6b.
If I follow correctly, 4550dd6c6b will implicity update the bvec's offset
and length during the split here since bio_iter_iovec resets the bvec's
length and offset:
---
#define __bio_for_each_segment(bvl, bio, iter, start) \
for (iter = (start); \
(iter).bi_size && \
((bvl = bio_iter_iovec((bio), (iter))), 1); \
bio_advance_iter((bio), &(iter), (bvl).bv_len))
--
More information about the Linux-nvme
mailing list