From mboxrd@z Thu Jan 1 00:00:00 1970 From: keith.busch@intel.com (Keith Busch) Date: Wed, 6 Jan 2016 16:21:17 +0000 Subject: [PATCH for-4.4] block: split bios to max possible length In-Reply-To: References: <1451931895-17474-1-git-send-email-keith.busch@intel.com> <20160105150938.GA20832@localhost.localdomain> <20160106055133.GA4868@localhost.localdomain> <20160106151836.GB15113@localhost.localdomain> Message-ID: <20160106162117.GE15113@localhost.localdomain> On Wed, Jan 06, 2016@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)) --