All of lore.kernel.org
 help / color / mirror / Atom feed
From: Ming Lei <ming.lei@redhat.com>
To: Bart Van Assche <bart.vanassche@wdc.com>
Cc: Jens Axboe <axboe@kernel.dk>,
	"linux-block@vger.kernel.org" <linux-block@vger.kernel.org>,
	Christoph Hellwig <hch@lst.de>, Mike Snitzer <snitzer@redhat.com>,
	Hannes Reinecke <hare@suse.com>,
	Johannes Thumshirn <jthumshirn@suse.de>
Subject: Re: [PATCH] block: Make __bio_clone_fast() copy bi_vcnt
Date: Thu, 28 Jun 2018 08:30:08 +0800	[thread overview]
Message-ID: <20180628003007.GG7583@ming.t460p> (raw)
In-Reply-To: <4995fc0c-e9d7-d747-7331-67396827a596@wdc.com>

On Wed, Jun 27, 2018 at 04:59:41PM -0700, Bart Van Assche wrote:
> On 06/27/18 16:50, Ming Lei wrote:
> > On Wed, Jun 27, 2018 at 01:12:31PM -0700, Bart Van Assche wrote:
> > > Although __bio_clone_fast() copies bi_io_vec, it does not copy bi_vcnt,
> > > the number of elements in bi_io_vec[] that contains data. Copy bi_vcnt
> > > such that code that needs this member behaves identically for original
> > > and for cloned requests.
> > > 
> > > Signed-off-by: Bart Van Assche <bart.vanassche@wdc.com>
> > > Cc: Christoph Hellwig <hch@lst.de>
> > > Cc: Mike Snitzer <snitzer@redhat.com>
> > > Cc: Ming Lei <ming.lei@redhat.com>
> > > Cc: Hannes Reinecke <hare@suse.com>
> > > Cc: Johannes Thumshirn <jthumshirn@suse.de>
> > > ---
> > >   block/bio.c | 1 +
> > >   1 file changed, 1 insertion(+)
> > > 
> > > diff --git a/block/bio.c b/block/bio.c
> > > index f7e3d88bd0b6..55f8e0dedd69 100644
> > > --- a/block/bio.c
> > > +++ b/block/bio.c
> > > @@ -605,6 +605,7 @@ void __bio_clone_fast(struct bio *bio, struct bio *bio_src)
> > >   	bio->bi_opf = bio_src->bi_opf;
> > >   	bio->bi_write_hint = bio_src->bi_write_hint;
> > >   	bio->bi_iter = bio_src->bi_iter;
> > > +	bio->bi_vcnt = bio_src->bi_vcnt;
> > >   	bio->bi_io_vec = bio_src->bi_io_vec;
> > 
> > No, don't do that.
> 
> Why not? I think it's a huge booby trap that cloned bio's have a bi_io_vec
> but zero bi_vcnt.

One core idea of immutable bvec is to use bio->bi_iter and the original
bvec table to iterate over anywhere in the bio. That is why .bi_io_vec
needs to copy, but not see any reason why .bi_vcnt needs to do.

Do you have use cases on .bi_vcnt for cloned bio?

Thanks,
Ming

  reply	other threads:[~2018-06-28  0:30 UTC|newest]

Thread overview: 15+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-06-27 20:12 [PATCH] block: Make __bio_clone_fast() copy bi_vcnt Bart Van Assche
2018-06-27 23:50 ` Ming Lei
2018-06-27 23:59   ` Bart Van Assche
2018-06-28  0:30     ` Ming Lei [this message]
2018-06-28 15:21       ` Bart Van Assche
2018-06-28 15:32         ` Mike Snitzer
2018-06-28 23:10         ` [PATCH] " Ming Lei
2018-06-28 23:16           ` Kent Overstreet
2018-06-28 23:54             ` Bart Van Assche
2018-06-29  0:04               ` Kent Overstreet
2018-06-29 20:00                 ` Bart Van Assche
2018-06-30 23:38                   ` Kent Overstreet
2018-06-29  2:18             ` Jens Axboe
2018-06-28 15:53 ` Jens Axboe
2018-06-28 22:53   ` 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=20180628003007.GG7583@ming.t460p \
    --to=ming.lei@redhat.com \
    --cc=axboe@kernel.dk \
    --cc=bart.vanassche@wdc.com \
    --cc=hare@suse.com \
    --cc=hch@lst.de \
    --cc=jthumshirn@suse.de \
    --cc=linux-block@vger.kernel.org \
    --cc=snitzer@redhat.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.