All of lore.kernel.org
 help / color / mirror / Atom feed
From: kent.overstreet@gmail.com (Kent Overstreet)
Subject: [PATCH for-4.4] block: split bios to max possible length
Date: Thu, 7 Jan 2016 01:46:37 -0900	[thread overview]
Message-ID: <20160107104637.GA22795@kmo-pixel> (raw)
In-Reply-To: <20160106162117.GE15113@localhost.localdomain>

On Wed, Jan 06, 2016@04:21:17PM +0000, Keith Busch wrote:
> 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))
> --

Yes, splitting in the middle of a bvec is perfectly fine. The reason
bio_for_each_segment takes a struct bvec and not a struct bvec * is because it's
computing what bv_len should be (taking the min of bv_len and bi_size, roughly).

See include/linux/bio.h:

bio_for_each_segment()
  bio_iter_iovec()
    bvec_iter_bvec()
      bvec_iter_len()

which does the actual bv_len computation.

  parent reply	other threads:[~2016-01-07 10:46 UTC|newest]

Thread overview: 15+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2016-01-04 18:24 [PATCH for-4.4] block: split bios to max possible length Keith Busch
2016-01-05  4:54 ` Ming Lei
2016-01-05 15:09   ` Keith Busch
2016-01-06  2:17     ` Ming Lei
2016-01-06  5:51       ` Keith Busch
2016-01-06  6:29         ` Ming Lei
2016-01-06  6:53           ` Ming Lei
2016-01-06 15:18             ` Keith Busch
2016-01-06 15:43               ` Ming Lei
2016-01-06 16:21                 ` Keith Busch
2016-01-07  0:14                   ` Ming Lei
2016-01-07 10:46                   ` Kent Overstreet [this message]
2016-01-09 11:10                     ` Ming Lei
2016-01-06 15:29           ` Keith Busch
2016-01-06  9:46         ` Ming Lei

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20160107104637.GA22795@kmo-pixel \
    --to=kent.overstreet@gmail.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.