Message ID | b23a4fc8baba99010c16059a236d2f72087199a1.1700623691.git.bo.wu@vivo.com |
---|---|
State | New |
Headers |
Return-Path: <linux-kernel-owner@vger.kernel.org> Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:612c:2b07:b0:403:3b70:6f57 with SMTP id io7csp1078372vqb; Tue, 21 Nov 2023 19:44:16 -0800 (PST) X-Google-Smtp-Source: AGHT+IEA7qehQ5Ge/0/f9mL+UfUd5yB7qYurP4Gvp4MKpgsy4hoXOoW1Vjdw4SfGf92DfqTAXsbx X-Received: by 2002:a05:6830:10d0:b0:6be:e553:334 with SMTP id z16-20020a05683010d000b006bee5530334mr1561349oto.7.1700624656320; Tue, 21 Nov 2023 19:44:16 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1700624656; cv=pass; d=google.com; s=arc-20160816; b=I1I45AKBD05g7NEESf5AM4yx59SKMIoeHlGDmHQqdQDj+Neq3RqKsF5ZXG5duGiDhk I+D2vgk9MnR712/ZXxYMj19wKOXSKsgGBdUSZzwbvY2M1AyqAs8U5AOpBEi4pZZt6Rsj Be7hNdUCQimBVq8hU1Q/j6sPah2a/XqzIEvCsVCef/ApMl4uwlynTy9Dg1I9p86pjX7M k0uJTwb0zoU6BfH8ZOxvxshAdpcVm0dBxI32XVgnTN1tcpWcD0UC0gVyhC5oMSQKphbi UT0GqSiD8g/Es+fKKWMvaU4QX0dS3QT5huMIBe2pHrXD5ahlWKJk+jCYkmI8LXH0Hnkm r2Zw== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:mime-version:content-transfer-encoding :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=zF7zxYa/iqdjwNaBWqKo3n/cQt49pxvEUHoeuOhUTi4=; fh=nBUTbZf3DSpGeIlTiqg7JFsZjlnLkdwh0+5N33OIULc=; b=AgWeTAiwiQI2Sz/Pbcd/WAGA9VMwX9ZRNLXbYjJnjhH4DIC9pUhymHhb23dItoyp/p FCo8w8HfI9t/Qo2MLgTsVsYDKTOjqdypFxTB4UCUUg91OOtXmj7J9Fe7qI3jkFJBY5Ig RQ2Uv8KyOolCaDtze2h2AeYReyRoc+jd3+N5FfoQ1YmtdkWZTsFHS7PnR9T5H12pbMP4 UV2QO6S4LQI4b5dkinGHzxDX7lD+OtxnejACDziS2l/WxYEbcnBxDZ9J4uAc60UIrdGX p971PeLtXAD9b8mCoVGEmTynOx/wRMQUJnC7M3IATgVmS71HtGdZUxaRnXAEiPCRzZ+W nGxA== ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@vivo.com header.s=selector2 header.b=BdOjx6DH; arc=pass (i=1 spf=pass spfdomain=vivo.com dkim=pass dkdomain=vivo.com dmarc=pass fromdomain=vivo.com); spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.35 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=vivo.com Received: from groat.vger.email (groat.vger.email. [23.128.96.35]) by mx.google.com with ESMTPS id bn13-20020a056a02030d00b005824bad8f81si12347355pgb.853.2023.11.21.19.44.15 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 21 Nov 2023 19:44:16 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.35 as permitted sender) client-ip=23.128.96.35; Authentication-Results: mx.google.com; dkim=pass header.i=@vivo.com header.s=selector2 header.b=BdOjx6DH; arc=pass (i=1 spf=pass spfdomain=vivo.com dkim=pass dkdomain=vivo.com dmarc=pass fromdomain=vivo.com); spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.35 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=vivo.com Received: from out1.vger.email (depot.vger.email [IPv6:2620:137:e000::3:0]) by groat.vger.email (Postfix) with ESMTP id 9B43180253B2; Tue, 21 Nov 2023 19:44:13 -0800 (PST) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.11 at groat.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1343617AbjKVDnx (ORCPT <rfc822;ouuuleilei@gmail.com> + 99 others); Tue, 21 Nov 2023 22:43:53 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:46498 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S235050AbjKVDnv (ORCPT <rfc822;linux-kernel@vger.kernel.org>); Tue, 21 Nov 2023 22:43:51 -0500 Received: from APC01-TYZ-obe.outbound.protection.outlook.com (mail-tyzapc01on2108.outbound.protection.outlook.com [40.107.117.108]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id A5B27D40; Tue, 21 Nov 2023 19:43:46 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=P/j39i+ZhYo4aedxp2jW/800TuKlxXn9EJRh4eKKj1Evy5PHWgc8u0nmO52VxlBVbgipshuBgfnUOB6wwajn4cth1tvXlWjWM7eP88x38wcRrU3WohkD/o6gUDqtVw6pUh/AZxTu7/ltyZo7446NFWUABYulcowRc/IOP+Q6x5NJNgIiGoudVDg7ntbbILxb4DyZyJ3StSo/mVR9NpNGksJw0s9EpAcpeXzu1ljCEpR2fs967+6NcB1kF0BLGekd7bZZsgl98SE77mTO8dfYZliawSNPGzM8vJOgBG7oxbZbHZK+mDN1yT4JPNorjiipFvst3gs+KZ2oSNk1EJsHcA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=zF7zxYa/iqdjwNaBWqKo3n/cQt49pxvEUHoeuOhUTi4=; b=eU/RviAohldrHalEbEF9gD7zc6wf6C+MzyoLvjRacNP/LPCJef/Ows5jfPu604I0lcxPBzdpsmcIy1hSxSy3kObDcwDlbeIjIAoedGtZs68Fq8nDpAK2NCkXEZz7jTP9qMAIyyymUZ9An+ESI8bK8urxI4sufBXITPyrGaOhNGp6zdUaw2k6BuYazkH5/+ghxFA6SV/RRsD15+tTajmWQmoWbIdgbl3cyxrCHIRulg+lCImFN6y1HxzDXm6+oHg0oFbYGMKTBAYoHXwF11A4frfPDN0RuVErXavme3njVuHdgDHjDi28pk5neGyFtSay+isZ2lflTzqmMI/9X2TI/g== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=vivo.com; dmarc=pass action=none header.from=vivo.com; dkim=pass header.d=vivo.com; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=vivo.com; s=selector2; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=zF7zxYa/iqdjwNaBWqKo3n/cQt49pxvEUHoeuOhUTi4=; b=BdOjx6DHWuzX4GjUJpZL/UR0awLzTlPPXbbD9ho5BgumwyFbX5HoKAn0biBs5ziehfvN7bLg5L2QxaK44q3UbqyteNsUY3RZcgJi2EET87xcF/gz1q3QY8tONUERyptLaLSAy56Z5LPHcpaOG7hZR4T1kaOBJkW+2ppUI0gNHpBAl+UH/7jj9c6RNPTU2y8/I5j3vacKKbJZukXPaFOqcd+qsdSkiwBfkN/CkMWRNnS3Nq5Hf+y7PHZpy31jRZycv4gcR/4POIRjPNHJgHQxuYHPP8/wK+Cfdw6N7JD/c7CAEWM+pB0Xrs+5qeYlT/OPb+kO+/wjNH70+UF3QvLn/Q== Authentication-Results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=vivo.com; Received: from PS2PR06MB3509.apcprd06.prod.outlook.com (2603:1096:300:67::17) by KL1PR0601MB3891.apcprd06.prod.outlook.com (2603:1096:820:2a::8) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7025.18; Wed, 22 Nov 2023 03:43:43 +0000 Received: from PS2PR06MB3509.apcprd06.prod.outlook.com ([fe80::863b:f0a1:3066:24d]) by PS2PR06MB3509.apcprd06.prod.outlook.com ([fe80::863b:f0a1:3066:24d%7]) with mapi id 15.20.7025.017; Wed, 22 Nov 2023 03:43:43 +0000 From: Wu Bo <bo.wu@vivo.com> To: Alasdair Kergon <agk@redhat.com>, Mike Snitzer <snitzer@kernel.org>, Mikulas Patocka <mpatocka@redhat.com> Cc: dm-devel@lists.linux.dev, linux-kernel@vger.kernel.org, Wu Bo <wubo.oduw@gmail.com>, Eric Biggers <ebiggers@kernel.org>, Wu Bo <bo.wu@vivo.com>, stable@vger.kernel.org Subject: [PATCH v2 2/2] dm verity: don't verity if readahead failed Date: Tue, 21 Nov 2023 20:51:50 -0700 Message-Id: <b23a4fc8baba99010c16059a236d2f72087199a1.1700623691.git.bo.wu@vivo.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <cover.1700623691.git.bo.wu@vivo.com> References: <cover.1700623691.git.bo.wu@vivo.com> Content-Transfer-Encoding: 8bit Content-Type: text/plain X-ClientProxiedBy: SG2P153CA0002.APCP153.PROD.OUTLOOK.COM (2603:1096::12) To PS2PR06MB3509.apcprd06.prod.outlook.com (2603:1096:300:67::17) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: PS2PR06MB3509:EE_|KL1PR0601MB3891:EE_ X-MS-Office365-Filtering-Correlation-Id: 40514c59-c666-4e35-6059-08dbeb0d3966 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: 9mgJeT2DMxqVMa5/YhRg1iDWgNPEWSInfEMEm7R79T2PPbh1L2g51df5ynB48ExZ+L/Z1asefSVV2ijj8iakLZZ+jnGnFWdrRIOqVr3M/LQOfst4Ffehx66S2Slmrr7lzRPHOHThETTSyqhyP/xJZbRAu+kOFYSEAEXTHxh6SdG/t8szIuiyQVdXhwCmGT/0IaVDih5LjPeMKIfypeuAOMfFOLeD46grtWK6rFW1u0Ffs83vEv6bJE4sLGARfcQYxllgbfPYAJfdE6OmLigE3hhA2iTSb61586IzCWqqVKyaPDT/GcHDyCl7QjPPI2TW1qQIkCbB568+y62tD8S/vz4t3RIe8fo34a0g82Lvg4Qo0jTJHh52WTveBoEwYFFYZZwlp1ZEo0kDc2fsZU5kPwkRYsAN8IvGJV3R+k2TXFdqC8z/x4giyKKG8C5u1RLcw8J3B4030ma1o1ilwbxejIg4YB58auRTEUwec3rA5yGdpbW7FBcnm2AbTjG70V6HVt+dPjz/WyRnM/rp77zN07fvdOgQX7AKns3VX89DgMULN6D7Y6NpAoIlBnUyx+7STEiqWOfBqJ8W2o9aWBKq9i4QcEa2QJ6dHlcGxlRrVkqYc2HhoY/JOCMLcTUhbKGC X-Forefront-Antispam-Report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:PS2PR06MB3509.apcprd06.prod.outlook.com;PTR:;CAT:NONE;SFS:(13230031)(39860400002)(366004)(396003)(346002)(376002)(136003)(230922051799003)(451199024)(64100799003)(186009)(1800799012)(41300700001)(38100700002)(5660300002)(2906002)(86362001)(6666004)(38350700005)(52116002)(6506007)(6512007)(36756003)(478600001)(6486002)(83380400001)(2616005)(26005)(54906003)(316002)(66556008)(110136005)(66946007)(4326008)(66476007)(8676002)(8936002);DIR:OUT;SFP:1102; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: ptU2ksE2HAoQme9mEZ77rdVetDbehL6GAPQA8IdWnxCCvJZ4dEDycMSm2Lt83aichP6rRFaLkk0JHoMgbdTXUpitSuqyHAStQdsdrdfHpcr6kbHBdhoZ1Xs1k1gozUDPr87vZyqI+WeF1Rd5seQD0j6RXGMFA6RHgeGXgpllEVfBzsSGeWD9xgpNjh2YQxM+o5YFin3XhF4fX2yybIgbFBM7Dar4Y0JpbtCIZ37Rwt6OiJHyelz6yYquuRetiWBR/h3fvv8zOUByhtVnGijTYHgjcByr/vzQNlBgf7tWGXMv0I44lrAoPxd4xuhDyM/KBzRg/Txc9iPdQkVuB0GwM3OEhg9Fh2kbHvUQ1UgDKJcMnaHma/SA5lX7i+NUs5NBLJCIwprs4VW4NA2Y/Fa+e0Bk2bEu/moWo7UWASGiliVVzZUnVS7Z1R/XNZcw6g7wH3B+e47WqNYaW5zUZzRa3d1K69xuqFuleuZeqZAOhRrxad+EPBKF1bipsv0aaBSP1Okr/asXPp4fLdHNqUVBLQAj8sZr2wOJ48ose4vg/FY/GMgn8iAkiTvctHTt52edZ5YLXTJMZlOJNt6Tni5jLSOdBE5xYsTOPytCcA2Gzsvacm3FggRL8xGkenrsjJ3F0OaCzhrDlqK7aKxwIe8PD3c0oEK9lCG7AIeogcWPVDaecE13pJnxV8jaIpyKZ9Ovw5Tw2rPKrRGOv1nguA+mWS5+GhAyb+ctcUDbvLJIEm07G2BHcc1CWe12M+gXxolfWS4eZaAAm14t8cQ0KaW7HK7U7hzsEie1oWDcxeD/efj2G2toV2Shf1R2+9UZjUs3+R79eVuIhnbiGRfWFXoknM1D248m9kQeobZiLTeE0NTi64cdIdeFtEmddPvx9vZDFTlE5k0jPX06SgD7RQREaz5lZpqs81eRulPq8g/HMb5F+8oQpbKt+1epCws3D+XiD4wU1tidKSVV1kIdJQ7QyMyMcL3XUjD7uLajG+CNevqpl26zuwhDspvDyn9C/iIs5JP7YzMAaIkOtJArGt75yGEVQOfov1XAq9RKCErBtyK726HbK9qiJ75gKCikSL7p7EuOUghhk4NUcpMRcXRptbM+nD8OYPk8pMFvSt7yeGsflVZksj7vBeIrmZg++KYcXCXJxeYgoyBD52bnOpsjblFYHUFXyxitC9iMcpUo4xZTcy8bjtyjOEmzH97iNDtVxH0kyF+mBlvTndFEIGfMzlzOFlvDVVSG8lkxDUJ13saD8m89Rd/9MmQ1oBIEaEckrsdugIm8qwQ6yVcG8xBNrnUqIWKr895OM259n5khHnLNLASGlOZ7KuCSWhZ8tsHttloKOL/3aQIrhIeUm+wT2pHFG0rttN0Mh90FyEe8LJAp28mY2DLMkQ7By63+tAT5BreuCVbfn6ndzXR9tFzDQ0WBFRrL/lyZZi64Uhlhzd80PPkJ70Iokfs6oEg3JdVjfWmTQtvQrYh/URmNGRxdrz0jZgxSKfYRaJmritrjrBCWOHhTFpMFnCalUQHpJiNoSj8LCZ/4tDS2HuJ+F2CQzKmfzL9gQWGYvO/py6njVkpVmFLZMdfl+bBzcLWTGcFe X-OriginatorOrg: vivo.com X-MS-Exchange-CrossTenant-Network-Message-Id: 40514c59-c666-4e35-6059-08dbeb0d3966 X-MS-Exchange-CrossTenant-AuthSource: PS2PR06MB3509.apcprd06.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 22 Nov 2023 03:43:43.4965 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: 923e42dc-48d5-4cbe-b582-1a797a6412ed X-MS-Exchange-CrossTenant-MailboxType: HOSTED X-MS-Exchange-CrossTenant-UserPrincipalName: S4U1xo8kz7MxwC+C4P9D6TMi5qpVWI9sp55pn/W8DXbjm00E/nCI2svgZEGRSNDAL/INf/SYuXt2vEV66nw5vw== X-MS-Exchange-Transport-CrossTenantHeadersStamped: KL1PR0601MB3891 X-Spam-Status: No, score=-0.9 required=5.0 tests=DKIM_SIGNED,DKIM_VALID, DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI, SPF_HELO_NONE,SPF_PASS,T_SCC_BODY_TEXT_LINE autolearn=unavailable autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on groat.vger.email Precedence: bulk List-ID: <linux-kernel.vger.kernel.org> X-Mailing-List: linux-kernel@vger.kernel.org X-Greylist: Sender passed SPF test, not delayed by milter-greylist-4.6.4 (groat.vger.email [0.0.0.0]); Tue, 21 Nov 2023 19:44:13 -0800 (PST) X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1783234199195372868 X-GMAIL-MSGID: 1783234199195372868 |
Series |
dm verity: fix FEC stuck during lower dm suspend
|
|
Commit Message
Wu Bo
Nov. 22, 2023, 3:51 a.m. UTC
We found an issue under Android OTA scenario that many BIOs have to do
FEC where the data under dm-verity is 100% complete and no corruption.
Android OTA has many dm-block layers, from upper to lower:
dm-verity
dm-snapshot
dm-origin & dm-cow
dm-linear
ufs
Dm tables have to change 2 times during Android OTA merging process.
When doing table change, the dm-snapshot will be suspended for a while.
During this interval, we found there are many readahead IOs are
submitted to dm_verity from filesystem. Then the kverity works are busy
doing FEC process which cost too much time to finish dm-verity IO. And
cause system stuck.
We add some debug log and find that each readahead IO need around 10s to
finish when this situation occurred. Because here has a IO
amplification:
dm-snapshot suspend
erofs_readahead // 300+ io is submitted
dm_submit_bio (dm_verity)
dm_submit_bio (dm_snapshot)
bio return EIO
bio got nothing, it's empty
verity_end_io
verity_verify_io
forloop range(0, io->n_blocks) // each io->nblocks ~= 20
verity_fec_decode
fec_decode_rsb
fec_read_bufs
forloop range(0, v->fec->rsn) // v->fec->rsn = 253
new_read
submit_bio (dm_snapshot)
end loop
end loop
dm-snapshot resume
Readahead BIO got nothing during dm-snapshot suspended. So all of them
will do FEC.
Each readahead BIO need to do io->n_blocks ~= 20 times verify.
Each block need to do fec, and every block need to do v->fec->rsn = 253
times read.
So during the suspend interval(~200ms), 300 readahead BIO make
300*20*253 IOs on dm-snapshot.
As readahead IO is not required by user space, and to fix this issue,
I think it would be better to pass it to upper layer to handle it.
Cc: stable@vger.kernel.org
Fixes: a739ff3f543a ("dm verity: add support for forward error correction")
Signed-off-by: Wu Bo <bo.wu@vivo.com>
---
drivers/md/dm-verity-target.c | 4 +++-
1 file changed, 3 insertions(+), 1 deletion(-)
Comments
ping. On 2023/11/22 11:51, Wu Bo wrote: > We found an issue under Android OTA scenario that many BIOs have to do > FEC where the data under dm-verity is 100% complete and no corruption. > > Android OTA has many dm-block layers, from upper to lower: > dm-verity > dm-snapshot > dm-origin & dm-cow > dm-linear > ufs > > Dm tables have to change 2 times during Android OTA merging process. > When doing table change, the dm-snapshot will be suspended for a while. > During this interval, we found there are many readahead IOs are > submitted to dm_verity from filesystem. Then the kverity works are busy > doing FEC process which cost too much time to finish dm-verity IO. And > cause system stuck. > > We add some debug log and find that each readahead IO need around 10s to > finish when this situation occurred. Because here has a IO > amplification: > > dm-snapshot suspend > erofs_readahead // 300+ io is submitted > dm_submit_bio (dm_verity) > dm_submit_bio (dm_snapshot) > bio return EIO > bio got nothing, it's empty > verity_end_io > verity_verify_io > forloop range(0, io->n_blocks) // each io->nblocks ~= 20 > verity_fec_decode > fec_decode_rsb > fec_read_bufs > forloop range(0, v->fec->rsn) // v->fec->rsn = 253 > new_read > submit_bio (dm_snapshot) > end loop > end loop > dm-snapshot resume > > Readahead BIO got nothing during dm-snapshot suspended. So all of them > will do FEC. > Each readahead BIO need to do io->n_blocks ~= 20 times verify. > Each block need to do fec, and every block need to do v->fec->rsn = 253 > times read. > So during the suspend interval(~200ms), 300 readahead BIO make > 300*20*253 IOs on dm-snapshot. > > As readahead IO is not required by user space, and to fix this issue, > I think it would be better to pass it to upper layer to handle it. > > Cc: stable@vger.kernel.org > Fixes: a739ff3f543a ("dm verity: add support for forward error correction") > Signed-off-by: Wu Bo <bo.wu@vivo.com> > --- > drivers/md/dm-verity-target.c | 4 +++- > 1 file changed, 3 insertions(+), 1 deletion(-) > > diff --git a/drivers/md/dm-verity-target.c b/drivers/md/dm-verity-target.c > index beec14b6b044..14e58ae70521 100644 > --- a/drivers/md/dm-verity-target.c > +++ b/drivers/md/dm-verity-target.c > @@ -667,7 +667,9 @@ static void verity_end_io(struct bio *bio) > struct dm_verity_io *io = bio->bi_private; > > if (bio->bi_status && > - (!verity_fec_is_enabled(io->v) || verity_is_system_shutting_down())) { > + (!verity_fec_is_enabled(io->v) || > + verity_is_system_shutting_down() || > + (bio->bi_opf & REQ_RAHEAD))) { > verity_finish_io(io, bio->bi_status); > return; > }
On Tue, 21 Nov 2023, Wu Bo wrote: > We found an issue under Android OTA scenario that many BIOs have to do > FEC where the data under dm-verity is 100% complete and no corruption. > > Android OTA has many dm-block layers, from upper to lower: > dm-verity > dm-snapshot > dm-origin & dm-cow > dm-linear > ufs > > Dm tables have to change 2 times during Android OTA merging process. > When doing table change, the dm-snapshot will be suspended for a while. > During this interval, we found there are many readahead IOs are > submitted to dm_verity from filesystem. Then the kverity works are busy > doing FEC process which cost too much time to finish dm-verity IO. And > cause system stuck. > > We add some debug log and find that each readahead IO need around 10s to > finish when this situation occurred. Because here has a IO > amplification: > > dm-snapshot suspend > erofs_readahead // 300+ io is submitted > dm_submit_bio (dm_verity) > dm_submit_bio (dm_snapshot) > bio return EIO > bio got nothing, it's empty > verity_end_io > verity_verify_io > forloop range(0, io->n_blocks) // each io->nblocks ~= 20 > verity_fec_decode > fec_decode_rsb > fec_read_bufs > forloop range(0, v->fec->rsn) // v->fec->rsn = 253 > new_read > submit_bio (dm_snapshot) > end loop > end loop > dm-snapshot resume > > Readahead BIO got nothing during dm-snapshot suspended. So all of them > will do FEC. > Each readahead BIO need to do io->n_blocks ~= 20 times verify. > Each block need to do fec, and every block need to do v->fec->rsn = 253 > times read. > So during the suspend interval(~200ms), 300 readahead BIO make > 300*20*253 IOs on dm-snapshot. > > As readahead IO is not required by user space, and to fix this issue, > I think it would be better to pass it to upper layer to handle it. > > Cc: stable@vger.kernel.org > Fixes: a739ff3f543a ("dm verity: add support for forward error correction") > Signed-off-by: Wu Bo <bo.wu@vivo.com> > --- > drivers/md/dm-verity-target.c | 4 +++- > 1 file changed, 3 insertions(+), 1 deletion(-) > > diff --git a/drivers/md/dm-verity-target.c b/drivers/md/dm-verity-target.c > index beec14b6b044..14e58ae70521 100644 > --- a/drivers/md/dm-verity-target.c > +++ b/drivers/md/dm-verity-target.c > @@ -667,7 +667,9 @@ static void verity_end_io(struct bio *bio) > struct dm_verity_io *io = bio->bi_private; > > if (bio->bi_status && > - (!verity_fec_is_enabled(io->v) || verity_is_system_shutting_down())) { > + (!verity_fec_is_enabled(io->v) || > + verity_is_system_shutting_down() || > + (bio->bi_opf & REQ_RAHEAD))) { > verity_finish_io(io, bio->bi_status); > return; > } > -- > 2.25.1 > Reviewed-by: Mikulas Patocka <mpatocka@redhat.com>
diff --git a/drivers/md/dm-verity-target.c b/drivers/md/dm-verity-target.c index beec14b6b044..14e58ae70521 100644 --- a/drivers/md/dm-verity-target.c +++ b/drivers/md/dm-verity-target.c @@ -667,7 +667,9 @@ static void verity_end_io(struct bio *bio) struct dm_verity_io *io = bio->bi_private; if (bio->bi_status && - (!verity_fec_is_enabled(io->v) || verity_is_system_shutting_down())) { + (!verity_fec_is_enabled(io->v) || + verity_is_system_shutting_down() || + (bio->bi_opf & REQ_RAHEAD))) { verity_finish_io(io, bio->bi_status); return; }