Received: by 2002:a05:6a10:206:0:0:0:0 with SMTP id 6csp2862318pxj; Sun, 6 Jun 2021 17:11:31 -0700 (PDT) X-Google-Smtp-Source: ABdhPJzZyiP2c2JP1GP9EuzsVLb9rWt7RkomizWTI5ccSzmSM6q+K5ZMzR6Q82V4YXZ+3abJ1IaX X-Received: by 2002:a17:906:d04f:: with SMTP id bo15mr14937087ejb.405.1623024691407; Sun, 06 Jun 2021 17:11:31 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1623024691; cv=none; d=google.com; s=arc-20160816; b=mw3Rvo6CEVvMCgvqTRSFgsUPjeS8TmLN/h69l1hXatRuqkfKyQwpdf6QtL5qB48u6F JNOfvkUlzDccoK6iQExQjE87o82OgnNLnACn1zzvQS8sTEvw5U38cr3jqBM6AVU9mpCO hobX/Z4K87jo6m9RBrxGKUY52cWdiguL2IW+DUDD0tHsoC7EiBYjE9BQo3CURCv0BEtf DzP3l9DthsmusGDjo+kDrQLKvRS8AxlW4K78v0J7NdjIueXwuQZxWJFZiYDZ2n2zVmBh EGRExdfVysWKfoh1pOfcBVg/CJeDnkgW9YfkxV9XZD9rx6CnAGlNZU99rGEBXo74AD7Z ZkVA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:in-reply-to:content-disposition:mime-version :references:message-id:subject:cc:to:from:date:dkim-signature; bh=VS0VjKAJZ5TDLigUxCxbJG/FM9ESIm9kTnLGe+d/ZcE=; b=Zout3auydXDgrAxxraszcWOVIZfpf7/qlrcSvg+oUifuEyrnijry0W2VCLj+vIYtk8 EA6BeVLWjouwTtxR7GP+Nd84bbUivstEP1hGGrVv7rwsvSXn30j+4MbZYwu2ncWaanvd qX6kW/rRK58dOC2cj5EypFBgYzUiPFdKdniTzrVqes31HnrYHEymjV3MQdwBK+6HmXYX PDtVlqiEJMMmowBQRUVacQ5QZYssz+BJiQgzWMwX1YyKN3esLTD2tDnmw09yfO148cEt YyHqyz1nm7VusGuuB0hfFpBUp0dxApM1gx6oq88aa2xPaK1aZ6FgtRmVgNqk3FmLLce3 BpEQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=RD9aKHLc; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=redhat.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id b13si12871871ede.317.2021.06.06.17.11.08; Sun, 06 Jun 2021 17:11:31 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=RD9aKHLc; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=redhat.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229991AbhFGALs (ORCPT + 99 others); Sun, 6 Jun 2021 20:11:48 -0400 Received: from us-smtp-delivery-124.mimecast.com ([170.10.133.124]:31770 "EHLO us-smtp-delivery-124.mimecast.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229884AbhFGALr (ORCPT ); Sun, 6 Jun 2021 20:11:47 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1623024597; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: in-reply-to:in-reply-to:references:references; bh=VS0VjKAJZ5TDLigUxCxbJG/FM9ESIm9kTnLGe+d/ZcE=; b=RD9aKHLcJSGhKj9J4rabMZT7LQ779AQbR3iVro+Kg4chgSBx9RGK9m6uiGOuyFO7Fr45Ij Qo3eFvUfeKqaZ/NrgS8BOIQAId1Br0E1dKkHsp3baf9Rryp21I99C8gDnhRi0rD2f7KBuu G82O8lUJu+IgOj7riXqdd2hbsirNF2Y= Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-460-loLTsHyRMvymEOT77fI9Dw-1; Sun, 06 Jun 2021 20:09:54 -0400 X-MC-Unique: loLTsHyRMvymEOT77fI9Dw-1 Received: from smtp.corp.redhat.com (int-mx05.intmail.prod.int.phx2.redhat.com [10.5.11.15]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 472D5800D55; Mon, 7 Jun 2021 00:09:52 +0000 (UTC) Received: from T590 (ovpn-12-62.pek2.redhat.com [10.72.12.62]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 9B7225D736; Mon, 7 Jun 2021 00:09:43 +0000 (UTC) Date: Mon, 7 Jun 2021 08:09:38 +0800 From: Ming Lei To: longli@linuxonhyperv.com Cc: linux-block@vger.kernel.org, Long Li , Jens Axboe , Johannes Thumshirn , Pavel Begunkov , Tejun Heo , "Matthew Wilcox (Oracle)" , Jeffle Xu , linux-kernel@vger.kernel.org, stable@vger.kernel.org Subject: Re: [Patch v2] block: return the correct bvec when checking for gaps Message-ID: References: <1622849839-5407-1-git-send-email-longli@linuxonhyperv.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <1622849839-5407-1-git-send-email-longli@linuxonhyperv.com> X-Scanned-By: MIMEDefang 2.79 on 10.5.11.15 Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Fri, Jun 04, 2021 at 04:37:19PM -0700, longli@linuxonhyperv.com wrote: > From: Long Li > > 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 > Cc: Johannes Thumshirn > Cc: Pavel Begunkov > Cc: Ming Lei > Cc: Tejun Heo > Cc: "Matthew Wilcox (Oracle)" > Cc: Jeffle Xu > Cc: linux-kernel@vger.kernel.org > Cc: stable@vger.kernel.org > Fixes: 07173c3ec276 ("block: enable multipage bvecs") > Signed-off-by: Long Li > --- > Change from v1: add commit details on how data corruption happens Reviewed-by: Ming Lei -- Ming