Received: by 2002:a05:6a10:206:0:0:0:0 with SMTP id 6csp734049pxj; Thu, 3 Jun 2021 18:56:07 -0700 (PDT) X-Google-Smtp-Source: ABdhPJzpBVwFx+o1Z5Lw5CWt/fiCs/Vny1l17cJ7qb6ypWgTMgS3uSITRASivA+Hj/bDaDShubfB X-Received: by 2002:a17:906:b2c1:: with SMTP id cf1mr1875675ejb.544.1622771767318; Thu, 03 Jun 2021 18:56:07 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1622771767; cv=none; d=google.com; s=arc-20160816; b=nXF4ZGD+yIQKMQStumZxfdqoIQU/y/UM9QgOzco8Lod0YOL7YHNLVx/f6wQQr+1S06 hx5mwAbdtUjCFCfZ3YYc9SyzFctlWuKbD638+PfLFhvqcOJejLldDlyq5C1eyKjc8yY6 85pkYHPEcDsdvrfYPP29ASEot49v0f6ebpfGN7QdX49V38V5smrW3aLowl6yYOuRkJ94 4RCfH4bUBKGOGJBUzAbErYXbxFytySX5HL0w4Snfo6p5xoLUbTClSSLkhCRrEYacYmlP DzfMl+aDVRhqAPh5H8GcWxNWgaMIzMquf7PwBQWNieX40AqreGIDpjQl7AQF+cqXkDKy nTrQ== 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=vqFUmniCC488GUpp4xBAu68FfZpCcKh9+CsQQqre8x4=; b=o4hCxZGa7vTLwO5lo/furubTwC4R5A+PN1mkMFViOs/sN9eRsV7+noHxEDgzRRbqRS XdBR2zjZzkG87LhD87SMkzmCtJ/b5SuRLO1FBVG42vPCIQlYB19SaL1G3dC4kmcaLVAr qsfo0X/QVE8PWP+RFVuPw/jyj8nK67H43Rg57iyh+lkcOWQbsU6uhcfmzGwBncjBMWGS NxzPT6EhmcIYZ2Ml1T/yGI6sHuEdWHMYKkCkb+qHmXxy9augs7tq/AedPGqrCSWSjeG3 GTmUEzoc/AomJ/ZfsUWyBIu0asi99sHIL6R61K0WlQbKLRkWz9yMHTrdX4nlqD7IjkIH PF1A== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=VBMjBNgH; 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 k4si3534202eds.218.2021.06.03.18.55.43; Thu, 03 Jun 2021 18:56:07 -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=VBMjBNgH; 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 S230063AbhFDBzU (ORCPT + 99 others); Thu, 3 Jun 2021 21:55:20 -0400 Received: from us-smtp-delivery-124.mimecast.com ([216.205.24.124]:48487 "EHLO us-smtp-delivery-124.mimecast.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230025AbhFDBzT (ORCPT ); Thu, 3 Jun 2021 21:55:19 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1622771613; 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=vqFUmniCC488GUpp4xBAu68FfZpCcKh9+CsQQqre8x4=; b=VBMjBNgHPvuGVLDChSqewLU922DlR4eXOObKTcEmPh/LavJ/8bACRl9MWIWs4kYEoK5cvz finv4+GLP/17TSwkE4vyTqafO2PcqEUwndhthMVShVLGJJk33J3B1kYwWJ+WWUatnYw+uA GxAPb48iimJy5WW9YER2YN75mo7BMmk= 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-5-J9nU4BbfOg6zaCj2GQz7qw-1; Thu, 03 Jun 2021 21:53:30 -0400 X-MC-Unique: J9nU4BbfOg6zaCj2GQz7qw-1 Received: from smtp.corp.redhat.com (int-mx02.intmail.prod.int.phx2.redhat.com [10.5.11.12]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 357EE3FD4; Fri, 4 Jun 2021 01:53:28 +0000 (UTC) Received: from T590 (ovpn-12-139.pek2.redhat.com [10.72.12.139]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 5276460C17; Fri, 4 Jun 2021 01:53:18 +0000 (UTC) Date: Fri, 4 Jun 2021 09:53:15 +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] block: return the correct bvec when checking for gaps Message-ID: References: <1622759671-14059-1-git-send-email-longli@linuxonhyperv.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <1622759671-14059-1-git-send-email-longli@linuxonhyperv.com> X-Scanned-By: MIMEDefang 2.79 on 10.5.11.12 Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Hello Long, On Thu, Jun 03, 2021 at 03:34:31PM -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. This causes data corruption on drivers relying on > the correct merging on virt_boundary_mask. Can you explain the data corruption a bit? IMO, either single page bvec or multipage bvec should be fine, because bio_will_gap() just checks if the last bvec of prev bio and the 1st bvec of next bio can be merged. > > Fix this by returning the multi-page bvec for 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 > --- > include/linux/bio.h | 11 ++++------- > 1 file changed, 4 insertions(+), 7 deletions(-) > > diff --git a/include/linux/bio.h b/include/linux/bio.h > index a0b4cfdf62a4..6b2f609ccfbf 100644 > --- a/include/linux/bio.h > +++ b/include/linux/bio.h > @@ -44,9 +44,6 @@ static inline unsigned int bio_max_segs(unsigned int nr_segs) > #define bio_offset(bio) bio_iter_offset((bio), (bio)->bi_iter) > #define bio_iovec(bio) bio_iter_iovec((bio), (bio)->bi_iter) > > -#define bio_multiple_segments(bio) \ > - ((bio)->bi_iter.bi_size != bio_iovec(bio).bv_len) > - > #define bvec_iter_sectors(iter) ((iter).bi_size >> 9) > #define bvec_iter_end_sector(iter) ((iter).bi_sector + bvec_iter_sectors((iter))) > > @@ -271,7 +268,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) > @@ -279,10 +276,10 @@ static inline void bio_get_last_bvec(struct bio *bio, struct bio_vec *bv) > struct bvec_iter iter = bio->bi_iter; > int idx; > > - if (unlikely(!bio_multiple_segments(bio))) { > - *bv = bio_iovec(bio); > + /* this bio has only one bvec */ > + *bv = mp_bvec_iter_bvec(bio->bi_io_vec, bio->bi_iter); > + if (bv->bv_len == bio->bi_iter.bi_size) > return; > - } > > bio_advance_iter(bio, &iter, iter.bi_size); The patch itself looks fine, given both bio_get_first_bvec() and bio_get_last_bvec() are used in bio_will_gap() only. Thanks, Ming