linux-block.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Ming Lei <ming.lei@redhat.com>
To: Matthew Wilcox <willy@infradead.org>
Cc: Jens Axboe <axboe@kernel.dk>,
	linux-block@vger.kernel.org,
	Tetsuo Handa <penguin-kernel@i-love.sakura.ne.jp>,
	Al Viro <viro@zeniv.linux.org.uk>,
	stable@vger.kernel.org
Subject: Re: [PATCH] block: allow for_each_bvec to support zero len bvec
Date: Mon, 10 Aug 2020 12:02:52 +0800	[thread overview]
Message-ID: <20200810040252.GC2202641@T590> (raw)
In-Reply-To: <20200810033309.GK17456@casper.infradead.org>

On Mon, Aug 10, 2020 at 04:33:09AM +0100, Matthew Wilcox wrote:
> On Mon, Aug 10, 2020 at 11:19:15AM +0800, Ming Lei wrote:
> > +++ b/include/linux/bvec.h
> > @@ -117,11 +117,18 @@ static inline bool bvec_iter_advance(const struct bio_vec *bv,
> >  	return true;
> >  }
> >  
> > +static inline void bvec_iter_skip_zero_bvec(struct bvec_iter *iter)
> > +{
> > +	iter->bi_bvec_done = 0;
> > +	iter->bi_idx++;
> > +}
> > +
> >  #define for_each_bvec(bvl, bio_vec, iter, start)			\
> >  	for (iter = (start);						\
> >  	     (iter).bi_size &&						\
> >  		((bvl = bvec_iter_bvec((bio_vec), (iter))), 1);	\
> > -	     bvec_iter_advance((bio_vec), &(iter), (bvl).bv_len))
> > +	     (bvl).bv_len ? bvec_iter_advance((bio_vec), &(iter),	\
> > +		     (bvl).bv_len) : bvec_iter_skip_zero_bvec(&(iter)))
> >  
> 
> What if you have two zero-length bvecs in a row?  Won't this just skip
> the first one?

The 2nd one will be skipped too when it is observed in next loop.

> 
> It would seem better to me to put the bv_len test in bvec_iter_advance()
> instead of making the macro more complicated.

The reason is that block layer won't support zero length bvec, and I'd
not bother bvec_iter_advance() for adding this check.


Thanks,
Ming


  reply	other threads:[~2020-08-10  4:03 UTC|newest]

Thread overview: 11+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-08-10  3:19 [PATCH] block: allow for_each_bvec to support zero len bvec Ming Lei
2020-08-10  3:33 ` Matthew Wilcox
2020-08-10  4:02   ` Ming Lei [this message]
2020-08-10  7:52 ` Tetsuo Handa
2020-08-10 16:23   ` Ming Lei
2020-08-12  9:00     ` Ming Lei
2020-08-12 10:03       ` Tetsuo Handa
2020-08-12 12:47         ` Ming Lei
2020-08-12 12:51           ` Matthew Wilcox
2020-08-13  1:13     ` Tetsuo Handa
2020-08-27 13:27       ` Tetsuo Handa

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=20200810040252.GC2202641@T590 \
    --to=ming.lei@redhat.com \
    --cc=axboe@kernel.dk \
    --cc=linux-block@vger.kernel.org \
    --cc=penguin-kernel@i-love.sakura.ne.jp \
    --cc=stable@vger.kernel.org \
    --cc=viro@zeniv.linux.org.uk \
    --cc=willy@infradead.org \
    /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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).