Received: by 2002:a05:6a10:206:0:0:0:0 with SMTP id 6csp498423pxj; Thu, 3 Jun 2021 11:48:19 -0700 (PDT) X-Google-Smtp-Source: ABdhPJzNxc4KB89lB6kKjuG2IZBvI7kNuzb2SY5LU4jYWsaULlbqwNxs2+pJxr7NuNYJy7UCGgjK X-Received: by 2002:a17:906:3057:: with SMTP id d23mr677546ejd.131.1622746099048; Thu, 03 Jun 2021 11:48:19 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1622746099; cv=none; d=google.com; s=arc-20160816; b=nuknAx1JbLtAe62aIKX1SFxAmln0Pd/LhU32ZM2igGWXQDqMSO367m4MqJ2C2rRoML zod4XmmigL+WNQ9NRDL9TbixEwz4rwGy1b4cjNuhgFn77LlMbwdxEq+lX2cQZVGVMJT5 eb1A0pXht5ZZThwdeAW7x20rEw9kE+4ZUrN36hwbk7SrfUS3QoVn7yFuTF8MmMRmdoR0 pgAac5IhOk7CWWckmcVCmZU/UUhJnMLhycQEm8wKCYEfObl+3HqQYlQ5VmOq5qcbUA2f TMIuPd6aNT/1GadfBUlGidOMBKc5G9/AndrFS3/r4c87XFpRfqSz5SauouwwMzwUrY4z 004A== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:message-id:date:subject:cc:to:from :dkim-signature:dkim-filter; bh=HI4zlfdxf8GbN+8OyNNKD0rxn8LbKNH+lRJ/OymYueI=; b=yd1ug56EJmAtMfgnqSkivzNN9P6PkPLqPB30Dg2Sqj7dhnU1PqNq22BywcQ1BwNOdy cFjU1tYQAyzxZIm4Rgz0NERBJeSwPHTOj6iyXy4+Ju/V3d1M1XQVBkcIHJVohE+WgU8T dS76NNUswRAj9biLa7KzT/bpCVPrXo/uOQhXJ57PN18eGMKI4gtGNcfwHA69W0Hf9hoU gc0SkakrgAR8uUoNexD/oQG1GmA5RqbZJbxGif323+IzhTayGjz2TdNVnrgq2AwbWdQt ynMpoAf8HxMvLPBqKuR7fHGN/oEewdTjB6IxXngWW9i06WEeFehPGb5EhKZR8rd5Jffy KENw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxonhyperv.com header.s=default header.b=IRGvEIjl; 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=linuxonhyperv.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id p21si2383816ejn.31.2021.06.03.11.47.54; Thu, 03 Jun 2021 11:48:19 -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=@linuxonhyperv.com header.s=default header.b=IRGvEIjl; 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=linuxonhyperv.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229884AbhFCSsc (ORCPT + 99 others); Thu, 3 Jun 2021 14:48:32 -0400 Received: from linux.microsoft.com ([13.77.154.182]:44924 "EHLO linux.microsoft.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229625AbhFCSsb (ORCPT ); Thu, 3 Jun 2021 14:48:31 -0400 Received: by linux.microsoft.com (Postfix, from userid 1004) id 5FFF320B7178; Thu, 3 Jun 2021 11:46:46 -0700 (PDT) DKIM-Filter: OpenDKIM Filter v2.11.0 linux.microsoft.com 5FFF320B7178 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linuxonhyperv.com; s=default; t=1622746006; bh=HI4zlfdxf8GbN+8OyNNKD0rxn8LbKNH+lRJ/OymYueI=; h=From:To:Cc:Subject:Date:From; b=IRGvEIjlLgf/5GppIFX+W/58cmOR91g3sDWw+p/rEYy8weYEmvc9vot3Diu2cOecX eRUIGcemNFSdlsyjD2XZwusIG9LayjjtQAFxtlVf4i2ijwjV03iNIBTr5Ol1isJGE7 2AsU+uEhgZsyC5vzFqQuXITLiuumw5k95eTqdDcs= From: longli@linuxonhyperv.com To: linux-block@vger.kernel.org Cc: Long Li , Jens Axboe , Johannes Thumshirn , Pavel Begunkov , Ming Lei , Tejun Heo , "Matthew Wilcox (Oracle)" , Jeffle Xu , linux-kernel@vger.kernel.org, stable@vger.kernel.org Subject: [PATCH] block: return the correct first bvec when checking for gaps Date: Thu, 3 Jun 2021 11:46:45 -0700 Message-Id: <1622746005-10785-1-git-send-email-longli@linuxonhyperv.com> X-Mailer: git-send-email 1.8.3.1 Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 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. Fix this by returning the bvec for multi-page bvec. 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 | 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