Messages in this thread | | | Date | Mon, 7 Jun 2021 08:09:38 +0800 | From | Ming Lei <> | Subject | Re: [Patch v2] block: return the correct bvec when checking for gaps |
| |
On Fri, Jun 04, 2021 at 04:37:19PM -0700, longli@linuxonhyperv.com wrote: > 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. 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@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> > --- > Change from v1: add commit details on how data corruption happens
Reviewed-by: Ming Lei <ming.lei@redhat.com>
-- Ming
| |