From patchwork Fri Nov 17 07:47:25 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Michael Lyle X-Patchwork-Id: 10062393 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id 5B33E6023A for ; Fri, 17 Nov 2017 07:48:49 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 4DF3B2A759 for ; Fri, 17 Nov 2017 07:48:49 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 41A322AAB9; Fri, 17 Nov 2017 07:48:49 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-6.9 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,RCVD_IN_DNSWL_HI autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 9E99B2A759 for ; Fri, 17 Nov 2017 07:48:48 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S964895AbdKQHsr (ORCPT ); Fri, 17 Nov 2017 02:48:47 -0500 Received: from mail-pf0-f195.google.com ([209.85.192.195]:37643 "EHLO mail-pf0-f195.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S964851AbdKQHso (ORCPT ); Fri, 17 Nov 2017 02:48:44 -0500 Received: by mail-pf0-f195.google.com with SMTP id t69so1370729pfg.4 for ; Thu, 16 Nov 2017 23:48:43 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=lyle-org.20150623.gappssmtp.com; s=20150623; h=from:to:cc:subject:date:message-id; bh=Nmi9yj9+R+m35IdxU6BCR+etMSnBPP/5wDGoiS+NIEk=; b=iYcDT9FF88bK6iChmzGYweOWdXkMIfrG0F+u2AdCp5O6LeGzsGtLad06wWKg8RiLeO fLDhHDyjENEBnow3NB2wV1yfteTXAY0+nMTCV8Wlc4Pn159jWUtyphTmrRVzU4mMFnqB 449enFrDtG9VkJcvQYlNRIpvCbqZcDNd153UZMbqqpx5WENdspS6Oiu1MlGZFOHRASGJ wvCCN+v7bZBlCltjEqXmW4eeK2TfXIQZ+wywYKtexXK6/DynmzXzyiSktkRVGU2Xvpog t5xJIXZZY6C8DgdizukZRDd03a1q7dxuV068iIov6Ry+P/OB+DbQTOQ4ZvhsbEGkaLCu 93BA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id; bh=Nmi9yj9+R+m35IdxU6BCR+etMSnBPP/5wDGoiS+NIEk=; b=T8MX0tNy84BqSNu7bnD66fZ3KffvjWla7K8JZjgkRxQqwxKaKWNx/NIMzSUkeqUBtN zRRofKqSJmBeiv/Jl5hZIanLcsTeWl1OuLqSoie5HDgAqD8BCSKKAXNhs2YXJIm0oTS1 MD5Tsq0ogee3raktz/uPfle4rvfyJWXkjDPtBYvRruOjP4cGbyb2/zaqbooA5V8101Zs VGQZcj73qid/Zizm3qfjZ4S9xkyGSP8g7v8YdnQrZhnF9bWcIZKQa2N151wwTOkjdg78 WNgfgUZJi3wEZCmULD07LPc31ziTbszsfMaIaWTWOx0tg+xmyTFEETF58ZK7xiNAg1Gp Gz3w== X-Gm-Message-State: AJaThX7a4y0W/ImdrBjYardW/3caXjFFHBogkX1P/tLFzLepW1DNp4TJ oMHIE12qQH/zuGgCAJnI22UINVylUDo= X-Google-Smtp-Source: AGs4zMbkgR5AMT3Eb7ogjFuMI4UI1JhqUR3vI1LTvMNQVVaraGpeU95+P08KMg5sVkCHiU4eFLic8g== X-Received: by 10.101.81.10 with SMTP id f10mr4300066pgq.148.1510904923009; Thu, 16 Nov 2017 23:48:43 -0800 (PST) Received: from midnight.lan (68-189-67-104.dhcp.prtv.ca.charter.com. [68.189.67.104]) by smtp.gmail.com with ESMTPSA id t84sm5993595pfe.160.2017.11.16.23.48.41 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 16 Nov 2017 23:48:42 -0800 (PST) From: Michael Lyle To: linux-block@vger.kernel.org, linux-bcache@vger.kernel.org Cc: Michael Lyle , Christoph Hellwig , Jens Axboe , stable@vger.kernel.org Subject: [PATCH] bio: ensure __bio_clone_fast copies bi_partno Date: Thu, 16 Nov 2017 23:47:25 -0800 Message-Id: <20171117074725.22536-1-mlyle@lyle.org> X-Mailer: git-send-email 2.14.1 Sender: linux-block-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-block@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP A new field was introduced in 74d46992e0d9dee7f1f376de0d56d31614c8a17a, bi_partno, instead of using bdev->bd_contains and encoding the partition information in the bi_bdev field. __bio_clone_fast was changed to copy the disk information, but not the partition information. At minimum, this regressed bcache and caused data corruption. Signed-off-by: Michael Lyle Fixes: 74d46992e0d9dee7f1f376de0d56d31614c8a17a Reported-by: Pavel Goran Reported-by: Campbell Steven Cc: Christoph Hellwig Cc: Jens Axboe Cc: Reviewed-by: Coly Li Reviewed-by: Ming Lei Reviewed-by: Christoph Hellwig --- block/bio.c | 1 + 1 file changed, 1 insertion(+) diff --git a/block/bio.c b/block/bio.c index 101c2a9b5481..33fa6b4af312 100644 --- a/block/bio.c +++ b/block/bio.c @@ -597,6 +597,7 @@ void __bio_clone_fast(struct bio *bio, struct bio *bio_src) * so we don't set nor calculate new physical/hw segment counts here */ bio->bi_disk = bio_src->bi_disk; + bio->bi_partno = bio_src->bi_partno; bio_set_flag(bio, BIO_CLONED); bio->bi_opf = bio_src->bi_opf; bio->bi_write_hint = bio_src->bi_write_hint;