From patchwork Tue Oct 25 06:50:24 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: =?utf-8?b?5p2O5oms6Z+s?= X-Patchwork-Id: 10518 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a5d:6687:0:0:0:0:0 with SMTP id l7csp846528wru; Mon, 24 Oct 2022 23:53:43 -0700 (PDT) X-Google-Smtp-Source: AMsMyM5vX1FGXayaKcCm8Wyx1+bTs++5JVEau0Q1bR/7t+TZ7tCJVn+MIrK/u3Z6sPIlLEQdHkve X-Received: by 2002:a17:907:2bf9:b0:7a4:bbce:dd98 with SMTP id gv57-20020a1709072bf900b007a4bbcedd98mr10814398ejc.669.1666680822901; Mon, 24 Oct 2022 23:53:42 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1666680822; cv=pass; d=google.com; s=arc-20160816; b=STMEVbazCC6qsIbZo70t5k4JnDMx7DYYsAP/nJDw2zKGJSfvFJ85kX9tU1v9iaYkoO VLeIHx9fjdH7Gwhpyoro0PQ4zZXqYiKAmB4P7ZEs+1VSKmEzcMlsBH1FZZhg75/e242Z v/0l827YiPk+hKjI2SjBCyiaq6qCb1rZbCpiU8Pz8/Da9/MSPdcgrg3IrMEFWeTBD2cF B3pdLpjPKov0N+ildRBZV3cKGu7jJMl1ytXGA2XzGXasrNlvsVIlrxral3rXGfx5Ur4E fBK1V8UPpsmVbchrb2xYWXmx4EnMEcrCo+DHNu0EmoQ6Hz8v9JDrQpn/T+x4HX+BvXHc km8w== 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=pysNbN8VkIYU1DHkLWkHGGdk2yU2bixq+963nWnPWhM=; b=fEF3rTN/SIqG0SzE3qxCpbh5q0TlKFUOIPDkfAqTeS03tBmynQTAO9q4PyAkQMbeDp F+jQmzNZfVpO7n8dW0g0G/udEBNShGhcnbdd8SMhs01DgsW/dcKKY/s5njVLyg98Ghx3 DxjQEb/SnQBRSgHHdjkzkoQv8dUL1gQZZllc0K3PJR6ZLF20bNsip4bfehT3v6ixQQpf BDUSG361RhD4Nr1WlJS7PnllySo3O9gJx+EnvnLKav3JCapnN8uQJIdwOWzW8c9VQT2o bubka9Tp+xs9+hphOt4c4Xh+ncAiO81nIWwPkZW2uFrMgSegCOBRrL4SGzQObJe3jee2 nFSw== ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@vivo.com header.s=selector2 header.b=G5fo14ZM; 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 sb31-20020a1709076d9f00b00780805b99ccsi2076905ejc.648.2022.10.24.23.53.19; Mon, 24 Oct 2022 23:53:42 -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=G5fo14ZM; 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 S231355AbiJYGus (ORCPT + 99 others); Tue, 25 Oct 2022 02:50:48 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:50892 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231263AbiJYGup (ORCPT ); Tue, 25 Oct 2022 02:50:45 -0400 Received: from APC01-TYZ-obe.outbound.protection.outlook.com (mail-tyzapc01on2117.outbound.protection.outlook.com [40.107.117.117]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id C54EC3FD42 for ; Mon, 24 Oct 2022 23:50:43 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=YiK2NTfpgctk3RV/hV3PQ2v8yYdhdJ98/QPmuzWKVMUX3yljjP+ryIL7dvZAPMOCXISscGL9Hz2VTHnhy8AAKIg3LUgA4TuZ0PXacx6EFqeh0PpEn6NHnBnSXQMM6mC4yUpZX0m6nITQ5MFgDFDDpJ8Gmpzv9k8ypm1WMwNZkGy+XFpFj5QwSxmMu9BtI7yjpaQ789w0WxuOHcUX38Fy3QuB9iMrSjyTAb+Hkwan6pn2vXn/s34PEMavhcIn1MjjaimTq08QLQKNZq0cwzGam4NY+3DmO92RYvWZomlnKyEkZq8DpnQzTy0kqawtnb52oBdjXnz9TiYEr/9t+515Gg== 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=pysNbN8VkIYU1DHkLWkHGGdk2yU2bixq+963nWnPWhM=; b=j2fbZMB95QxcTzoQPhp8ljmrcx04NVgXm2dCE2n+m9IS9pNqRCaGYaN9NjJjrkxdSgggovS/6yiUc5Mvesf/mhe1HYpbDwdEuIlnDWNWR1b1GfFazRTJGIy2zB1Y5M86dYkKYqIa4ru9Wye3GuB1BXMSBlIJRzK4T97rAiL51TyKVob2++DWZhVpsU8EiUbyurbXqx7royayEMfwiaYaGsu6OJMg8ERGc8fRkxn8o1tQK5TTbRvSCJDScwp7Z01QYJ552duP7MjHIeTWZy/syqm0p5TLF9N1Cnc5F5Ij+aBNTBUTzpj5KjYnYnewhqvCCWkDhwqpwhe1HuDZLYc0gw== 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=pysNbN8VkIYU1DHkLWkHGGdk2yU2bixq+963nWnPWhM=; b=G5fo14ZM9ZQt0h7gbCEY8VZ/Ej+xmofIJFqJIk+OBbgv234xul1CExDbCMzGTY/LJkrEyzZe2ysS6iAZLX/lrq2Upu2nQXJHHzms8BKW5N46uGDxMvWW0IxmwyCdSv2v2VQ70yepgBV0/E/nIDfcytuHruh75JcHqAyazTUEcIxS4vM8oobfuNiEJxa+Pt4CypMFb5/IZfdgKbEHK4N5eZtr9efacXQ0jkeY2/DCzm49LXu0ooNhao8ZZpARy+rvZiwyAErGOURiu6+DoajR8z8QaIPjY6y1NAfQ06/iZ0uAZ24n01XyJbcXLCaBrVFmoh5HYaAQTk4vH/Jna2PZow== Authentication-Results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=vivo.com; Received: from SEZPR06MB5269.apcprd06.prod.outlook.com (2603:1096:101:78::6) by TYZPR06MB4144.apcprd06.prod.outlook.com (2603:1096:400:20::11) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5746.28; Tue, 25 Oct 2022 06:50:39 +0000 Received: from SEZPR06MB5269.apcprd06.prod.outlook.com ([fe80::c84b:5a6c:d66f:c0fd]) by SEZPR06MB5269.apcprd06.prod.outlook.com ([fe80::c84b:5a6c:d66f:c0fd%3]) with mapi id 15.20.5746.023; Tue, 25 Oct 2022 06:50:38 +0000 From: Yangtao Li To: jaegeuk@kernel.org, chao@kernel.org Cc: linux-f2fs-devel@lists.sourceforge.net, linux-kernel@vger.kernel.org, Yangtao Li Subject: [PATCH v2 1/2] f2fs: fix gc mode when gc_urgent_high_remaining is 1 Date: Tue, 25 Oct 2022 14:50:24 +0800 Message-Id: <20221025065025.35017-1-frank.li@vivo.com> X-Mailer: git-send-email 2.35.1 X-ClientProxiedBy: SI2PR02CA0053.apcprd02.prod.outlook.com (2603:1096:4:196::16) To SEZPR06MB5269.apcprd06.prod.outlook.com (2603:1096:101:78::6) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: SEZPR06MB5269:EE_|TYZPR06MB4144:EE_ X-MS-Office365-Filtering-Correlation-Id: 23d3b9ec-fd59-4512-2f21-08dab65539e5 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: +SBk8FG5R/a9qTKsWvuMehyFkRR2IF0HKhw74AXaX7ELh7kBEmMUQpO3CpaXC7A388KZmVQuJTrN7pBbXp6H1xzJ4vqwFAS2jiLtqmqLjvBCwvoxisXa99gOAYwTwAmResZXA/YM4r9x6yht/8ZjhnLmQrA3He5us37H9zEohWJdrhEfgLnw0aWowBQp+8t23El9J3zeslqCHfmIjEWjL3vyt0V6z3Z8yFK/YvDfoUU5pCfmZeCp1nk7QSoEj99Yz0eW49Bqr6kFCllW0m3NjynoHRLYZh6Fq/UM/VQSGxPAZfoeosEuqfL3/28fmKv4PkO/hVfn4Yxu79Ii9qmjKnUSqJbaadWosYEuw7CSuD6Wm27g/fYpMQ1o6rEVtNeoLt+WplHVIzWJK/kd2iXT/Sy3BmW4fSmDhc7Mm+IbnL2L1JhOUWPlXnTQ09P3yXWOCpCazc2UuVPzc+0C74OaJcyleM+HpBWKJoB58vEUrICN/hcCS7LIm87LbR9Eww395shGCZfeFwWRuPefbUjAxYLBHNINS6+KxGtImlxGq+O5bGDmBDGBZwrS6d18uZYtTcZvXD48iG8LAQVHc7Se3FQU0JAuJG9p5riRHiwMPtdEFZWpJg7cyTcKKKGDo9MO1t9b3XVAWrg8k4Y07yKVmYSc4TVseYYI6lK/lig1R/Pzf1ZZas2FYTpyylEdNvgf0CP2KmBNCjP+aGcW//0jstiy19O5lzljp1vRpBn5CE59etWjz1411tNIzMPIosQ1oB5jmznrSTbce/dVEn29dw== X-Forefront-Antispam-Report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:SEZPR06MB5269.apcprd06.prod.outlook.com;PTR:;CAT:NONE;SFS:(13230022)(4636009)(346002)(366004)(396003)(376002)(39860400002)(136003)(451199015)(83380400001)(186003)(1076003)(6512007)(2616005)(2906002)(26005)(38100700002)(5660300002)(36756003)(41300700001)(107886003)(6506007)(52116002)(6666004)(38350700002)(66556008)(316002)(8936002)(66476007)(4326008)(86362001)(8676002)(66946007)(478600001)(6486002);DIR:OUT;SFP:1102; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: gQao9MpCOpmIC/yayS6K1nxvhQij/9GI7MRnsBcMy2B/Xa58YL+EP1WVOMKlvxV3bb+xTIO3SpeYuHqszSmskenLwj2Nn46pOMb6dt5UcLnVVD0guRcAsyURdfspyNToB4n+PHNgXSUVeio7vNJXvkMp40Ul0wvfmuxFNIox3sBWTm9rgX88v4fur1EhSDpE29Qaqxn0pvazQijRx8/Z8RhCKYm/vR/CkX7tcpIuoe1iGRC7GvZIldo4VHnWGEeQX83dzccvyatxxInKPuCiOPEa2BS7jjZ4zypwNo3EWZCwjs0ccXc3ie1a+vkojkFwqYAvIBY6V53rtPAOccvwdHdzbi9erTrzGNx9M5zAobcFre1M4WXG7knLg//kVOLGFyLX8wqLH8iBnoU4OrDPDIfXCwyMKGMTTeqT6LMB6tSx+2PkX0aKoL7ikCq4XZ7q8kqY27Xbhk8JLyQ/WV+qlNe0a8UmBxyM8RH0KC9zkxOqI2SP/u5EZ5n7SEW+iveXaXGYFc1uU0Fz4p2EN5jisqxyvcUNiQnpTUoR0kMQ2yZPxMfJJh2RYGYHWBRcuB3JrVawAeW9NZkPsTOk5XKgsjsJFMzJsx4Gg+Ca7YjEoEhAiSnmGSIdK4ckgLSiW3tOQhWJadnUPkbwAyj0JyONFkeUgsBoHHyrb9cwLJ3hoUpsEyCCEZrf3DYR76giNTrr1/6gyO3fQP3bIPGCJYMHquIxDpaiEDx0rrA9y2H1145z9wU1NDQFIA6wLKU0Ii6s5JWq4YwUA75/XN1Pyuw/5qCnzIxp61EbmxKh8d4eIyHK8XjOLnvDFXCn79U/d6bE/WGKsexeevPumHBHAqFR8hcmrPML2Xlz9O03tP9MmK4NzrK8bzMAsudpTycAFx0KHxc/5+/DiRUEXGE6dt4rFb42278Etpxxzj/bHZ+/5Ea8ER0J+Nww2BMzQMr8qW4+oDn8Gb4astwLcjYQXXb5sPYdT/XB+fJvzv0BdLPWjJq4mMNMX+XAA43EVF3mc0sXybYYZxAhrJzpd4deroLqPAyiWryvNjyxWMRK4g/bswM2ymQ/01NFR2YpDhKWCMWI4pmrEW/Dnhw4yN8D0UOHmfMvrQELF223Hqvg2eJiZx6rgK0883aqkavLT9yeotNDdNux1v54L2cnF7tqFL7vx06+aqg9jlwMMXM3SYLKLNsPo/k8SyQ4+/Jz3S/jGpyY6kwMWHCvcYppGrbMSCKnRN3MGgJO4fhO2sdAjvsivohiXr6WrIu9fo6pAL4zLu2JRFPQF4DPr2RgeWImrjFeociXDlMw7PtY+K/03ZCvRO12Og3ysIAyi5nBeysN3xKifkycJYDDoT4dHX8jFUxS2uKPw9EehGin2JDB6GJWeXxvKeGaL3hwFrmESJ/NxI3XK9iLRRX9bB4IIQEMpJ/bJJyFcluK28corJI9sklu2hMXq7nYMc/RQg7NifZGHOkf4DcNRtALcJ+0CzD6n+dnLG+z19mvx3hnB4LuSYK1yItpPp6dcPFg+YLUjPIIiCigaz/EM4qDQN7GU4anFR/KRRdIFk5rVZDYtzac4WbzGb3q/wV2mVxdzxxZ5jDxSDgt X-OriginatorOrg: vivo.com X-MS-Exchange-CrossTenant-Network-Message-Id: 23d3b9ec-fd59-4512-2f21-08dab65539e5 X-MS-Exchange-CrossTenant-AuthSource: SEZPR06MB5269.apcprd06.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 25 Oct 2022 06:50:38.7861 (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: x9mhJ53lKDjb+N1zBJJlJkYXMWlT5TJLo1ifgfs7MQ56L/+Jj3rhSdkggihPMNdebXAuMkfAzdch3t29Use7pg== X-MS-Exchange-Transport-CrossTenantHeadersStamped: TYZPR06MB4144 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_NONE, RCVD_IN_MSPIKE_H2,SPF_HELO_PASS,SPF_PASS,URIBL_BLOCKED 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-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1747641510785632422?= X-GMAIL-MSGID: =?utf-8?q?1747641510785632422?= Under the current logic, when gc_urgent_high_remaining is set to 1, the mode will be switched to normal at the beginning, instead of running in gc_urgent mode. Let's switch the gc mode back to normal when the gc ends. Fixes: 265576181b4a ("f2fs: remove gc_urgent_high_limited for cleanup") Signed-off-by: Yangtao Li Reviewed-by: Chao Yu --- fs/f2fs/gc.c | 19 +++++++++---------- 1 file changed, 9 insertions(+), 10 deletions(-) diff --git a/fs/f2fs/gc.c b/fs/f2fs/gc.c index 4546e01b2ee0..e0ff99c7e3f2 100644 --- a/fs/f2fs/gc.c +++ b/fs/f2fs/gc.c @@ -96,16 +96,6 @@ static int gc_thread_func(void *data) * invalidated soon after by user update or deletion. * So, I'd like to wait some time to collect dirty segments. */ - if (sbi->gc_mode == GC_URGENT_HIGH) { - spin_lock(&sbi->gc_urgent_high_lock); - if (sbi->gc_urgent_high_remaining) { - sbi->gc_urgent_high_remaining--; - if (!sbi->gc_urgent_high_remaining) - sbi->gc_mode = GC_NORMAL; - } - spin_unlock(&sbi->gc_urgent_high_lock); - } - if (sbi->gc_mode == GC_URGENT_HIGH || sbi->gc_mode == GC_URGENT_MID) { wait_ms = gc_th->urgent_sleep_time; @@ -162,6 +152,15 @@ static int gc_thread_func(void *data) /* balancing f2fs's metadata periodically */ f2fs_balance_fs_bg(sbi, true); next: + if (sbi->gc_mode == GC_URGENT_HIGH) { + spin_lock(&sbi->gc_urgent_high_lock); + if (sbi->gc_urgent_high_remaining) { + sbi->gc_urgent_high_remaining--; + if (!sbi->gc_urgent_high_remaining) + sbi->gc_mode = GC_NORMAL; + } + spin_unlock(&sbi->gc_urgent_high_lock); + } sb_end_write(sbi->sb); } while (!kthread_should_stop()); From patchwork Tue Oct 25 06:50:25 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: =?utf-8?b?5p2O5oms6Z+s?= X-Patchwork-Id: 10519 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a5d:6687:0:0:0:0:0 with SMTP id l7csp846548wru; Mon, 24 Oct 2022 23:53:45 -0700 (PDT) X-Google-Smtp-Source: AMsMyM6d+EBoxCYyNvePhrs6AIM57yjo0vUD5mCgC4uFDeqa7idFsXJCI5JSVnG3XzTKk9GfiAOb X-Received: by 2002:a17:907:6d8c:b0:78d:b65a:ab12 with SMTP id sb12-20020a1709076d8c00b0078db65aab12mr29339973ejc.573.1666680825434; Mon, 24 Oct 2022 23:53:45 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1666680825; cv=pass; d=google.com; s=arc-20160816; b=oCLN+7OkO4HbT+Gnthf2qb9Zb1agnoLyMRbCcTN03SDVbPw3n12Brqz7GMftOPouhR YH3TVDRxw7vRN+Q59uvSLzdpx0k0e96LASsPVYnuemGu0pnfLE9w+5a2WxAqkKu05+/q lq7Th0y+OXhIk24qNi2pyVcij2zPsZpHoSVdNzH5SQm9QUHn33PcjtU1LpSTGYYTcjMf 6BUkB8qJTDeyr7q5j0EzK9+xXc+jU9mDeRkYswnzwpdXRRxw+0DyiPDAynbbKJ+4ijvF jFyZ0mILfXvi+9hCE15bDhDsrsCaWBn2otXeRX0bLa+TeStfTKFNaq4xmKW7K3QRalv6 +E0w== 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=9kTFwIpKCO41V09Jhhe6dgE98wIEtEgOZvh9GCH28zs=; b=yh6veamWXjF1+o/i27thIEqmWalIGByBLXJ55UTWiYrj+2ja7J9esZqBadbSS2JJ7E O18GqgJ7aSoG/vam/iODYRigjB4S9Stky9ELNpyaODSD4jjTYzvEj2ygm+hziDr6Xcrx nqs0ICs6cUBQCJijf03ibMEMBhAS/+SgG9YxmNfSesjmYggfXsGd8GSdb/C2nuZIgthg yEEGSc+Ny+QgWlweXqBhtGXOajpH+Dr6jP7Ep0p5V2S2nZykbwCw/vyrTQQoSO2I+Whd r5w6UMJruXxVBcKliTgx4V4+cQK3plkuiwR+wDJCCDDD2kcBF2Zgf4UZ5CkyJa4lNxhK Dofw== ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@vivo.com header.s=selector2 header.b=i8eK+n3f; 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 g7-20020a1709063b0700b0078d9c0e896bsi1654655ejf.525.2022.10.24.23.53.21; Mon, 24 Oct 2022 23:53:45 -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=i8eK+n3f; 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 S231356AbiJYGuv (ORCPT + 99 others); Tue, 25 Oct 2022 02:50:51 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:51000 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229574AbiJYGuq (ORCPT ); Tue, 25 Oct 2022 02:50:46 -0400 Received: from APC01-TYZ-obe.outbound.protection.outlook.com (mail-tyzapc01on2117.outbound.protection.outlook.com [40.107.117.117]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 650F23F1F5 for ; Mon, 24 Oct 2022 23:50:45 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=fx2Bcw38WutwRfMIB/Mees+ThzWUKSS4UFSCERVP9JPetQyV3hIK5/RVjKnD5vEed3RBO4cB06AmCzi7SIyWWW9BArplKc1nW+Kkx49Z3AUCAiisZjuUeqWckri9GAImwPGvkz6SXdqNPzrP/rQ5Bh0mQwvftX+S74yjRQLWL7q6vfZQtWAkYIVO2+snv3KDYjWJTx1HoU9gpII1isShqmNAeda7PQspdqikqsPPFWFh1jRsQhACHFMPmf5AJA/Fj/89dIKc7leZnevUasmXFb6zoBLTd2F154lQSOHvRM3vjoji80K8tVECfI5CtrjMAN0FrhdU/LhZ0zKdlkc5Sw== 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=9kTFwIpKCO41V09Jhhe6dgE98wIEtEgOZvh9GCH28zs=; b=jqvuG7/S6ERWhpCdZPfVMd8civILO/mOUUsLuGxqC1/jQMaJEXL9tgXsFVEPhFRTvIhzXH+vpQeUWfK9kqQc8IhfqvkEjVTLiEn27alXiHijg+DhO2V5DZ8bZgr0hwXvM7nCM7Pohy4Vq5ZwxD1sUrtsi41mfKnoKtW9rib4sI8hVmD+Sf7c9qRKcDn9mRH2ygRQwupXy8kcl2RE0TATnSiZIzGlIJ+CVXZzqx76Bv7eEMfIHaWGWxZbBcF8HKMZeZDy9Uiju/eXmDQ4MbpIZCQfaBKnGSuSXwwUp27CAcdAvHj5erjjXvvQvegqnr5VPrOQBquKKLiOnbWOOnlsGw== 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=9kTFwIpKCO41V09Jhhe6dgE98wIEtEgOZvh9GCH28zs=; b=i8eK+n3fDSzsy/Qe9pmR6/xR4Tukj+PSRYhMgCeUfEYyX74DfdP05A3ix7t3vlVvS7mIB6CQtI1JRFA0LMHxQE+EDV91Uy3umRow28DX8G/9bOS4FSI4XIQdL7JXn/QLx1nrV31ZxC5TRLWrnYcQLwxyQXCx/o7tLkwgtmK5YzHgrzwcL23JkIJDZGhkgHoUZTGXbJ2nbqXUQzM60nKZgWD9WSyFkSORpZsAksL6qfAymIzIWN+ktmAlxl+dXNL4juAj+AJfhxS6TVsuKrmKfEr8VMJ0fmy37gUeZ3LobalSYAeMH7qcSKJgdAD7HBoNN6vPxkYoZKHVmtAMkoXU1g== Authentication-Results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=vivo.com; Received: from SEZPR06MB5269.apcprd06.prod.outlook.com (2603:1096:101:78::6) by TYZPR06MB4144.apcprd06.prod.outlook.com (2603:1096:400:20::11) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5746.28; Tue, 25 Oct 2022 06:50:41 +0000 Received: from SEZPR06MB5269.apcprd06.prod.outlook.com ([fe80::c84b:5a6c:d66f:c0fd]) by SEZPR06MB5269.apcprd06.prod.outlook.com ([fe80::c84b:5a6c:d66f:c0fd%3]) with mapi id 15.20.5746.023; Tue, 25 Oct 2022 06:50:41 +0000 From: Yangtao Li To: jaegeuk@kernel.org, chao@kernel.org Cc: linux-f2fs-devel@lists.sourceforge.net, linux-kernel@vger.kernel.org, Yangtao Li Subject: [PATCH v2 2/2] f2fs: introducr gc_urgent_idle_remaining sysfs node and mark gc_urgent_high_remaining node deprecated Date: Tue, 25 Oct 2022 14:50:25 +0800 Message-Id: <20221025065025.35017-2-frank.li@vivo.com> X-Mailer: git-send-email 2.35.1 In-Reply-To: <20221025065025.35017-1-frank.li@vivo.com> References: <20221025065025.35017-1-frank.li@vivo.com> X-ClientProxiedBy: SI2PR02CA0053.apcprd02.prod.outlook.com (2603:1096:4:196::16) To SEZPR06MB5269.apcprd06.prod.outlook.com (2603:1096:101:78::6) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: SEZPR06MB5269:EE_|TYZPR06MB4144:EE_ X-MS-Office365-Filtering-Correlation-Id: fb3dc23e-fb46-45e1-62ea-08dab6553b67 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: MqfOoC1kfE994xCwngyRUx9IPX0EZMrZAbZZJMpa+qlm0v5+eeFnIjuu0Zedv9D0PU3/lkEg2fHarCNOwbGICmFTpLrD8PoOLarfvzqjpZT1BX2b2GzX4LbTFYVk2lsqsyXKLpHSkbr3t9Vte0sCcFXv1X96EzCKBsmg3ZSYU/YVq4X47K8nIz91KRFM3FecS8mN4bCQbwdSpL5EWMekioLT5R1CXQUfgfuoqPTx1shww3FKq7CAkLgVL7qmMTA5kvrRJjNRUJ5nQdFNp28ySzFGlqSfsQu58YP1qTw3prLiG4tnTTjSojriEuNCQm1LdBTzULwxE2d1uz4xWbMFWDH1U0LeB2gGANGz1HMU9MaFiQXvNvBuCrLnZV4+NNYuYWoMM87LYEDKIQYXSus+tSuqBah8+PqSzwutt4VpuarThnVfuJmWjFxC6/v4kOfiZcogVoxUX5r5UB0YUvHi/VbVcwy9N8I2yPucwIQE97Hk6QQLjU8eHpftBYY052kw4oJknrr6Yr8FrVOSXmrFkV4d7b1FFoyD81viuQj8BvjaHiA2joI02oupdFxIlfT2jQrbYuSNqf7xpUZtDciaXySJi7P3OmpDSMR5SyBoo4RMR1ltpY1tNUAhHJrD/Mzmn0rHFI1Nr7hNImr9fPGeQwqzM3h4icGuegfb72MqC1bjsY6l0IWB1gKn3Mz219P1rXTiBUF4KlEoikhmBHHJNn46svNHr9wUZM6Hd8+QEslJH90ABSkh94vrUk013XUsRmUFCCLK7f7bpJzXM+Ni0w== X-Forefront-Antispam-Report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:SEZPR06MB5269.apcprd06.prod.outlook.com;PTR:;CAT:NONE;SFS:(13230022)(4636009)(346002)(366004)(396003)(376002)(39860400002)(136003)(451199015)(83380400001)(186003)(1076003)(6512007)(2616005)(2906002)(26005)(38100700002)(5660300002)(36756003)(41300700001)(107886003)(6506007)(52116002)(6666004)(38350700002)(66556008)(316002)(19627235002)(8936002)(66476007)(4326008)(86362001)(8676002)(66946007)(478600001)(6486002);DIR:OUT;SFP:1102; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: S/9zz65tqCtO5obPalSNr08KQT1g6JqxlhOFCUIZi7KNUyThHpvUUM6NOeXgT3KhPqPDJDlbogyxEFwofZQGuQIEFlXeGsP04cPr891+o0EHJlpqX2ExcyR7kXMxqeYDoh4FPDeymzp6sgHPyUV/9zR77caEzQWh9M2wVc+O649CwPkaYXPxc7VctYxxlgI3z+0c0Z5eVebRZn8Gs9FfudScQ9XSFnuoIsnKhGz8NtbcZumEZgsqoTMW8SntwphgXCsQM+fL6MR2SdOZ4JtEKr9t/asNoIB0dE0oLhKpkCA4/OEq+5czqBDDXbfAlNsJvOshZM2YjXtj9vlH4EtREIC5C8ssuFwgVuKMHn+GY80dFz2lDU37o89G8UDq0CvBSBEFUJgiwgxM8l1O5XfQS6OXM8KkDGSUgMy7RtLFX071yvaBgmKKOJ6xO4ad572BXRJlO1rQrE9sX1HMg+31BS7q7quF35aJWyUIbFEXklNwXSdRJ2gclTPsae4SCsRLVs6aMWTMV4Bo1Aw3JLylcGMqLe4a1zquXa6gJU6TYtfgUMzzt3hEXUBUeEjzVhMjURc4FwmYifbvbf7ukB4KhKFWVNZtqPF6pRe1L8LY24u7KB8vNz6ORfZUXzkyUrCE79xea9UPlgSBN1miaLBeH0DyYusI0rlqEM7GJmQZ4YSrZdNuyeC9Eh7xjm/7+2fyBHZi0imTLr20l6/ch5RFmcNx/fv9M/G5tbIDHUu2hsrkHpJVZ2tlm2vL/e69j+0iYSK0R49+UreueJLih+D6v5s7sx0hdLJZ2FkdNYpchdjgykdbqbc8P+mVRk/wqVqFRTdc2KpTOB3Qq6M1+BZYsS+im99OXw9CYVF30qDpjI6ztGIF7roWUFeNRy0oYJbU+l3GCqdYMkRvOdUf6pP3y1yZ0l44Qx7uIMoOREUilC6IndJlEcUoK/0hK5fUlwwnY6E7Wxd9i1PsL7HO61Sbe13udjiTkncBO1xwp2kewu4d8vp9Ym6GPPK7Vl/W2B/6ajfT/73yluBjngRf1qqzqTmcbdjEm6TSVA8i7FPzDZOLg+6WqLODPN0sXs0cRjW1jE9TUTL1vgyoGccORMWrQDDcua5t0QuB9XuJnW4Pnxsmj9NZDCzsOKUQrynfUcRnCUwxlbg27Egfsa6OtxcBcrWwTu57sDosxONorhr39Fm3Kl+HcnoaISfFl2YsrpCB3o+9q+Wzls5jupLms9el+D2zKFDTJ4XUcd/xBPklLkqa4rResL5URENdTmqGCNE9BByr/WjLKbKTokOvp8sH2x7wZfQRd2TGoB+fhRPf66ebRrcgeiddphMC7u3G/Jzl+tSEQ8uBC/u2DLhrftaynLZixuaIuSK5ua3ZME/QtvYEoitVmoUQ2QkL0nOC88UvObB/9ItxjfxoTfTFyMjG8XABKtalnKNv48XdNRAXzeaU5iCQCsR1rArcqteN9ciGoVWb7J4M1i8uWNECdzbCaB6S0hP0iSZuC225iDiMwG955c+IG2UfvBosrFfNexQtZZ2AcNgDvJ157fyd9bKJbnXm+f90tcQQ8K9b78RRaicad0mQWR65rqnCS5Zw/3or X-OriginatorOrg: vivo.com X-MS-Exchange-CrossTenant-Network-Message-Id: fb3dc23e-fb46-45e1-62ea-08dab6553b67 X-MS-Exchange-CrossTenant-AuthSource: SEZPR06MB5269.apcprd06.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 25 Oct 2022 06:50:41.3015 (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: nMkOK1c7pUfqdsHj7Im2r+oAVfNpxep/cWawZmvHHCmrcuo1aZwCzp0bL+wnnC8cOCILMOg9B8gsg5mlYc/kvg== X-MS-Exchange-Transport-CrossTenantHeadersStamped: TYZPR06MB4144 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_NONE, RCVD_IN_MSPIKE_H2,SPF_HELO_PASS,SPF_PASS,URIBL_BLOCKED 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-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1747641513347724428?= X-GMAIL-MSGID: =?utf-8?q?1747641513347724428?= Added a new sysfs node called gc_urgent_idle_remaining. The user can set the trial count limit for GC urgent and idle mode with this value. If GC thread gets to the limit, the mode will turn back to GC normal mode finally. This method is not only applicable to gc_urgent_high, but applicable to all gc modes. Also mark gc_urgent_high_remaining as deprecated, so that the node can be removed in the future. Signed-off-by: Yangtao Li --- Documentation/ABI/testing/sysfs-fs-f2fs | 8 ++++++++ fs/f2fs/f2fs.h | 6 ++++-- fs/f2fs/gc.c | 12 ++++++------ fs/f2fs/super.c | 2 +- fs/f2fs/sysfs.c | 14 ++++++++++---- 5 files changed, 29 insertions(+), 13 deletions(-) diff --git a/Documentation/ABI/testing/sysfs-fs-f2fs b/Documentation/ABI/testing/sysfs-fs-f2fs index 483639fb727b..859c4e53a846 100644 --- a/Documentation/ABI/testing/sysfs-fs-f2fs +++ b/Documentation/ABI/testing/sysfs-fs-f2fs @@ -598,6 +598,14 @@ Contact: "Daeho Jeong" Description: You can set the trial count limit for GC urgent high mode with this value. If GC thread gets to the limit, the mode will turn back to GC normal mode. By default, the value is zero, which means there is no limit like before. + + +What: /sys/fs/f2fs//gc_urgent_idle_remaining +Date: October 2022 +Contact: "Yangtao Li" +Description: You can set the trial count limit for GC urgent and idle mode with this value. + If GC thread gets to the limit, the mode will turn back to GC normal mode. + By default, the value is zero, which means there is no limit like before. What: /sys/fs/f2fs//max_roll_forward_node_blocks Date: January 2022 diff --git a/fs/f2fs/f2fs.h b/fs/f2fs/f2fs.h index e6355a5683b7..2bad69cf9fd9 100644 --- a/fs/f2fs/f2fs.h +++ b/fs/f2fs/f2fs.h @@ -1734,8 +1734,10 @@ struct f2fs_sb_info { unsigned int cur_victim_sec; /* current victim section num */ unsigned int gc_mode; /* current GC state */ unsigned int next_victim_seg[2]; /* next segment in victim section */ - spinlock_t gc_urgent_high_lock; - unsigned int gc_urgent_high_remaining; /* remaining trial count for GC_URGENT_HIGH */ + spinlock_t gc_urgent_idle_lock; + /* remaining trial count for GC_URGENT_* and GC_IDLE_* */ + unsigned int gc_urgent_idle_remaining; + unsigned int gc_urgent_high_remaining; /* deprecated */ /* for skip statistic */ unsigned long long skipped_gc_rwsem; /* FG_GC only */ diff --git a/fs/f2fs/gc.c b/fs/f2fs/gc.c index e0ff99c7e3f2..0ed5b3c5922c 100644 --- a/fs/f2fs/gc.c +++ b/fs/f2fs/gc.c @@ -152,14 +152,14 @@ static int gc_thread_func(void *data) /* balancing f2fs's metadata periodically */ f2fs_balance_fs_bg(sbi, true); next: - if (sbi->gc_mode == GC_URGENT_HIGH) { - spin_lock(&sbi->gc_urgent_high_lock); - if (sbi->gc_urgent_high_remaining) { - sbi->gc_urgent_high_remaining--; - if (!sbi->gc_urgent_high_remaining) + if (sbi->gc_mode != GC_NORMAL) { + spin_lock(&sbi->gc_urgent_idle_lock); + if (sbi->gc_urgent_idle_remaining) { + sbi->gc_urgent_idle_remaining--; + if (!sbi->gc_urgent_idle_remaining) sbi->gc_mode = GC_NORMAL; } - spin_unlock(&sbi->gc_urgent_high_lock); + spin_unlock(&sbi->gc_urgent_idle_lock); } sb_end_write(sbi->sb); diff --git a/fs/f2fs/super.c b/fs/f2fs/super.c index 3834ead04620..f90a8c0a53ec 100644 --- a/fs/f2fs/super.c +++ b/fs/f2fs/super.c @@ -3616,7 +3616,7 @@ static void init_sb_info(struct f2fs_sb_info *sbi) sbi->seq_file_ra_mul = MIN_RA_MUL; sbi->max_fragment_chunk = DEF_FRAGMENT_SIZE; sbi->max_fragment_hole = DEF_FRAGMENT_SIZE; - spin_lock_init(&sbi->gc_urgent_high_lock); + spin_lock_init(&sbi->gc_urgent_idle_lock); atomic64_set(&sbi->current_atomic_write, 0); sbi->dir_level = DEF_DIR_LEVEL; diff --git a/fs/f2fs/sysfs.c b/fs/f2fs/sysfs.c index df27afd71ef4..2b1c653b37cf 100644 --- a/fs/f2fs/sysfs.c +++ b/fs/f2fs/sysfs.c @@ -531,10 +531,14 @@ static ssize_t __sbi_store(struct f2fs_attr *a, return count; } - if (!strcmp(a->attr.name, "gc_urgent_high_remaining")) { - spin_lock(&sbi->gc_urgent_high_lock); - sbi->gc_urgent_high_remaining = t; - spin_unlock(&sbi->gc_urgent_high_lock); + /* deprecated */ + if (!strcmp(a->attr.name, "gc_urgent_high_remaining")) + return -EINVAL; + + if (!strcmp(a->attr.name, "gc_urgent_idle_remaining")) { + spin_lock(&sbi->gc_urgent_idle_lock); + sbi->gc_urgent_idle_remaining = t; + spin_unlock(&sbi->gc_urgent_idle_lock); return count; } @@ -826,6 +830,7 @@ F2FS_RW_ATTR(FAULT_INFO_TYPE, f2fs_fault_info, inject_type, inject_type); F2FS_RW_ATTR(F2FS_SBI, f2fs_sb_info, data_io_flag, data_io_flag); F2FS_RW_ATTR(F2FS_SBI, f2fs_sb_info, node_io_flag, node_io_flag); F2FS_RW_ATTR(F2FS_SBI, f2fs_sb_info, gc_urgent_high_remaining, gc_urgent_high_remaining); +F2FS_RW_ATTR(F2FS_SBI, f2fs_sb_info, gc_urgent_idle_remaining, gc_urgent_idle_remaining); F2FS_RW_ATTR(CPRC_INFO, ckpt_req_control, ckpt_thread_ioprio, ckpt_thread_ioprio); F2FS_GENERAL_RO_ATTR(dirty_segments); F2FS_GENERAL_RO_ATTR(free_segments); @@ -953,6 +958,7 @@ static struct attribute *f2fs_attrs[] = { ATTR_LIST(data_io_flag), ATTR_LIST(node_io_flag), ATTR_LIST(gc_urgent_high_remaining), + ATTR_LIST(gc_urgent_idle_remaining), ATTR_LIST(ckpt_thread_ioprio), ATTR_LIST(dirty_segments), ATTR_LIST(free_segments),