From patchwork Fri Jan 20 13:40:26 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Yangtao Li X-Patchwork-Id: 13109883 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from lists.sourceforge.net (lists.sourceforge.net [216.105.38.7]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 8D1D4C27C7C for ; Fri, 20 Jan 2023 13:41:14 +0000 (UTC) Received: from [127.0.0.1] (helo=sfs-ml-4.v29.lw.sourceforge.com) by sfs-ml-4.v29.lw.sourceforge.com with esmtp (Exim 4.95) (envelope-from ) id 1pIrdp-00045H-FA; Fri, 20 Jan 2023 13:41:12 +0000 Received: from [172.30.20.202] (helo=mx.sourceforge.net) by sfs-ml-4.v29.lw.sourceforge.com with esmtps (TLS1.2) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.95) (envelope-from ) id 1pIrdm-00045A-Rb for linux-f2fs-devel@lists.sourceforge.net; Fri, 20 Jan 2023 13:41:10 +0000 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=sourceforge.net; s=x; h=MIME-Version:Content-Type:Content-Transfer-Encoding :Message-Id:Date:Subject:Cc:To:From:Sender:Reply-To:Content-ID: Content-Description:Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc :Resent-Message-ID:In-Reply-To:References:List-Id:List-Help:List-Unsubscribe: List-Subscribe:List-Post:List-Owner:List-Archive; bh=vU1ycY7GCmUeqhh20nXHtH1ShX3OQjcr+pnw1xwkW1s=; b=FreiLtrop2bjR+42zpLy4AZBMd czWa8/nq7U39JYvXnkwX+vaG+kfi+05NQXwF/RpNxuLCC62AS9prodLiw4rWswZUNpmwvvzyupXFX oFHhNMuxUIz+0wcP8WdeIZZ8CSJ/pKMk9sgoGMbG7VJC2PWbTOXP8iHBEAfPft6/nFyI=; DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=sf.net; s=x ; h=MIME-Version:Content-Type:Content-Transfer-Encoding:Message-Id:Date: Subject:Cc:To:From:Sender:Reply-To:Content-ID:Content-Description:Resent-Date :Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:In-Reply-To: References:List-Id:List-Help:List-Unsubscribe:List-Subscribe:List-Post: List-Owner:List-Archive; bh=vU1ycY7GCmUeqhh20nXHtH1ShX3OQjcr+pnw1xwkW1s=; b=a PYEi+RiEOxH1sPFU00vnXdRgv5zEciAw+KVuphpB6uV+aOIzCmkkYtqqHslZk115sm+NnJss5kxJo twYui1naWQHB3DHjZoglDJGXYF+BxF++gwGK0Kh+DF+cP75VXr69U1FN05wAt5MtbVN2jbG3MQF3n cIrlgqq32Phsgd7o=; Received: from mail-psaapc01on2129.outbound.protection.outlook.com ([40.107.255.129] helo=APC01-PSA-obe.outbound.protection.outlook.com) by sfi-mx-1.v28.lw.sourceforge.com with esmtps (TLS1.2:ECDHE-RSA-AES256-GCM-SHA384:256) (Exim 4.95) id 1pIrdh-00AF7t-Je for linux-f2fs-devel@lists.sourceforge.net; Fri, 20 Jan 2023 13:41:09 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=ZO2P5MaRaElfGvxtu6946t3E2PFisdEn5ym408QngP9qKXxQHdk1IWXqD2N7KWtnorsXqzmXuThWVIPsB9eeBu7OS0s/f+jPhxsX3VbZqMGymyt2Vmm3bl8meoybg9/KaqCsna2pNIFIt5h4wWZL6+pd2Szi2f9RUun9WQqJ7B683t6oIOPlmQYtJUbWD3qu9kLgW0eNJcIQpOYhXOZNqVgFHREUhLTYgqb6My8nrlUiuIT9+xGd9YoSZNkvz7sUYP4mTs4uO1xyU+b6DszXd+srifafSM4juokX1YvnorrSBfRZXR9LZiqzf8I4XayxdFzD2YQu6PkmCi8b3rq3vQ== 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=vU1ycY7GCmUeqhh20nXHtH1ShX3OQjcr+pnw1xwkW1s=; b=bcLpem5r29M58MEsfZ3cwTmk2vZ8VKN7o0GveGEZJa6jkaiMMV7KNp/E/GaaikLydAt+uLk/Qglk/iGiI4ZJiIJ0+TdyGqOtZuQumjnzXxjFXs6IzKoIHUCo8QVUBC5jtIQoEULEy1Nfqk6sEPZXKpyaKXzMa7i5kHzyf8TsvcqZckWReGpz+4UR90CPZCKPwsBE5Y2wUxyNWkX07X35P3p6JsKJczRH89xU+aMJXAI84KfLYlfWEhnG4WyAl98WnBBZdY+TH1qrQD2fD6HxT/7DyvgiktJJRPwJJRSRg6u5XlWRiTer79ika67bRhGJRuDqeqv8/0Wtmn0rlHHXYQ== 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=vU1ycY7GCmUeqhh20nXHtH1ShX3OQjcr+pnw1xwkW1s=; b=b27vdpUFuztfGG43Fb25p1LuZi+peu6h69Uz+nmsAGUPpjgI4eJtG3yifu4hf7HscR1o3u6CJz9IBWltry8UAMfMNwzQUgKhNKyjwKa+Ci54TANGF8sDGS1hi3s6BRnGjQemklzhRONF5AMvjJW9OYG65/xHyhXI0T8YjuW+tI/e4ieCEiq8c8A0KG5fCEAtrES2mW1gNdZtYNbJwxuWFARBQeEK1PImzX6pmq5R4qdR0vHuPIOFUCq3O7qeyAFcKfJVQV2p88Ek6Rh8vGABM6dJB1OBt0VB3PpDV9+pcIVIzZVkWHJ3oQbKgP+oIPzaqaLPRapyzJ3ktbb2yTyrgw== 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 TY0PR06MB5127.apcprd06.prod.outlook.com (2603:1096:400:1b2::8) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6043.5; Fri, 20 Jan 2023 13:40:50 +0000 Received: from SEZPR06MB5269.apcprd06.prod.outlook.com ([fe80::3e52:d08c:ecf4:d572]) by SEZPR06MB5269.apcprd06.prod.outlook.com ([fe80::3e52:d08c:ecf4:d572%5]) with mapi id 15.20.6002.012; Fri, 20 Jan 2023 13:40:49 +0000 To: jaegeuk@kernel.org, chao@kernel.org Date: Fri, 20 Jan 2023 21:40:26 +0800 Message-Id: <20230120134029.69200-1-frank.li@vivo.com> X-Mailer: git-send-email 2.35.1 X-ClientProxiedBy: SG2PR06CA0234.apcprd06.prod.outlook.com (2603:1096:4:ac::18) To SEZPR06MB5269.apcprd06.prod.outlook.com (2603:1096:101:78::6) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: SEZPR06MB5269:EE_|TY0PR06MB5127:EE_ X-MS-Office365-Filtering-Correlation-Id: cbfd678e-4f62-4000-a676-08dafaebf0ef X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: NEPvmUuDh777qxZNYL34+3UhLk6j4CCWydtZhmrmQoDHt7xDY8mK2JNOs3KJnCs53G1waUq/1xX+4w/IevkVi7CSc1V469XVube58PBrG3EzRkCT+SL0oZAgYl4SMr8wPaBbNASQ5eeL926iQX8ILfbAK23FOxIVME0xeJmMRmU8VZ1yoXPA49aWVIvYAK/ReGJ3dHfufap/c7RXcMay1mKXBbiX6EqqxS4Zbm+0qSfRzAcHcJQHIrUsYpwAiqiR7qv/9a9G/hWk1hlwA8i+Jxzt7N8Eapg65yBbIzwiXlKg+7t11qFNeaA6n3EP5v9/yYtJyE9arrA+4zbVZAIzMySx9MKNF1Lz//V1T9rwh35Q7kr8DP80Bj2gw8BkXi2HrwI0aYHrxf6eQkkVo2vdlBnpTteu6x06qyKda4AJluBzp8Kz3yIq10xYqm1tPuGmktf8UDHu93S8rmRFMgzlcyG69FY0KixoiMxoi/xMOlh9NtPvkwHWKL+CRpebV+oxhNoSxKkL2ed5s6gshoCczf2sjNJiLh2C+y6SWuJL2Dn8P8GX7wl6EfHTVuQGYL2CIxGnv+oYHTMtepilDJLWNIFW4AastTt7Oflci3luKjUWqls0suWGxGf7aIcWGgP48Hxi96dLwnbpIQKJiqvf1mtfTlI55x974/722QJvr1kP3x9UY7z3Gt6d8Yt8CrgeoaqhHxI5PZHTLdX1o+8TWA== 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)(376002)(346002)(136003)(396003)(39860400002)(451199015)(316002)(38350700002)(6506007)(38100700002)(66556008)(66476007)(66946007)(6666004)(107886003)(2906002)(1076003)(2616005)(4326008)(26005)(52116002)(478600001)(8676002)(8936002)(186003)(6512007)(5660300002)(83380400001)(36756003)(41300700001)(86362001)(6486002); DIR:OUT; SFP:1102; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: JuuHN6IpVIvKaQ8SynbOuWqztiKXEDlA6UIHK0sJGCVwfeODxr4arARB4V6Z1nM4Vu9e1VVX9TTXIgdfSeyBrnp7wn2Lvl4nEV3ORkTDguOKgDLB44AjHTKXtRP3To3oHTKkJDertiBRf6cVn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bT5Tijc4lCq6D+tLaJsXvbyn1sQJr8GxQHv+W3yeIdh9jlPJzr8ta3KVa+wRRbrI9hPSX7OuUAHatcg4orpIAiI5quvqWWUwa+AeHBoICSwHjeb02aPPnx3N2XqSPcCTuyZXecYMZgEtEWn2Df4U7BFjQ4tDfzzTIhGpFqkb9v5cv1OB4HfIniNhXGK3bgsgxtOSnQ9XucCBtrLCjrInapUK4w4lACZG92J6GvFdf6id+BQbYxdR9vtg5/sb6Pe6IY/96hWPaNFfpbcT0O/M8PiW/009soLrpG3OeJ5HrxjyMvLOgHUzTSmdSurmwnBfLQJ2z22HQHgI2hRCt5V2mh8DRx6ptWS/JS9ypv2L1E+lRFYTBO9u8Yunm X-OriginatorOrg: vivo.com X-MS-Exchange-CrossTenant-Network-Message-Id: cbfd678e-4f62-4000-a676-08dafaebf0ef X-MS-Exchange-CrossTenant-AuthSource: SEZPR06MB5269.apcprd06.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 20 Jan 2023 13:40:49.4729 (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: EmAQt5s2l/zxaNKLCip/goliOWp3dyOpbVMc58XMMT+NjO1dYBgWke/Mc/XPwip+2BFXUpUs/xLxtN9k7CTyBA== X-MS-Exchange-Transport-CrossTenantHeadersStamped: TY0PR06MB5127 X-Headers-End: 1pIrdh-00AF7t-Je Subject: [f2fs-dev] [PATCH 1/4] f2fs: fix to set ipu policy X-BeenThere: linux-f2fs-devel@lists.sourceforge.net X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-Patchwork-Original-From: Yangtao Li via Linux-f2fs-devel From: Yangtao Li Reply-To: Yangtao Li Cc: Yangtao Li , linux-kernel@vger.kernel.org, linux-f2fs-devel@lists.sourceforge.net Errors-To: linux-f2fs-devel-bounces@lists.sourceforge.net For LFS mode, it should update outplace and no need inplace update. When using LFS mode for small-volume devices, IPU will not be used, and the OPU writing method is actually used, but F2FS_IPU_FORCE can be read from the ipu_policy node, which is different from the actual situation. And after remount, ipu should be disabled when convert to lfs mode, let's fix it. commit bdc48fa11e46 ("checkpatch/coding-style: deprecate 80-column warning") increased the limit to 100 columns. BTW modify some unnecessary newlines. Fixes: 84b89e5d943d ("f2fs: add auto tuning for small devices") Signed-off-by: Yangtao Li --- fs/f2fs/segment.h | 2 ++ fs/f2fs/super.c | 20 +++++++++----------- 2 files changed, 11 insertions(+), 11 deletions(-) diff --git a/fs/f2fs/segment.h b/fs/f2fs/segment.h index ad6a9c19f46a..0b0eb8f03cba 100644 --- a/fs/f2fs/segment.h +++ b/fs/f2fs/segment.h @@ -670,6 +670,8 @@ static inline int utilization(struct f2fs_sb_info *sbi) #define SMALL_VOLUME_SEGMENTS (16 * 512) /* 16GB */ +#define F2FS_IPU_DISABLE 0 + enum { F2FS_IPU_FORCE, F2FS_IPU_SSR, diff --git a/fs/f2fs/super.c b/fs/f2fs/super.c index d8a65645ee48..ebc76683f05d 100644 --- a/fs/f2fs/super.c +++ b/fs/f2fs/super.c @@ -2272,6 +2272,9 @@ static int f2fs_remount(struct super_block *sb, int *flags, char *data) if (err) goto restore_opts; + if (F2FS_OPTION(sbi).fs_mode == FS_MODE_LFS) + SM_I(sbi)->ipu_policy = F2FS_IPU_DISABLE; + /* * Previous and new state of filesystem is RO, * so skip checking GC and FLUSH_MERGE conditions. @@ -4080,10 +4083,9 @@ static void f2fs_tuning_parameters(struct f2fs_sb_info *sbi) /* adjust parameters according to the volume size */ if (MAIN_SEGS(sbi) <= SMALL_VOLUME_SEGMENTS) { if (f2fs_block_unit_discard(sbi)) - SM_I(sbi)->dcc_info->discard_granularity = - MIN_DISCARD_GRANULARITY; - SM_I(sbi)->ipu_policy = BIT(F2FS_IPU_FORCE) | - BIT(F2FS_IPU_HONOR_OPU_WRITE); + SM_I(sbi)->dcc_info->discard_granularity = MIN_DISCARD_GRANULARITY; + if (F2FS_OPTION(sbi).fs_mode != FS_MODE_LFS) + SM_I(sbi)->ipu_policy = BIT(F2FS_IPU_FORCE) | BIT(F2FS_IPU_HONOR_OPU_WRITE); } sbi->readdir_ra = true; @@ -4310,9 +4312,7 @@ static int f2fs_fill_super(struct super_block *sb, void *data, int silent) test_opt(sbi, MERGE_CHECKPOINT)) { err = f2fs_start_ckpt_thread(sbi); if (err) { - f2fs_err(sbi, - "Failed to start F2FS issue_checkpoint_thread (%d)", - err); + f2fs_err(sbi, "Failed to start F2FS issue_checkpoint_thread (%d)", err); goto stop_ckpt_thread; } } @@ -4320,14 +4320,12 @@ static int f2fs_fill_super(struct super_block *sb, void *data, int silent) /* setup f2fs internal modules */ err = f2fs_build_segment_manager(sbi); if (err) { - f2fs_err(sbi, "Failed to initialize F2FS segment manager (%d)", - err); + f2fs_err(sbi, "Failed to initialize F2FS segment manager (%d)", err); goto free_sm; } err = f2fs_build_node_manager(sbi); if (err) { - f2fs_err(sbi, "Failed to initialize F2FS node manager (%d)", - err); + f2fs_err(sbi, "Failed to initialize F2FS node manager (%d)", err); goto free_nm; } From patchwork Fri Jan 20 13:40:27 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Yangtao Li X-Patchwork-Id: 13109881 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from lists.sourceforge.net (lists.sourceforge.net [216.105.38.7]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 2F642C25B4E for ; Fri, 20 Jan 2023 13:41:11 +0000 (UTC) Received: from [127.0.0.1] (helo=sfs-ml-1.v29.lw.sourceforge.com) by sfs-ml-1.v29.lw.sourceforge.com with esmtp (Exim 4.95) (envelope-from ) id 1pIrdl-0003FA-Jw; Fri, 20 Jan 2023 13:41:08 +0000 Received: from [172.30.20.202] (helo=mx.sourceforge.net) by sfs-ml-1.v29.lw.sourceforge.com with esmtps (TLS1.2) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.95) (envelope-from ) id 1pIrdi-0003Ep-7e for linux-f2fs-devel@lists.sourceforge.net; Fri, 20 Jan 2023 13:41:05 +0000 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=sourceforge.net; s=x; h=MIME-Version:Content-Type:Content-Transfer-Encoding :References:In-Reply-To:Message-Id:Date:Subject:Cc:To:From:Sender:Reply-To: Content-ID:Content-Description:Resent-Date:Resent-From:Resent-Sender: Resent-To:Resent-Cc:Resent-Message-ID:List-Id:List-Help:List-Unsubscribe: List-Subscribe:List-Post:List-Owner:List-Archive; bh=smT8vJ0bT+nzUyUQ1bOT7yb2PHCpctRrRzjc0vu+iEQ=; b=c18Vg9RNvisfAFmozj/vWLCMNx MdrqZWXACPZOJ2DFvy22ysvuRGd5J4fecZQLheQC9SG8DXGLnMkaAKWFcCer2z/upa9G1EbRcKcQ4 11uxcEwEj8ijaU32EkR5qp3PDyrhBEobEJ6fmCPlQGMV16tLDMwRi/19VBuZ9UThv/x8=; DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=sf.net; s=x ; h=MIME-Version:Content-Type:Content-Transfer-Encoding:References: In-Reply-To:Message-Id:Date:Subject:Cc:To:From:Sender:Reply-To:Content-ID: Content-Description:Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc :Resent-Message-ID:List-Id:List-Help:List-Unsubscribe:List-Subscribe: List-Post:List-Owner:List-Archive; bh=smT8vJ0bT+nzUyUQ1bOT7yb2PHCpctRrRzjc0vu+iEQ=; b=KfL9NSoYjPXLndRatsxgQ2zaVM ALpjaRbEntMBE7cO3BnJ/wCy8f+/gw0dsBimBLsXtDy4ybTijTju+WJB3Ksu3OYlTOfqQU/M5XnMl tSs6dosmsdY6kQxOS3xvIbl04jhPX6zfbxWjkiWA4euA+YPooL8gkiWta+Hxe+px41FA=; Received: from mail-psaapc01on2129.outbound.protection.outlook.com ([40.107.255.129] helo=APC01-PSA-obe.outbound.protection.outlook.com) by sfi-mx-1.v28.lw.sourceforge.com with esmtps (TLS1.2:ECDHE-RSA-AES256-GCM-SHA384:256) (Exim 4.95) id 1pIrdb-00AF7t-B7 for linux-f2fs-devel@lists.sourceforge.net; Fri, 20 Jan 2023 13:41:05 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=JW+Y0WiZRgva8ciRyQwo44pSbllhhDtNS8MNMd/kayB+KlLsuBZy3Y0aVbLPw2Rzc6cZyZKDfrKfJxNaIoQeSSxiLMQ0We6K86Iq44ofH4DkWmkE8VWbJeMBJ48b7Ue6o0e+m0FWfhHLdwkais8ln04d5XkLshTSPCUTAvkvAUvGgjOMRR+sJUM4jDe9vNIvFbYJ3N4BCNYFKP3HJHt+n59gVWCZVMFOQjyGTSD5rwGHRykooUjjY9E87Dypoarno3YERyZgiA4KlQRvOXCIR1j6GpCLMcMDkl2mXz1AhA9IWtLT9UVR4lRNKaBUWS8ztNhr3fdlM7eoBpD9XYct3A== 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=smT8vJ0bT+nzUyUQ1bOT7yb2PHCpctRrRzjc0vu+iEQ=; b=iJpKx0OIZ93V0ejwWC0UFWRU96l+vec83GYWcIFOf5VSovEoItRNIHOnUhnE/Vz1dmzZbkneCU/ETRxzn4aZTQiPceg0kHvYcs1dxlP6EmVTzuLTYhkIfIxYDNKzbtZZgTGJQasGxROjChT1CDnMwE8SapdyNJdrYLTsRUO5DqUMMumBaozwhJjAvdcgV1gdxG4KnZAe+WJZIFwJQuiA94W6EJIFTzWgAeFJnBqtdyyhqFQq95QML6oKHHRnxamkTTRz68PZFD9fuqBSWL454K/6vk3DzIB0QTknOo71hhAck/Fj1TgH+ro5pDsddQWG8a6OXfHCKBn2Wvjs13R9EQ== 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=smT8vJ0bT+nzUyUQ1bOT7yb2PHCpctRrRzjc0vu+iEQ=; b=ejhVpBpWvNtzRDNkdReCZR/A9BmakOpS1S51gEieaYNiJ+ms9pzNKJHDbPf4jD0x3H65QQZnJ3fwxsZuoAS7rCInDhoE6r0b0Z3gCv8/FFNKUb3qjUaAw+V7TS0a7bo+cxFCe+ESu7fKjg3X0X7AQgXtpdh8QmytZAgkrfcpMQaJ+RYUSgppPmuorm9VvZI7cqA619LZF5UNk5UOkpWrdIDHSSiU1N/9/pY3pn0JTm2ZLbZY06ZiY0YjWFQZhpN8ZdpuI3u2J8qNmgjcfs6pC5HgUWOMH8lK2xLxc9/aXBJKJ3tKAtDcguMrjgHtoCNTVzSZNz5a63Lm2vkzkDfoTw== 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 TY0PR06MB5127.apcprd06.prod.outlook.com (2603:1096:400:1b2::8) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6043.5; Fri, 20 Jan 2023 13:40:52 +0000 Received: from SEZPR06MB5269.apcprd06.prod.outlook.com ([fe80::3e52:d08c:ecf4:d572]) by SEZPR06MB5269.apcprd06.prod.outlook.com ([fe80::3e52:d08c:ecf4:d572%5]) with mapi id 15.20.6002.012; Fri, 20 Jan 2023 13:40:52 +0000 To: jaegeuk@kernel.org, chao@kernel.org Date: Fri, 20 Jan 2023 21:40:27 +0800 Message-Id: <20230120134029.69200-2-frank.li@vivo.com> X-Mailer: git-send-email 2.35.1 In-Reply-To: <20230120134029.69200-1-frank.li@vivo.com> References: <20230120134029.69200-1-frank.li@vivo.com> X-ClientProxiedBy: SG2PR06CA0234.apcprd06.prod.outlook.com (2603:1096:4:ac::18) To SEZPR06MB5269.apcprd06.prod.outlook.com (2603:1096:101:78::6) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: SEZPR06MB5269:EE_|TY0PR06MB5127:EE_ X-MS-Office365-Filtering-Correlation-Id: 331be740-6006-4157-8302-08dafaebf280 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: 34U/fznAnjtyyvG1NMu1QjcawJqFnCJ96IHvP8PuvK0xMO2A2OoPUcMafsDthJOz4hfJYK0TSHhYj+yVgDTsyLnhz9ZbP/wrfRe+M26IpzciID9Kvk2nyFyIYg/QUcC/qbyT8m9rqPmg+idL4hcdq6pKK05LFXNT6IO5GdqWjoIDTGuW8wHtLhAnhwLMOqZ+m/Nb93jn9T8q56AGgfL4r8a+Wc2ETB9I5vbMl0u35rJgvKK7o6EXW/qAWmYfjWNhWOyE721ZRLb97dI3ChmRejic+lfQdze9FIJz62FAL6eQgr/K2bQPZPH2x5LlBoUFXIj7Jsd9RvFIWRnQyapHtZFMnZSUz9fhLdQdeFykUf10OU3yE+Z1o78df4o7Pas6XMvskGApb8eZm+T6eSIIe9uesXqhu3WqULwQrquOj4CTuHZOoGz/xDkxuh2EVsEfCVsH71nnYnPS1EGNKi+p43Gne6CeqZ/eKq1H5p1HJOe8tMJl8sQLQdtoY4uqJPh1w/P3lGr4cJ7XnH4r9ImN+li0m3sNzLh++mTuDgK/fHZz0pTDh8ViSFbJlstSjJbImETvKTBjPnv4FSgr2n1aAEaDMrWZfHK8dFb215OXoIpmOk0d9XkNZYmGE1Rc/hb6Dkl8OivV/cmDY5b66RZv7v/SKKvjWziFbWOdsZOttL0h9ly85GH9I9jXHJTVbkqM 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)(376002)(346002)(136003)(396003)(39860400002)(451199015)(316002)(38350700002)(6506007)(38100700002)(66556008)(66476007)(66946007)(6666004)(107886003)(2906002)(1076003)(2616005)(4326008)(26005)(52116002)(478600001)(8676002)(8936002)(186003)(6512007)(5660300002)(83380400001)(36756003)(41300700001)(86362001)(6486002); DIR:OUT; SFP:1102; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: RWGgjf44CD8q8i5vfgPV1OwvM65zlZbCu67NZlB8eK+JfP7MRPJp0o2j0gC0CiHoe9s5Vo4wxWzE5tC/JC6cPNE15F0uKd3vNYW05WMIA6kMdeXZ/+OsoPSfaFFFtLVeVKizPanLrWnJyhw1zMgwtV7PloriUP45uJhZobwzn7FTp9P1jebuS1a4hw88JXKUWznWHQ0ogVf6AWPb3Rk7Jv+m21qqw/H1QBW5D6maSnw9mjG+zZS/DSXhzom6BZHU/HkZonm0c+8nypUxMjT4oLnMxncnfN0rDvmxfCxpfc/gYe7WyH5XmLrXWRVzFOcGlfcfN5uSbjk89wb0GKrEpDN1mJAaux3Ef8MZ8H6/4gw3Pv7sb7H8U9hJFB9CZ88hXoyblLX266wMNSxNa4u+B6J95AVgEJlgYQHo0EAMa2xEi4VRd1mtc1CvgsoqLswOKV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4+Ofw/Fl48JT2vNK1op+wSxTcKSx9RI7G31yI0mTZ85glB8XfBd2cwFr1J1h X-OriginatorOrg: vivo.com X-MS-Exchange-CrossTenant-Network-Message-Id: 331be740-6006-4157-8302-08dafaebf280 X-MS-Exchange-CrossTenant-AuthSource: SEZPR06MB5269.apcprd06.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 20 Jan 2023 13:40:52.0206 (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: HnugIPF/2l2ForYzuwyAbeFYkPA5WRhDBlCOnGVqKw/Fh4EuligokRvTZT7z093Jgv89fF/l/CEg7LhRWo0Tdw== X-MS-Exchange-Transport-CrossTenantHeadersStamped: TY0PR06MB5127 X-Headers-End: 1pIrdb-00AF7t-B7 Subject: [f2fs-dev] [PATCH 2/4] f2fs: add sanity check for ipu_policy X-BeenThere: linux-f2fs-devel@lists.sourceforge.net X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-Patchwork-Original-From: Yangtao Li via Linux-f2fs-devel From: Yangtao Li Reply-To: Yangtao Li Cc: Yangtao Li , linux-kernel@vger.kernel.org, linux-f2fs-devel@lists.sourceforge.net Errors-To: linux-f2fs-devel-bounces@lists.sourceforge.net Disallow the value set beyond the range, and disallow to change the value in lfs mode. BTW, convert open code to use BIT(). Signed-off-by: Yangtao Li --- fs/f2fs/segment.h | 1 + fs/f2fs/sysfs.c | 11 ++++++++++- 2 files changed, 11 insertions(+), 1 deletion(-) diff --git a/fs/f2fs/segment.h b/fs/f2fs/segment.h index 0b0eb8f03cba..d73e988566a5 100644 --- a/fs/f2fs/segment.h +++ b/fs/f2fs/segment.h @@ -681,6 +681,7 @@ enum { F2FS_IPU_ASYNC, F2FS_IPU_NOCACHE, F2FS_IPU_HONOR_OPU_WRITE, + F2FS_IPU_MAX, }; #define F2FS_IPU_POLICY(name) \ diff --git a/fs/f2fs/sysfs.c b/fs/f2fs/sysfs.c index bdc761f36310..576e6416ffb9 100644 --- a/fs/f2fs/sysfs.c +++ b/fs/f2fs/sysfs.c @@ -452,7 +452,7 @@ static ssize_t __sbi_store(struct f2fs_attr *a, if (ret < 0) return ret; #ifdef CONFIG_F2FS_FAULT_INJECTION - if (a->struct_type == FAULT_INFO_TYPE && t >= (1 << FAULT_MAX)) + if (a->struct_type == FAULT_INFO_TYPE && t >= BIT(FAULT_MAX)) return -EINVAL; if (a->struct_type == FAULT_INFO_RATE && t >= UINT_MAX) return -EINVAL; @@ -706,6 +706,15 @@ static ssize_t __sbi_store(struct f2fs_attr *a, return count; } + if (!strcmp(a->attr.name, "ipu_policy")) { + if (F2FS_OPTION(sbi).fs_mode == FS_MODE_LFS) + return -EINVAL; + if (t >= BIT(F2FS_IPU_MAX)) + return -EINVAL; + SM_I(sbi)->ipu_policy = (unsigned int)t; + return count; + } + *ui = (unsigned int)t; return count; From patchwork Fri Jan 20 13:40:28 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Yangtao Li X-Patchwork-Id: 13109882 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from lists.sourceforge.net (lists.sourceforge.net [216.105.38.7]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id A6715C05027 for ; Fri, 20 Jan 2023 13:41:13 +0000 (UTC) Received: from [127.0.0.1] (helo=sfs-ml-1.v29.lw.sourceforge.com) by sfs-ml-1.v29.lw.sourceforge.com with esmtp (Exim 4.95) (envelope-from ) id 1pIrdp-0003Fw-Uj; Fri, 20 Jan 2023 13:41:13 +0000 Received: from [172.30.20.202] (helo=mx.sourceforge.net) by sfs-ml-1.v29.lw.sourceforge.com with esmtps (TLS1.2) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.95) (envelope-from ) id 1pIrdo-0003Fd-4y for linux-f2fs-devel@lists.sourceforge.net; Fri, 20 Jan 2023 13:41:11 +0000 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=sourceforge.net; s=x; h=MIME-Version:Content-Type:Content-Transfer-Encoding :References:In-Reply-To:Message-Id:Date:Subject:Cc:To:From:Sender:Reply-To: Content-ID:Content-Description:Resent-Date:Resent-From:Resent-Sender: Resent-To:Resent-Cc:Resent-Message-ID:List-Id:List-Help:List-Unsubscribe: List-Subscribe:List-Post:List-Owner:List-Archive; bh=U5emMNXcn5nO4RQsCH/yOtGcWvmEc1t6pdeO4lYcqJU=; b=nFC2npC7geYyjmVt47suMDIxoS PjjEIBjTkvYa2V2PQ+rmT5cEchZeG59Hhr8qAe8AsyfGonYDQW0k5z4KphQEuWf+Vn/pluAxVgl2H RL7PkrRrKlpHhIHfLB1p97b6HHeUXZQ0jGIY5Zw/PPdrjuRMMMWihlMn5adWodm0d9Uc=; DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=sf.net; s=x ; h=MIME-Version:Content-Type:Content-Transfer-Encoding:References: In-Reply-To:Message-Id:Date:Subject:Cc:To:From:Sender:Reply-To:Content-ID: Content-Description:Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc :Resent-Message-ID:List-Id:List-Help:List-Unsubscribe:List-Subscribe: List-Post:List-Owner:List-Archive; bh=U5emMNXcn5nO4RQsCH/yOtGcWvmEc1t6pdeO4lYcqJU=; b=IHYlDd34djJILxn2+BRCnPyCBB KLXE8OCVhrQixuiFA7wswj7M25UKvhI+QkHcd4K8S49YdU0sCex6XUF4EGETSfNQjXG5v7yTe+/am sboUgwzQnBJJ6p160rJ4e70n5MfCEtt5xBnr++awFVFUsrKHWIAmt8YBeL2lf8T12kIA=; Received: from mail-psaapc01on2129.outbound.protection.outlook.com ([40.107.255.129] helo=APC01-PSA-obe.outbound.protection.outlook.com) by sfi-mx-1.v28.lw.sourceforge.com with esmtps (TLS1.2:ECDHE-RSA-AES256-GCM-SHA384:256) (Exim 4.95) id 1pIrdl-00AF7t-L1 for linux-f2fs-devel@lists.sourceforge.net; Fri, 20 Jan 2023 13:41:11 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=mTxvMjxd5b+5u790FetDa3dUnWNuSrf5l9xYK3q+KM7EgYjJWgEWmrBoIJHm6jDJALKiScDpYNvV5rDuwZYPhctu8MJfHASa/hSxg0uc2WweA7+XMWiu5rzqbyZJK/fH89/dPkJBukPg4by9idMsSYXr/ZOiuVg/fLYNRDste9pQcgMwinVGHHJVO4NwCmXDZTUmb6cVOvtvLd00zi0tipJl5QJR5TN8UPt4bVfySQ0EWratghuVo+cEzta5WJHugFLcHQKBKlzhPE3PbJgTegTB7+Vhf9Mmz/kn1HPD9uGTt9WZ0MKfluNzoMVLAE5AtL5WWcz7mibF85exYEUcOQ== 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=U5emMNXcn5nO4RQsCH/yOtGcWvmEc1t6pdeO4lYcqJU=; b=j1kYe+X9ec9rDig3PUT11XGugEdHBYLDPCS0ZSgePaze7y7iBhr3Qn631QeuxCI8JSWlXwnONGo/k8ZjUHM5IySshXkkWQoRrpSkSXXwXGKf01GJGallfH6cErGD2IOuTvmkeQZJSjfw5YiImTpVL3MSoUvWSqR9OfC0JVOaWeNopVsnW4bj2StO+5LRv6w74if2r+L82lHgTHd5UJhN1ULC045g5gLM0aLYQsc0iJlMaz2sFYSVli7+2LPqD7OVPXSDRpklDW5Jn4CrGv2vacxkb5dB4Q3MxwTI2QNx3xsoE9JLSNLbhtPckZfWKahkcuCcJ8II5u9hMLgpBjynmw== 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=U5emMNXcn5nO4RQsCH/yOtGcWvmEc1t6pdeO4lYcqJU=; b=bihMwYZzrX51oJjGWlC3xoL958U387HIYZUxj23vElANOwmqEPuMJlAzjKIRPD2Ep1NHwgxaFep7ssxC+eE1v6a9+FU4lECkGJ+0K0u9GDF6UBGdXbX0of0SW5id4v6itF45LTDog51bF0oZGjLAYkKFwK4u64Re6d6v00Oz9R0M4ZNES+1sT+z4w7GZhBgTjANmy1yZ+5ogYpL+WXuL1la80CRY0V/8FGw+eg/DH6aeiqYEoguffqiEOo7DAv0XLTKb6bJm/TT9RXGSPtvWHisU9SN59SV2J92im9yB64HOZApfjMKfOA1dVI+hRljUMywKvLiSlDMngpcariQpPA== 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 TY0PR06MB5127.apcprd06.prod.outlook.com (2603:1096:400:1b2::8) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6043.5; Fri, 20 Jan 2023 13:40:54 +0000 Received: from SEZPR06MB5269.apcprd06.prod.outlook.com ([fe80::3e52:d08c:ecf4:d572]) by SEZPR06MB5269.apcprd06.prod.outlook.com ([fe80::3e52:d08c:ecf4:d572%5]) with mapi id 15.20.6002.012; Fri, 20 Jan 2023 13:40:54 +0000 To: jaegeuk@kernel.org, chao@kernel.org Date: Fri, 20 Jan 2023 21:40:28 +0800 Message-Id: <20230120134029.69200-3-frank.li@vivo.com> X-Mailer: git-send-email 2.35.1 In-Reply-To: <20230120134029.69200-1-frank.li@vivo.com> References: <20230120134029.69200-1-frank.li@vivo.com> X-ClientProxiedBy: SG2PR06CA0234.apcprd06.prod.outlook.com (2603:1096:4:ac::18) To SEZPR06MB5269.apcprd06.prod.outlook.com (2603:1096:101:78::6) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: SEZPR06MB5269:EE_|TY0PR06MB5127:EE_ X-MS-Office365-Filtering-Correlation-Id: a6cddac8-d20c-43df-47ca-08dafaebf3b6 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: 8MXvqp9MScye/SjJZRoqqU7y+AWyeMm4p7BaFHPSH0E5dweOXOXzADDc6jtSIZijr2Qk4Iw3jP4DaN5vM64vWj1dggPB49xVclPmGB/sZ4CFCDkXdRXdHEn3j/jk2PZ/Var18u2Q4xV1qPwNa8iSBw9x0F9wnnjJxoeCNKtbge8yUrib7FKvPPnRairn4m3KipCTUiKK84xB2K8olk0as9Jxibm2w/5uSOV5XeB2Wmxs0Hls2Bt1WZjZBKIqvZ8PdVF+6S/6qjbHVmVeqy+kgfcd0sXo1yn6tAfmEz4eyH4K1pgotjlZhPnskzAaHxBl/uINCiFEcciPHkC2qCj4qt+rJCBCYvLC18eCOO65zghGMfRgbZoJyh6OxhPjbF+dZEcf4pUjZEIH2VN0JJonf77MtCooaDlRjhaVRss8vwuIUAhCFv9rldcHio641/uD3DKQ5QFieRlxdeVWLOprnKpLEi5m54LpxSgDj7+EVTP+vF57y85+LT36wsQlHCUQJiLjukr5ey3WQvf9dSDfEjtp82MiprlYfOiu7I4MV4ba/6eRTZkITfUNV+bxLcXhpOf47/rZ2E0xzDD4IU8UGYY2JlLgTzLKe6iJlN91IkJfkxeQ8mj0gXO1SJUqueTv0UNmXSPKwNr27+f3QaqOsygR6nHgs2MVNVEB88gymbXgFd+FjqBIC6twrbOf7cVhux3huNogiyD+L2ouhkIsIQ== 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)(376002)(346002)(136003)(396003)(39860400002)(451199015)(19627235002)(316002)(38350700002)(6506007)(38100700002)(66556008)(66476007)(66946007)(6666004)(107886003)(2906002)(1076003)(2616005)(4326008)(26005)(52116002)(478600001)(8676002)(8936002)(186003)(6512007)(5660300002)(83380400001)(36756003)(41300700001)(86362001)(6486002); DIR:OUT; SFP:1102; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: wPjxsoFdVHRgNrUK6yA0oS9z0Y9VTXQn4ObcUtAM1f6iXb0kyAChyQTfSnFcIqj8xcZLHmblvuLLfrjmDYgB74KplaA3iFbNtuChAnfbN3Ig8Wg9yoDsw9A2pAVrVp6uq7EuUiAfDig5zOIzmrZV7cddY42LxgyHTpzazRSpYUWWjqfvAvDg+fafHnft+886lHg9aoyd5nCtRIqC8+Lf7o9DlvR6zh1+5nBp6RrU/LhN6iT2+/G/0DpjQ4fBail9q7g+caxtjsTmVDs7H+v4Fh+8sJZc4JATS5OyNf7Yi9w+YLwu416g9NFsNbaVNWFXZjeEKxCeWhWSlqEmiBGWy5hHipiiQIFxQ+Ay5Bm/C45lePEZcYNVOQT/CgmrLU19i3hQAiPO/PNU2E0u5cicaDtGrd14VzokxrgkiLTsGy7AqNyXH2q2ffZV2eQTr+byvctF1jRmKflLB7TWbhs3WQPrRV7HMC6T43dZTkOZSRI+BiON8Cnjy6cv9JmSNcJ8IbfSVkf5f5KbsTaFwUt9+xJ4DL22chhRbw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id: a6cddac8-d20c-43df-47ca-08dafaebf3b6 X-MS-Exchange-CrossTenant-AuthSource: SEZPR06MB5269.apcprd06.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 20 Jan 2023 13:40:54.0508 (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: qn4qQ5dbZu7dhmcjDaXwgKhV7cuENZEZ/MZu6++5kWSnKjdqvuyS96dXo6/g0XACjc5t3ZMc2cYhzN21kLVlkg== X-MS-Exchange-Transport-CrossTenantHeadersStamped: TY0PR06MB5127 X-Headers-End: 1pIrdl-00AF7t-L1 Subject: [f2fs-dev] [PATCH 3/4] f2fs: introduce ipu_mode sysfs node X-BeenThere: linux-f2fs-devel@lists.sourceforge.net X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-Patchwork-Original-From: Yangtao Li via Linux-f2fs-devel From: Yangtao Li Reply-To: Yangtao Li Cc: Yangtao Li , linux-kernel@vger.kernel.org, linux-f2fs-devel@lists.sourceforge.net Errors-To: linux-f2fs-devel-bounces@lists.sourceforge.net Add a ipu_mode sysfs node to show the current ipu policy as a string. Since we use ipu_policy as a bitmap, and the bitmap API parameter is unsigned long type data, let's change ipu_policy to unsigned long type. Signed-off-by: Yangtao Li --- Documentation/ABI/testing/sysfs-fs-f2fs | 6 ++++++ fs/f2fs/f2fs.h | 4 ++-- fs/f2fs/segment.h | 1 + fs/f2fs/sysfs.c | 26 +++++++++++++++++++++++++ 4 files changed, 35 insertions(+), 2 deletions(-) diff --git a/Documentation/ABI/testing/sysfs-fs-f2fs b/Documentation/ABI/testing/sysfs-fs-f2fs index 0f17adc80488..64b15a28fe30 100644 --- a/Documentation/ABI/testing/sysfs-fs-f2fs +++ b/Documentation/ABI/testing/sysfs-fs-f2fs @@ -722,3 +722,9 @@ What: /sys/fs/f2fs//last_age_weight Date: January 2023 Contact: "Ping Xiong" Description: When DATA SEPARATION is on, it controls the weight of last data block age. + +What: /sys/fs/f2fs//ipu_mode +Date: January 2023 +Contact: "Yangtao Li" +Description: Show the current ipu policy as a string. + This is a read-only entry. diff --git a/fs/f2fs/f2fs.h b/fs/f2fs/f2fs.h index 9edad9ccc2cd..b221a3bdb3fe 100644 --- a/fs/f2fs/f2fs.h +++ b/fs/f2fs/f2fs.h @@ -1071,7 +1071,7 @@ struct f2fs_sm_info { struct list_head sit_entry_set; /* sit entry set list */ - unsigned int ipu_policy; /* in-place-update policy */ + unsigned long ipu_policy; /* in-place-update policy */ unsigned int min_ipu_util; /* in-place-update threshold */ unsigned int min_fsync_blocks; /* threshold for fsync */ unsigned int min_seq_blocks; /* threshold for sequential blocks */ @@ -1323,7 +1323,7 @@ enum { MAX_TIME, }; -/* Note that you need to keep synchronization with this gc_mode_names array */ +/* Modification on enum should be synchronized with gc_mode_names array */ enum { GC_NORMAL, GC_IDLE_CB, diff --git a/fs/f2fs/segment.h b/fs/f2fs/segment.h index d73e988566a5..50c63155ad56 100644 --- a/fs/f2fs/segment.h +++ b/fs/f2fs/segment.h @@ -672,6 +672,7 @@ static inline int utilization(struct f2fs_sb_info *sbi) #define F2FS_IPU_DISABLE 0 +/* Modification on enum should be synchronized with ipu_mode_names array */ enum { F2FS_IPU_FORCE, F2FS_IPU_SSR, diff --git a/fs/f2fs/sysfs.c b/fs/f2fs/sysfs.c index 576e6416ffb9..aaf5d8650518 100644 --- a/fs/f2fs/sysfs.c +++ b/fs/f2fs/sysfs.c @@ -51,6 +51,17 @@ static const char *gc_mode_names[MAX_GC_MODE] = { "GC_URGENT_MID" }; +static const char *ipu_mode_names[F2FS_IPU_MAX] = { + "FORCE", + "SSR", + "UTIL", + "SSR_UTIL", + "FSYNC", + "ASYNC", + "NOCACHE", + "HONOR_OPU_WRITE", +}; + struct f2fs_attr { struct attribute attr; ssize_t (*show)(struct f2fs_attr *a, struct f2fs_sb_info *sbi, char *buf); @@ -149,6 +160,19 @@ static ssize_t gc_mode_show(struct f2fs_attr *a, return sysfs_emit(buf, "%s\n", gc_mode_names[sbi->gc_mode]); } +static ssize_t ipu_mode_show(struct f2fs_attr *a, + struct f2fs_sb_info *sbi, char *buf) +{ + int len = 0, i = 0; + + if (SM_I(sbi)->ipu_policy == F2FS_IPU_DISABLE) + return sysfs_emit(buf, "DISABLE\n"); + + for_each_set_bit(i, &SM_I(sbi)->ipu_policy, F2FS_IPU_MAX) + len += scnprintf(buf + len, PAGE_SIZE - len, "%s\n", ipu_mode_names[i]); + return len; +} + static ssize_t features_show(struct f2fs_attr *a, struct f2fs_sb_info *sbi, char *buf) { @@ -907,6 +931,7 @@ 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); +F2FS_GENERAL_RO_ATTR(ipu_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); @@ -997,6 +1022,7 @@ static struct attribute *f2fs_attrs[] = { ATTR_LIST(max_ordered_discard), ATTR_LIST(pending_discard), ATTR_LIST(gc_mode), + ATTR_LIST(ipu_mode), ATTR_LIST(ipu_policy), ATTR_LIST(min_ipu_util), ATTR_LIST(min_fsync_blocks), From patchwork Fri Jan 20 13:40:29 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Yangtao Li X-Patchwork-Id: 13109884 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from lists.sourceforge.net (lists.sourceforge.net [216.105.38.7]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id ABFEAC25B4E for ; Fri, 20 Jan 2023 13:41:28 +0000 (UTC) Received: from [127.0.0.1] (helo=sfs-ml-2.v29.lw.sourceforge.com) by sfs-ml-2.v29.lw.sourceforge.com with esmtp (Exim 4.95) (envelope-from ) id 1pIre4-00073s-UI; Fri, 20 Jan 2023 13:41:28 +0000 Received: from [172.30.20.202] (helo=mx.sourceforge.net) by sfs-ml-2.v29.lw.sourceforge.com with esmtps (TLS1.2) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.95) (envelope-from ) id 1pIrdp-00073f-4A for linux-f2fs-devel@lists.sourceforge.net; Fri, 20 Jan 2023 13:41:12 +0000 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=sourceforge.net; s=x; h=MIME-Version:Content-Type:Content-Transfer-Encoding :References:In-Reply-To:Message-Id:Date:Subject:Cc:To:From:Sender:Reply-To: Content-ID:Content-Description:Resent-Date:Resent-From:Resent-Sender: Resent-To:Resent-Cc:Resent-Message-ID:List-Id:List-Help:List-Unsubscribe: List-Subscribe:List-Post:List-Owner:List-Archive; bh=mLOdM8LVsxaz86Ehuw6AfCW5Tg8yFGJpSkcggspwKKM=; b=YTwHw93fqUaFOigSm50RIuYuWq vzWiMeyqrbTlY0VSgScptP6CtU3xSUxgW6sxSp12lVKThHY/DrD41NjvMLAJIGu4wlqXOSJXZSKt1 G6sbnXF5UdyckyfM52gFalkMVLIekaBuawJsucm255+vlzm3AXHgLOHqPMHoHSr/VFLw=; DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=sf.net; s=x ; h=MIME-Version:Content-Type:Content-Transfer-Encoding:References: In-Reply-To:Message-Id:Date:Subject:Cc:To:From:Sender:Reply-To:Content-ID: Content-Description:Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc :Resent-Message-ID:List-Id:List-Help:List-Unsubscribe:List-Subscribe: List-Post:List-Owner:List-Archive; bh=mLOdM8LVsxaz86Ehuw6AfCW5Tg8yFGJpSkcggspwKKM=; b=fR+1XiFQN0kjYyJgvpgmsj8/4R oXRxOebCkkJT8uZO47n8pp/nMu3U16Y4PAkIaB2fLQ8IUycVDl9FgUTztUmiLmm3n6z/kUxzJ8anV Q3exo2hIH77uHuWYTbgBGLd0p33bq8NRUA7u3VS08xqtk+JsVGVFM7WKQNM6DQPurgUw=; Received: from mail-psaapc01on2129.outbound.protection.outlook.com ([40.107.255.129] helo=APC01-PSA-obe.outbound.protection.outlook.com) by sfi-mx-1.v28.lw.sourceforge.com with esmtps (TLS1.2:ECDHE-RSA-AES256-GCM-SHA384:256) (Exim 4.95) id 1pIrdn-00AF7t-IR for linux-f2fs-devel@lists.sourceforge.net; Fri, 20 Jan 2023 13:41:12 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=mWygaqxgitnd8dn2c+qGk6UjnUe/RnweViC29rKSi1/7KP2z05Min7QOxMiU3J5lF/I4rrdPgrLdLC3TtFDDLfFtwsIYAvAmXamYjDvdv5ywX13NEn7cNN2SJsAs/XCPZCJY/jxKPDrRHMCOu/3PRJb7lyZzmNXmQKnH9yWA9oP2xv/w7XRjeHJovEqKVyALZ+jMGERnJwjRdj+HIZaUiBAIm2aVGLjIyTkq3Ycx2f4DcPCMq8uf6eMWYwgbqIuD7kB80zf952cF3P1iYGqGLlnmeG8IsRGBocsyKBsgRW+QKy65ua/1lZICyI6W7Yap1/DML3M2QWOJiOVX8wH/aw== 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=mLOdM8LVsxaz86Ehuw6AfCW5Tg8yFGJpSkcggspwKKM=; b=kMKr+CsACZYrbp8Hds/N1UgO6q92vPBe9rLHHDSMfpZbO3upH6DQJnM6UPiSzNa/wKMQbS+INgXDhngZq2cXhJejuMWgO/78DH9mK0VcQRT9pK2ZZxKskrH8FCtpxOC3U8lkmkaaW+T2GxfAk0tHOuzuUYlN7aqfVCnQxpKYpCLVE6u4OQQFyJ7awKmdXW2jr9efhoc4mgefyhCLqfNy0pIk+Z5rXt2I1nMnvSbLCpQbIYw1RYTigeHHAsz37jLcXgGCK+IBW/hYEnGKdhwS9SBj9QDAV9OD/r5Jsnbj0SygkJvUV3abszi6aP4mh4rBG/m6NSWTuiMNpzVKlcK6wA== 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=mLOdM8LVsxaz86Ehuw6AfCW5Tg8yFGJpSkcggspwKKM=; b=kS4Jz2b/8wJAuU/eNVLPGmz/3RGi9hVWb1xyYDMitKXVLbKGfjQi0H9fy/YBGrByPTjmuHI+k7wTUU33fIkWSN5/5xPZvlZSIo4aw3Gi1jJAgdkFb9JTeNxaj51zsHW2HmU/lSE3R2YSW3UGs+ZB4Fu/GM6A3D/2sF+jfg5NqdYWtMTgFAFvuOHrDclLXbALYgmz8966FqRAGQ2jG01mHtOpNwggcwenG63y/j20R0IOuI4aY215fzYNWrU4UQLWokOQ+TcEKaE9raqgZP8OxfzOpHV/2YMtjYR02sG5FKXigxdFOFqrdtYnoRnEpdT3MsxJXd9ZzSga6DjqBZHC9Q== 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 TY0PR06MB5127.apcprd06.prod.outlook.com (2603:1096:400:1b2::8) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6043.5; Fri, 20 Jan 2023 13:40:56 +0000 Received: from SEZPR06MB5269.apcprd06.prod.outlook.com ([fe80::3e52:d08c:ecf4:d572]) by SEZPR06MB5269.apcprd06.prod.outlook.com ([fe80::3e52:d08c:ecf4:d572%5]) with mapi id 15.20.6002.012; Fri, 20 Jan 2023 13:40:55 +0000 To: jaegeuk@kernel.org, chao@kernel.org Date: Fri, 20 Jan 2023 21:40:29 +0800 Message-Id: <20230120134029.69200-4-frank.li@vivo.com> X-Mailer: git-send-email 2.35.1 In-Reply-To: <20230120134029.69200-1-frank.li@vivo.com> References: <20230120134029.69200-1-frank.li@vivo.com> X-ClientProxiedBy: SG2PR06CA0234.apcprd06.prod.outlook.com (2603:1096:4:ac::18) To SEZPR06MB5269.apcprd06.prod.outlook.com (2603:1096:101:78::6) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: SEZPR06MB5269:EE_|TY0PR06MB5127:EE_ X-MS-Office365-Filtering-Correlation-Id: d5d70597-7217-44d4-9901-08dafaebf4c8 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: ZUlJPiQfTYT0/hMnJM5SlxgETyLURTu0prdUkakWb/9gaVOYw0b5OIsbch6UF6TlwvhzbNpCo/3ajfPSYFbGYYjZaZg9dFvRGg9wOw+fPl5oxk1kIofmSGKLVsr2wymnQHloAnu6d/gZwlzXRHTnB9SxRbEPc7LpU04rpoawbWj1bZ2UGLuN0WJzUPHCiH8wv2IP1zOhg+0A1cRmaGePugbFvdBzDtqNqxhFbT7rR1lzQyslRkQ8yjRi6btuQG5LHXbDQcJePJpQqzksuNl9h39D0SXO+2QAqJxWYWG4xrK2baJcR9ECztA38XPUfpciwP5Qkyn/WlcRRoB1qEp7/s3OmfjRAWNpPs22yzgl6+Viucu8FLRHBRARq0TuktJ2I+kkTMGNGUN/Xx2luHbZCmKzsXiU76dNKw0a7Ebk0YSQTaeFMrcyWnOD+XU3Ks1bmmC+9AxHyFfrVuxIJuD/+PmbQQ4TxLy46XzJm+dg2KB0/buqXIb56pi0msv+ESUhoJf3pVM1e4BAMLG7kVV8X9O91TqVQ3fSCntjqJOJT6ZhcONRz7VcC3irugfHaNyznm5jUYLewqkQoq3DnKHU51MRH9VPTESEUInEWvPPwD5QBiqsp5I3Q5L7MA+b/rx1lZKUCyDjUaoJml74IKhx1P9H2GJ/klc5QelyLWtravmnL763cHsyRjsWk5BALk6/YdpUVWVY6g7zEX23KCEm2w== 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)(376002)(346002)(136003)(396003)(39860400002)(451199015)(19627235002)(316002)(38350700002)(6506007)(38100700002)(66556008)(66476007)(66946007)(6666004)(107886003)(2906002)(1076003)(2616005)(4326008)(26005)(52116002)(478600001)(8676002)(8936002)(186003)(6512007)(5660300002)(83380400001)(36756003)(41300700001)(86362001)(6486002); DIR:OUT; SFP:1102; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: svZaHbfGHIEgDb0RXUIDDxW9kdW7bKoYatlAxP4NTrzy4Nnq9QKpWGTCXWPJq098ji+LH9PJZS25+gfykaOU9WIJbLaOT0Y59ucMp5DiKKyudxLyBV8QRffNqhwl976riDwk0aRCRKhqobL/2Gtf32zjcfVEXIdAjzyzQSwiap2QjWKTWRJJHsfDc5ivGHVt4XwLeSKSR6HYq4hScu2v6tD8HBl7Vey74I/pkw6i5TCI8BLV1N5jMc6KEmMIDn9AuPulG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RvnRIo/7QpB2PjnXR58eJ46xHQUzzLbDcbG93A0JX1nuYLmk70XYd2ZIJ6XGTWj5IScwdrNMhiacPlBz6g7A3CuvjHVZHOGyHkZ2pBrkzwPv+sTK61PneDjJj/gWHsJi6YOpfStnwynLiCZB1zIAjmSwhViczARk1yUiN6d1MiMhW+jF8mPdnVVFpr0mxdWqk2ZWERUk8bKng2Up0coUesDCNlrGC6HrRXH0UXfO+cmQtv/JeMva6NjegAc6wDf3kM X-OriginatorOrg: vivo.com X-MS-Exchange-CrossTenant-Network-Message-Id: d5d70597-7217-44d4-9901-08dafaebf4c8 X-MS-Exchange-CrossTenant-AuthSource: SEZPR06MB5269.apcprd06.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 20 Jan 2023 13:40:55.8485 (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: PneOskVXex82iWQAgRf65AkqA2+J76zUPd/HGGDA2ZZyvfHrztIWu+sfGZtd1zDZNGoZJn+bd+3/HRLGPF9bcw== X-MS-Exchange-Transport-CrossTenantHeadersStamped: TY0PR06MB5127 X-Headers-End: 1pIrdn-00AF7t-IR Subject: [f2fs-dev] [PATCH 4/4] f2fs: move ipu_policy definitions to separated file X-BeenThere: linux-f2fs-devel@lists.sourceforge.net X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-Patchwork-Original-From: Yangtao Li via Linux-f2fs-devel From: Yangtao Li Reply-To: Yangtao Li Cc: Yangtao Li , linux-kernel@vger.kernel.org, linux-f2fs-devel@lists.sourceforge.net Errors-To: linux-f2fs-devel-bounces@lists.sourceforge.net User can control f2fs ipu policy through /sys/fs/f2fs//ipu_policy, export related definitions and introduce new macro to make it more convenient for users to use. Signed-off-by: Yangtao Li --- Documentation/ABI/testing/sysfs-fs-f2fs | 25 ++++++------ fs/f2fs/segment.c | 2 +- fs/f2fs/segment.h | 37 ++--------------- fs/f2fs/super.c | 2 +- fs/f2fs/sysfs.c | 2 +- include/uapi/linux/f2fs.h | 54 +++++++++++++++++++++++++ 6 files changed, 73 insertions(+), 49 deletions(-) diff --git a/Documentation/ABI/testing/sysfs-fs-f2fs b/Documentation/ABI/testing/sysfs-fs-f2fs index 64b15a28fe30..d05ad2bc56d1 100644 --- a/Documentation/ABI/testing/sysfs-fs-f2fs +++ b/Documentation/ABI/testing/sysfs-fs-f2fs @@ -49,18 +49,19 @@ Contact: "Jaegeuk Kim" Description: Controls the in-place-update policy. updates in f2fs. User can set: - ==== ================= - 0x01 F2FS_IPU_FORCE - 0x02 F2FS_IPU_SSR - 0x04 F2FS_IPU_UTIL - 0x08 F2FS_IPU_SSR_UTIL - 0x10 F2FS_IPU_FSYNC - 0x20 F2FS_IPU_ASYNC - 0x40 F2FS_IPU_NOCACHE - 0x80 F2FS_IPU_HONOR_OPU_WRITE - ==== ================= - - Refer segment.h for details. + ==== ============================ + 0x00 SET_F2FS_IPU_DISABLE + 0x01 SET_F2FS_IPU_FORCE + 0x02 SET_F2FS_IPU_SSR + 0x04 SET_F2FS_IPU_UTIL + 0x08 SET_F2FS_IPU_SSR_UTIL + 0x10 SET_F2FS_IPU_FSYNC + 0x20 SET_F2FS_IPU_ASYNC + 0x40 SET_F2FS_IPU_NOCACHE + 0x80 SET_F2FS_IPU_HONOR_OPU_WRITE + ==== ============================ + + Refer include/uapi/linux/f2fs.h for details. What: /sys/fs/f2fs//min_ipu_util Date: November 2013 diff --git a/fs/f2fs/segment.c b/fs/f2fs/segment.c index a007f5084e84..c56f5a80d3a6 100644 --- a/fs/f2fs/segment.c +++ b/fs/f2fs/segment.c @@ -5138,7 +5138,7 @@ int f2fs_build_segment_manager(struct f2fs_sb_info *sbi) sm_info->rec_prefree_segments = DEF_MAX_RECLAIM_PREFREE_SEGMENTS; if (!f2fs_lfs_mode(sbi)) - sm_info->ipu_policy = BIT(F2FS_IPU_FSYNC); + sm_info->ipu_policy = SET_F2FS_IPU_FSYNC; sm_info->min_ipu_util = DEF_MIN_IPU_UTIL; sm_info->min_fsync_blocks = DEF_MIN_FSYNC_BLOCKS; sm_info->min_seq_blocks = sbi->blocks_per_seg; diff --git a/fs/f2fs/segment.h b/fs/f2fs/segment.h index 50c63155ad56..c064ddffe91b 100644 --- a/fs/f2fs/segment.h +++ b/fs/f2fs/segment.h @@ -7,6 +7,7 @@ */ #include #include +#include /* constant macro */ #define NULL_SEGNO ((unsigned int)(~0)) @@ -646,51 +647,19 @@ static inline int utilization(struct f2fs_sb_info *sbi) sbi->user_block_count); } -/* - * Sometimes f2fs may be better to drop out-of-place update policy. - * And, users can control the policy through sysfs entries. - * There are five policies with triggering conditions as follows. - * F2FS_IPU_FORCE - all the time, - * F2FS_IPU_SSR - if SSR mode is activated, - * F2FS_IPU_UTIL - if FS utilization is over threashold, - * F2FS_IPU_SSR_UTIL - if SSR mode is activated and FS utilization is over - * threashold, - * F2FS_IPU_FSYNC - activated in fsync path only for high performance flash - * storages. IPU will be triggered only if the # of dirty - * pages over min_fsync_blocks. (=default option) - * F2FS_IPU_ASYNC - do IPU given by asynchronous write requests. - * F2FS_IPU_NOCACHE - disable IPU bio cache. - * F2FS_IPU_HONOR_OPU_WRITE - use OPU write prior to IPU write if inode has - * FI_OPU_WRITE flag. - * F2FS_IPU_DISABLE - disable IPU. (=default option in LFS mode) - */ #define DEF_MIN_IPU_UTIL 70 #define DEF_MIN_FSYNC_BLOCKS 8 #define DEF_MIN_HOT_BLOCKS 16 #define SMALL_VOLUME_SEGMENTS (16 * 512) /* 16GB */ -#define F2FS_IPU_DISABLE 0 - -/* Modification on enum should be synchronized with ipu_mode_names array */ -enum { - F2FS_IPU_FORCE, - F2FS_IPU_SSR, - F2FS_IPU_UTIL, - F2FS_IPU_SSR_UTIL, - F2FS_IPU_FSYNC, - F2FS_IPU_ASYNC, - F2FS_IPU_NOCACHE, - F2FS_IPU_HONOR_OPU_WRITE, - F2FS_IPU_MAX, -}; - #define F2FS_IPU_POLICY(name) \ static inline int IS_##name(struct f2fs_sb_info *sbi) \ { \ - return SM_I(sbi)->ipu_policy & BIT(name); \ + return TEST_##name(SM_I(sbi)->ipu_policy); \ } +F2FS_IPU_POLICY(F2FS_IPU_DISABLE); F2FS_IPU_POLICY(F2FS_IPU_FORCE); F2FS_IPU_POLICY(F2FS_IPU_SSR); F2FS_IPU_POLICY(F2FS_IPU_UTIL); diff --git a/fs/f2fs/super.c b/fs/f2fs/super.c index ebc76683f05d..b19085fa335a 100644 --- a/fs/f2fs/super.c +++ b/fs/f2fs/super.c @@ -4085,7 +4085,7 @@ static void f2fs_tuning_parameters(struct f2fs_sb_info *sbi) if (f2fs_block_unit_discard(sbi)) SM_I(sbi)->dcc_info->discard_granularity = MIN_DISCARD_GRANULARITY; if (F2FS_OPTION(sbi).fs_mode != FS_MODE_LFS) - SM_I(sbi)->ipu_policy = BIT(F2FS_IPU_FORCE) | BIT(F2FS_IPU_HONOR_OPU_WRITE); + SM_I(sbi)->ipu_policy = SET_F2FS_IPU_FORCE | SET_F2FS_IPU_HONOR_OPU_WRITE; } sbi->readdir_ra = true; diff --git a/fs/f2fs/sysfs.c b/fs/f2fs/sysfs.c index aaf5d8650518..375ace5f330d 100644 --- a/fs/f2fs/sysfs.c +++ b/fs/f2fs/sysfs.c @@ -165,7 +165,7 @@ static ssize_t ipu_mode_show(struct f2fs_attr *a, { int len = 0, i = 0; - if (SM_I(sbi)->ipu_policy == F2FS_IPU_DISABLE) + if (IS_F2FS_IPU_DISABLE(sbi)) return sysfs_emit(buf, "DISABLE\n"); for_each_set_bit(i, &SM_I(sbi)->ipu_policy, F2FS_IPU_MAX) diff --git a/include/uapi/linux/f2fs.h b/include/uapi/linux/f2fs.h index 955d440be104..1b672fb6af91 100644 --- a/include/uapi/linux/f2fs.h +++ b/include/uapi/linux/f2fs.h @@ -5,6 +5,60 @@ #include #include +/* + * For /sys/fs/f2fs//ipu_policy entry + * + * Sometimes f2fs may be better to drop out-of-place update policy. + * And, users can control the policy through sysfs entries. + * There are five policies with triggering conditions as follows. + * F2FS_IPU_FORCE - all the time, + * F2FS_IPU_SSR - if SSR mode is activated, + * F2FS_IPU_UTIL - if FS utilization is over threashold, + * F2FS_IPU_SSR_UTIL - if SSR mode is activated and FS utilization is over + * threashold, + * F2FS_IPU_FSYNC - activated in fsync path only for high performance flash + * storages. IPU will be triggered only if the # of dirty + * pages over min_fsync_blocks. (=default option) + * F2FS_IPU_ASYNC - do IPU given by asynchronous write requests. + * F2FS_IPU_NOCACHE - disable IPU bio cache. + * F2FS_IPU_HONOR_OPU_WRITE - use OPU write prior to IPU write if inode has + * FI_OPU_WRITE flag. + * F2FS_IPU_DISABLE - disable IPU. (=default option in LFS mode) + */ +#define F2FS_IPU_DISABLE 0 +/* Modification on enum should be synchronized with ipu_mode_names array */ +enum { + F2FS_IPU_FORCE, + F2FS_IPU_SSR, + F2FS_IPU_UTIL, + F2FS_IPU_SSR_UTIL, + F2FS_IPU_FSYNC, + F2FS_IPU_ASYNC, + F2FS_IPU_NOCACHE, + F2FS_IPU_HONOR_OPU_WRITE, + F2FS_IPU_MAX, +}; + +#define SET_F2FS_IPU_DISABLE F2FS_IPU_DISABLE +#define SET_F2FS_IPU_FORCE BIT(F2FS_IPU_FORCE) +#define SET_F2FS_IPU_SSR BIT(F2FS_IPU_SSR) +#define SET_F2FS_IPU_UTIL BIT(F2FS_IPU_UTIL) +#define SET_F2FS_IPU_SSR_UTIL BIT(F2FS_IPU_SSR_UTIL) +#define SET_F2FS_IPU_FSYNC BIT(F2FS_IPU_FSYNC) +#define SET_F2FS_IPU_ASYNC BIT(F2FS_IPU_ASYNC) +#define SET_F2FS_IPU_NOCACHE BIT(F2FS_IPU_NOCACHE) +#define SET_F2FS_IPU_HONOR_OPU_WRITE BIT(F2FS_IPU_HONOR_OPU_WRITE) + +#define TEST_F2FS_IPU_DISABLE(val) ((val) == F2FS_IPU_DISABLE) +#define TEST_F2FS_IPU_FORCE(val) ((val) & BIT(F2FS_IPU_FORCE)) +#define TEST_F2FS_IPU_SSR(val) ((val) & BIT(F2FS_IPU_SSR)) +#define TEST_F2FS_IPU_UTIL(val) ((val) & BIT(F2FS_IPU_UTIL)) +#define TEST_F2FS_IPU_SSR_UTIL(val) ((val) & BIT(F2FS_IPU_SSR_UTIL)) +#define TEST_F2FS_IPU_FSYNC(val) ((val) & BIT(F2FS_IPU_FSYNC)) +#define TEST_F2FS_IPU_ASYNC(val) ((val) & BIT(F2FS_IPU_ASYNC)) +#define TEST_F2FS_IPU_NOCACHE(val) ((val) & BIT(F2FS_IPU_NOCACHE)) +#define TEST_F2FS_IPU_HONOR_OPU_WRITE(val) ((val) & BIT(F2FS_IPU_HONOR_OPU_WRITE)) + /* * f2fs-specific ioctl commands */