Message ID | 20221025033217.14840-2-frank.li@vivo.com |
---|---|
State | New |
Headers |
Return-Path: <linux-kernel-owner@vger.kernel.org> Delivered-To: ouuuleilei@gmail.com Received: by 2002:a5d:6687:0:0:0:0:0 with SMTP id l7csp787991wru; Mon, 24 Oct 2022 20:48:22 -0700 (PDT) X-Google-Smtp-Source: AMsMyM4WTgQD00kH5l0EjFSmRpRQt1auVhGH/34mjUrDCKeCOx4oguDK7yQjaeCiAVpiaSxxUPoC X-Received: by 2002:a17:907:7638:b0:7aa:987f:4e91 with SMTP id jy24-20020a170907763800b007aa987f4e91mr4574710ejc.442.1666669702246; Mon, 24 Oct 2022 20:48:22 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1666669702; cv=pass; d=google.com; s=arc-20160816; b=q2hoIPxOS+kgMfaecvX705HCnA5Yj2iKr+WGfO2eh8QUaro7PCRzdsrg71VEqhtjhb wNXoCUawKdRdy7NxWfKjbURDf104pPZFYALlr7kK8XuoeyjMV/QuNIj1hbWbUS3toMNV c7W7fY/THydOt+ZS5Gl/W9R7uLfBDE9RuKTaD/3gk060u32kEjHAWMPkY1UWvHBhVOEg 5BQgmdr5yiCs+WfyoDVMO8I+s7mDuZBr7aRNnSIMaFpJ2Q2udZAFsiofqp43ruiy0u3k fKMtsH2HtgWMxQLEZ/+zkZaHXGekx2YrxyUOjQdDmZnZBpu2w9s9hhjVuBtjipQM4ySY aYZQ== 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=WSeboihTMheBmII6ZDUPfIbdD40SKL/aSPKoFHjyIgo=; b=XdDYzPTRansATugKrnDd1wFcb0R2HmukpWR1+aJAvjuS68qGTzvaYuzadW6B9wxlM/ B0Myl2ux9xZqHBGghqUjVF3PvexJVFF6uWaRZ70/tWGVvGaFkfPdplotioJRCk2SsVZe 4tOWCo79rfZ1ZxP2t30RBenwpV+3TJx6De7Qz8b2+ZpMpicpkk3NuRaqcj5SqgFA1EEy 1DcmKuAX95VixYs5ewbVeWjzO3xRuR/447hur5MY9BtZAOMqI7adSazfB1SKSjYte9mW yFBA07wmaXi7+Drls82WpA29meTQN1/eKhBOBboKWuw+/hnwkX30pHhgUybF93Kofun2 feFw== ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@vivo.com header.s=selector2 header.b="pdDc/Rft"; 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 e26-20020a056402149a00b00461d02225a3si1391061edv.448.2022.10.24.20.47.58; Mon, 24 Oct 2022 20:48:22 -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="pdDc/Rft"; 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 S230242AbiJYDcm (ORCPT <rfc822;pwkd43@gmail.com> + 99 others); Mon, 24 Oct 2022 23:32:42 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:60808 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230075AbiJYDcg (ORCPT <rfc822;linux-kernel@vger.kernel.org>); Mon, 24 Oct 2022 23:32:36 -0400 Received: from APC01-SG2-obe.outbound.protection.outlook.com (mail-sgaapc01on2121.outbound.protection.outlook.com [40.107.215.121]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 9A7B1BB3B5 for <linux-kernel@vger.kernel.org>; Mon, 24 Oct 2022 20:32:33 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=fO5BtC1Ip7l9dGE/nUdOnUZlqDmIGZO6I5X/cdeFXyMWQAtK2g0xYw+2pUVhP0kj1PMIYzhRGvithQMKpJf5qrMhmP0BfJK/UiNeXCtptkmiX+8qpfSIb5+4HpfN0t/1MohncpxafMYI05na7b9LduhTTXGTFuZ40W7dIh5MPDSI5SFQ6gU9tD40kk28FOx2XOlLKr734f0jCaAMz+etDHreb2MKsUaDrI0W0i5o+7ZzfEZPnI5D3wzJDrqAM1HH73ZFYDs1zTiDxxfpbAnry2rgj+LiO5bVmt2p2clR+NtNuYCuxyubIDOECa8Jm1plt5fpd0XWmTgyOaExoGjzsA== 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=WSeboihTMheBmII6ZDUPfIbdD40SKL/aSPKoFHjyIgo=; b=FoZE7LA8M+rtIkQd29X8xzvmgoWa5/AIaL5Lk3kLdX7IKfnXJ8Y/UFvMuRDHXnHRte4CRFNLDt96OUaGg7CRSCUCR4EUbIiDrt+IzAH1E+AnyV+9CLjVFwhaOv1zvIu9rsWf5IONsc7UTKzJvoOCRRUZVJRDt6gCQGroJl8asWlOGeeMdjmjsOvaxCmSHFYgkBf2lqEd53C2kLICWtgvOVJbciNhrmkZd42IX5iKeCHHqPtsAJiN6GhzsAtDXDTLgzIF37BeD6SJzX8BWtVt24k//r0fMqDvlK1OyWUeAHf4KPS1EX8MT2+0CC6Nxfzr0BSfbKEHd9FYNkiimFrfcQ== 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=WSeboihTMheBmII6ZDUPfIbdD40SKL/aSPKoFHjyIgo=; b=pdDc/RftWa28RtqtHNxmINxoDqVuHv9clcIChkHmDyw/TaW6fffS9q3QHf0p0UZIjQiHmIcWUFVsfWnYxUMptfH4Gn5C1WLXV4cMK8QgyWyoDPMnvnypKBVZAtYltizO2Yaa9n7tJ4cH5N1m+VHuq5oR4BbObnREpBp3GQhaHrFGOT4mpfvig3o+9u5GpQyB7OJ0LmfN902suil32e0j3enj5UJYeghJN99CUs16hBngjPCyiIS9HfswsfN7SoBfH1CgGOnL5yACq20nyv14bzHS8PXG+bZ7wWB8qqHQjoffAD0Fj2ybcpCYLXdsaplymwP1kpla9TfL/00LlNqMcw== 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 PUZPR06MB6247.apcprd06.prod.outlook.com (2603:1096:301:111::5) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5746.21; Tue, 25 Oct 2022 03:32:30 +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 03:32:30 +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, Yangtao Li <frank.li@vivo.com> Subject: [PATCH 2/2] f2fs: introduce gc_mode sysfs node Date: Tue, 25 Oct 2022 11:32:17 +0800 Message-Id: <20221025033217.14840-2-frank.li@vivo.com> X-Mailer: git-send-email 2.35.1 In-Reply-To: <20221025033217.14840-1-frank.li@vivo.com> References: <20221025033217.14840-1-frank.li@vivo.com> Content-Transfer-Encoding: 8bit Content-Type: text/plain X-ClientProxiedBy: SG2PR06CA0248.apcprd06.prod.outlook.com (2603:1096:4:ac::32) To SEZPR06MB5269.apcprd06.prod.outlook.com (2603:1096:101:78::6) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: SEZPR06MB5269:EE_|PUZPR06MB6247:EE_ X-MS-Office365-Filtering-Correlation-Id: 761666b8-d08b-465f-9dd9-08dab6398bf5 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: l9IShIxQPhPDrM648KxPWmW3Cov4yLJUBX5UhgwoLwPFAZKtxoWQ/K75BLImaNS/czhl39CQA22YAvSU4a/V1sz0LXqY+fqnIhdpv/NaTXsFe6+NnD4m7GwxwclxgVRXQnab6AaFhUimZeDot/ynLODHOGz5edeo9ZHLcHeUcvd6X7sQUGia1aWpggmJSiBDe+O11kBEnRrNx3N3U9PUwHGvUy2EThZla/r8lJYig48GULcWdb1Hx2sk6NNKolWJ8kP/fkzzUpvcDrzeLiqi7QvaSFTm4S2sDWYEfxKFbJB+T8CWgqpfFOEC+RLsl4i9mV0hjWk4qZx6rseZmzrSyEOpBDkNKV8AW/bPE4R0ZN7DY5zP+wE0qF6eTHfQ4h6GpelPlqyxPzgf4OiAKbxpTpXCu1AO2vgiaHN7N2KmWx26lfDws+E1Hlu2VM2mdQ/xR4TuzEFSNjY/zGyCM2yRL3D70eV/a+73a8sPO+yFAdICqdmggisjjNU8gGROVbLd5pg3XmxfL6+lKiTMoVZl9eEVIkczAnFDq6kXLbA/X5YtibTGb9AmWs4TNQemou5ZadpifrwVuZXp+/G2D5ma0gux+wpt5NW/qMtuNThV2v3PxIIcUexb9F+cE7GEYPCpy0VQlvGK1nA1s+RZO5cUmuuTvhY6v4ykVpu0Y/SAFi3lEuNoeV8Vuc7Qm+mIh7BAkrzn8IfFokbvCacuDoptzqLRaI4AQNTnzhJQFdeUyuM2EoNy8Nn/QfI1kMbBFGl9 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)(366004)(346002)(136003)(376002)(396003)(39860400002)(451199015)(19627235002)(107886003)(41300700001)(36756003)(66946007)(4326008)(66556008)(52116002)(66476007)(6666004)(6506007)(8676002)(86362001)(8936002)(2616005)(83380400001)(6512007)(26005)(5660300002)(186003)(478600001)(316002)(6486002)(1076003)(38350700002)(2906002)(38100700002);DIR:OUT;SFP:1102; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: PXfPuCFj2/Hjrnc5OwQtFsqmH8duchs5apbWDsuL7zs3EoN+L3/Zt6FAANLQCANx+kg5qholc/tM46FDBOimyI8xsx1cAhjkwgX8tzAI1V0EYwgIEpG1YnDJ2zdVByvY0PF++r/uuZSUcUJRoWUglO87mJhofBMJ7u6QmSzzSdbvkPMFrxH4OO3Vd0EnD9Nen5Pfz2JhJtTSrALupCO66PwBpSs9n8l46zkb+djwxvfE+GHixT0fxP92FaxkwlSu6pvgLHFsxKtXc9W/tOq29KHa4Jj5sX3Dp2YJmLOJWc1l5uMNO7TM9aUfVr71KcuxqFMttJtm7EFDGX5yEWEDXIOUP6oVPGbEBzJ+EXIgtUKK93olFVU3l709hIW1Oax4Mb0i1rMTb+75jlMHp86OG89fcTPReTPuRWNGAsX0dZrF2mwmfo/Wjvk99tZ7ugnpLyjlCCviXOw6Eh80pN/KzYZNP4VxEs5ypN5dhoRrXTZcD+FjYvRh6b9ua+LLgmolytjukXc388Zua00k/rClnyaH7OAzlaUfZHNwc8KpC7j/YcmSJbhAZZ/LZg98usMXul32e/DdTEhlaeusGe4RZ7119hAUUW9PgNq6D0+a9nYXiDpPrYv4xWnj5Jo5TOsAnEe4kOcg02JiCoMl5sKKBTpAFDJvq9FJjW5n276LXxb070At8Wj2Vzx8txv8Ht4v6qvD0eVsQVZkO7Z31JUTG4eXqlySfOMrV7hQUfCvag6OLFjcCEWBWBUm4PnYg5xwS+tdDk7utaB0yunf7LMXEsWE+fuHdHArnmlTub58vw0sxupUEv7H3Jllof6MaDYAcZSlNx38CE6r67z3KvJPO2cloHNGOQhXPLGC8cSDGkvfiuV2AGUbUmAL7cDqc5SbfzuqqZ2syg3uE5/rxNaKqIVNrqsxMjXpDb/WN9Rm59AaYoHqnCKgPh2YX1kcgQA4NJOEsoxlW40aF5X3z/LPYfNLmYUBFZnSFNyIxQbdeREVHGds3n6khc09KMV2g1zVtk5he7iabcZxbY8U3zePXca4rCMMmvXiMxXujbb/gP+laQud79gwa9KgaA9KJfR7g5aTT9aqwvKMbe7dvUvkB/uRiQOHdPcZhiYnlhkevb/yySQRylJhdNUNR6Bkk8UnKSaVe5cNEEkHy1SZ/z4o5jb7IrBYKkw/zZsbguniPJDQWHp62T2ymPThKdAf9mEeRcYnA+NVF24Mqc5/8th+5P2p9eNNPw1Ogv8kQBMVGUI3iZpnkWiE9cbi4R0hAAId3Qe2BAt5G0K9xKtwodf7qffKG0uH46WYvlyeJNiJJFSJBW0INbKfctb4/8ULvVqbi3HLAQunLEKak814l7tgLjWodoq0IwQNPSSlYjIakEWMcYETeGPQQN6aLiWB78rbqkZXmp33F+HvV9JR+Imt4eVPkYiGwWLVk4/v6Iss67fT0jLqMAwwo8nVZJYgsXkuO0GEIBVTCPv7+yeTF1aJI7hdpjTCEy8Z9byfO8X/8wQ4aGZjT5w6gaO2BWDc+SpctbyeP+MCG+UGpwUXvxC9XgfgbUH1fhf1eS04ifjmAnJxIUvIuriqTbEChhSS3KK5 X-OriginatorOrg: vivo.com X-MS-Exchange-CrossTenant-Network-Message-Id: 761666b8-d08b-465f-9dd9-08dab6398bf5 X-MS-Exchange-CrossTenant-AuthSource: SEZPR06MB5269.apcprd06.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 25 Oct 2022 03:32:30.5273 (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: Sm10aPh+X1sfcvmI1CFQqVJzSzCRqC1ZkValzvpRosAtyjyfP3UvS6htYFILvbRe1aL/4jVvqZ7noK6ZJeiumA== X-MS-Exchange-Transport-CrossTenantHeadersStamped: PUZPR06MB6247 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: <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?1747629849933104148?= X-GMAIL-MSGID: =?utf-8?q?1747629849933104148?= |
Series |
[1/2] f2fs: Revert "f2fs: make gc_urgent and gc_segment_mode sysfs node readable"
|
|
Commit Message
李扬韬
Oct. 25, 2022, 3:32 a.m. UTC
gc_mode sysfs node can show the current gc_mode as a string.
Introducing it increases readability.
Signed-off-by: Yangtao Li <frank.li@vivo.com>
---
Documentation/ABI/testing/sysfs-fs-f2fs | 6 ++++++
fs/f2fs/f2fs.h | 1 +
fs/f2fs/sysfs.c | 18 ++++++++++++++++++
3 files changed, 25 insertions(+)
Comments
Hi, I merged two patches and modified a bit. Please take a look. https://git.kernel.org/pub/scm/linux/kernel/git/jaegeuk/f2fs.git/commit/?h=dev&id=28ea9479410bab555db26e8437ea61b180e768d6 On 10/25, Yangtao Li wrote: > gc_mode sysfs node can show the current gc_mode as a string. > Introducing it increases readability. > > Signed-off-by: Yangtao Li <frank.li@vivo.com> > --- > Documentation/ABI/testing/sysfs-fs-f2fs | 6 ++++++ > fs/f2fs/f2fs.h | 1 + > fs/f2fs/sysfs.c | 18 ++++++++++++++++++ > 3 files changed, 25 insertions(+) > > diff --git a/Documentation/ABI/testing/sysfs-fs-f2fs b/Documentation/ABI/testing/sysfs-fs-f2fs > index 483639fb727b..6466f3b1f0a9 100644 > --- a/Documentation/ABI/testing/sysfs-fs-f2fs > +++ b/Documentation/ABI/testing/sysfs-fs-f2fs > @@ -634,3 +634,9 @@ Date: July 2022 > Contact: "Daeho Jeong" <daehojeong@google.com> > Description: Show the accumulated total revoked atomic write block count after boot. > If you write "0" here, you can initialize to "0". > + > +What: /sys/fs/f2fs/<disk>/gc_mode > +Date: October 2022 > +Contact: "Yangtao Li" <frank.li@vivo.com> > +Description: Show the current gc_mode as a string. > + This is a read-only entry. > diff --git a/fs/f2fs/f2fs.h b/fs/f2fs/f2fs.h > index e6355a5683b7..80f23e44a442 100644 > --- a/fs/f2fs/f2fs.h > +++ b/fs/f2fs/f2fs.h > @@ -1318,6 +1318,7 @@ enum { > MAX_TIME, > }; > > +/* Note that you need to keep synchronization with this gc_mode_names array */ > enum { > GC_NORMAL, > GC_IDLE_CB, > diff --git a/fs/f2fs/sysfs.c b/fs/f2fs/sysfs.c > index 49898a7243ba..058857d8b3b9 100644 > --- a/fs/f2fs/sysfs.c > +++ b/fs/f2fs/sysfs.c > @@ -41,6 +41,16 @@ enum { > ATGC_INFO, /* struct atgc_management */ > }; > > +static const char *gc_mode_names[MAX_GC_MODE] = { > + "GC_NORMAL", > + "GC_IDLE_CB", > + "GC_IDLE_GREEDY", > + "GC_IDLE_AT", > + "GC_URGENT_HIGH", > + "GC_URGENT_LOW", > + "GC_URGENT_MID" > +}; > + > struct f2fs_attr { > struct attribute attr; > ssize_t (*show)(struct f2fs_attr *, struct f2fs_sb_info *, char *); > @@ -133,6 +143,12 @@ static ssize_t pending_discard_show(struct f2fs_attr *a, > &SM_I(sbi)->dcc_info->discard_cmd_cnt)); > } > > +static ssize_t gc_mode_show(struct f2fs_attr *a, > + struct f2fs_sb_info *sbi, char *buf) > +{ > + return sprintf(buf, "%s\n", gc_mode_names[sbi->gc_mode]); > +} > + > static ssize_t features_show(struct f2fs_attr *a, > struct f2fs_sb_info *sbi, char *buf) > { > @@ -823,6 +839,7 @@ F2FS_GENERAL_RO_ATTR(encoding); > F2FS_GENERAL_RO_ATTR(mounted_time_sec); > F2FS_GENERAL_RO_ATTR(main_blkaddr); > F2FS_GENERAL_RO_ATTR(pending_discard); > +F2FS_GENERAL_RO_ATTR(gc_mode); > #ifdef CONFIG_F2FS_STAT_FS > F2FS_STAT_ATTR(STAT_INFO, f2fs_stat_info, cp_foreground_calls, cp_count); > F2FS_STAT_ATTR(STAT_INFO, f2fs_stat_info, cp_background_calls, bg_cp_count); > @@ -904,6 +921,7 @@ static struct attribute *f2fs_attrs[] = { > ATTR_LIST(max_discard_issue_time), > ATTR_LIST(discard_granularity), > ATTR_LIST(pending_discard), > + ATTR_LIST(gc_mode), > ATTR_LIST(batched_trim_sections), > ATTR_LIST(ipu_policy), > ATTR_LIST(min_ipu_util), > -- > 2.25.1
Minor comments below. On 2022/10/25 11:32, Yangtao Li wrote: > gc_mode sysfs node can show the current gc_mode as a string. > Introducing it increases readability. Introducing it to increase readability. > > Signed-off-by: Yangtao Li <frank.li@vivo.com> > --- > Documentation/ABI/testing/sysfs-fs-f2fs | 6 ++++++ > fs/f2fs/f2fs.h | 1 + > fs/f2fs/sysfs.c | 18 ++++++++++++++++++ > 3 files changed, 25 insertions(+) > > diff --git a/Documentation/ABI/testing/sysfs-fs-f2fs b/Documentation/ABI/testing/sysfs-fs-f2fs > index 483639fb727b..6466f3b1f0a9 100644 > --- a/Documentation/ABI/testing/sysfs-fs-f2fs > +++ b/Documentation/ABI/testing/sysfs-fs-f2fs > @@ -634,3 +634,9 @@ Date: July 2022 > Contact: "Daeho Jeong" <daehojeong@google.com> > Description: Show the accumulated total revoked atomic write block count after boot. > If you write "0" here, you can initialize to "0". > + > +What: /sys/fs/f2fs/<disk>/gc_mode > +Date: October 2022 > +Contact: "Yangtao Li" <frank.li@vivo.com> > +Description: Show the current gc_mode as a string. > + This is a read-only entry. > diff --git a/fs/f2fs/f2fs.h b/fs/f2fs/f2fs.h > index e6355a5683b7..80f23e44a442 100644 > --- a/fs/f2fs/f2fs.h > +++ b/fs/f2fs/f2fs.h > @@ -1318,6 +1318,7 @@ enum { > MAX_TIME, > }; > > +/* Note that you need to keep synchronization with this gc_mode_names array */ Good point. /* Modification on enum should be synchronized with gc_mode_names array */ > enum { > GC_NORMAL, > GC_IDLE_CB, > diff --git a/fs/f2fs/sysfs.c b/fs/f2fs/sysfs.c > index 49898a7243ba..058857d8b3b9 100644 > --- a/fs/f2fs/sysfs.c > +++ b/fs/f2fs/sysfs.c > @@ -41,6 +41,16 @@ enum { > ATGC_INFO, /* struct atgc_management */ > }; > > +static const char *gc_mode_names[MAX_GC_MODE] = { > + "GC_NORMAL", > + "GC_IDLE_CB", > + "GC_IDLE_GREEDY", > + "GC_IDLE_AT", > + "GC_URGENT_HIGH", > + "GC_URGENT_LOW", > + "GC_URGENT_MID" > +}; > + > struct f2fs_attr { > struct attribute attr; > ssize_t (*show)(struct f2fs_attr *, struct f2fs_sb_info *, char *); > @@ -133,6 +143,12 @@ static ssize_t pending_discard_show(struct f2fs_attr *a, > &SM_I(sbi)->dcc_info->discard_cmd_cnt)); > } > > +static ssize_t gc_mode_show(struct f2fs_attr *a, > + struct f2fs_sb_info *sbi, char *buf) > +{ > + return sprintf(buf, "%s\n", gc_mode_names[sbi->gc_mode]); > +} > + > static ssize_t features_show(struct f2fs_attr *a, > struct f2fs_sb_info *sbi, char *buf) > { > @@ -823,6 +839,7 @@ F2FS_GENERAL_RO_ATTR(encoding); > F2FS_GENERAL_RO_ATTR(mounted_time_sec); > F2FS_GENERAL_RO_ATTR(main_blkaddr); > F2FS_GENERAL_RO_ATTR(pending_discard); > +F2FS_GENERAL_RO_ATTR(gc_mode); > #ifdef CONFIG_F2FS_STAT_FS > F2FS_STAT_ATTR(STAT_INFO, f2fs_stat_info, cp_foreground_calls, cp_count); > F2FS_STAT_ATTR(STAT_INFO, f2fs_stat_info, cp_background_calls, bg_cp_count); > @@ -904,6 +921,7 @@ static struct attribute *f2fs_attrs[] = { > ATTR_LIST(max_discard_issue_time), > ATTR_LIST(discard_granularity), > ATTR_LIST(pending_discard), > + ATTR_LIST(gc_mode), > ATTR_LIST(batched_trim_sections), > ATTR_LIST(ipu_policy), > ATTR_LIST(min_ipu_util),
diff --git a/Documentation/ABI/testing/sysfs-fs-f2fs b/Documentation/ABI/testing/sysfs-fs-f2fs index 483639fb727b..6466f3b1f0a9 100644 --- a/Documentation/ABI/testing/sysfs-fs-f2fs +++ b/Documentation/ABI/testing/sysfs-fs-f2fs @@ -634,3 +634,9 @@ Date: July 2022 Contact: "Daeho Jeong" <daehojeong@google.com> Description: Show the accumulated total revoked atomic write block count after boot. If you write "0" here, you can initialize to "0". + +What: /sys/fs/f2fs/<disk>/gc_mode +Date: October 2022 +Contact: "Yangtao Li" <frank.li@vivo.com> +Description: Show the current gc_mode as a string. + This is a read-only entry. diff --git a/fs/f2fs/f2fs.h b/fs/f2fs/f2fs.h index e6355a5683b7..80f23e44a442 100644 --- a/fs/f2fs/f2fs.h +++ b/fs/f2fs/f2fs.h @@ -1318,6 +1318,7 @@ enum { MAX_TIME, }; +/* Note that you need to keep synchronization with this gc_mode_names array */ enum { GC_NORMAL, GC_IDLE_CB, diff --git a/fs/f2fs/sysfs.c b/fs/f2fs/sysfs.c index 49898a7243ba..058857d8b3b9 100644 --- a/fs/f2fs/sysfs.c +++ b/fs/f2fs/sysfs.c @@ -41,6 +41,16 @@ enum { ATGC_INFO, /* struct atgc_management */ }; +static const char *gc_mode_names[MAX_GC_MODE] = { + "GC_NORMAL", + "GC_IDLE_CB", + "GC_IDLE_GREEDY", + "GC_IDLE_AT", + "GC_URGENT_HIGH", + "GC_URGENT_LOW", + "GC_URGENT_MID" +}; + struct f2fs_attr { struct attribute attr; ssize_t (*show)(struct f2fs_attr *, struct f2fs_sb_info *, char *); @@ -133,6 +143,12 @@ static ssize_t pending_discard_show(struct f2fs_attr *a, &SM_I(sbi)->dcc_info->discard_cmd_cnt)); } +static ssize_t gc_mode_show(struct f2fs_attr *a, + struct f2fs_sb_info *sbi, char *buf) +{ + return sprintf(buf, "%s\n", gc_mode_names[sbi->gc_mode]); +} + static ssize_t features_show(struct f2fs_attr *a, struct f2fs_sb_info *sbi, char *buf) { @@ -823,6 +839,7 @@ F2FS_GENERAL_RO_ATTR(encoding); F2FS_GENERAL_RO_ATTR(mounted_time_sec); F2FS_GENERAL_RO_ATTR(main_blkaddr); F2FS_GENERAL_RO_ATTR(pending_discard); +F2FS_GENERAL_RO_ATTR(gc_mode); #ifdef CONFIG_F2FS_STAT_FS F2FS_STAT_ATTR(STAT_INFO, f2fs_stat_info, cp_foreground_calls, cp_count); F2FS_STAT_ATTR(STAT_INFO, f2fs_stat_info, cp_background_calls, bg_cp_count); @@ -904,6 +921,7 @@ static struct attribute *f2fs_attrs[] = { ATTR_LIST(max_discard_issue_time), ATTR_LIST(discard_granularity), ATTR_LIST(pending_discard), + ATTR_LIST(gc_mode), ATTR_LIST(batched_trim_sections), ATTR_LIST(ipu_policy), ATTR_LIST(min_ipu_util),