Received: by 2002:a05:7412:31a9:b0:e2:908c:2ebd with SMTP id et41csp3097379rdb; Wed, 13 Sep 2023 01:42:31 -0700 (PDT) X-Google-Smtp-Source: AGHT+IFDzh2acISaJKhHUfKtLxNqN97YcDgHnM3+8ptFDXc0+d9g5pPEHIhbfibZtvQap53oi2iV X-Received: by 2002:a05:6a21:18a:b0:13d:fff1:c672 with SMTP id le10-20020a056a21018a00b0013dfff1c672mr2108081pzb.4.1694594551501; Wed, 13 Sep 2023 01:42:31 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1694594551; cv=pass; d=google.com; s=arc-20160816; b=OG4fPx0sUTgKIzE6ABg3GBp3crwvLlPhkV0mjPhfCq0ip4TLQeqnz34NgQaXd/3eY5 0w2Oa8Ho4PR4wHkPAY+vSSPB4k+3VCGnMGGLUIQBlDLVZw7RQxA7KEdvFCivaFfkL71F wTA++K9qz/fWVx2+/t64qjnqKC7wg5t5GoIhJnzJ4yh4mClrv2gXGczApJB2MWeHOaAt KK6awXLMDq6ZJPRpoTrOiAGH2jqZg7xnLFYWT/LZDK0PI4rOZdy9uApd8poVjUZS1md1 wFDJ9/6CYpo/1Vl/qvdeyiPQyvnW28udGx7UVUCt/D/MD7pAKY95K6PJCp4z7GLNhQbG HN3A== 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=leHni/rV083nmaV95ijUmrfz99VzOQVFds0i7ZePYm0=; fh=TnvRJIKuyI3P3Bf2FKdmHFYplSUKcv/cC843hhYcB48=; b=uYXYRWK/8nrOsO8lWaKSHQjiz/lVXxXuBC0dFunwkJHp5MG3A46BCFH6CPrB+wmVd9 EcYNOmPZQvmH+KCZ/fDWpYCQe2QLocWUq/mKxy/JlnlP+lEVFyanSBq9lC1378i11F6V /jY8rQiccZj+VXDd72MX8rfWNaj5MVDOCcf28eWnWVkYknaHQPS2Ow3L+aQI5xFlEgtJ 6o00R9OQWrVnvQpCeEhdEVVHxJNRv/2VyysVxzTkYyIcojyHtR38uz4G2ZFvKEEq7kAF JV+HX+0aojGL4ge2kPdAleLgBP1ecQtYHm2qXxZRwnCHmJN+jUfPv1EFXsowEVa//1zF 2Jzg== ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@vivo.com header.s=selector2 header.b=ocEFRGtg; 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:4 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=vivo.com Return-Path: Received: from howler.vger.email (howler.vger.email. [2620:137:e000::3:4]) by mx.google.com with ESMTPS id m3-20020a170902c44300b001bf298450d5si9345343plm.211.2023.09.13.01.42.31 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 13 Sep 2023 01:42:31 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:4 as permitted sender) client-ip=2620:137:e000::3:4; Authentication-Results: mx.google.com; dkim=pass header.i=@vivo.com header.s=selector2 header.b=ocEFRGtg; 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:4 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 howler.vger.email (Postfix) with ESMTP id 17332874E644; Tue, 12 Sep 2023 07:13:55 -0700 (PDT) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.10 at howler.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S235011AbjILONj (ORCPT + 99 others); Tue, 12 Sep 2023 10:13:39 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:50322 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230151AbjILONi (ORCPT ); Tue, 12 Sep 2023 10:13:38 -0400 Received: from APC01-SG2-obe.outbound.protection.outlook.com (mail-sgaapc01on2091.outbound.protection.outlook.com [40.107.215.91]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 6EFF6CF; Tue, 12 Sep 2023 07:13:34 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=eTevNafkAoHQSc9cnxt9Od69WIGxt5+nqsA9RfCGe49L8UvkWJsSixx+8VlnojKe4xtk+oCi6wUyZx6gC3UAd8gJVdZhwVR5DFLTZ1i7TTsay5cwZwLL6xBWoRLr3bHXgafENrbkx02ttWWoYF/xBad+9BYtFb9ePfMXNnqyJAuSa/5yI92Tg52RmHowX3ay2jagd3pXop83g72tGvdzo5gNCDFi/J2CGMKcdCS4m+voINbaB/2iOw1qt/kBkvJhFElS64s+PgqGwerpDIcRcf7Wfbiv1RxLFiBO9nUbC/nq5Ha5yqRky6MGQj7YG/b87bOrQzAB3csThk6OeakQww== 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=leHni/rV083nmaV95ijUmrfz99VzOQVFds0i7ZePYm0=; b=kp+Exg6MUMW+rQ5n2vaxwO6T4ZgToxzrnufKTJZEBMjSCHncg2TUZNuiYNrP1/DqzDGY3K+4fGXzPA/UOzYllXY1pkXXW84kd+Jif2BQvJg+JlbOFz5JTagnTepIFVWPYRk1+v8Rr0YMUD693I1xIlQ52gPTV87d48CCiFtXiDUk8nn+zaZsaH+5zZd5TG04B77gwR7dFtJJa0mEEmTGQUApcrIhPyvCDRpw6GDBOcVpazhiA3+V6M1OXvk4DDLlanquGS3R/u+dBhR6BTFDXDmyRkaa5Ab4eU9SM/lAYDZt7uCy3QVbLgqTKhpIru5kzgNIp4ewrcKcfMqX2zWydw== 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=leHni/rV083nmaV95ijUmrfz99VzOQVFds0i7ZePYm0=; b=ocEFRGtguinMhlDStF+Ppiyzb/RXey1PYperpn0XGBwe7fCeW6pnL8gZK+peY6zbtODqQZ8FFBvv0fj2e5JHPg6UTM7qmEPWm+OhUC1bht3GKUX1U4L06EGxsUy523IXY/j61sqF5rMHg4tCTokvQBMwtxvuWVG3xCJQinUdm7r8wmgse6lEOyfFTBBU1Cpv7NEiyJl0jM/mA498qA1KebOAo6G0yok1Mkt8rGekzi1Z0wGlYuf6cd4VcULdoYqB/WmX6BfglJmI/+fU6RF15fjxW4ezJSIXEmDJY5Jzdio0YvLOMTJK3EpXCr2KkNV3bc+fAifBUIsu5NSsd6cUig== Authentication-Results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=vivo.com; Received: from SG2PR06MB3338.apcprd06.prod.outlook.com (2603:1096:4:97::23) by SEYPR06MB6108.apcprd06.prod.outlook.com (2603:1096:101:c5::7) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6768.30; Tue, 12 Sep 2023 14:13:27 +0000 Received: from SG2PR06MB3338.apcprd06.prod.outlook.com ([fe80::1c:4eaa:202a:5485]) by SG2PR06MB3338.apcprd06.prod.outlook.com ([fe80::1c:4eaa:202a:5485%4]) with mapi id 15.20.6768.036; Tue, 12 Sep 2023 14:13:27 +0000 From: Chunhai Guo To: viro@zeniv.linux.org.uk, brauner@kernel.org Cc: chao@kernel.org, jaegeuk@kernel.org, linux-fsdevel@vger.kernel.org, linux-kernel@vger.kernel.org, Chunhai Guo Subject: [PATCH] fs-writeback: writeback_sb_inodes: Do not increase 'total_wrote' when nothing is written Date: Tue, 12 Sep 2023 08:20:43 -0600 Message-Id: <20230912142043.283495-1-guochunhai@vivo.com> X-Mailer: git-send-email 2.25.1 Content-Transfer-Encoding: 8bit Content-Type: text/plain X-ClientProxiedBy: TYCPR01CA0023.jpnprd01.prod.outlook.com (2603:1096:405::35) To SG2PR06MB3338.apcprd06.prod.outlook.com (2603:1096:4:97::23) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: SG2PR06MB3338:EE_|SEYPR06MB6108:EE_ X-MS-Office365-Filtering-Correlation-Id: 0ae9490e-d969-4148-2201-08dbb39a6e78 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: R91rs0aEI5Pi6wpsz4/uafXsCg2R/EFhZHrxe3/q4Afqjo1iuC7lvPQHCGJpMXLkZhS6wp4KVog4lham3aa5K0o+avi2IOg5TPBIS37pmeMdV/JRI7qc4iMptP0vXC4oZrv3n0uuKoOEgOrdu8f3oMSrJ6cZfdU+OmgUo4XBvrTzNTZ1SF8EVpZxIBO5v0lLp0ylIt8g/Wl/muKPV+R3BodhDGj2OvXts5FqAX2i90or6nCAwJhPZuNRtLdtmVCyzwSs38BrVwEXuReU2yG9Ogpg2YbsEIvq5rL/Iw7kfQ8/EVQKu4yCnWAN5X17K3eejBYXq1MTb2KTSADU52M5GuqmzXFLfxouLHj/FVbLe45EFuISQGHKkshAldWXS1OMBW3iVHU+GgO3BnBPStBnCDMg0+DjI2Hy0lTvMBSL5uWIhpK0je3EHFQVHfnM8rXfaIj3xidkrk5ourAKbwcjgCXplAj0C6M9oJE0FTOM6HKAPa9TU8hH/bzCNj3RHcfAk74Z3ydiGUbKuLOYBto37Gf9JnIvHz+W6OQQCHMBnC14j4klPfOhwzNQUKln6SVVJYW0Wu+pAPpfEaN4itfs5s69Pi9v9+7TCrIKtpLbU6EFXFm3HWzsDB2AXFE5WMwG X-Forefront-Antispam-Report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:SG2PR06MB3338.apcprd06.prod.outlook.com;PTR:;CAT:NONE;SFS:(13230031)(136003)(39860400002)(396003)(376002)(366004)(346002)(1800799009)(186009)(451199024)(41300700001)(6486002)(6666004)(52116002)(6506007)(478600001)(6512007)(83380400001)(66476007)(107886003)(1076003)(26005)(316002)(4326008)(66946007)(66556008)(2616005)(8676002)(2906002)(5660300002)(8936002)(36756003)(38100700002)(38350700002)(86362001);DIR:OUT;SFP:1102; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: =?us-ascii?Q?GMnLJqIRqiJm0/bvZkhWH4qoy6bSfrbNcNzhrUna67qTKXbhH+NvGuXukDl9?= =?us-ascii?Q?gRlcH5glOey/OYOUKzmFAkpWtApTEk3WroE4AvyIam0/O61OF1SyrGFq8XwU?= =?us-ascii?Q?Fvnu+2Fd2iJJwmnuCZZfLKaaj1o6w0M/Vop/vutVVtiDVQE4PgO3gqwWAYWq?= =?us-ascii?Q?mvg2Z9hHuf1T5yPjvcpgfqjaJaYXzOGmHF0B1gCIO+UphM5z792AcHWVB5qj?= =?us-ascii?Q?qA17yOa/vr1+OzHlRR8LMLo+Pl2NQg4BfG+sryAMW6aIbY8ezLSmghTuDvyr?= =?us-ascii?Q?vPfUqWvoyFe8yRnBtY0OQVw5yN/goxnz8mMtfiUyZ0SVZeJJ3DS8/djIM1sq?= =?us-ascii?Q?RrwEU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jd3w8MnyXOIr5N2TAKJYGWfWl?= =?us-ascii?Q?KEZx+OkFXTOETD+d24QdUAinkjXaFcqysnGAemywM5n/DgHejSNUEQCWezwy?= =?us-ascii?Q?pJJi4+nLvnz48c0mMr4W5hcN16TmfAB5nbN8LW0AVuAqqx7OOZ2a9jSgLlHF?= =?us-ascii?Q?fWiYIIBvrZ5uMuOwV9+pfiJCZld6eoy6Gpb+pRZ6MaxRzmd3otQXMP8hAutU?= =?us-ascii?Q?Qd1MyxERBSsiiMd2IOPWJohMWabPgz0XORHcfXPFo9dQ1J5bYtnB1QXsnidx?= =?us-ascii?Q?blZtyVFbezbgzRroao5z8MMGeVgFjwhmJI5nioCS5TN9yokzS8yxh5ADTz4N?= =?us-ascii?Q?O4bRmOY1xOmVNhSW4cK3jGMTKmmYXzEu7n9rkDyj?= X-OriginatorOrg: vivo.com X-MS-Exchange-CrossTenant-Network-Message-Id: 0ae9490e-d969-4148-2201-08dbb39a6e78 X-MS-Exchange-CrossTenant-AuthSource: SG2PR06MB3338.apcprd06.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 12 Sep 2023 14:13:26.7325 (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: kpNJa8+EaNrHuxaHKBEkN4Fr5PcHIasQYfkrh1BonpjOqMB/J+Cty7iwT6Bl5Cro4GfP6ZL7rMjK9H3yiCyiqA== X-MS-Exchange-Transport-CrossTenantHeadersStamped: SEYPR06MB6108 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 (howler.vger.email [0.0.0.0]); Tue, 12 Sep 2023 07:13:55 -0700 (PDT) I am encountering a deadlock issue as shown below. There is a commit 344150999b7f ("f2fs: fix to avoid potential deadlock") can fix this issue. However, from log analysis, it appears that this is more likely a fake progress issue similar to commit 68f4c6eba70d ("fs-writeback: writeback_sb_inodes: Recalculate 'wrote' according skipped pages"). In each writeback iteration, nothing is written, while writeback_sb_inodes() increases 'total_wrote' each time, causing an infinite loop. This patch fixes this issue by not increasing 'total_wrote' when nothing is written. wb_writeback fsync (inode-Y) blk_start_plug(&plug) for (;;) { iter i-1: some reqs with page-X added into plug->mq_list // f2fs node page-X with PG_writeback filemap_fdatawrite __filemap_fdatawrite_range // write inode-Y with sync_mode WB_SYNC_ALL do_writepages f2fs_write_data_pages __f2fs_write_data_pages // wb_sync_req[DATA]++ for WB_SYNC_ALL f2fs_write_cache_pages f2fs_write_single_data_page f2fs_do_write_data_page f2fs_outplace_write_data f2fs_update_data_blkaddr f2fs_wait_on_page_writeback wait_on_page_writeback // wait for f2fs node page-X iter i: progress = __writeback_inodes_wb(wb, work) . writeback_sb_inodes . __writeback_single_inode // write inode-Y with sync_mode WB_SYNC_NONE . . do_writepages . . f2fs_write_data_pages . . . __f2fs_write_data_pages // skip writepages due to (wb_sync_req[DATA]>0) . . . wbc->pages_skipped += get_dirty_pages(inode) // wbc->pages_skipped = 1 . if (!(inode->i_state & I_DIRTY_ALL)) // i_state = I_SYNC | I_SYNC_QUEUED . total_wrote++; // total_wrote = 1 . requeue_inode // requeue inode-Y to wb->b_dirty queue due to non-zero pages_skipped if (progress) // progress = 1 continue; iter i+1: queue_io // similar process with iter i, infinite for-loop ! } blk_finish_plug(&plug) // flush plug won't be called Signed-off-by: Chunhai Guo --- fs/fs-writeback.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/fs/fs-writeback.c b/fs/fs-writeback.c index 969ce991b0b0..54cdee906be9 100644 --- a/fs/fs-writeback.c +++ b/fs/fs-writeback.c @@ -1820,6 +1820,7 @@ static long writeback_sb_inodes(struct super_block *sb, struct inode *inode = wb_inode(wb->b_io.prev); struct bdi_writeback *tmp_wb; long wrote; + bool is_dirty_before; if (inode->i_sb != sb) { if (work->sb) { @@ -1881,6 +1882,7 @@ static long writeback_sb_inodes(struct super_block *sb, continue; } inode->i_state |= I_SYNC; + is_dirty_before = inode->i_state & I_DIRTY_ALL; wbc_attach_and_unlock_inode(&wbc, inode); write_chunk = writeback_chunk_size(wb, work); @@ -1918,7 +1920,7 @@ static long writeback_sb_inodes(struct super_block *sb, */ tmp_wb = inode_to_wb_and_lock_list(inode); spin_lock(&inode->i_lock); - if (!(inode->i_state & I_DIRTY_ALL)) + if (!(inode->i_state & I_DIRTY_ALL) && is_dirty_before) total_wrote++; requeue_inode(inode, tmp_wb, &wbc); inode_sync_complete(inode); -- 2.25.1