linux-block.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Ming Lei <ming.lei@redhat.com>
To: Bart Van Assche <bvanassche@acm.org>
Cc: Jens Axboe <axboe@kernel.dk>,
	linux-block@vger.kernel.org, Christoph Hellwig <hch@lst.de>,
	stable@vger.kernel.org
Subject: Re: [PATCH 4/5] block: Fix zero_fill_bio()
Date: Sat, 16 May 2020 13:50:12 +0800	[thread overview]
Message-ID: <20200516055012.GA3393@T590> (raw)
In-Reply-To: <20200516001914.17138-5-bvanassche@acm.org>

On Fri, May 15, 2020 at 05:19:13PM -0700, Bart Van Assche wrote:
> Multiple block drivers use zero_fill_bio() to zero-initialize the data
> buffer used for read operations. Make sure that all pages are zeroed
> instead of only the first if one or more multi-page bvecs are used to
> describe the data buffer.
> 
> Cc: Christoph Hellwig <hch@lst.de>
> Cc: Ming Lei <ming.lei@redhat.com>
> Cc: stable@vger.kernel.org
> Signed-off-by: Bart Van Assche <bvanassche@acm.org>
> ---
>  block/bio.c         | 27 ++++++++++++++++++++++-----
>  include/linux/bio.h |  1 +
>  2 files changed, 23 insertions(+), 5 deletions(-)
> 
> diff --git a/block/bio.c b/block/bio.c
> index 1594804fe8bc..48fcafbdae70 100644
> --- a/block/bio.c
> +++ b/block/bio.c
> @@ -527,17 +527,34 @@ struct bio *bio_alloc_bioset(gfp_t gfp_mask, unsigned int nr_iovecs,
>  }
>  EXPORT_SYMBOL(bio_alloc_bioset);
>  
> +void zero_fill_bvec(const struct bio_vec *bvec)
> +{
> +	struct page *page = bvec->bv_page;
> +	u32 offset = bvec->bv_offset;
> +	u32 left = bvec->bv_len;
> +
> +	while (left) {
> +		u32 len = min_t(u32, left, PAGE_SIZE - offset);
> +		void *kaddr;
> +
> +		kaddr = kmap_atomic(page);
> +		memset(kaddr + offset, 0, len);
> +		flush_dcache_page(page);
> +		kunmap_atomic(kaddr);
> +		page++;
> +		left -= len;
> +		offset = 0;
> +	}
> +}
> +EXPORT_SYMBOL(zero_fill_bvec);
> +
>  void zero_fill_bio_iter(struct bio *bio, struct bvec_iter start)
>  {
> -	unsigned long flags;
>  	struct bio_vec bv;
>  	struct bvec_iter iter;
>  
>  	__bio_for_each_segment(bv, bio, iter, start) {

The 'bv' from __bio_for_each_segment() is single page bvec, and so far
only [__]bio_for_each_bvec iterates over multi-page bvec.

So nothing to be fixed and this patch isn't necessary.

Thanks, 
Ming


  reply	other threads:[~2020-05-16  5:50 UTC|newest]

Thread overview: 23+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-05-16  0:19 [PATCH 0/5] Block layer patches for kernel v5.8 Bart Van Assche
2020-05-16  0:19 ` [PATCH 1/5] block: Fix type of first compat_put_{,u}long() argument Bart Van Assche
2020-05-16  7:40   ` Arnd Bergmann
2020-05-16 12:41   ` Christoph Hellwig
2020-05-16  0:19 ` [PATCH 2/5] bio.h: Declare the arguments of bio iteration functions const Bart Van Assche
2020-05-16  8:55   ` Alexander Potapenko
2020-05-16 17:10     ` Bart Van Assche
2020-05-16 12:42   ` Christoph Hellwig
2020-05-17 22:46   ` Chaitanya Kulkarni
2020-05-16  0:19 ` [PATCH 3/5] block: Document the bio_vec properties Bart Van Assche
2020-05-16 12:43   ` Christoph Hellwig
2020-05-16  0:19 ` [PATCH 4/5] block: Fix zero_fill_bio() Bart Van Assche
2020-05-16  5:50   ` Ming Lei [this message]
2020-05-16  0:19 ` [PATCH 5/5] null_blk: Zero-initialize read buffers in non-memory-backed mode Bart Van Assche
2020-05-16  9:40   ` Alexander Potapenko
2020-05-18  1:12   ` Damien Le Moal
2020-05-18  1:32     ` Bart Van Assche
2020-05-18  2:10       ` Damien Le Moal
2020-05-18  2:56         ` Bart Van Assche
2020-05-18  3:12           ` Damien Le Moal
2020-05-18 14:31             ` Bart Van Assche
2020-05-19  3:03               ` Damien Le Moal
2020-05-19  4:10                 ` Bart Van Assche

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=20200516055012.GA3393@T590 \
    --to=ming.lei@redhat.com \
    --cc=axboe@kernel.dk \
    --cc=bvanassche@acm.org \
    --cc=hch@lst.de \
    --cc=linux-block@vger.kernel.org \
    --cc=stable@vger.kernel.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).