All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] block: return the correct first bvec when checking for gaps
@ 2021-06-03 18:46 longli
  2021-06-03 19:01 ` Long Li
  0 siblings, 1 reply; 2+ messages in thread
From: longli @ 2021-06-03 18:46 UTC (permalink / raw)
  To: linux-block
  Cc: Long Li, Jens Axboe, Johannes Thumshirn, Pavel Begunkov,
	Ming Lei, Tejun Heo, Matthew Wilcox (Oracle),
	Jeffle Xu, linux-kernel, stable

From: Long Li <longli@microsoft.com>

After commit 07173c3ec276 ("block: enable multipage bvecs"), a bvec can
have multiple pages. But bio_will_gap() still assumes one page bvec while
checking for merging. This causes data corruption on drivers relying on
the correct merging on virt_boundary_mask.

Fix this by returning the bvec for multi-page bvec.

Cc: Jens Axboe <axboe@kernel.dk>
Cc: Johannes Thumshirn <johannes.thumshirn@wdc.com>
Cc: Pavel Begunkov <asml.silence@gmail.com>
Cc: Ming Lei <ming.lei@redhat.com>
Cc: Tejun Heo <tj@kernel.org>
Cc: "Matthew Wilcox (Oracle)" <willy@infradead.org>
Cc: Jeffle Xu <jefflexu@linux.alibaba.com>
Cc: linux-kernel@vger.kernel.org
Cc: stable@vger.kernel.org
Fixes: 07173c3ec276 ("block: enable multipage bvecs")
Signed-off-by: Long Li <longli@microsoft.com>
---
 include/linux/bio.h | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/include/linux/bio.h b/include/linux/bio.h
index a0b4cfdf62a4..e89242a53bbc 100644
--- a/include/linux/bio.h
+++ b/include/linux/bio.h
@@ -271,7 +271,7 @@ static inline void bio_clear_flag(struct bio *bio, unsigned int bit)
 
 static inline void bio_get_first_bvec(struct bio *bio, struct bio_vec *bv)
 {
-	*bv = bio_iovec(bio);
+	*bv = mp_bvec_iter_bvec(bio->bi_io_vec, bio->bi_iter);
 }
 
 static inline void bio_get_last_bvec(struct bio *bio, struct bio_vec *bv)
-- 
2.17.1


^ permalink raw reply related	[flat|nested] 2+ messages in thread

* RE: [PATCH] block: return the correct first bvec when checking for gaps
  2021-06-03 18:46 [PATCH] block: return the correct first bvec when checking for gaps longli
@ 2021-06-03 19:01 ` Long Li
  0 siblings, 0 replies; 2+ messages in thread
From: Long Li @ 2021-06-03 19:01 UTC (permalink / raw)
  To: longli, linux-block
  Cc: Jens Axboe, Johannes Thumshirn, Pavel Begunkov, Ming Lei,
	Tejun Heo, Matthew Wilcox (Oracle),
	Jeffle Xu, linux-kernel, stable

Hi,

Please discard this patch as it's from a wrong work branch. The patch is not complete. I'll resubmit.

Long

> -----Original Message-----
> From: longli@linuxonhyperv.com <longli@linuxonhyperv.com>
> Sent: Thursday, June 3, 2021 11:47 AM
> To: linux-block@vger.kernel.org
> Cc: Long Li <longli@microsoft.com>; Jens Axboe <axboe@kernel.dk>;
> Johannes Thumshirn <johannes.thumshirn@wdc.com>; Pavel Begunkov
> <asml.silence@gmail.com>; Ming Lei <ming.lei@redhat.com>; Tejun Heo
> <tj@kernel.org>; Matthew Wilcox (Oracle) <willy@infradead.org>; Jeffle Xu
> <jefflexu@linux.alibaba.com>; linux-kernel@vger.kernel.org;
> stable@vger.kernel.org
> Subject: [PATCH] block: return the correct first bvec when checking for gaps
> 
> From: Long Li <longli@microsoft.com>
> 
> After commit 07173c3ec276 ("block: enable multipage bvecs"), a bvec can
> have multiple pages. But bio_will_gap() still assumes one page bvec while
> checking for merging. This causes data corruption on drivers relying on the
> correct merging on virt_boundary_mask.
> 
> Fix this by returning the bvec for multi-page bvec.
> 
> Cc: Jens Axboe <axboe@kernel.dk>
> Cc: Johannes Thumshirn <johannes.thumshirn@wdc.com>
> Cc: Pavel Begunkov <asml.silence@gmail.com>
> Cc: Ming Lei <ming.lei@redhat.com>
> Cc: Tejun Heo <tj@kernel.org>
> Cc: "Matthew Wilcox (Oracle)" <willy@infradead.org>
> Cc: Jeffle Xu <jefflexu@linux.alibaba.com>
> Cc: linux-kernel@vger.kernel.org
> Cc: stable@vger.kernel.org
> Fixes: 07173c3ec276 ("block: enable multipage bvecs")
> Signed-off-by: Long Li <longli@microsoft.com>
> ---
>  include/linux/bio.h | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/include/linux/bio.h b/include/linux/bio.h index
> a0b4cfdf62a4..e89242a53bbc 100644
> --- a/include/linux/bio.h
> +++ b/include/linux/bio.h
> @@ -271,7 +271,7 @@ static inline void bio_clear_flag(struct bio *bio,
> unsigned int bit)
> 
>  static inline void bio_get_first_bvec(struct bio *bio, struct bio_vec *bv)  {
> -	*bv = bio_iovec(bio);
> +	*bv = mp_bvec_iter_bvec(bio->bi_io_vec, bio->bi_iter);
>  }
> 
>  static inline void bio_get_last_bvec(struct bio *bio, struct bio_vec *bv)
> --
> 2.17.1


^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2021-06-03 19:01 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-06-03 18:46 [PATCH] block: return the correct first bvec when checking for gaps longli
2021-06-03 19:01 ` Long Li

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.