From patchwork Thu Feb 2 08:48:13 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: 51802 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:adf:eb09:0:0:0:0:0 with SMTP id s9csp120962wrn; Thu, 2 Feb 2023 00:55:39 -0800 (PST) X-Google-Smtp-Source: AK7set/jwntflodk59zvIJ84nvLm63bsxDnJ/V6CnFTLoELArTBiILl/P6HYxeWGfvfwuKkq1xL4 X-Received: by 2002:a17:90a:1a11:b0:22b:b76b:5043 with SMTP id 17-20020a17090a1a1100b0022bb76b5043mr5859287pjk.9.1675328138418; Thu, 02 Feb 2023 00:55:38 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1675328138; cv=pass; d=google.com; s=arc-20160816; b=GYjWHjcXz3wrdvt5nctD5gTxOh0vZMlvsF4p2DPbuvP4nJBHq492ADAnATYB1kZGgX MPpMdmkGvyLvRS+plU3C5Ha2HoKUxe8UCHkYI48QwrVK2HHrL5fpwT3R86Y6aQVeo3vv 3Sm72E8qMu3FtWQt2jT1WPNm0IBjBxswPS10Zme+WRWE6Hsl3qHYjY6of86xwavO0GXk M0QUJ6UB8bOMUjmT00Wx0UcvNz2mfdgVB7du0M94erZ99bO5KMId3oTHcNWez2M26AOH BU4ztxDtaAat54hBtjVDjZn0NAzCSdKPfPq8I+IF8Odg7KzQxSer+kacOeBZd+vONmfn uweQ== 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=wMsmnbmNXYRUEU5YT/7odIoE+ovaE20i3kq0sGhW1Ks=; b=Id9URoUwkaSSOp7V3//CnroGlMthlNkP/UU2Npnq9yGKciEyNZupU5KNOgGlI3vJ9H eH0Vkr8lQIrmHSV6qywBQ6z6rmFop3l+CSZxYVSgRX0HdeKZhSS1Xl823c1AzLByJUqm JUHdVkO2Ap6/3q+CGAwHujwud9lNvCYNpg4XvUmp3dITPWxSH0t76Z09w2+RJTr243zN X0vzgPewdaN/ORJnfu8n4lgLDkLgUc/vnk450LRl6Dp8LVtQn35tF+U7znMOlVKD72IE 2RXyUJGs+7vmxvuj8UwrN0KwPmlIGpj8u/6iaECdr9xftlAMbn1CHWGdMOaLrvDkOJac r3Tw== ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@vivo.com header.s=selector2 header.b=fUbgVoRQ; 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 mu7-20020a17090b388700b0022960cd9da1si5169073pjb.63.2023.02.02.00.55.25; Thu, 02 Feb 2023 00:55:38 -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=fUbgVoRQ; 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 S231903AbjBBIsu (ORCPT + 99 others); Thu, 2 Feb 2023 03:48:50 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:60186 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231737AbjBBIsi (ORCPT ); Thu, 2 Feb 2023 03:48:38 -0500 Received: from APC01-PSA-obe.outbound.protection.outlook.com (mail-psaapc01on2092.outbound.protection.outlook.com [40.107.255.92]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 065C845220 for ; Thu, 2 Feb 2023 00:48:37 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=lTq2GRRHt6FKJivm8ojbN/I4KT4gqQYHuTdcKddMqCui8IoRFw4QpTolqCLtKcOG9BTKGRMPAjHie9jrnJPHTNxK35FNMh/YXLISc5g4iv7350a9i7n9ON10nT2uBleSGweh4kfbVpow/HNP0Yl1HRnBmwnRK4XsGMp6Jdc9tcvjb7ijL327kzUU6L8qiwU0GrigcQ6sS/M0sgqcXPHr3BYkyL5hjZpxBuDFTITg+6DcEC5RNnhRMLt3SFugorxJtuXP5swiQU+Z6Q6j4536YvGplAEcdEJAbwIMUC2rt5nVxGtGBru8n1Sw/DU3QZ20HYEpiddQyKkGn1abwOT4Og== 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=wMsmnbmNXYRUEU5YT/7odIoE+ovaE20i3kq0sGhW1Ks=; b=LXB8Gt0LBCfWp1bHJjApcJEpNcT2W+Js2AQzxeCBqwkYQNZYEaxPdqdCuCpmqBLfgUV4MIuXqzwhWh67zpRaWLWx8RfJs0SUekvLAhMfwDy+ZBFC0wdPc0RS11BPu1fDDHEC/QHbRh27A90yYSZpYefSa/Fh4M4SpGXDtpEwdpL8cCze9rDdi80ptQGI56NUXGlH8nCf8Jzg9NZoxQ3uIsn1iCnH8vo3M67qGFuDYZVtGN1tWakTzNJWVQq6RpdEzb8guq8ZKc/zjFCWMnoIiWEoUrccsqbaLgJ9mNMLT3q228HsxkVLYC4GLt490mb+bnGzYovr9gY3zs1BS7yFiQ== 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=wMsmnbmNXYRUEU5YT/7odIoE+ovaE20i3kq0sGhW1Ks=; b=fUbgVoRQAPyW/PI4I+Z4bGopNLs28xgP+dgc9ctFjcudP2k23P09j3f2QBIGWJ1VY6ZV8kWuCkTirYUpYEq9M7suZ6Q3K/t3TFO0NTv6QRrvlCxcTAEHW+vYewEh5HGvBbHUIYYQl2/wlQguaxpPlRjJhXZ0rnt6a4N+bvziCpNZ33BzDslVWD5pGzZ+5ytKAvYSq0Py/8Rkfu7Ha+v7akdUVXrZtgXFO/Y42yoJv6eGaZXfro+wAYm3zz2cBz0DqFbNwwP+EHX6nBk2tTY9P28OLTikkRzbIgtdYg0698EK6NzfoIQFWqm1ntyjiLqG3d0YGQxSTvngqF5u8b4OZA== 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 KL1PR0601MB4514.apcprd06.prod.outlook.com (2603:1096:820:72::13) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6064.22; Thu, 2 Feb 2023 08:48:29 +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.6064.022; Thu, 2 Feb 2023 08:48:29 +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 v3 1/3] f2fs: fix to set ipu policy Date: Thu, 2 Feb 2023 16:48:13 +0800 Message-Id: <20230202084815.70791-1-frank.li@vivo.com> X-Mailer: git-send-email 2.35.1 X-ClientProxiedBy: SG2PR04CA0184.apcprd04.prod.outlook.com (2603:1096:4:14::22) To SEZPR06MB5269.apcprd06.prod.outlook.com (2603:1096:101:78::6) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: SEZPR06MB5269:EE_|KL1PR0601MB4514:EE_ X-MS-Office365-Filtering-Correlation-Id: 412cf13c-a36f-4882-6127-08db04fa4194 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: /3T1XnvRo/RiKTXFf5akE3u7AoQvbzg/rIzgV4sp9i15Dj2mwS8sc5eR+fr0GEqePTqMhVfjO15wYxzuYLnJyGP625Juu3p3fTsJjOeH3Ld1KHCrMDFvhi5bKC+ku2/v+o5qiPzHM/Nc9Y8abU0Ljp8RDjpHHHqtybQt4HNFaTt4exQUylIfJHcu21GpmJDSHPKslX/fl2nDbl8NOs3dYILdApliI5cc2buP2Z2Wbwr4CLFY3VrvbLWR1/RNQVEirnXVxB+fVKuOlfpnpYGn7rJY9KmJnwoYait/4q3JrvJsZDnHccS5y+UM6j+sShJuOUqdxM05GknHoAmlcJpHBpqbBkNM8Q14xFc/vUyrSdf81QGUQfE1RKx8IvvtR+mCeCt3rW8dU3q3aNcB0sGCjwSTSYNqShhJ98WSZMlZntXO495+fAX4uCX+3q560pc8BxlO7e5zYE1URTwr9oTvLE2QHwQAiZiJyAqIRGCgmQCE5N4ATOndBiHdNDnS5UneaMYaiy52ESaga0zdnvXjyRuWoSikaqr99RT0lj3fCwq1ipXdJPf8n17eIYySaPDRgDxXgu1k0T2pWQZ386xh1YUKcoZntH+bQc+4XZu5zK3vEkL3icNSOCycFz0NXAp9oZD4JK/dsA5eXjUXXrQNbdYT6maGBU7OPPdmHcXECgkpyfmQjkV68ZBqi3IDpr0ju5/pVassF+Vaubn+iFOgLy7uSzXfcdNY22nlI49eFvw= 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:(13230025)(4636009)(376002)(396003)(346002)(39860400002)(136003)(366004)(451199018)(6512007)(1076003)(478600001)(8936002)(186003)(2906002)(107886003)(26005)(6666004)(52116002)(6506007)(2616005)(6486002)(86362001)(8676002)(5660300002)(83380400001)(4326008)(41300700001)(38350700002)(38100700002)(316002)(66556008)(66946007)(66476007)(36756003)(309714004);DIR:OUT;SFP:1102; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: BWscXEltD3M9kLIRp3NAg2+tFE2p0KvkNwzTPWGhFr4Z1vxVXAkU0X0tZ4rAoSOh2bz8wdLRp9sFQT9yNmgmHZSGGkgGgOBU0/mNd9kU055H4A2D4XQECFB4KASE9VlYb9V/QQkmwP0ECjM4QgXAwLpWk1L5dxqlXsLuwN+Fz/+Tw0eN3ckfqNfmD4mBN2Dck1J5vk84G//q9zLhA6qYU+IxdhCQ9XcvPnjGueGwlZshl5xEYa+gH1F/38F6/ogtxsfLiPx4QP4Y3JwHrkrIby/paXDy6NkMcaRy1cXpHCHq2+MSNbhHHKJKhzxv4N3SH3yJqwybt0CFwbbGJIIWwhVBCgXzet58BJxPxSGmxSnMjPyRyA8S8LPUiCqXnFuO4fvOjyU7FnxnanobuVqO6nfx/zPIHig73BJnYqJGk4WkfKnZHJJdUAg1zsU3wWUcgRKvkAnfDZoV56oUeCBhDCpTncIvkmDdnPEkzUSaEx6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5AJL7ka6+QeApotSaBpuvo X-OriginatorOrg: vivo.com X-MS-Exchange-CrossTenant-Network-Message-Id: 412cf13c-a36f-4882-6127-08db04fa4194 X-MS-Exchange-CrossTenant-AuthSource: SEZPR06MB5269.apcprd06.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 02 Feb 2023 08:48:29.3197 (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: lvuXBKEKSb8RatGj+o3ykjlUz+Kv2blpEy6PptcENTyMHiVmGfSWl5CsmfoUab+Q099ZgkmneKS8M1+Awd7I2Q== X-MS-Exchange-Transport-CrossTenantHeadersStamped: KL1PR0601MB4514 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 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?1756708878212959185?= X-GMAIL-MSGID: =?utf-8?q?1756708878212959185?= 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 remount to lfs mode should be disallowed when f2fs ipu is enabled, let's fix it. Fixes: 84b89e5d943d ("f2fs: add auto tuning for small devices") Signed-off-by: Yangtao Li --- v3: -add check in __sbi_store() -introduce IS_F2FS_IPU_DISABLE() -convert to f2fs_lfs_mode() fs/f2fs/segment.h | 10 +++++++++- fs/f2fs/super.c | 13 +++++++++---- fs/f2fs/sysfs.c | 9 +++++++++ 3 files changed, 27 insertions(+), 5 deletions(-) diff --git a/fs/f2fs/segment.h b/fs/f2fs/segment.h index 0f3f05cb8c29..8ee5e5db9287 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, @@ -679,10 +681,16 @@ enum { F2FS_IPU_ASYNC, F2FS_IPU_NOCACHE, F2FS_IPU_HONOR_OPU_WRITE, + F2FS_IPU_MAX, }; +static inline bool IS_F2FS_IPU_DISABLE(struct f2fs_sb_info *sbi) +{ + return SM_I(sbi)->ipu_policy == F2FS_IPU_DISABLE; +} + #define F2FS_IPU_POLICY(name) \ -static inline int IS_##name(struct f2fs_sb_info *sbi) \ +static inline bool IS_##name(struct f2fs_sb_info *sbi) \ { \ return SM_I(sbi)->ipu_policy & BIT(name); \ } diff --git a/fs/f2fs/super.c b/fs/f2fs/super.c index fddff5deaed2..f06af2af215f 100644 --- a/fs/f2fs/super.c +++ b/fs/f2fs/super.c @@ -2302,6 +2302,12 @@ static int f2fs_remount(struct super_block *sb, int *flags, char *data) } } #endif + if (f2fs_lfs_mode(sbi) && !IS_F2FS_IPU_DISABLE(sbi)) { + err = -EINVAL; + f2fs_warn(sbi, "LFS not compatible with IPU"); + goto restore_opts; + } + /* disallow enable atgc dynamically */ if (no_atgc == !!test_opt(sbi, ATGC)) { err = -EINVAL; @@ -4081,10 +4087,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_lfs_mode(sbi)) + SM_I(sbi)->ipu_policy = BIT(F2FS_IPU_FORCE) | BIT(F2FS_IPU_HONOR_OPU_WRITE); } sbi->readdir_ra = true; diff --git a/fs/f2fs/sysfs.c b/fs/f2fs/sysfs.c index 3c6425f9ed0a..e1f1ebfa59d6 100644 --- a/fs/f2fs/sysfs.c +++ b/fs/f2fs/sysfs.c @@ -697,6 +697,15 @@ static ssize_t __sbi_store(struct f2fs_attr *a, return count; } + if (!strcmp(a->attr.name, "ipu_policy")) { + if (f2fs_lfs_mode(sbi)) + 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;