f2fs: compress: fix to call f2fs_wait_on_page_writeback() in f2fs_write_raw_pages()
Message ID | 20230316094847.32486-1-frank.li@vivo.com |
---|---|
State | New |
Headers |
Return-Path: <linux-kernel-owner@vger.kernel.org> Delivered-To: ouuuleilei@gmail.com Received: by 2002:a5d:604a:0:0:0:0:0 with SMTP id j10csp387248wrt; Thu, 16 Mar 2023 02:59:16 -0700 (PDT) X-Google-Smtp-Source: AK7set+3L/jgmsNug5k77Ql4P1kbxHP6J72xw/1MaVNO7H8RFoRyMZpOvgMNIy288UBtmWnCCAFL X-Received: by 2002:a05:6a20:918c:b0:d3:e4d8:a684 with SMTP id v12-20020a056a20918c00b000d3e4d8a684mr3448143pzd.7.1678960756561; Thu, 16 Mar 2023 02:59:16 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1678960756; cv=pass; d=google.com; s=arc-20160816; b=ln8RC3ezXDVUgMhae+zQjafkXRt2kaxzNKGPkzbPcbkGyfFLhSBG6CIrujzyDYEFJE pVudzh+CqlDX9jVXbvY9Eyjan1KGP/qJCGFZMsLcVu34dTPu00vCiwrQIWX1w/8UuaBi o36SZGwfjZHyJn9A7haOI5qZTF9UF+vC/qcxVKQFOZ3oUwPZt+eE6BYi+8DbrHmTlpOh aYknh15VPpgkprb7eIIwzORVP591HxB1uO6KxYJTqJK9/WcOZR6cpk0gE2DPtnzIMMS0 RlaV+v4Rmo7/3t+EkTzFerGriB+lTrDTOWw8ygzRMLINYqGmlofpc0lFVmyKeGFMffdQ rrpg== 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 :message-id:date:subject:cc:to:from:dkim-signature; bh=38gNMJ9SsfkgOaV79jEwIUUP0mz+Rvvz5t9IAGYrGMY=; b=O6zVb7xphQxgUClsQrxqjIzs6evnIMLzr6DMqysjhKKtRyrncQAxG68VM41mHnt2HX aG4beczJVCvK+E1VamFCZImx80JUtEfpac0fti+1FtBCGVFM95iw2CuoeIXQM7vSsoVt yDjPGSKYEeYIiaseHErPeqdGewMlOMjN+DEDSddgdNwcnEwuTbls6do2PBAJ3TeCPTc+ HCMIsK4HxDh9rMesnLznAMIU+DHGqzcBCwCwSucruy2OmIKeoifUxaGPKHxMxXECuCib /lio5bsf1lzjNW4PC4dZJOpmOwTaphlHwV/iLr6SzLU+b625EKJ6y5VDBALqCxIgD1Q5 zA8g== ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@vivo.com header.s=selector2 header.b=VkLucwXJ; 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::1:20 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 (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id fd38-20020a056a002ea600b00625f517e72csi1417963pfb.8.2023.03.16.02.59.04; Thu, 16 Mar 2023 02:59:16 -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=@vivo.com header.s=selector2 header.b=VkLucwXJ; 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::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=vivo.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229734AbjCPJtG (ORCPT <rfc822;pwkd43@gmail.com> + 99 others); Thu, 16 Mar 2023 05:49:06 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:50566 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229506AbjCPJtF (ORCPT <rfc822;linux-kernel@vger.kernel.org>); Thu, 16 Mar 2023 05:49:05 -0400 Received: from APC01-TYZ-obe.outbound.protection.outlook.com (mail-tyzapc01on2130.outbound.protection.outlook.com [40.107.117.130]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 116412F790 for <linux-kernel@vger.kernel.org>; Thu, 16 Mar 2023 02:49:03 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=lvcOaFIbDLWog6rWo0hAsz9FI//nzS2tog4rEzNzJ92N6O+eWcrHCQOVo0iX2sEgwm1HmZpnJWB/Z8i/MSMMQTkGtpmUCcEp6ZBrHSFCFKIjeKIodtqrTfAg9EAhF19tgV2fMfmBVfcovpItJ301U2BOydTQf/mhymIGeUHtLfx9TpUgUxBJseB8KJlf+g5VJHQb1Z2Y9QoVPdnRHT/a4VGhCkMbr49g7JOaGevmfJW+LWty2XAcVFV83mKphwiPIxGMhpT+Q7m/YOD9ZOqlwcVb1ckBoG9BbC8jXFrY/C/V8cMHXtbXAh8Ko75ConYmgmbUIOctpb46gezEAJ9qLw== 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=38gNMJ9SsfkgOaV79jEwIUUP0mz+Rvvz5t9IAGYrGMY=; b=QGzgImyr+9+hRrsUHm/MHpHpCl+kfyS0ji0aS54E1wP4AwwhMfZknxzOEGezW4+86QwlrXgL2oZsC6JItiROSus241Q5N20Hx+kcMdNctu8VvBlHGjjYV0HA0Ou//Py7MNVz7kjkpC8vsn2AdxyZmmBxTjdcBOssMyokwgiSPKWoUZRXuXcQJZwc2VX8t5NpetA8dtNMuMbIb1HCvUbLKo97tuLD/XGyBJoYQ0o7pLmYXK0ARzZ7qisSE3oSdDpNkt0UWSSbt/PnOBcYRngOEPw1rCsHsokDfHSzqPDi967wSGgBIGV8QHA4BhLTFMYt84zfpbV1NVNNZSDAQp9ESw== 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=38gNMJ9SsfkgOaV79jEwIUUP0mz+Rvvz5t9IAGYrGMY=; b=VkLucwXJdsnjT+p2deocov3XqWpvtyKmEX+dG0RAm+q9VABPuSOfe5tEp+0vibEDJtGjz5PIwp4AGQR8myNDLDccGOlrnpEh/Rd8dJNAaDTD9S3L/H8h1TPLOO3G8KMiWK75O7v2SyA3GfO+TsWdyFY8oAQDibA03eVmeMX+sue8s1pcsyg3+U9dOV5qEfAHDh6TCbe6S/LgGwuW1XoYDGtvtH/T7v8kzQrX3/SXCK/fE+PgXqY74mI1hoLDdhEcuBS1MbKnVMQf73+abihaSuG5Bt4k8LYDnpGLLTJULLG4+ruGqVMfqbQpmZaMazwvq8LfOThhcGSIc8nOge9J4w== Authentication-Results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=vivo.com; Received: from TYZPR06MB5275.apcprd06.prod.outlook.com (2603:1096:400:1f5::6) by SI2PR06MB5196.apcprd06.prod.outlook.com (2603:1096:4:1e0::7) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6178.31; Thu, 16 Mar 2023 09:48:59 +0000 Received: from TYZPR06MB5275.apcprd06.prod.outlook.com ([fe80::a2c6:4a08:7779:5190]) by TYZPR06MB5275.apcprd06.prod.outlook.com ([fe80::a2c6:4a08:7779:5190%2]) with mapi id 15.20.6178.026; Thu, 16 Mar 2023 09:48:59 +0000 From: Yangtao Li <frank.li@vivo.com> To: jaegeuk@kernel.org, chao@kernel.org Cc: linux-f2fs-devel@lists.sourceforge.net, linux-kernel@vger.kernel.org, hanqi@vivo.com, Yangtao Li <frank.li@vivo.com> Subject: [PATCH] f2fs: compress: fix to call f2fs_wait_on_page_writeback() in f2fs_write_raw_pages() Date: Thu, 16 Mar 2023 17:48:47 +0800 Message-Id: <20230316094847.32486-1-frank.li@vivo.com> X-Mailer: git-send-email 2.35.1 Content-Transfer-Encoding: 8bit Content-Type: text/plain X-ClientProxiedBy: SG2PR01CA0126.apcprd01.prod.exchangelabs.com (2603:1096:4:40::30) To TYZPR06MB5275.apcprd06.prod.outlook.com (2603:1096:400:1f5::6) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: TYZPR06MB5275:EE_|SI2PR06MB5196:EE_ X-MS-Office365-Filtering-Correlation-Id: 08f89ec0-114d-4f8c-d25c-08db2603aa98 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: xis5Q4r92xVXeUcPy8YD3mTWZIp007szmL/eyPpBXVDJqphZGx5kTKvIxIf4bSLN1EL6chUW2U2kXsDUINeebhklkWjvfHQF/07EoJVcxC3AhmzUnBbP2syKMl4ULmfgD+Wn3aX8UndpcEuo4BQBqQGSG0Y6GiQdoOSlD0VoSLX4FohpL7l5bzPdbdY3KNpNAw4FjKUvhid2g8eDZtcgviruZ/jJslpK1meJDMNyVXRpu6AXjNk3tzcqZEAbtrJ+Gs0Bscy63vHW7nC2jkKIoRvvXG0bcWofMHxWj2cLMFyKcVtWZfZ2n4urJi0opr3Z4NQka6v0Kh5SvCj4ecu2v+D/ZIlnUv0mu2pVvUc66iBqCPtZNyLmNyyrJa9ihu/7O4g1Bx+P8tWuum+FeZFsZj68zKQewO/2frVTG8qXPONkLzJGKTtOSnyb+kkwggeCURCI0e4xqI0oAsHf4J1zyZs3vGFBg594OM0fzLn5y2+/y0ck9SUdsUz6ydftySsf/oJw/0tQSD+JbLBvkCedU+cfaSlXoEFvdupbU1scSu7VQaj9KeX10Tit7HBKzmn96pIU1mqDfva9BElI5zLmeEB6qVuqVEBWmAZUTx/kJPDEFXIrwWxBxupf1R20vWXjL7NQcGk6BuDKK3fECPteFYC1P8qpIkXtTnb6ay7VMmR916YOKWTh5fc2HpERktImQ/97k5qIXggcTuJpsLOlZw== X-Forefront-Antispam-Report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:TYZPR06MB5275.apcprd06.prod.outlook.com;PTR:;CAT:NONE;SFS:(13230025)(4636009)(366004)(376002)(39860400002)(136003)(346002)(396003)(451199018)(86362001)(36756003)(38350700002)(2906002)(41300700001)(38100700002)(8936002)(5660300002)(2616005)(6506007)(1076003)(26005)(6512007)(186003)(4326008)(316002)(83380400001)(6666004)(66476007)(66556008)(8676002)(6486002)(66946007)(107886003)(52116002)(478600001);DIR:OUT;SFP:1102; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: oRvkElUvCiTIFxFjrWoWjwwDkBk3YuxzzvyeQUz+MU+BpjcIMMkZdF5MvVfpAZxWad0DaSgYg1aeBv438HPYAYnnWE9YCTIceGDCJ30XC9YLD8AiA1Hga3wzapUVWWEUNUqOI2th2cVYGb/1E7GpPtQqlwhRpBELvsM5+UzMdFGi1i7x3zPx73d1ohQrLt/15EsA07DXZPCihPOKIrcHxWF3EsWpJhsZ7pIBGyRHEymR8x7PejWo3rtgYwjpxOd9iw/rOg0EbDLMDMR4YEO8Ifgxtllw0RwJ35I6A7KKfk32tumGdlw1PS6SkKQckVGrEtd9a+dfJ82/m+u9KIgjDvpon4llk++T/LmnmbYtixFVCQNqe5fBYj0XnXlQnvAs7RDDPuoqA+Ql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+z5iE6snHXYkvZjwvClSnu9TgViBTlFWF0cwjp0gozCtJW6k/9cS/t7Sz9QM08L14bYoOZLQenNvxAaFNnZQtCrk43Qo6H7urcWedAOS9+HOKmWgPl6gJd6o7g0BXc X-OriginatorOrg: vivo.com X-MS-Exchange-CrossTenant-Network-Message-Id: 08f89ec0-114d-4f8c-d25c-08db2603aa98 X-MS-Exchange-CrossTenant-AuthSource: TYZPR06MB5275.apcprd06.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 16 Mar 2023 09:48:59.2893 (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: 4ZpnFlj5lfeSjsE9jg5t8bpvmWC9awYrdNvs8b4hYZLiqgCdfl7582Y4T4YiKTp3gZGt0OviXla1ZQo4DUGmJg== X-MS-Exchange-Transport-CrossTenantHeadersStamped: SI2PR06MB5196 X-Spam-Status: No, score=-0.8 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_NONE, RCVD_IN_MSPIKE_H2,RCVD_IN_VALIDITY_RPBL,SPF_HELO_PASS,SPF_PASS autolearn=no 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: <linux-kernel.vger.kernel.org> X-Mailing-List: linux-kernel@vger.kernel.org X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1760517954294240006?= X-GMAIL-MSGID: =?utf-8?q?1760517954294240006?= |
Series |
f2fs: compress: fix to call f2fs_wait_on_page_writeback() in f2fs_write_raw_pages()
|
|
Commit Message
李扬韬
March 16, 2023, 9:48 a.m. UTC
BUG_ON() will be triggered when writing files concurrently, because the same page is writtenback multiple times. 1597 void folio_end_writeback(struct folio *folio) 1598 { ...... 1618 if (!__folio_end_writeback(folio)) 1619 BUG(); ...... 1625 } kernel BUG at mm/filemap.c:1619! Call Trace: <TASK> f2fs_write_end_io+0x1a0/0x370 blk_update_request+0x6c/0x410 blk_mq_end_request+0x15/0x130 blk_complete_reqs+0x3c/0x50 __do_softirq+0xb8/0x29b ? sort_range+0x20/0x20 run_ksoftirqd+0x19/0x20 smpboot_thread_fn+0x10b/0x1d0 kthread+0xde/0x110 ? kthread_complete_and_exit+0x20/0x20 ret_from_fork+0x22/0x30 </TASK> Below is the concurrency scenario: [Process A] [Process B] [Process C] f2fs_write_raw_pages() - redirty_page_for_writepage() - unlock page() f2fs_do_write_data_page() - lock_page() - clear_page_dirty_for_io() - set_page_writeback() [1st writeback] ..... - unlock page() generic_perform_write() - f2fs_write_begin() - wait_for_stable_page() - f2fs_write_end() - set_page_dirty() - lock_page() - f2fs_do_write_data_page() - set_page_writeback() [2st writeback] This problem was introduced by the previous commit 7377e853967b ("f2fs: compress: fix potential deadlock of compress file"). All pagelocks were released in f2fs_write_raw_pages(), but whether the page was in the writeback state was ignored in the subsequent writing process. Let's fix it by waiting for the page to writeback before writing. Fixes: 4c8ff7095bef ("f2fs: support data compression") Fixes: 7377e853967b ("f2fs: compress: fix potential deadlock of compress file") Signed-off-by: Qi Han <hanqi@vivo.com> Signed-off-by: Yangtao Li <frank.li@vivo.com> --- fs/f2fs/compress.c | 8 ++++++++ 1 file changed, 8 insertions(+)
diff --git a/fs/f2fs/compress.c b/fs/f2fs/compress.c index 93fec1d37899..904af359fa8e 100644 --- a/fs/f2fs/compress.c +++ b/fs/f2fs/compress.c @@ -1456,6 +1456,14 @@ static int f2fs_write_raw_pages(struct compress_ctx *cc, if (!PageDirty(cc->rpages[i])) goto continue_unlock; + if (PageWriteback(cc->rpages[i])) { + if (wbc->sync_mode != WB_SYNC_NONE) + f2fs_wait_on_page_writeback(cc->rpages[i], + DATA, true, true); + else + goto continue_unlock; + } + if (!clear_page_dirty_for_io(cc->rpages[i])) goto continue_unlock;