Message ID | 20230120134029.69200-2-frank.li@vivo.com |
---|---|
State | New |
Headers |
Return-Path: <linux-kernel-owner@vger.kernel.org> Delivered-To: ouuuleilei@gmail.com Received: by 2002:adf:eb09:0:0:0:0:0 with SMTP id s9csp204003wrn; Fri, 20 Jan 2023 05:42:07 -0800 (PST) X-Google-Smtp-Source: AMrXdXsdDRQHbUOVl7AmgETo+V/yNKFUIfWD8yFmx2g7L4oGTU9q24O4hWqrJ0zopF2FPf+H4vLt X-Received: by 2002:a17:907:1b0f:b0:86b:93ea:3366 with SMTP id mp15-20020a1709071b0f00b0086b93ea3366mr22795679ejc.3.1674222126807; Fri, 20 Jan 2023 05:42:06 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1674222126; cv=pass; d=google.com; s=arc-20160816; b=dXGcpnBGCjF6o+4CggocepZb5IOYLuqaXIKnaJayLSHobcEUMcvFxq8gkevEBdL0mc ofqGugkUWn6/W6s4stoiEIZHj9KOglLGcD8RPzRc3aQUhguXj8mYRdrMWPINeMBUH9Bh 69FijLEsMAkN7ITnPu9Vs/Y5DwPRsmkEKqZIRqimG99kSnZ6TQeAaWz77Xc3mOD1t5GF 17Fc0VdqtorQ86cH6sPTtbMLnCXHKr2yWfzFKoQC3oAV6PJkqn8TWDz0wWNgshkjwnH7 nnlWj7up85yjQnYCnB9wVBS3Jd4IpX/1uoF7bJQ12k6WL+a2eDap6tIGfh8IyaYht9JY ibuQ== 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=smT8vJ0bT+nzUyUQ1bOT7yb2PHCpctRrRzjc0vu+iEQ=; b=neWWE5OY65mUpa791dDykTRnATiG+Knlagwb5bwTf1N3s61A28q2UkQ1BI1MEeg1YX Ft0i/wTu5JMNKNjiqMi547+NRzJZKVrTfqxsVTEQsqkqNr5iYt1qS9/0PAmFjON31NQd ZnBjB3jZZiFQ6XW5YOfBP4UH+/GlZbnZQ+G8G9NnrHZ6Rm8+RHhqnQ9lNcs4M2YXv5pP sQ10WefKlT3rO50jxn2yZLKw0Q9sjs8kQyq1Gx095CvK3aw17ddKCKJHy5uxTppdnuRL j7f/Gqk7s5fxk3Z7mRQbjRBmB5+BUmkzdO7Vy0TZZvGviukGMSEt2oFbIrodMcZLHv8O M/8Q== ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@vivo.com header.s=selector2 header.b=ejhVpBpW; 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 ho19-20020a1709070e9300b00872236c2730si15815321ejc.216.2023.01.20.05.41.42; Fri, 20 Jan 2023 05:42:06 -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=ejhVpBpW; 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 S229770AbjATNk5 (ORCPT <rfc822;literming00@gmail.com> + 99 others); Fri, 20 Jan 2023 08:40:57 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:50000 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229539AbjATNkz (ORCPT <rfc822;linux-kernel@vger.kernel.org>); Fri, 20 Jan 2023 08:40:55 -0500 Received: from APC01-TYZ-obe.outbound.protection.outlook.com (mail-tyzapc01on2094.outbound.protection.outlook.com [40.107.117.94]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 63D8F7AF26 for <linux-kernel@vger.kernel.org>; Fri, 20 Jan 2023 05:40:54 -0800 (PST) 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 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/4] f2fs: add sanity check for ipu_policy 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> Content-Transfer-Encoding: 8bit Content-Type: text/plain 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/4gw3Pv7sb7H8U9hJFB9CZ88hX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TQ4n6piKu0RiUvM89HBXHArrrrjHnTiROk68rtgeLWjdNCPEphw84OFnvF7Mb1BQ4+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-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: <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?1755549140692036161?= X-GMAIL-MSGID: =?utf-8?q?1755549140692036161?= |
Series |
[1/4] f2fs: fix to set ipu policy
|
|
Commit Message
李扬韬
Jan. 20, 2023, 1:40 p.m. UTC
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 <frank.li@vivo.com>
---
fs/f2fs/segment.h | 1 +
fs/f2fs/sysfs.c | 11 ++++++++++-
2 files changed, 11 insertions(+), 1 deletion(-)
Comments
On 2023/1/20 21:40, Yangtao Li wrote: > Disallow the value set beyond the range, and disallow to change > the value in lfs mode. IMO, it's better to merge this patch into 1/4. > > BTW, convert open code to use BIT(). How about using one patch to change 1 << xx to BIT(xx) for all cases of f2fs rather than one by one? Thanks, > > Signed-off-by: Yangtao Li <frank.li@vivo.com> > --- > 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;
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;