Received: by 2002:a05:6a10:2726:0:0:0:0 with SMTP id ib38csp689537pxb; Tue, 5 Apr 2022 18:54:32 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwaFkKzfswsHL/Xpnd0kGVGwq9sb/uyg7VAWjOPw7lOcyz9JXCfLXXIBZtebG8HO/enDfkD X-Received: by 2002:a63:7e43:0:b0:374:75ce:4d80 with SMTP id o3-20020a637e43000000b0037475ce4d80mr5239060pgn.589.1649210071836; Tue, 05 Apr 2022 18:54:31 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1649210071; cv=none; d=google.com; s=arc-20160816; b=UEg43gzzuwRQFjKm8JWXkmdPhknvBM5EC4ZbM5pR34zSgX8zLCMcXkJe6IfoVhNRly mpmm11vpudi2YUmUkPBCTjTyCwbxLy7nAl24CdbhpGBCXVm1L9ASSWolNAdOwqoKjN/0 lZ5U8CTcHowz+Cx0OvLMuNQ3aL5zkWvVvTZZHUV5CQssyQ0P4QtrmfX+ipxT1sNsbQaq cHPOhWS+IeiPFiWFKtMbfwIc+cuatf1MmOwV3zAC5pmBydfR0DcIX37oIZl44+HOFf8V NFJUK6+Nl/vkHNqGdn4U5nCUrO/+kXaKQEOI9X62mzHVmjRrUk64OGdlknv/rA2fIcmE +WVQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :user-agent:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=prTihVfy/MDdeKuqA/YnHNsBcmufbMLeFlzpTY9Nbts=; b=pis3edk4/CxiUgT5uAQJWUGocitubefPSXpnWAhHP0Imm2O5LFigT0KrcgBqlSPTnc mcywE4/RwKh+eVSm5vTOeKKEf7+wn6rvtUgFDeqUHu+nOQ+KFL7qfGKUfY2avXETZR7M MfspHZ2HE9peaP45zuVriOUJ4SwHFGrftSDqm1GsWi7UiE2xl/Wy7cRl0dQVF4UGLv+9 ZcW38uty1hE4dhU8iB1Zmcp1APd83uJ7cpvBrjIusTN9+no4kqxLoD/ERGu2tgg3+usD aea0ps4T7+7NpNVtXNrE6nbw1ss++zfgiiTTddDCA8FpPHUSkssnGMVfLn70JoOnnyMg n61A== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b="I/lmXYOk"; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id x7-20020a17090a9dc700b001bd14e01f1dsi3294350pjv.11.2022.04.05.18.54.18; Tue, 05 Apr 2022 18:54:31 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b="I/lmXYOk"; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1383935AbiDEM0k (ORCPT + 99 others); Tue, 5 Apr 2022 08:26:40 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:39666 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S240925AbiDEIsP (ORCPT ); Tue, 5 Apr 2022 04:48:15 -0400 Received: from dfw.source.kernel.org (dfw.source.kernel.org [IPv6:2604:1380:4641:c500::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id D7ED527B29; Tue, 5 Apr 2022 01:36:35 -0700 (PDT) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by dfw.source.kernel.org (Postfix) with ESMTPS id 82F5561470; Tue, 5 Apr 2022 08:36:32 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 8D89CC385A0; Tue, 5 Apr 2022 08:36:31 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1649147791; bh=VD6RhK8TDJ39OE2besGcNGyIkkLTOm36pAjK63/kddY=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=I/lmXYOkS0pUJRBiH4yUvG33ATVwmnQCCoklKqcF5ABXLTAOavnM9wsdW4cHlvJ3j h4l4R9Gs5pSCxLlVtEevbhYTfmq1KT3sZSlufbkPzM9S1p52gO9xEZXQLPeHGQRyoH 6HCPVj/vYc0eAMXG+7bvAU5AW9QpXOXhLRA1CNZ8= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Lars Ellenberg , =?UTF-8?q?Christoph=20B=C3=B6hmwalder?= , Jens Axboe Subject: [PATCH 5.16 0124/1017] drbd: fix potential silent data corruption Date: Tue, 5 Apr 2022 09:17:17 +0200 Message-Id: <20220405070357.879319460@linuxfoundation.org> X-Mailer: git-send-email 2.35.1 In-Reply-To: <20220405070354.155796697@linuxfoundation.org> References: <20220405070354.155796697@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-7.1 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_HI, SPF_HELO_NONE,SPF_PASS,T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Lars Ellenberg commit f4329d1f848ac35757d9cc5487669d19dfc5979c upstream. Scenario: --------- bio chain generated by blk_queue_split(). Some split bio fails and propagates its error status to the "parent" bio. But then the (last part of the) parent bio itself completes without error. We would clobber the already recorded error status with BLK_STS_OK, causing silent data corruption. Reproducer: ----------- How to trigger this in the real world within seconds: DRBD on top of degraded parity raid, small stripe_cache_size, large read_ahead setting. Drop page cache (sysctl vm.drop_caches=1, fadvise "DONTNEED", umount and mount again, "reboot"). Cause significant read ahead. Large read ahead request is split by blk_queue_split(). Parts of the read ahead that are already in the stripe cache, or find an available stripe cache to use, can be serviced. Parts of the read ahead that would need "too much work", would need to wait for a "stripe_head" to become available, are rejected immediately. For larger read ahead requests that are split in many pieces, it is very likely that some "splits" will be serviced, but then the stripe cache is exhausted/busy, and the remaining ones will be rejected. Signed-off-by: Lars Ellenberg Signed-off-by: Christoph Böhmwalder Cc: # 4.13.x Link: https://lore.kernel.org/r/20220330185551.3553196-1-christoph.boehmwalder@linbit.com Signed-off-by: Jens Axboe Signed-off-by: Greg Kroah-Hartman --- drivers/block/drbd/drbd_req.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) --- a/drivers/block/drbd/drbd_req.c +++ b/drivers/block/drbd/drbd_req.c @@ -180,7 +180,8 @@ void start_new_tl_epoch(struct drbd_conn void complete_master_bio(struct drbd_device *device, struct bio_and_error *m) { - m->bio->bi_status = errno_to_blk_status(m->error); + if (unlikely(m->error)) + m->bio->bi_status = errno_to_blk_status(m->error); bio_endio(m->bio); dec_ap_bio(device); }