linux-block.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Matthew Wilcox <willy@infradead.org>
To: Ming Lei <ming.lei@redhat.com>
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 04:33:09 +0100	[thread overview]
Message-ID: <20200810033309.GK17456@casper.infradead.org> (raw)
In-Reply-To: <20200810031915.2209658-1-ming.lei@redhat.com>

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?

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

  reply	other threads:[~2020-08-10  3:33 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 [this message]
2020-08-10  4:02   ` Ming Lei
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=20200810033309.GK17456@casper.infradead.org \
    --to=willy@infradead.org \
    --cc=axboe@kernel.dk \
    --cc=linux-block@vger.kernel.org \
    --cc=ming.lei@redhat.com \
    --cc=penguin-kernel@i-love.sakura.ne.jp \
    --cc=stable@vger.kernel.org \
    --cc=viro@zeniv.linux.org.uk \
    /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).