From patchwork Tue Nov 21 08:55:28 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Wu Bo X-Patchwork-Id: 167557 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:612c:2b07:b0:403:3b70:6f57 with SMTP id io7csp482932vqb; Tue, 21 Nov 2023 00:48:32 -0800 (PST) X-Google-Smtp-Source: AGHT+IFFjTd4zExkvdaDIErlfD1oVftlDxlEoGgbyiUBLGcez7ZzeElAx75sD9KK3wV7Ty6mMk8n X-Received: by 2002:a17:902:d4c4:b0:1cc:5920:1d2a with SMTP id o4-20020a170902d4c400b001cc59201d2amr9815853plg.13.1700556512509; Tue, 21 Nov 2023 00:48:32 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1700556512; cv=pass; d=google.com; s=arc-20160816; b=01sTaWc/Mt+EmjWDq+OvnU9+6yFWOEfHgOAssvV8r2tL5TKUYvBhnvpkq6V268fHCb g82uzjuIvUld944yQp5+K9lSOoHl108KUG3Zefn3LEbA0TdJrCwxsLVVZO2mARvTzmLr KfPSrXSb+4FpZDHcijytNFy+gOEzLScj1lvsbhUZ3/pe6uSAnDpe2pTLRqZ+Oupfw3Rk NYsARwI/ffI10IJCULe3Ff81DrYQQhQYosmSb7enPlztLYcDE3/x6mkR8jBHgxjrow1d DbBPJ+xTteoyRFSfLMDSBFCHVat7IZlHnOa/uZna8FfL07NHm79ExcqA8mKZ5raweX4K pcKA== 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=zOZj09/M3VElLeovXt9H4i98jVpN1nF8xPItEn3ROYM=; fh=J30sqVfw9OjtpxbNumwD0tVG0bXXvvrP5TOHSwVy/Ns=; b=NN2nwwLd5sL4Nw9cOOxo7Jl5ZaNS+pfZjBF1XekhzIhc3KJy8u9Xrwzw0wqfmF3vgz Ni9i1nU+rtnoMR1Tq9tdiiq7zVgJcoo8LByADCYEg+Bub+8P1KMe3AYhcJLiNC325vdt UwftKFzfqVRR7JsQUUYkecu9Gp8FyV1MC0ivC11fRJby0ApeGgVYDl0t2NF2qi9TgNRK UWC0v7J5W3PavxXG4OtDBNnjYEoSRBWt1PbR1vaHvc5aOUjLc1yG2GyvRoMrqPeoxxsc MYobaYppxDv7HudsJ2WYZ4dtqRgLj/maHtn3PaT8MAl9QpQ05ZRT685m/jhWIrAJsFZ6 OzHQ== ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@vivo.com header.s=selector2 header.b=K08EHM4E; 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 2620:137:e000::3:7 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 snail.vger.email (snail.vger.email. [2620:137:e000::3:7]) by mx.google.com with ESMTPS id f9-20020a170902ce8900b001cf652d73fdsi3048891plg.284.2023.11.21.00.48.32 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 21 Nov 2023 00:48:32 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:7 as permitted sender) client-ip=2620:137:e000::3:7; Authentication-Results: mx.google.com; dkim=pass header.i=@vivo.com header.s=selector2 header.b=K08EHM4E; 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 2620:137:e000::3:7 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 snail.vger.email (Postfix) with ESMTP id E0DD480E06A7; Tue, 21 Nov 2023 00:47:13 -0800 (PST) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.11 at snail.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230435AbjKUIrB (ORCPT + 99 others); Tue, 21 Nov 2023 03:47:01 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:38128 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230385AbjKUIq4 (ORCPT ); Tue, 21 Nov 2023 03:46:56 -0500 Received: from APC01-SG2-obe.outbound.protection.outlook.com (mail-sgaapc01on2118.outbound.protection.outlook.com [40.107.215.118]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 5799210F for ; Tue, 21 Nov 2023 00:46:52 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=mPQU4m/AS87lg6iWtsGwCzR46n90I/w8PlBOnzfIYDUupEFhorrhtpLYpFoXq7wuS6AiQcRYoxnli7+5fuirs++GC7wzaIEtDWGMNdIg7lWqTHtAG0MPAh9zXMr539BE9gk5KUSVOrPAqCz8EMHON+V5CCXQVDcdt7r5AXE+4oJkmacxSJyUQqT9zoaOlMDbDMGR+aTF5XsxAiyOLbakGNigw63CTMUEU9R5joAbzmW7T206V+1/uATql+F/TvL2lcpNCWkgSmvCBkU2k3KBR+dr69tQMbFbGujNjM5W3RaELSLUfz6QI2IIpr4JnAYJnZ3ywpQNznXOUBr/WqkTCw== 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=zOZj09/M3VElLeovXt9H4i98jVpN1nF8xPItEn3ROYM=; b=WpyIlTPpph/jHHfuF920Gk/WpABY9F+IdvjPOgCrlZtEjX5u+lx+EtEJswJC2cwxo54gVHd1UEZ3tUstYYyOXfYlkfgNxWKclA5kmy7QOCfyjLMIVdLehZHL2k1pPt+D8R3mVJ0PleGF2sQlW8o74DLsuYgO13irrzhvZgr0jieANdAwGK9+K8q7UiHnS/4I/yefSSte4WEFc5m4MpzPlWW4JVnYG3WYuwxSPwsqkhQV4VcEit4kX0YiF9pYsjuKiPH7Cy28e9UKUeXKZsUeu9MEOo9m/+NncnwTjZ/uI5vb6hrMCTZ0IYMyCumMKHIrpNdMerjW2JRVHSJtHtM2hA== 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=zOZj09/M3VElLeovXt9H4i98jVpN1nF8xPItEn3ROYM=; b=K08EHM4EAlZgF30fhPjlwekJlR1DGpM3H1kZEbDG1SUp8usIBvS2iRlDAlg1Sh3cP9fQEETI6JfA0Obyo6wO3a30apMIPwgCZJiv/fjLgchqaiXOCs/iCFF7WOXdvgUq0FtYHhP6vhj66Urtu01vJZgqbKnVKcrHWNePJVHjccvn12KrksmqKHdOSKf1bHx6VKQiUWuJ6AlieYwHIGBx3883JmTL2DqXqg4kDfIqFW408VKj32oyz+6ufLpcLxlbpMkvQwP8mNYHKGNigxAEvJBajqvsyvWRZAli8705c6gom1YC1dK/Im1+XGvyE0fPu7k8PhQ2gdRm3Mo7LKpcYA== 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 TYZPR06MB4127.apcprd06.prod.outlook.com (2603:1096:400:6::6) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7002.28; Tue, 21 Nov 2023 08:46:49 +0000 Received: from PS2PR06MB3509.apcprd06.prod.outlook.com ([fe80::863b:f0a1:3066:24d]) by PS2PR06MB3509.apcprd06.prod.outlook.com ([fe80::863b:f0a1:3066:24d%6]) with mapi id 15.20.7002.027; Tue, 21 Nov 2023 08:46:49 +0000 From: Wu Bo To: Alasdair Kergon , Mike Snitzer , Mikulas Patocka Cc: dm-devel@lists.linux.dev, linux-kernel@vger.kernel.org, Wu Bo , Wu Bo Subject: [PATCH 1/2] dm verity: init fec io before cleaning it Date: Tue, 21 Nov 2023 01:55:28 -0700 Message-Id: <419e7aa58f67d90020512892f7652623e8c9f059.1700555778.git.bo.wu@vivo.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: References: X-ClientProxiedBy: SI1PR02CA0047.apcprd02.prod.outlook.com (2603:1096:4:1f5::15) To PS2PR06MB3509.apcprd06.prod.outlook.com (2603:1096:300:67::17) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: PS2PR06MB3509:EE_|TYZPR06MB4127:EE_ X-MS-Office365-Filtering-Correlation-Id: 7739ea1a-2ffe-4979-ca50-08dbea6e6604 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: c2Dc2uRDVOb8o3V/CCaEvHWup+z+f+KM2YIiVfb2b/D+KaBezp5wKFjqrYSvdA+vHZp8Bdrg3Nrv09g+lmYvK2Q5kSUFE+hHdWPNsnz3F3/ucgqbYsisfJcvA0Q+wEm4vrnKEnvfWnaEIc9vrhQXlEwpf1ISAP68S2e2kp26H+29V9/B47OsANndDHHgp4UGfWepkvSEWNSi9eiYXTJAYbIKTFjb/SS+qC4m+KXj/FU1mR+CwQSR4fVaUmrTZz6/mw2JY/3ifzJD7hSjxDkfwvg0nTWuMiVHoMQhnMOJLd3W37ZaowbD158S3yw211D55PdKDpVfDgIW0gXn438cCauqnh05miPPYnO4oWZ9IGrRe4x1cKQvXKWSHWavdRK+uwIH5zAl0lXqhHna0xrOmI4wJojoBKOAQJ8FPFveRfUiuZpj7MlZ9ZeNsGRjbo7HgdFBxrYpZgKQmMhS99E7cUy437YdgoJ8Xhv6zI9elc2KZq6uE/gcE6BWhisX7Nx0P83b/MJ2dYdTdbKPvWe5AVhksC0eSUZrcnr4XkN1SpJyeJHd5HRbSee/nMWVujdu6V6Xt3Z2pLClsE4PhmLLFs7sL94Pjw/h3ecS/MN8tMQIIGwIxuorOXn9dOrfMp6R 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)(346002)(376002)(39850400004)(136003)(396003)(366004)(230922051799003)(451199024)(64100799003)(186009)(1800799012)(316002)(110136005)(54906003)(66946007)(66476007)(66556008)(36756003)(52116002)(6512007)(6666004)(6506007)(2616005)(26005)(107886003)(6486002)(478600001)(38350700005)(38100700002)(83380400001)(86362001)(2906002)(5660300002)(8936002)(4326008)(8676002)(41300700001);DIR:OUT;SFP:1102; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: LGRtE2X/rNXFYOOsS5YubsX3M33L89w7KtXvMR74dzL0nUbWKN2GnKqX4jNlwgBFngNSJEzVDsvNL6Jn/r/4fc0u1zCQ8sKGpiJOgWNgd83Pm472+6NksyYdYlmb1/YuOVY+Qutv5mUNDmvVZrt6YmIEBMdKcku110QwT6jFbkYdniYTH95gkkW7RNAxlcYpWYJejlnB5K4Ofu3KmBjpCWCfidAayzmoZW+t75jzDkQEG00DI4s10mxFaY/tC8aYX4AXJXkxmNxPa5p3SAIftR6pcnJGY1LnBTdurq6BjFymcaa/Zr6UrxosjspeR6r2fm4ihKt/i61sD/7FjvY6K/7jpNnpoUZF1h4Fghme0WuWcrC9N+yZrIWpAvtg7CsqjtaJnlqJuKXwhn7TYT+Qd5Rb/REl6KXWjo1hbEs2Uc7xkh45DtZx1YdFQ2blYLxLp2zV4trJcJPyN/aaIURYT6/2sBdur80BmOpfKic/tqGGSQDqgLk6RunKTw3GUTi0rsbGxboz6MqQu7Ct6jzfG4TfVTng+IERJm5fQw+FVPphVOobPPOnzY2o42X8whmjX9jSHWeTUMKnxi4PoL0NXnWBUZrstTETDxQCST7q3MXcWa1A54OgzO+1iQqnnTRPMS2+TaRnAeD6hXliJgTh3FhFkT2XgOIJlDLmIneH+JgRYhx9n1o7mb9SzB4cOdJgOXJUO64XDc8r43yFU852ByA5yLUjS+qeymtiXIwntiOsjxNdw2l0UPV0yzIIhpioIfqw2oagMtIj0QBUdVxTFW8U6/Uj5AGcGvGk0hyZ6ydF78VUG5mKku/XE0QGZkxVG4RTQjUCe6Tp0TSVRH9nc/skJOW9Ssm2EDd4Qz9UwbAGiM9qSwt2MSOhR7s4olvTa9wOPTbYYSj5bWeqQ3s5zA2xciiLIibxrl8rbSD7J21FpYQ6b3d8zcAUohQ6yv2BA96+iAGK7x1HpyKPNTNucOMfd6U3p5/a+m97JLTikyXomBKalTZWyVX46mBm8cFGvQiee1GdL/bQRxWjjOTFXFinfjlyutDXW8C+ok7ibecKTk/2lzzImS2wydB25KKl3BmOaFyDeAmRc0I0x7sOBX1Izh6sn+c7NddkgdYbeibhq1txk/g0nKZ+7QEZMuHo/c9kJHFPnETb9QFKz0SartfSj6mDT3c13B1X7sFUaJmoguRNGVFqAPjfHx57qGnrQ5jtnEZuvKTws6atlQpUjjzMTBUZYrV3VSQLh45OSKDWcu9k0qIZfVhOs/3xarU1/OXWAQHHBUVLwnNhA7pLR6RDgx78JWrfv8yB4qsBG3iBh3tTMjyHJudJH/PUK1BTS5Ncnjnvau74P9DqnceYTEbD/0tTd065P6fI0GXyUIoau396aOgzdxhtTXSEscK8BFNXbAfk3F10xGTjmS9PKEYgmrn8yNZqZAhvlmdha9FCLVuInDokrFeYeh++RCv7SQF7FeYIT45+ZAkbb7WcsJv7HQL4Qpw3WWf592rVnfZ6E2oPETseyJdqXZGftKvApFe+jDEyvDO8aFg58+QeKJm6BJvtgw3/nqbYPJxOSGgXa1lq4tPWLZVNmY2XUglo X-OriginatorOrg: vivo.com X-MS-Exchange-CrossTenant-Network-Message-Id: 7739ea1a-2ffe-4979-ca50-08dbea6e6604 X-MS-Exchange-CrossTenant-AuthSource: PS2PR06MB3509.apcprd06.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 21 Nov 2023 08:46:48.9329 (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: 21kDYlBMzv3tj0+xmxqKhAppm5qU9rdOoJTApDKOi+Ywub/FNR+nsl1X6yW02DuGNiB4PmNTg1mAru9zztDPJQ== X-MS-Exchange-Transport-CrossTenantHeadersStamped: TYZPR06MB4127 X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_BLOCKED, RCVD_IN_MSPIKE_H2,SPF_HELO_PASS,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 X-Greylist: Sender passed SPF test, not delayed by milter-greylist-4.6.4 (snail.vger.email [0.0.0.0]); Tue, 21 Nov 2023 00:47:14 -0800 (PST) X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1783162745898750492 X-GMAIL-MSGID: 1783162745898750492 If BIO error, it may goto verity_finish_io() before verity_fec_init_io(). Therefor, the fec_io->rs is not initialized and may crash when doing memory freeing in verity_fec_finish_io(). Crash call stack: die+0x90/0x2b8 __do_kernel_fault+0x260/0x298 do_bad_area+0x2c/0xdc do_translation_fault+0x3c/0x54 do_mem_abort+0x54/0x118 el1_abort+0x38/0x5c el1h_64_sync_handler+0x50/0x90 el1h_64_sync+0x64/0x6c free_rs+0x18/0xac fec_rs_free+0x10/0x24 mempool_free+0x58/0x148 verity_fec_finish_io+0x4c/0xb0 verity_end_io+0xb8/0x150 Signed-off-by: Wu Bo --- drivers/md/dm-verity-target.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/md/dm-verity-target.c b/drivers/md/dm-verity-target.c index e115fcfe723c..42b2483eb08c 100644 --- a/drivers/md/dm-verity-target.c +++ b/drivers/md/dm-verity-target.c @@ -642,7 +642,6 @@ static void verity_work(struct work_struct *w) io->in_tasklet = false; - verity_fec_init_io(io); verity_finish_io(io, errno_to_blk_status(verity_verify_io(io))); } @@ -667,6 +666,7 @@ static void verity_end_io(struct bio *bio) { struct dm_verity_io *io = bio->bi_private; + verity_fec_init_io(io); if (bio->bi_status && (!verity_fec_is_enabled(io->v) || verity_is_system_shutting_down())) { verity_finish_io(io, bio->bi_status); From patchwork Tue Nov 21 08:55:29 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Wu Bo X-Patchwork-Id: 167556 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:612c:2b07:b0:403:3b70:6f57 with SMTP id io7csp482670vqb; Tue, 21 Nov 2023 00:47:43 -0800 (PST) X-Google-Smtp-Source: AGHT+IFfcv5/RH8Dvyc/87v6hTsO22xZ59Qmca7QrnsPDUAADWN51aNU8vr25HKjPXNvf35L4GBq X-Received: by 2002:a17:903:18c:b0:1cf:55dd:9a0e with SMTP id z12-20020a170903018c00b001cf55dd9a0emr7712857plg.15.1700556463351; Tue, 21 Nov 2023 00:47:43 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1700556463; cv=pass; d=google.com; s=arc-20160816; b=jQlhIO9b9mjpgzNJsFMqmgv30arvCX4pm2OtwlvOoWRpro5WWXXCCVt3C85w3ECsUk usBAa4llnVZaXRDfslksl8E3ivZNwc/3+9jGlivLxSOmtx7tQn9yXjnjUngLhL5AmMRx QDLYHlzz6OvkLVljHOub/3jYCPq4/sDEZ4J2qeg84CaoJ2+WadNdtA572N836H5DQQyB veXrHRExW6MRFIULpV5nPcDmWW9dp1js5IEelhLGkotm0xkW+UbttPEAiC1Vk9dAYlpp 6JSMIppYd3qIif8bEEU3aaqPQd+jYcVlYRrp6XfPItmrAWf1swqlnhD0Xc5Ty4o7TyaA nJ7Q== 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=O1jKzEvgvT1xkpQeOmtQYxQ49es/Ht9A/RtNWtHmNZ4=; fh=J30sqVfw9OjtpxbNumwD0tVG0bXXvvrP5TOHSwVy/Ns=; b=Wf0Byih2ydPOwOj0+Hpxo03DmSTKqpbPEkuEmmeMLgPgEq39OgIw7QDIoCrPo0uyht WTFVJOuyD6hH5I5ezKrqlQ54X9TnrBcQsBPHSGuxH84+73+qeXly1gYwrAv+4YQ1GILN 6ZgFaTVkVGsxn9/IRuIw0mLaIeF7VfHneZjeHrGJk0f/+T3ypOf100Ks2DCwW6TBg04T hjQ381A1mEOBoXan2Guesrwj3sl5NPuTfZqhBfnUiQ3VIY+kXxsZQUQi5IsL+HFI7Lv9 lMlMH4XDa36ox/s43Dyj9YIPECldAL8cgg+sNAKxBuBz8fesc94DvhkDKpn+R5wUn0jQ 7qzw== ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@vivo.com header.s=selector2 header.b=mE8aMExB; 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 2620:137:e000::3:3 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 lipwig.vger.email (lipwig.vger.email. [2620:137:e000::3:3]) by mx.google.com with ESMTPS id z16-20020a170902d55000b001cc5420241bsi10667048plf.413.2023.11.21.00.47.42 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 21 Nov 2023 00:47:43 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:3 as permitted sender) client-ip=2620:137:e000::3:3; Authentication-Results: mx.google.com; dkim=pass header.i=@vivo.com header.s=selector2 header.b=mE8aMExB; 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 2620:137:e000::3:3 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 lipwig.vger.email (Postfix) with ESMTP id C4AFC802EEC8; Tue, 21 Nov 2023 00:47:40 -0800 (PST) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.11 at lipwig.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231580AbjKUIrR (ORCPT + 99 others); Tue, 21 Nov 2023 03:47:17 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:54604 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231573AbjKUIrM (ORCPT ); Tue, 21 Nov 2023 03:47:12 -0500 Received: from APC01-SG2-obe.outbound.protection.outlook.com (mail-sgaapc01on2135.outbound.protection.outlook.com [40.107.215.135]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 03BBC199 for ; Tue, 21 Nov 2023 00:47:04 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=ci2fjush3uHy2eHrR4KMEL7OPv45k7sEvXP4HEDwRlymTV6sx29lC460E4PmOEfyJDjFLxhop7hIGqlyyooFT64i3A8rWXSYQ3x+PrXjHm2j8NvzS1Nw9kSZou2MDU+sEVrMS+tVRBbPb1MxOMJ+OFq0orTxhqQKteVng3ebt+gMZMWx5ybnEACpBwXg8CYVddOnKMc4p9xvUMMWOgQFa2DHGhz5pOTsMz1wY9eZUQYoT+eHjWQZxX4yQVXcI0yhnNC1zDjmo2gusMEhlVfmMZuElNex+n6QHHmI26iomKWXpyWJcjl8bhNVkTtJBW8sVSyJZtRFLcxlOlVtEi2Tyw== 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=O1jKzEvgvT1xkpQeOmtQYxQ49es/Ht9A/RtNWtHmNZ4=; b=VLCmUgL/avC7vfn6DmFa3Nn6RoShaKYfvsdQqcl3v0XYLbhhI6ACfjQYdbTXSj02oO/n8JrU13yIvRqBIiB/YXgVhkJBUYnQIlKbt+jClDphZdmD2h4p+2m9753GK/BevyMyvE4f2BogMvfzWqx3ThGwBB4+BOCc85N59XqmBqKdLISRl8Z6rtLMUNYdd2yV4TOnFYJdeXql4AjMk5mvBg4P+viEeH7QNypRHVgPUv1nZdW79Cfwdcu9GNLCo/0N0i83t44KE5H6OGi5e+qf/2B+8lvL25JdLhwNRvyzS4i7ITGaWQacgpeqYNgVAzpm8pY7AQV3vzft/g0eQ6Dbsw== 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=O1jKzEvgvT1xkpQeOmtQYxQ49es/Ht9A/RtNWtHmNZ4=; b=mE8aMExBBVw0CZ3ESwN/tK4mB0gNugE75EOWAktq79bGZwqI277C6FZavJ3OsLBtNQBv31VmwtMt9TZf4qPw5pvmWFl/pMxdgb9nWRSywYMUL2LJ7Go9oYrlwxcP8chr0hWRqiX0BUZiuxy/uIL3WDN2EFK1EYD1NASrCKSyL178n+/VoUZziEVx4/WfoMBko3Vs0SWmykrE2KLc4syl/IkdB/sSFhvhRW3HimiLOY7CC7/RFGvfCUCbtDqenVT4un8Z5x1eY021GsEzPzqMSYks3MnAhpYOHuLzbp36IsTgu5XXV3TiDYpFI8NC4lzimV8LW+tGTIRDnfkXdIA3zw== 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 TYZPR06MB4127.apcprd06.prod.outlook.com (2603:1096:400:6::6) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7002.28; Tue, 21 Nov 2023 08:47:01 +0000 Received: from PS2PR06MB3509.apcprd06.prod.outlook.com ([fe80::863b:f0a1:3066:24d]) by PS2PR06MB3509.apcprd06.prod.outlook.com ([fe80::863b:f0a1:3066:24d%6]) with mapi id 15.20.7002.027; Tue, 21 Nov 2023 08:47:01 +0000 From: Wu Bo To: Alasdair Kergon , Mike Snitzer , Mikulas Patocka Cc: dm-devel@lists.linux.dev, linux-kernel@vger.kernel.org, Wu Bo , Wu Bo Subject: [PATCH 2/2] dm verity: don't verity if readahead failed Date: Tue, 21 Nov 2023 01:55:29 -0700 Message-Id: X-Mailer: git-send-email 2.25.1 In-Reply-To: References: X-ClientProxiedBy: SI1PR02CA0047.apcprd02.prod.outlook.com (2603:1096:4:1f5::15) To PS2PR06MB3509.apcprd06.prod.outlook.com (2603:1096:300:67::17) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: PS2PR06MB3509:EE_|TYZPR06MB4127:EE_ X-MS-Office365-Filtering-Correlation-Id: 5d432032-10af-4a18-d72e-08dbea6e6d88 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: /HawtCY3vSSeuxSf5+LAIyoTq+P71LClA+OTpQH1f2qBLAqCx5mOI6naWBaza8eMt0tVTARjE5iI/87/MsVvxLLnD2eC/SXuAh3Z59WuWssj8zv0AUZrVbC73iJ0xoP8uo4n1VneSgsq3wp3SvBjYm99oZAX//D72zV62O7wd5npQodt/POoh/ZX8t8OAdF3ssaY+InVlnozvljby1uSNsMCbw+mKeoC0+Gb3Q9H4TyDU/QZv7Yl0CY1wMg/AFiHq9NL+75kh03o7vdp4Pww0jb0ivZguQbTE9VF+0m3Yn0JSs2GtiIQbaMzmt1WNtOjSo4LLUesSrcMMZRCrLtuRrLumHSPaCTF21vdeKtj4KlUPnjh2HHLMdItIO+fE6bh/8y3ReJvwSVpXxCfgo01P0ZCVOxmomjB0wAZqd2OCfWOjB7RlTUx8uevzuXu1Y4mP813c8s1EjDwDTW9qs+iqz2frlEmUQg6+5BOwRBf/0OLPJLZetSaARuJUm2yyFHY8UEhCO76nvDCiXWKB16pkfqI98Ha9Nw0nM0/lU2SUI/+aX/rESVTNo5unQk3L1McZfKihk6g9IZ1pRfqHbZ6FQGZBe2ljnYUb97ri0+4zHdagxJcgBmDeGdOEx/PY0RE 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)(346002)(376002)(39850400004)(136003)(396003)(366004)(230922051799003)(451199024)(64100799003)(186009)(1800799012)(316002)(110136005)(54906003)(66946007)(66476007)(66556008)(36756003)(52116002)(6512007)(6666004)(6506007)(2616005)(26005)(107886003)(6486002)(478600001)(38350700005)(38100700002)(83380400001)(86362001)(2906002)(5660300002)(8936002)(4326008)(8676002)(41300700001);DIR:OUT;SFP:1102; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: kHQxOKA//8tBgx5jtF6Nh5l34U+UqkCdi3+Hl95+xS5aLZ7LWjUCsSPRAMRcfkShwsMuz5H20H4KjP3Gcn93q4uLXdCH9DPbpdWmp7lHw4LWPk2b0fm2QJtvzD9mjSkQ32c6Mcs0lnbmQgHULXlDXmIRVL4lHmrCOXO2mRnJy6lnLVM1sbwFwPD0JWz+SAyD+j/mIrjao/tVeJtw9TcXsznG0kKokJFVdtzRTJXi+L5wZw/zRhCtdbb+XhHD8GSE1roBWduVn76Mmz2VKLQp1jxf9wvwWwXqoF4+cA9ibTYvFmqpSdRLJdYa4oF4d1RYb6aytVrjNiAmYnO28tqPQrgYneZJalxQ1mr6vWt3AMmYePXma896htF9i1SjaxAhmchEJeoj5hH2OWz88BE17kRJtI73pFI1yiffQVydgbYGiBuwHnZgcVfwY3/DcqUFljnGpU2M/VaEZ7B40s0puD5cXsyDA4gFApVgPsuHsoCFaDEBymn/oArDNv2G8+VkguhaqQg+QRTPZ5Kpw/kILYJs86UIyq8JWAKGhK2A3JWcC073NKOGs5VoEu2BAgV8pnO+bWNkbfFo3mYO/DzO2r6MCEQ9I0t3ytICNs6JaF00jC93qjUzFvSdS3HcyWUPYSqhtyBOPROPt0xTw8wNnD2daCjxhw8oirRtzMb/ArCtEk2LtyfTYWVPp8UkmWYT0dfAk671rDQACpBwvTr4+KVpcC2A3xwAWpACwrcZX631jDEMf3LFq6vdDA10cLtXt7V3VAHxZMdabN1lNmz/mdBslq6OOVzkOp3KjZ0770bvZDIq6CQssY6hagLQXyTzkFCO20jbHYgtyuX5a3rAr7zKHlyQBAm5T+sDq2/AVC3aZiLZeGJZQpi62UrowRZnygIpXqUd6HanZqW351FZ/tS4gHViQJhZ6PK85N+cxWfONpuj9aL5wQ6JsMZnAM+pOXlosaW+AhH3CxpAgRFrTzaayv53cxaRrIQrLECI073QxpZ5ViVQW9tksVuGnDx2KWb4QVjkzTxROoZG/8con0WEYBLaYi4eQCyyZWQr40ikrZ5dxm2iQquS66/1DD6KLpgshaOnM4n3pjQp6mwXfIRBkD34nKYFmejWtatdhXWNl5LjK1LwaAA85Dd0CokY4V50tOlOvB0vvNwPkJON48K5IEvyUHeAKc7SyqFeo6E8Bod136oxaFAiwvUVCOA+AJGrtyadRCkETxIYChMno+hwQ63/HXKD4eQOoKldt6ZqYNjIUdnkFOqA9uXQy8iVixpZ1iAMVvWq3OsCHkNSj76WzL1ANNDD4ffA5M9ipFcO4aQj3D+QBTAixR7VDL81j7vn3juUgDKslxKtLEpztzLV1efEPlhGLUptKvKTVQj2xBpOnlohJ84A020swExpsW9CgPruddv1Aoi9qwe8EhZo9i0ouJLj81UZUYn7ZjBrkVu3HyvOjiE+cdCLcDd04ZatMZlBnSSuuxAmhZQFtLJk1kJCAm78i+yjx4x0cR3IoFiiIVrYZGKN8pUWykP3lEU88nZQKEpUDHLgwnpblnSuKWXzEpj2R9/E8YcTcB7PqjuG4Mb8quhoOWu1bivd X-OriginatorOrg: vivo.com X-MS-Exchange-CrossTenant-Network-Message-Id: 5d432032-10af-4a18-d72e-08dbea6e6d88 X-MS-Exchange-CrossTenant-AuthSource: PS2PR06MB3509.apcprd06.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 21 Nov 2023 08:47:01.0043 (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: S0jWMWJjjtI5Yfp/n9IkXjl6gxZ4TG9i+WCBbtZG9tUxVI7owFufb3B1AOfrpOjs7PlE/7YO81PzSQZwzp0yNw== X-MS-Exchange-Transport-CrossTenantHeadersStamped: TYZPR06MB4127 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 lipwig.vger.email Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-Greylist: Sender passed SPF test, not delayed by milter-greylist-4.6.4 (lipwig.vger.email [0.0.0.0]); Tue, 21 Nov 2023 00:47:40 -0800 (PST) X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1783162694243487940 X-GMAIL-MSGID: 1783162694243487940 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. Signed-off-by: Wu Bo --- 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 42b2483eb08c..d242e50ec869 100644 --- a/drivers/md/dm-verity-target.c +++ b/drivers/md/dm-verity-target.c @@ -668,7 +668,9 @@ static void verity_end_io(struct bio *bio) verity_fec_init_io(io); 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; }