From patchwork Sat Jan 21 05:12:04 2023 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: 46778 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:adf:eb09:0:0:0:0:0 with SMTP id s9csp586429wrn; Fri, 20 Jan 2023 21:47:14 -0800 (PST) X-Google-Smtp-Source: AMrXdXuFb0hzGNNe60SC/Wl/ommhIb9RVMh9Osi5BxNy2RMnpBTnZsQ0Ca4EPVJNndtltsH8cRvO X-Received: by 2002:a05:6a20:9c8b:b0:b8:bc13:c838 with SMTP id mj11-20020a056a209c8b00b000b8bc13c838mr18086754pzb.53.1674280034023; Fri, 20 Jan 2023 21:47:14 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1674280034; cv=pass; d=google.com; s=arc-20160816; b=kbGYIne1/3LKFR+MyghTcZunLRsqGo8sbMtE8uEGfGIJoeCi/0ysMiKxc5xA0ZIpjs 3R0wrDtNp14vwLRIRVnZZs7risf2VRoRSBK6pyAejekcIPNTuc9NiD/aOtOKnQD6wAVn zTUdje75mp96cTDqFRaemmNCkcxE2NflMmE+/pWFUf/a+jeL9eo8IG0/Qh0e7pmUQTTg 4dP1mF2RNCvrfB0Y4985JmsQKsShpAFzNYFga6mHkI6MkbpaNWRBsMywU2nmXkwuGGDs bvylgBfdmi+2OQ6FSBDxfVVgDNsc436VhjQacWV9TyQUJ6H9vYo+ZYO1r/wedlh9o71K EECw== 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=Re6VwMN0RWL3pDrBsb3XEkXWS2NBdN/1YA9ZEpvi8F4=; b=p5DvSabJU6sL9rg+XPPUhNY0dzHSTX7yY1CE64TYLtftpDgPdev+kVfjVVYXYrpSft ud0bE2RFEUx1uxiHklwkxsBH9T4GHAyz7lLQBG9wBhqUyuWySds7/Ww+R8bBtVqCJkcu logQ83hqanB/HJlZpIL2+94uPaJVb3Co1Cn9afao6aOzOW6pR9O2J64W/9igsD2uQatl vALaanSuYvoweeckej+vrlXSvEorhw4tgavZbi5hteluDZqU648smTPpOr8XfaWt4hl5 7DK0fkJ3hOIIocFcN7Wxf2aPt1azBq/NRuLWq/pVzJUIZD7BQ76sT3hsdKOFrQ0CTqir CU0g== ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@vivo.com header.s=selector2 header.b="Nh/J7AAq"; 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 e34-20020a630f22000000b00477c62b9498si46087682pgl.212.2023.01.20.21.46.59; Fri, 20 Jan 2023 21:47:13 -0800 (PST) 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="Nh/J7AAq"; 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 S229764AbjAUFMn (ORCPT + 99 others); Sat, 21 Jan 2023 00:12:43 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:48920 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229735AbjAUFMd (ORCPT ); Sat, 21 Jan 2023 00:12:33 -0500 Received: from APC01-TYZ-obe.outbound.protection.outlook.com (mail-tyzapc01on2134.outbound.protection.outlook.com [40.107.117.134]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id CABF973147 for ; Fri, 20 Jan 2023 21:12:31 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=H9qJnZq3uXl7I7/gMFaWqFfqyKP9o7R8PZdv/vU9+3xOJ+helXXtartZAhawFp3XgIbAR3NuZX9NIb5a4iRqyOw0uOPuziQMnLkvOJuFIiX6VRrzf2WTj/Gv9mUtkk9cQCv58niJkrx7GtBJVwlUc55rqoVQesrx72ITNb5ZD6FZrCouS5ZgMtiqBdUCYI+Er9lTE12zYpFJ5mU7U+Gd8G6g09FDuITBD9UcrCUnwuUv5DWgKhgh7TQjFjsgX0o8s+asmC2vDHHhXXgh1ShNyVX1qVwAK4mqD3nfzvlGR9xzQe8yjXzSn9ci8fNr+rhwEeeJvdhDX+bCJ8vbRwA8OA== 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=Re6VwMN0RWL3pDrBsb3XEkXWS2NBdN/1YA9ZEpvi8F4=; b=nIJF3U59k/xCI6/iOrtz7PexWO4RB1Zxysayn+M09FIZhYb5H40C1DQSXiaFKnlvkD+eOqYLd6FsiJ+Z6A/6Oeo/lb6ihfxzC11WLiFYu6dy5L43OFZYUO69CgrFmsAGNZwDYt9yy/uZ0vkXxj4ICStmX5TRQZubFB3RC3JP2XU9Y1ziHyRmHnsZuClzX5J/T8OOhxmQwqcmVr4G5WssLXJauVpl/S9WMZGEZkDK2IuliYCL/O+iZD0HdhXVEw+tsbKZ7R8UIx5pNOAReeToF5zbmIBsOVJLzeIAeL3CeNh8XFgCDyqJ1OeJ3mmOw8sG3TyZKbAwRrbBK+1BDWusEA== 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=Re6VwMN0RWL3pDrBsb3XEkXWS2NBdN/1YA9ZEpvi8F4=; b=Nh/J7AAqOCbUEFLbKxZiq9zOqMJkLBy+NQxM8P4orOA8eX3FnovYep2DoduTkXa5A37VeWE6hzT9PrUBuiA3uDH/hTU9eJN2cpX8NPmQU7EnhEfnNI+JsBngLnIzZ2w2gSa4PxUS324xy1gvWubagnhaYdXa6ZmD9Y+vZ3irSRXjkrgx2ZlPWlNM7a8uTxiOUQDACpd1LhSbolvI5AF0PEviANmWBdRagEr4ODZf8QEIQz8DKVbiBLCMgMCsknvUMms/FaL8ZmtWAY6FTHX/Up9h4cKsJE2a0lH1dKbSndYyu2JA+a/XyO9ECOPmtFJcC/daEzjq8tixYB2CjQB+IQ== 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 TYZPR06MB3885.apcprd06.prod.outlook.com (2603:1096:400:6::14) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6043.9; Sat, 21 Jan 2023 05:12:27 +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; Sat, 21 Jan 2023 05:12:26 +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 5/5] f2fs: move ipu_policy definitions to uapi header file Date: Sat, 21 Jan 2023 13:12:04 +0800 Message-Id: <20230121051204.81251-5-frank.li@vivo.com> X-Mailer: git-send-email 2.35.1 In-Reply-To: <20230121051204.81251-1-frank.li@vivo.com> References: <20230121051204.81251-1-frank.li@vivo.com> X-ClientProxiedBy: SI2PR01CA0008.apcprd01.prod.exchangelabs.com (2603:1096:4:191::10) To SEZPR06MB5269.apcprd06.prod.outlook.com (2603:1096:101:78::6) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: SEZPR06MB5269:EE_|TYZPR06MB3885:EE_ X-MS-Office365-Filtering-Correlation-Id: e9648a97-96cd-4a1a-674a-08dafb6e1667 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: J+FnAFwArb4bhfMuhuHPR/LXRT4gifBuuen5MLolEUWCdyCesS6JCHULlgl0980LR9VeG7H0BaqzIHD4pqxUkKdNQeduBpHEGczG3y+eXdfdTIKPU7Lw2BXHv5q82F/rUikAtypP3ydMu762tJLwpA6+WcWa5BEXOuJjoNETLN5Ju9/sSU4TDlKhqE3p+QolngUd1gNycUXOsVVwKtaquBlkFEkNc0X2AQl4/BUZMZ4uNrMN7LVJ2ItjZopwY9mY3coR2zF7bLR3Gnr1Uz36Sp4LdWM7uL0ny5BUllhKKnOOt5xhhR+SnZrN9wQE+9xkIUy/DfoAn4wADOfsbvFzBKG8n7KtT7z1shGdThFNMPmco1JtqfKfJN/QUkcQR5R/wT4J0JZlHG9/T6htXloJ4lRymhOU3CuL/GxmNwuV6lt4BOq0hKXZ6+XKs3Wo03kWIxi1LxHRa2CFJWh7yucLFjpgpyfWr6iBWQNI9Eh2QgA+Nh4mVcIlGxzEhZsZ4QxUopU8AXJzRlOq1mBDJ+1zNu895ObngKusq1HCTKoNB3PCjpbEOb43NXxuooW0W8onbXD2EYYx28OUP1ez3idvEOfvslzf+h+mA3Uk8OltC7UQIK3zJOtCRUcqu1wr87LgNJG066KAU+9WqYHptVvff50XnbofOX1l69v0AhNjFsyvwjjDVTQjzdQXioIjGu7fb926yh8UYgCfyEMfaRePxg== 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)(396003)(39850400004)(136003)(346002)(376002)(366004)(451199015)(38350700002)(38100700002)(86362001)(6666004)(5660300002)(8936002)(2906002)(66556008)(66476007)(8676002)(4326008)(66946007)(41300700001)(1076003)(2616005)(6506007)(6512007)(186003)(26005)(83380400001)(19627235002)(316002)(107886003)(52116002)(478600001)(6486002)(36756003);DIR:OUT;SFP:1102; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: Gg8CNCMA3NVwhgCdIPm02X5921yVn7a3Rxr4fKy5USlACx7fW/whF3oF9jso/aOBirSss/YHjFjATEoRY+cNeNPhF8lPtFjp4Hz60hlPFgThbAuSaG2rnNutFU0b8rHhIv0yBbQXVDlq6guFtX3vXceUc2YBTGYbAZk2fgLIGjGU6Uot2NWeb0QaiJKrs7Us4pVz/AkyFCKzN8UEx2yqFXPOshxfnj4HkOqjdR1Ev0uTOj7zuU7Lpq0wR7OCqDjFeoaRwnyHELeZeI18eAzNsXkn8ALBWSGHqIoD0Xet4Hs8k42Tj+PPEwCLqlYTzAerbSkXHdb6p3xtILpR+1kWtMIGDmuRgvCeaMFyGpZ2qHsnpRekgpsTkjf6ydhB1ConZI1QzmsE/9VF56aL1bvgGKjrD0d5Z3mAnTReAYvwaI/Jqd/GRbRPER/NaKq+k5fLPMVDVnWwW8E0YzD8yzReA7oUQey2+qsDWTEmDkSUlx0LphhcEbIvvJu5cZMWaAMfHuQLkF9xBnijyQ+Gv4DJj6W3SASKK3sjNiNi18YH/pn+WPYt9ZDYZC5+Xp2c6TXoDc7TZwoJplA2NnhnzKpfuA7F1wGfG3pdhVnd7Y4vD/ACi0XtuwPj/yISK9o+3+N8hFvIDiuVYzSl0t4mje/tZn9LRlL97DPkZbo6k67LYcCXaG7WDV9Gl4wmscTsBkbEDbrkPRXRYH4Hq6WMNZ0pJHDPYl9pc84asWEhDbmnkksIHUHPGs1/rYYmEhZiPfxzLTdnVL/N8Z41tFttuo8uSQhIAzKRPub5IwSMpW4eRIVoSumxgdH9G6+8NKRTSo0ftpx3PXMhPYkpV0XorSnVq4Dw4hBrcH2flMKELYUS+tK3xKgePyr5+UiTrFLr/us9UFpRu1HbN9nIDSI/8/9IZ0VwN5cPmuYyJ8m62hz1kuh+n2czfm7PR0ojfIz0aFrmPrIhUOc+IPQ7Z+vPiDhKZQEpfvb4+R4BpcwAP/kiMMX/o1NxfSB0kioRCiiTWycR34NJlgFyWFQqFIhrjV9VrQZsQHWp9rxCazcgTrdQjlxCc10EhE7GPZDRn7q7YTrmIuOKBP599MMoKXR3deW+kI3LRjF7toC+fxxr44tcX1PuNU4EmGVYXwEZEhqjM9joO+KBnGmxohdY4FwWk0aVVwuXFqyOaUvSczIVoCmnzFKxp0btMOfCWsAllo9jm/BH5xreaLghvN4OIWeXAnxHTlaIvsc1nN2oWOHk7CEo4UnWC4k1KXOWNCyc1pYvNoefnH5lQXebd/W2u3iLbyeYicfTN1jkcO2kZJmapxglmPxpH8FMFWRqjqdFStcFIieCnJeScWMy3CHBcqvRAk1nr+6R4A5WN726prUCwM5N4ZxoczNeElNTfTxIaWi7jnIA4bMEDYAOTK9+6o0wuEASDHE8QoUr2RHMCOg4js2zUYREaG/r6fMASMYHniwSAb5MyKVmAOc6g8nvd9pC0OdamaELpQHMtsGKPRM1YUnGfcbfzoNu2Bs+bbqAS1N7L4Wu1h3iTdKsCKTWGKZmNx6rGvP0QZpiafRuOZp07vJjNiKUtfNA1xAaZNnKrHETc0tE X-OriginatorOrg: vivo.com X-MS-Exchange-CrossTenant-Network-Message-Id: e9648a97-96cd-4a1a-674a-08dafb6e1667 X-MS-Exchange-CrossTenant-AuthSource: SEZPR06MB5269.apcprd06.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 21 Jan 2023 05:12:26.8758 (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: rlIcwEE8kLzmIMNKzYYrufq+VWv9guG/KklvnPTMxulPrMtdOrZuCEP7BgaZ4NWhfkEKik0SgzteoUk9eO+eSQ== X-MS-Exchange-Transport-CrossTenantHeadersStamped: TYZPR06MB3885 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?1755609861030298813?= X-GMAIL-MSGID: =?utf-8?q?1755609861030298813?= 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 --- v2: -convert to SET_F2FS_IPU_DISABLE Documentation/ABI/testing/sysfs-fs-f2fs | 25 ++++++------ fs/f2fs/segment.c | 2 +- fs/f2fs/segment.h | 37 ++--------------- fs/f2fs/super.c | 4 +- fs/f2fs/sysfs.c | 2 +- include/uapi/linux/f2fs.h | 54 +++++++++++++++++++++++++ 6 files changed, 74 insertions(+), 50 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 7d98ba537241..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 ed4a0a721116..236f82675ba0 100644 --- a/fs/f2fs/super.c +++ b/fs/f2fs/super.c @@ -2214,7 +2214,7 @@ static int f2fs_remount(struct super_block *sb, int *flags, char *data) goto restore_opts; if (F2FS_OPTION(sbi).fs_mode == FS_MODE_LFS) - SM_I(sbi)->ipu_policy = F2FS_IPU_DISABLE; + SM_I(sbi)->ipu_policy = SET_F2FS_IPU_DISABLE; /* * Previous and new state of filesystem is RO, @@ -3950,7 +3950,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 15e9921dcb01..285a1e78fc03 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..0ca19d1c9acf 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 */