[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <YL1jwr2MfbW4hFb7@T590>
Date: Mon, 7 Jun 2021 08:09:38 +0800
From: Ming Lei <ming.lei@...hat.com>
To: longli@...uxonhyperv.com
Cc: linux-block@...r.kernel.org, Long Li <longli@...rosoft.com>,
Jens Axboe <axboe@...nel.dk>,
Johannes Thumshirn <johannes.thumshirn@....com>,
Pavel Begunkov <asml.silence@...il.com>,
Tejun Heo <tj@...nel.org>,
"Matthew Wilcox (Oracle)" <willy@...radead.org>,
Jeffle Xu <jefflexu@...ux.alibaba.com>,
linux-kernel@...r.kernel.org, stable@...r.kernel.org
Subject: Re: [Patch v2] block: return the correct bvec when checking for gaps
On Fri, Jun 04, 2021 at 04:37:19PM -0700, longli@...uxonhyperv.com wrote:
> From: Long Li <longli@...rosoft.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. If the pages in the bvec go across the
> seg_boundary_mask, this check for merging can potentially succeed if only
> the 1st page is tested, and can fail if all the pages are tested.
>
> Later, when SCSI builds the SG list the same check for merging is done in
> __blk_segment_map_sg_merge() with all the pages in the bvec tested. This
> time the check may fail if the pages in bvec go across the
> seg_boundary_mask (but tested okay in bio_will_gap() earlier, so those
> BIOs were merged). If this check fails, we end up with a broken SG list
> for drivers assuming the SG list not having offsets in intermediate pages.
> This results in incorrect pages written to the disk.
>
> Fix this by returning the multi-page bvec when testing gaps for merging.
>
> Cc: Jens Axboe <axboe@...nel.dk>
> Cc: Johannes Thumshirn <johannes.thumshirn@....com>
> Cc: Pavel Begunkov <asml.silence@...il.com>
> Cc: Ming Lei <ming.lei@...hat.com>
> Cc: Tejun Heo <tj@...nel.org>
> Cc: "Matthew Wilcox (Oracle)" <willy@...radead.org>
> Cc: Jeffle Xu <jefflexu@...ux.alibaba.com>
> Cc: linux-kernel@...r.kernel.org
> Cc: stable@...r.kernel.org
> Fixes: 07173c3ec276 ("block: enable multipage bvecs")
> Signed-off-by: Long Li <longli@...rosoft.com>
> ---
> Change from v1: add commit details on how data corruption happens
Reviewed-by: Ming Lei <ming.lei@...hat.com>
--
Ming
Powered by blists - more mailing lists