From patchwork Mon Jun 12 03:01:16 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Sheng Yong X-Patchwork-Id: 13275404 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 7D3E3C7EE37 for ; Mon, 12 Jun 2023 03:02:25 +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 1q8Xox-0005UV-OI; Mon, 12 Jun 2023 03:02:22 +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 1q8Xoo-0005UN-1T for linux-f2fs-devel@lists.sourceforge.net; Mon, 12 Jun 2023 03:02: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=xKUnwyC/3gqOQ5IDTKfKbE911KLBhciRAlD1Y3QD7PA=; b=JPD+rdG6eJSSmZ2FmLBTyt884T G5ucm7hXfMjDFFSWTegd3wMBNnD80r588cNxW27Dtk2KHOJ3XL6rDLGQL5HlAP0v/T+pOocuAm16H A8RjyiW8hBe/Fb8UjOx51XqPdaYO51cL1rzEQvH5Plf3/A+XaYvAdD/jvzSmuE0hitLc=; 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=xKUnwyC/3gqOQ5IDTKfKbE911KLBhciRAlD1Y3QD7PA=; b=UiHo79SCQdCBJGtHuxOW2q1AnL agwG0lpXvl53V+BD9yie1m1f9kU2fntLlpxdweaU3ItKBkQzE/0i7QrpKSkFTqoxbt00Plop3Z6rO 27nPyQXjhAOzGufuFwF95eiVns06wcDy42BkB4qj++tTViYNuuai0uCc5P9k7MZcM1bA=; Received: from mail-tyzapc01on2054.outbound.protection.outlook.com ([40.107.117.54] helo=APC01-TYZ-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 1q8Xof-000MRd-UP for linux-f2fs-devel@lists.sourceforge.net; Mon, 12 Jun 2023 03:02:10 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=iyPbewnLX1SqBcLlQJ3Q6AYoEq2WoyJPna2C9C6ioNoGdwwnnY+g1dt75BfqS7ldjBinBFUSWmkBYmGk7tInZSP3wybwlrojBVsj98f6VeYm5pmP/hkLzOYUTLWlRTwNZeRrLZ9MSrnl5RUhbmZexNis2R3Rmp68uecP+of5qtow18o3FCsn4XgTux6526xFbf4LIRsuSDvlw6/sKcNLyXHx6d0jINFBC2GjB2s0qfDloH8AViQU82AuavBim7f1FoL4uIIdk6/uVfToc51crNby4zpk39bIEGJf58ApNVyETyITW3Wd022i2meBd3XBbYJhUcdAhxA7x0atjtQRmA== 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=xKUnwyC/3gqOQ5IDTKfKbE911KLBhciRAlD1Y3QD7PA=; b=jO4ghU2YUxY/oZqXdNMb29qMNjE+ANPO866uAXT0tFzee8Hir2xueBlV0nfvA5ZgavVj4LLv0NJcYdSKiPFcPCwUcSkZbg8Xrq/Uwd/y2fjNxVKEnhdU5So+3ZvP4mRiNAo91ChujNhhWhTVZsovf/inbTaoypg1+TZ0VOi6zwpoWez36oAvl5F0+gIdSUHvtuUqu8hSrIXZOOjV81ANlQnDsmhbU8vwp+PZ1//LtANx0L1bUaFCZLgYzAA1PuCXd0SgXkpvNR/oQAsk8dYzGAEHOoZPA4ucWL+TAb7CIyaRzsZcu3UsHn/uRGLZchQCDQ76dWIPka/SkyTYV4zCog== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=oppo.com; dmarc=pass action=none header.from=oppo.com; dkim=pass header.d=oppo.com; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=oppo.com; s=selector1; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=xKUnwyC/3gqOQ5IDTKfKbE911KLBhciRAlD1Y3QD7PA=; b=lJe922hJ/B5rOoE139STwggd1N8o7LZHkUCMzEmOwXGWBtG5DwzqPTy732UuRUGGSsXiCpa4FYTuA2cgAfleXSQKkhC12p8vh0vFyAgoTY03pUBhrPQwZVUs6XyurPPOItqvUG4p0KgUU1MwvQn0SpAZkA9b/UP0Z2dRQk68BTI= Authentication-Results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=oppo.com; Received: from SI2PR02MB5148.apcprd02.prod.outlook.com (2603:1096:4:153::6) by KL1PR02MB6259.apcprd02.prod.outlook.com (2603:1096:820:dc::9) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6500.21; Mon, 12 Jun 2023 03:01:45 +0000 Received: from SI2PR02MB5148.apcprd02.prod.outlook.com ([fe80::6297:13a6:41f1:e471]) by SI2PR02MB5148.apcprd02.prod.outlook.com ([fe80::6297:13a6:41f1:e471%6]) with mapi id 15.20.6500.020; Mon, 12 Jun 2023 03:01:45 +0000 To: jaegeuk@kernel.org, chao@kernel.org Date: Mon, 12 Jun 2023 11:01:16 +0800 Message-Id: <20230612030121.2393541-2-shengyong@oppo.com> X-Mailer: git-send-email 2.40.1 In-Reply-To: <20230612030121.2393541-1-shengyong@oppo.com> References: <20230612030121.2393541-1-shengyong@oppo.com> X-ClientProxiedBy: SI1PR02CA0029.apcprd02.prod.outlook.com (2603:1096:4:1f4::20) To SI2PR02MB5148.apcprd02.prod.outlook.com (2603:1096:4:153::6) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: SI2PR02MB5148:EE_|KL1PR02MB6259:EE_ X-MS-Office365-Filtering-Correlation-Id: 974a3f92-7b30-4a0c-3107-08db6af15ae0 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: kJRww8yGYpFgXVhFu5kRZyIIVvgSO4tQpjU+11vfzcuZCsAW/z7fWRh2l3UyFjzk1hibJG4Up2kX2ailmQpSb0IgsVDRi01Fw27ZrQdOVa6ZZIAvPbDp81ts95jX4d5MsQs8Y2R/ZUuga/MSSlEKGQDnRelttm5Yr6vpjLArNVyROjPrR3hRy/CGksY7ayBVjfwpai8LNew5D+WPvBjoXNHckoUtFfXTtcTKs2EEDpPP4HIc2MjzGJz4mToNXzRj+d4j11O5HR7am2OW+2ORMOiMJwYc2KgVdeyl91EruUmRuFC2JAOBKw/N2G/dGvDsW16/PW5gwLHoTuyRHNL3qYRGahjsMvYaqltTuOkfNkkAW39A78W+pZMh4StM/0nTvXdGindKFL++8nrsByxrDUCCTsYx6irnMzo7r7ajuRcRxdFkLrB+YK7OouyufoQFWMPn/x9endIid3MHl4+bzbPxby9Luzztfblgcnw9SFRqrRyFelqI+CWL7ycd8nYlCEo0iryETp80X4m3WAuluGL7AE+XMFn/XpiI7R53wAw02W4Dqf3NlVHDCAwHOq2YWORIh4ap2nsSwWIVayxUxhpsQqaVeYnV/gILuDmyX/9hBDiyKEcllMcDx8v+6lF9 X-Forefront-Antispam-Report: CIP:255.255.255.255; CTRY:; LANG:en; SCL:1; SRV:; IPV:NLI; SFV:NSPM; H:SI2PR02MB5148.apcprd02.prod.outlook.com; PTR:; CAT:NONE; SFS:(13230028)(4636009)(346002)(39860400002)(366004)(376002)(396003)(136003)(451199021)(66476007)(66556008)(8936002)(5660300002)(8676002)(36756003)(66946007)(4326008)(478600001)(6666004)(41300700001)(52116002)(6486002)(316002)(38100700002)(38350700002)(6512007)(6506007)(1076003)(26005)(186003)(2906002)(107886003)(2616005)(86362001)(83380400001); DIR:OUT; SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: SEC8H9JRq5/89BmcTRPqKuolxfgIyDYtc9GaWeDy0Yh/Z+ZnVOVJ9VSu9WjECxQcmy/Xp0QlFMJ0bPMkiQN8L3xxjnaZU738tC18Mke4Q/pd2iBNXMCm4PJ6Gm4ZcRjYrM8xAnGLCkAkbwQuQFpxPt9wcw+HzS/NQqvblKqvPWXhi0W2Q82HkR/sPaCL3ryScDppNlKJRmy6/Ct2/ig2RgCCUGa7U/vX9rzU9TLnRUBfNqpg6tL20btWBBtJ9C25lD3TLHwRanCWcnzqCiCZrz2jOD9/xpv6reRMXXJ3gbXifXrdwRPe9HiUa6K/7674EY95VgKrscHfOEaAbHFOoYPV5T5XoLuH6hMoqvd7JxQX+Y/1OS3eO3z9y9u6G9miot82LHks3OaWzu7dFNJxf0QBO/wpsYvScZuIT5GaqE93j13F5JEuMb+EsPE9o1pD0IBag6OfpCSxtJqVIXRCrI388vqqjKtyr52UEBvITrpIV7nDwQHBfJOtAW4D3+K81rOBzBDuXsEkvhCqLWEeFbvct/kxWsZfatyRZmJHz+4ZmxsIfxKDKE1P4n+/eyUPfjCL2/g7M9jlbr8bQwnEnyjNkqNXa/s1rqo2kCWLSx+qb9h81c2Gwx7eTTNWt6ffyoQbfbhTEMb1TGdjSJ08mMdwc8zzqV/c3q7CIaqkPieLWF7xdHeMjb7hUyxB1Et6IeEO1Lc0KHIxo9+Dp8so1AP5z9heaeFXAczQKpk6e05vB/LKHZvwqVfCB6yBpyf94daPYWeGiRF3OWz4rmzPBDoD/qy/nhR4wyAbKtcfAvcB9IPbDv9iELfuf6Y1sN4IPzw0HCv19ReMzhy4fnC5COEUX/ixmMMAk6T6Aq6pOiiIc1iScKPulWidwMyzCrfg0ml6tUaHabj/SwymgzlryM5I9QsRYVSOWCSkzySkXjIu8fV4zLKtG9WyeiALYDq0h5Qz6mW824krrLhQ7eRAZFtVycDcmX7ouLIpoKHPJWt2SlKjceRxmAFJG4KObBsUGk2pODrRrQvTZfN6QRB/xvtm3Ss0OUVlOQGiSHRnd0eXD7CWgTaqSVZY2k7u3Vi0AGSosOxsEHiTVe0M6o6qzHHHJIS5ayXxAjg/tT+/FKCScdfwv7BrJtTRerg58I46HnTyVAGTJdF8b6SlO54sWMpubbzjjEdDiqpbLjgYbRg94OTUuc3fp2s2E93OOccfEm/Yhj2flmG5lYWbN1afinskI0VbH/hNHu2uH6KQhqEVNRxti5Aqn0u6RuOS5YOfK6D2keNnNanujX3rxFoyOoQO52WdcMHu+vKoz2sltEYDSBcHReYx/DtkNveR89+6sdPzJ45jzgbf5+hDiodG+zm3nXCzaCLcufMvTUkCc/PEAp6TcVbR1lvLwIVZMI+H6VOGmQnvJW7MpD/CpxLl8oQLAwI2YUzLObI9sCQSjWyFw+Je9SEEgNzDCTI8DFBsYVea4TflMyxdizKc91DUGBJjdPhSlJebkzqNX/I72XDPwg/BuZGMcOxkC7oQ4Uw97NxqiZ3WHaK0lnv/jV2jSx/KZWJpvlGt1U54DAVdNoWyV4/fuIVMoAwKax1BjokF X-OriginatorOrg: oppo.com X-MS-Exchange-CrossTenant-Network-Message-Id: 974a3f92-7b30-4a0c-3107-08db6af15ae0 X-MS-Exchange-CrossTenant-AuthSource: SI2PR02MB5148.apcprd02.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 12 Jun 2023 03:01:44.8760 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: f1905eb1-c353-41c5-9516-62b4a54b5ee6 X-MS-Exchange-CrossTenant-MailboxType: HOSTED X-MS-Exchange-CrossTenant-UserPrincipalName: IDUJGWFcQWIbiauI+Ynd+9XGcpaT3uQaOY/JM+1s8oXZUKyNZ3CfJLFX68+HTq+EcD0UjbPeq8c0pvReG4O4VA== X-MS-Exchange-Transport-CrossTenantHeadersStamped: KL1PR02MB6259 X-Headers-End: 1q8Xof-000MRd-UP Subject: [f2fs-dev] [PATCH v4 1/6] f2fs: add helper to check compression level 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: Sheng Yong via Linux-f2fs-devel From: Sheng Yong Reply-To: Sheng Yong Cc: ebiggers@kernel.org, linux-kernel@vger.kernel.org, linux-f2fs-devel@lists.sourceforge.net Errors-To: linux-f2fs-devel-bounces@lists.sourceforge.net This patch adds a helper function to check if compression level is valid. Signed-off-by: Sheng Yong Reviewed-by: Chao Yu --- fs/f2fs/compress.c | 31 +++++++++++++++++++++++++++++++ fs/f2fs/f2fs.h | 2 ++ fs/f2fs/super.c | 4 ++-- 3 files changed, 35 insertions(+), 2 deletions(-) diff --git a/fs/f2fs/compress.c b/fs/f2fs/compress.c index 1132d3cd8f337..63a496137ebe7 100644 --- a/fs/f2fs/compress.c +++ b/fs/f2fs/compress.c @@ -55,6 +55,7 @@ struct f2fs_compress_ops { int (*init_decompress_ctx)(struct decompress_io_ctx *dic); void (*destroy_decompress_ctx)(struct decompress_io_ctx *dic); int (*decompress_pages)(struct decompress_io_ctx *dic); + bool (*is_level_valid)(int level); }; static unsigned int offset_in_cluster(struct compress_ctx *cc, pgoff_t index) @@ -308,11 +309,23 @@ static int lz4_decompress_pages(struct decompress_io_ctx *dic) return 0; } +static bool lz4_is_level_valid(int lvl) +{ + if (lvl == 0) + return true; +#ifdef CONFIG_F2FS_FS_LZ4HC + if (lvl >= LZ4HC_MIN_CLEVEL && lvl <= LZ4HC_MAX_CLEVEL) + return true; +#endif + return false; +} + static const struct f2fs_compress_ops f2fs_lz4_ops = { .init_compress_ctx = lz4_init_compress_ctx, .destroy_compress_ctx = lz4_destroy_compress_ctx, .compress_pages = lz4_compress_pages, .decompress_pages = lz4_decompress_pages, + .is_level_valid = lz4_is_level_valid, }; #endif @@ -477,6 +490,13 @@ static int zstd_decompress_pages(struct decompress_io_ctx *dic) return 0; } +static bool zstd_is_level_valid(int lvl) +{ + if (lvl < zstd_min_clevel() || lvl > zstd_max_clevel()) + return false; + return true; +} + static const struct f2fs_compress_ops f2fs_zstd_ops = { .init_compress_ctx = zstd_init_compress_ctx, .destroy_compress_ctx = zstd_destroy_compress_ctx, @@ -484,6 +504,7 @@ static const struct f2fs_compress_ops f2fs_zstd_ops = { .init_decompress_ctx = zstd_init_decompress_ctx, .destroy_decompress_ctx = zstd_destroy_decompress_ctx, .decompress_pages = zstd_decompress_pages, + .is_level_valid = zstd_is_level_valid, }; #endif @@ -542,6 +563,16 @@ bool f2fs_is_compress_backend_ready(struct inode *inode) return f2fs_cops[F2FS_I(inode)->i_compress_algorithm]; } +bool f2fs_is_compress_level_valid(int alg, int lvl) +{ + const struct f2fs_compress_ops *cops = f2fs_cops[alg]; + + if (cops->is_level_valid) + return cops->is_level_valid(lvl); + + return lvl == 0; +} + static mempool_t *compress_page_pool; static int num_compress_pages = 512; module_param(num_compress_pages, uint, 0444); diff --git a/fs/f2fs/f2fs.h b/fs/f2fs/f2fs.h index 80c783215b5a3..1b17bbe7e8656 100644 --- a/fs/f2fs/f2fs.h +++ b/fs/f2fs/f2fs.h @@ -4236,6 +4236,7 @@ bool f2fs_compress_write_end(struct inode *inode, void *fsdata, int f2fs_truncate_partial_cluster(struct inode *inode, u64 from, bool lock); void f2fs_compress_write_end_io(struct bio *bio, struct page *page); bool f2fs_is_compress_backend_ready(struct inode *inode); +bool f2fs_is_compress_level_valid(int alg, int lvl); int __init f2fs_init_compress_mempool(void); void f2fs_destroy_compress_mempool(void); void f2fs_decompress_cluster(struct decompress_io_ctx *dic, bool in_task); @@ -4300,6 +4301,7 @@ static inline bool f2fs_is_compress_backend_ready(struct inode *inode) /* not support compression */ return false; } +static inline bool f2fs_is_compress_level_valid(int alg, int lvl) { return false; } static inline struct page *f2fs_compress_control_page(struct page *page) { WARN_ON_ONCE(1); diff --git a/fs/f2fs/super.c b/fs/f2fs/super.c index 8fd23caa1ed99..023981824d240 100644 --- a/fs/f2fs/super.c +++ b/fs/f2fs/super.c @@ -606,7 +606,7 @@ static int f2fs_set_lz4hc_level(struct f2fs_sb_info *sbi, const char *str) if (kstrtouint(str + 1, 10, &level)) return -EINVAL; - if (level < LZ4HC_MIN_CLEVEL || level > LZ4HC_MAX_CLEVEL) { + if (!f2fs_is_compress_level_valid(COMPRESS_LZ4, level)) { f2fs_info(sbi, "invalid lz4hc compress level: %d", level); return -EINVAL; } @@ -640,7 +640,7 @@ static int f2fs_set_zstd_level(struct f2fs_sb_info *sbi, const char *str) if (kstrtouint(str + 1, 10, &level)) return -EINVAL; - if (!level || level > zstd_max_clevel()) { + if (!f2fs_is_compress_level_valid(COMPRESS_ZSTD, level)) { f2fs_info(sbi, "invalid zstd compress level: %d", level); return -EINVAL; } From patchwork Mon Jun 12 03:01:17 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Sheng Yong X-Patchwork-Id: 13275406 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 48531C7EE23 for ; Mon, 12 Jun 2023 03:02: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 1q8Xp5-0002Uc-Nf; Mon, 12 Jun 2023 03:02:27 +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 1q8Xoz-0002To-UU for linux-f2fs-devel@lists.sourceforge.net; Mon, 12 Jun 2023 03:02:24 +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=yG4NaiIwJDVRa91GbUkjytPpX0qB5PkhDezBZEAmJxM=; b=f9rfUtNHIwne3HKciYGf8XobjP yTRRErnbfBSSH2jg9KOTw7S6AS4e4TsUklPmPxD9uNXEZ9CTsIPjPhYXyH/7sEsUm4thU0RWXGojA MTkCFeW0b4r+qHzaxsxubbxFZAbVSSK9XuEwsfkB9Rq65ArrqWqX7r3Nt9Ruo6/GnG/I=; 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=yG4NaiIwJDVRa91GbUkjytPpX0qB5PkhDezBZEAmJxM=; b=lAB4lOUvcP0YQJAZmfirBlr7Tg 774AuD55XXiYFI1SC406FgcTAaavH9OvaudWFeyxcEx6HujLjvk4VuGnYVq9htd/I7bIl+DNs6ISG 9ieJWHgC09P8T2Vo+4yrDr5uEdXnNrZoNubfiBbyMldzLB3EtVdr/L3VuLDBOC/9wE5k=; Received: from mail-tyzapc01on2071.outbound.protection.outlook.com ([40.107.117.71] helo=APC01-TYZ-obe.outbound.protection.outlook.com) by sfi-mx-2.v28.lw.sourceforge.com with esmtps (TLS1.2:ECDHE-RSA-AES256-GCM-SHA384:256) (Exim 4.95) id 1q8Xon-0007se-BR for linux-f2fs-devel@lists.sourceforge.net; Mon, 12 Jun 2023 03:02:15 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=oHywBGUK7RtIahJCVitMtgTRZxuq62SBfPfc4ljyg3HBynRACDy4vXyvxv550BHwXv9163vfKxO167HV87KQghhZ+qQYrSe5KlnGF3mhySvRl6qKdTSjwb2Kxvia48QlGicN30LOUICSh35140bHeS3x+nIcjJIuPE56MN7p4sju/ZUOiS3KxIEipOrm/DPHqsgYV9B/fEbmzD+90s2eVH93HK1yrOQhL484GnsqdbqdiPpnDe5FMF3662pwTKp6HRmyvYJoDDzFjaECk0e/fTWTV+jfclVKCVTr6JoBLBb62hN8bIqIEoTY+NvfbBCzqtgCaZSKteSVel5WiaoIag== 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=yG4NaiIwJDVRa91GbUkjytPpX0qB5PkhDezBZEAmJxM=; b=iWV5rSI+YaCh9WHVyT1BMXoMPqiAbFD0mutn2RVgrl+Nhnzr9u+9CQWAKTS+aycslXVuGbmYTIBZKKK4MO8hyMxH2fq9NLlQu2MuGlQWp4EZqer50WXkRVuNDY24y/DDy070+212TBCPGaYEpkbVOarQr95uoP7zuwenqekyICEXzV2bEsEEZ2HIZX8EdjqtdolZermbNAl+9PyjMmXD/vUukjyV0JOCk5im4pR8a2yJIiyMQJNlU6u/EqDNScNDU/wcLRJz5E01PXsH7rCkTGWMucitRQRx9/Ln5dKsWb12i61ADJyvA/ReK6WwV/nme62GYu0dNXWXjSCO82ruMw== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=oppo.com; dmarc=pass action=none header.from=oppo.com; dkim=pass header.d=oppo.com; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=oppo.com; s=selector1; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=yG4NaiIwJDVRa91GbUkjytPpX0qB5PkhDezBZEAmJxM=; b=ZlpEdXJZxSA+P7zmhq6IrKNTAw1XaAeKs74eS3ncErV8WBklXjMALn4mF7tsprdTMh4+l/T9AZh4wRY/Y3MlTl3ClvQoWtfNiwbRTxk0/qXG/Ae7jNmIKmiRxYhHLKXWgEJpop9N4PAdWJ9ZXNyE/XAj1238pulgBtjC67df52g= Authentication-Results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=oppo.com; Received: from SI2PR02MB5148.apcprd02.prod.outlook.com (2603:1096:4:153::6) by KL1PR02MB6259.apcprd02.prod.outlook.com (2603:1096:820:dc::9) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6500.21; Mon, 12 Jun 2023 03:01:46 +0000 Received: from SI2PR02MB5148.apcprd02.prod.outlook.com ([fe80::6297:13a6:41f1:e471]) by SI2PR02MB5148.apcprd02.prod.outlook.com ([fe80::6297:13a6:41f1:e471%6]) with mapi id 15.20.6500.020; Mon, 12 Jun 2023 03:01:46 +0000 To: jaegeuk@kernel.org, chao@kernel.org Date: Mon, 12 Jun 2023 11:01:17 +0800 Message-Id: <20230612030121.2393541-3-shengyong@oppo.com> X-Mailer: git-send-email 2.40.1 In-Reply-To: <20230612030121.2393541-1-shengyong@oppo.com> References: <20230612030121.2393541-1-shengyong@oppo.com> X-ClientProxiedBy: SI1PR02CA0029.apcprd02.prod.outlook.com (2603:1096:4:1f4::20) To SI2PR02MB5148.apcprd02.prod.outlook.com (2603:1096:4:153::6) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: SI2PR02MB5148:EE_|KL1PR02MB6259:EE_ X-MS-Office365-Filtering-Correlation-Id: ee3d659b-a27b-4415-8a83-08db6af15b5e X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: 5x6AMKJbDVweatTajHefXK3uD/csCXbk23plknNb/SJsddH6Kb5Ki4D+gXmz895DCeYu75ZNNlSAFor1B1ngsZqs/hWeep+9XS4HeVAzr5d/clcPbwqAeVn9Qh44PnXfankRclPar/7++U4+dfIMjX6Froo/HRlFlb1dN5GPp8zs0vLgjwG3Cdg4cAh1e8agacpEPbhlgk6/UGaFFtKrHrtwAiHEJDT2RGoGxOEnEkjCyIcInUg0e/BNfbtKiagcnFDN6r1SFrCHzL+IFbuzILgnE+Dl+hebLxc+OmzrEnViQNVcSPgsDRP+W8Lrlra37mK7e+54uQyDzaw1VMziY3/WrTbYpibHnq71BYFpR0zSTl7XoE9hVGzwkbPGejPRqSYBjdu91V7CcaskLqOEYlltiKtEKeychCVDfHjVHAwiPwAzWbch2JFT7GeLqRzrP3xc+kUVj1nfj+vAHdqQNiaybvl7uW8hViTwynVy469+q2c0MDbOPnY1sORd5QSO7z4Suoxl8Q4+/IFj8dGkslNZKuoG580BPhubvNseyShkCTsXfZdLIZn0yeRTfnnF3J9JRIQoWBWe07jkR1XKbyDtmrLPBLw/++/dwLnaeoNe32iZ+Oyji2tK0aQ8/G8Y X-Forefront-Antispam-Report: CIP:255.255.255.255; CTRY:; LANG:en; SCL:1; SRV:; IPV:NLI; SFV:NSPM; H:SI2PR02MB5148.apcprd02.prod.outlook.com; PTR:; CAT:NONE; SFS:(13230028)(4636009)(346002)(39860400002)(366004)(376002)(396003)(136003)(451199021)(66476007)(66556008)(8936002)(5660300002)(8676002)(36756003)(66946007)(4326008)(478600001)(6666004)(41300700001)(52116002)(6486002)(316002)(38100700002)(38350700002)(6512007)(6506007)(1076003)(26005)(186003)(2906002)(107886003)(2616005)(86362001)(83380400001); DIR:OUT; SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: DUlp9yiDqy1Tn20fL2JCARYWAH6lmKYKBcdK6ePhMe0z+ctliDbCdj/o07yw6AkB+TsymsXNi3OaQf7mNmqThVkXBsJRWUnBtRYpThg3G9AgajfyMyvJO1L0QzTrv4NDkeo+aw7K7sz3psXxgl+DUDDralHUaLEE58ycsAiVwilrLg7cNX3xFhiisZ/yez9q2JHGsKA0V56Cn2C9Otyyx5aWk4WFnkqYM6FzT33uBLb4+p5zD0vMaQRVGgx32tXjgBMR/Xj0XZAqwDEWpF85zBBUPK3mTPHzBLBtIwj8E/ayVUYIq0/g3sha3DxpqaOOTq7E8R1Nm1LLrUg+dac6QM8lHTwUbxtBsQmRruUOkOOkhqCTkfnVbr6vEmAwGiO6nfk5gnFVobTHb8PLfV4IaeCVvRdoiW6jAfHb/KBiIAnH9q6ItZC56+j9rKldn1lTxdxULI32G9jRFjis8XTUSLV3Yt4mPvHLa4SQUqSJspihWtLxmEtBNAWCVwTlYBof1Tlu/GrX08S6vXFAe9uktEwd5wM4ILyIDPExQ6IdtcVGOoIzhWq3ihjFUgqmfXs9NcsJl3uJgg7PgjXuqvxH8RBxrz0WKTpu9cUIQytNI+iUw2X0Yd2oTdvbKswezI8DxNTwsyeEZrHyuznK27a4mdr0Jsx74jQWKjpBkkLoAtkREDUTUvovKWaugnZoNgXeD91QadY2C4C3iV4uObJ2JqCzvwT1vqoKubi34hp8qRc/aU5re4aNo+0eVLm1Djm4LmHK8dvWCE99yZK64cNs7UDwVgkCVvue94f2QK6PNha1oviFxmBnk9dg4LeLOabc9PljsuIB1K2UcZu9A+YIcL0z9cHeEYrs/yAHZRKhGb/EZI1RDrt0cE5WGJ0C6VDb9sFe3fCCJx31YZ1QUCKHmm+q6fniEpFgomccYa/LhGOCRfcbokgtT+SVEPeB+vsGktVVX47/f23femfBNMJa64FGenOG4cvajLVa0mDyUxKweWy2aXiugwdYS9qRyB18Sa0evUpd3pTxRp2WLpQHNTisvxVcOaxPTf8rPhSUdjNqKfEsArOLI+1gyyUWP61pQUwj3Sd5W1WjUtFM5CvL7QXvDTvo2arr0rAY1Tg5TdfDREplNpHQe8ncIWzTp1Y/CG9fI9UeZCKpExhpXD5T1tuYAQQ/XligAd6LaK2RENhCvSe++NV+on5TmvSiQJV8Ib9/Q2E/KpuWi9zE32N6X1ip+nqheWh05CrbhDo1NtBi0GMnXieGO6o/EJ/Odl4F29T4jGYDmZK/xLo4/Z99lJQXNZZJG4XSeUx5sbo3DOLcnIflq8eTJaH2peqj4WGo+FmbBANyMpxfdeJCAurxOcnpaCVVJb7aeKRsXs8Ifd7u4raNcPHNc3xavsEc6vQGvliWT0CDpqXP7bMD/tW0YjVEvcARbgKO3GtFqqS3OrPzmQV7Qftfo0LXVs2hXTDsLHZ6L/BHaO9UpyLMj2+VsY4BochTSzJ2BVwnN+85jgWrOc2j2hixTH3r+euYt2lXG+GJvGYT4lLsgcFSPVUzi2b3r+qeANz6k5t2T7nqpBqBrEECGPcCVL6WKFEiYpYl X-OriginatorOrg: oppo.com X-MS-Exchange-CrossTenant-Network-Message-Id: ee3d659b-a27b-4415-8a83-08db6af15b5e X-MS-Exchange-CrossTenant-AuthSource: SI2PR02MB5148.apcprd02.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 12 Jun 2023 03:01:46.0237 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: f1905eb1-c353-41c5-9516-62b4a54b5ee6 X-MS-Exchange-CrossTenant-MailboxType: HOSTED X-MS-Exchange-CrossTenant-UserPrincipalName: rP1XJo4UT6OPywRqHJTJf8wg9uRpZGidI8pUhWGjaNnpInRbvTYP3WR+6XaNhrhU0sqKslHEL2mwUEc4L1OyGw== X-MS-Exchange-Transport-CrossTenantHeadersStamped: KL1PR02MB6259 X-Headers-End: 1q8Xon-0007se-BR Subject: [f2fs-dev] [PATCH v4 2/6] f2fs: cleanup MIN_INLINE_XATTR_SIZE 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: Sheng Yong via Linux-f2fs-devel From: Sheng Yong Reply-To: Sheng Yong Cc: ebiggers@kernel.org, linux-kernel@vger.kernel.org, linux-f2fs-devel@lists.sourceforge.net Errors-To: linux-f2fs-devel-bounces@lists.sourceforge.net Signed-off-by: Sheng Yong Reviewed-by: Chao Yu --- fs/f2fs/super.c | 2 +- fs/f2fs/xattr.h | 1 + 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/fs/f2fs/super.c b/fs/f2fs/super.c index 023981824d240..d7630f6dcbd62 100644 --- a/fs/f2fs/super.c +++ b/fs/f2fs/super.c @@ -1361,7 +1361,7 @@ static int parse_options(struct super_block *sb, char *options, bool is_remount) return -EINVAL; } - min_size = sizeof(struct f2fs_xattr_header) / sizeof(__le32); + min_size = MIN_INLINE_XATTR_SIZE; max_size = MAX_INLINE_XATTR_SIZE; if (F2FS_OPTION(sbi).inline_xattr_size < min_size || diff --git a/fs/f2fs/xattr.h b/fs/f2fs/xattr.h index 416d652774a33..b1811c392e6f1 100644 --- a/fs/f2fs/xattr.h +++ b/fs/f2fs/xattr.h @@ -83,6 +83,7 @@ struct f2fs_xattr_entry { sizeof(struct f2fs_xattr_header) - \ sizeof(struct f2fs_xattr_entry)) +#define MIN_INLINE_XATTR_SIZE (sizeof(struct f2fs_xattr_header) / sizeof(__le32)) #define MAX_INLINE_XATTR_SIZE \ (DEF_ADDRS_PER_INODE - \ F2FS_TOTAL_EXTRA_ATTR_SIZE / sizeof(__le32) - \ From patchwork Mon Jun 12 03:01:18 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Sheng Yong X-Patchwork-Id: 13275402 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 D02E0C77B7A for ; Mon, 12 Jun 2023 03:02:21 +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 1q8Xoy-0002TW-9y; Mon, 12 Jun 2023 03:02:20 +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 1q8Xos-0002T4-F3 for linux-f2fs-devel@lists.sourceforge.net; Mon, 12 Jun 2023 03:02:15 +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=K1K6vKgsEBr9XA5kkiRlKqIymaZ3HjuFwbvqRqXXQqE=; b=l+sDImieMcVP2PufKBr9nKroKl RIahQ6pXUaVqFZXmXuYeMJzkTtPmHbWoJ8gaXg09P32GIY8UTtuslc04ncG1g8GL9YEjm+MwyUvOz Vbnh1EpcpEhR+oVdmME9mORe5+xPlcqVQutNmhFDw94ugqyODRonwlX9+UZOu4Djvy5A=; 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=K1K6vKgsEBr9XA5kkiRlKqIymaZ3HjuFwbvqRqXXQqE=; b=eei0Xz8Wk3hlaZLWZ6Pte4LWB1 M2aaxcyzeGpXj+8uKAh5gE0u1FYOBE92kP4og+IREw46qhhKuUbh9pz7NgF1BaMqnzvta5+x1fxpf WOyWA3+ZoOVuo41zqAKBdZwX04S/nMoEgsLdE8B34YrPtYe8DcUOAtOvCeG/24KLEfvs=; Received: from mail-tyzapc01on2054.outbound.protection.outlook.com ([40.107.117.54] helo=APC01-TYZ-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 1q8Xoo-000MRd-S0 for linux-f2fs-devel@lists.sourceforge.net; Mon, 12 Jun 2023 03:02:14 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=gefyTtI6qnFg4mkf8Cn5DbsVqG5gtPdulGlp02XsqhYcswjCBZRs89t/YPauvre5PEt9QW4a9c+FzlBMSooPhRpnKqDqcabw7eGNMsuY7EJjIb4Y/ziF6sCC5uVnMVEjVEi0x7Ux+8ZN+c1uDVnmQaNiAPMtmBFRw9EnVPG6a/hMfpbTku/FcM1bVoPxHjkXc4u+biKLzvMFevFZ8znzUPZ0VjYuKqk6CVM4h3aiJDfAWTrZ0Qhc8X0NLCBSq/9wIB8wz3ulRchfvPKJ7HY8ThOKr61N+9V5TZ7Xq+CjSd3e+NVeqe43v8g0YQF9MBQPpgE9R1wWlxqG+OjFluQcjw== 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=K1K6vKgsEBr9XA5kkiRlKqIymaZ3HjuFwbvqRqXXQqE=; b=f55LxVh15ouqzAbHz1IOQVvf7mnTS6J3tpTuaMwVCp7HGmJgCxQXmlJ7Bw2xm/rrkgMs6gINrWqLNpg9l3L1G94rhRt4uiESbQ9snbCHa3UEW4m+JeQ35DEi5gVa645QoYwch7laUEYjwzXS94+c1TzWOjt5EST02bYJ95/pt0wuFeFgxUaUrWrBhjgIFfiXm6PkCXhxepl6wiRGeBJIjGQcHT7PXN4RSjvQ6vCrC8Lx9ZgJ/nP6TwWLMeoYWPoUApo/PjpJPsQ1BhNwROXif7lCQgQpdTDuqEEsFhYb0nHNk+KaqEcXn0/o43JDAuRVzhYl4F+Gmg6Ta0hPOHKjxQ== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=oppo.com; dmarc=pass action=none header.from=oppo.com; dkim=pass header.d=oppo.com; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=oppo.com; s=selector1; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=K1K6vKgsEBr9XA5kkiRlKqIymaZ3HjuFwbvqRqXXQqE=; b=u9BdKaewtxNIrKB9JOt2ftXsBKq5qTztTk6EdohVMn9ztNYZix00psdCpf5xQRUqM6syFigK4dWltIYG1eOBhAoD1A3omoKZGFuD+xJFqflAHBxaaqZ1VQCCc3eLDTvzZ6Gq7U9Rs+DHfVEzMMsWDSD3ktIBn1ITT3rcUtOSQcg= Authentication-Results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=oppo.com; Received: from SI2PR02MB5148.apcprd02.prod.outlook.com (2603:1096:4:153::6) by KL1PR02MB6259.apcprd02.prod.outlook.com (2603:1096:820:dc::9) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6500.21; Mon, 12 Jun 2023 03:01:47 +0000 Received: from SI2PR02MB5148.apcprd02.prod.outlook.com ([fe80::6297:13a6:41f1:e471]) by SI2PR02MB5148.apcprd02.prod.outlook.com ([fe80::6297:13a6:41f1:e471%6]) with mapi id 15.20.6500.020; Mon, 12 Jun 2023 03:01:47 +0000 To: jaegeuk@kernel.org, chao@kernel.org Date: Mon, 12 Jun 2023 11:01:18 +0800 Message-Id: <20230612030121.2393541-4-shengyong@oppo.com> X-Mailer: git-send-email 2.40.1 In-Reply-To: <20230612030121.2393541-1-shengyong@oppo.com> References: <20230612030121.2393541-1-shengyong@oppo.com> X-ClientProxiedBy: SI1PR02CA0029.apcprd02.prod.outlook.com (2603:1096:4:1f4::20) To SI2PR02MB5148.apcprd02.prod.outlook.com (2603:1096:4:153::6) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: SI2PR02MB5148:EE_|KL1PR02MB6259:EE_ X-MS-Office365-Filtering-Correlation-Id: 13e7c429-77f1-4b3a-143d-08db6af15c16 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: 7I4/FA2hFiQuVVAz9R1yGywr3BSyyNCCeOGFWK/DDCND8Q3TgWMzzdJ77ZYZjCp28Kg9CiNAHOfMf4zUSEfAyW5sJ9qVCAnqVUQ37qiQBgl7Zc2FAchop24Wq+sumgsuO1l+/gkuFCOiwvWqiRBh5yI8rN2XKpx1o3d8inEBJ1my2Meh/uS8fkDt7d/hWcrlgVJfQSkOmew251XggV+Z/5DV6i0UVUSvh6EuKPfXR+1yQnVhvVsppP1Q2WH4qw6k7dbpBmRMZsCLsY1Ecj5IBtZVsuG789R577hgApLdvGisD0eWhmpDwAjWWsRSQjJ7d0Jk3O3F6nNquTGcsddUny2fqdIgHOM5TAk+k2IKKvwD/G6QfWAbYIFhAp8A2HLwUa5oRj2Q5mu3RXAI0oxwaehiB7d+8jYI1ogt7A1mg1SkzXD2r9d7FJgZh7tiAn40skelpacIkDA13/f307ML+pBL7MBY6OfBqMCJEWC6nMVj8pjzgn96N0BdL+S2QlyVMMSgNPe0tPhq8FlDj/Ir2AEUvDflFp1H/FGvyj4RxroW13q7XqhSiZvdWICxbl8qGipWpU5ircVxqBV6dXsanIoHKk9MO9vokY66mphoOfPYVC5PkKNGt2xjmuxiGnAV X-Forefront-Antispam-Report: CIP:255.255.255.255; CTRY:; LANG:en; SCL:1; SRV:; IPV:NLI; SFV:NSPM; H:SI2PR02MB5148.apcprd02.prod.outlook.com; PTR:; CAT:NONE; SFS:(13230028)(4636009)(346002)(39860400002)(366004)(376002)(396003)(136003)(451199021)(66476007)(66556008)(8936002)(5660300002)(8676002)(36756003)(66946007)(4326008)(478600001)(6666004)(41300700001)(52116002)(6486002)(316002)(38100700002)(38350700002)(6512007)(6506007)(1076003)(26005)(186003)(2906002)(107886003)(2616005)(86362001)(83380400001); DIR:OUT; SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: 1oKzPXMpSFmRfjZLMxqYewpPNuxV4U5B/mePqkADj40sDpDTYWgkQ8xtfqOA9xS0RN7c3KH4fjHxlTjljPJ+fZgc2t5xKIe4kXeAcXIlbExYSL2Yp5Dw/U8ZM8FUYxOm4qOVYLstU356bWQSMerWEyeMhyaKjnyOD4TYi1sg4bZmKNwm20AX3ycUSi9WsqAmgqPqAKj061eGbeojguWNnnjM00mZQT8jHWip5+1bkgiq7oVD5SHquULCaTeu8+CEFZicXGZdhS4uhQIKVD7hAth0qpAJSmMwlJs0tKm4kIUcJKLY8YKOKYsdKp+XPGoBBpGu1QFXpuZAceG2lE43JQllX+JEU0Ai8mQg2q4r8iuRn42NqL37Wj+svZ99MumzizLBL7zXJwQFGHocvuK6cO9v6/M0cffnHYHESz8XLMoDJEmIkw91pw3Wru2WhvNDxKihKZXUHRiCSoIXgj/SZRt36fujHmG2AWXfpioux9CnDUJ16xJ1HFQjByezHHjcT/+iVtYqbpx57Drnwvb5kc/hrSuxPgNSpx8Zs2GsH/rDf/9wb0hmptAOGvs+uyeF/7tJBUroyyBzFILeCiRHmd/2DyiQi39po/p31Joe4EFJnSlfzAy6cCZ5NhVgysRL//DNjXsgEBw2Yw5S9KnG+2lQyLMIITo9sxzgr8Pkiur/7vCAsJPI34v2TmM//ws1t4z3qkmv/6Ymjsi0QtOqjfHWe/O+DjocNAvO0NeAmkMCuVsRxb3UR6WRI+B6Ug778KTcXoGGSvBScZTY9AlnawowSB1RSChOhpxwG/xDToA6p1bn4Tp7Iq3t3qP+8AltX/d/+GngKp2lcYC/lX7RAcKOO0I8vcRs+XKcyLe2dPxME7mmidT/Td/B7wc6st5NKDN5wfT87Rekg07lD060zRtC3yK9ooUpn6GnIbYSdmq9z7ONDFvhsdf922YCFMzoUQJyqvzZwdmlciuiqa/GoaXTyRbalKbenCJXyeFLzvBSsVcC8wbmI3HmsENrzvU6eL9BMDJwWPvsAFfTBmvzOGvKY17f7TFPr/8aMv7LZu6rJCWHSNs2IUllRDLeFehGWdekET62FM/Ehjni+G7uLw8mYac49pNwDHtFISATvEq8RzyayPl4vFuK0Hr/ExaDdWalTJEt4jGFbTzFyqpeJ5ejR2cdIagOas3WqgMUO7SJj5IFYaFkteTT6RQ1aoSUK4PcSy8Nx5EDv7kYTw/LkFicxhlcAdbOYaUAHx/ft+cz6PlcnkF0bp1+fEgN/rabONFEovxpQDxux0FT1kKDhGIlXn10Hv42/+bpzr7iFZ8C+CcsE4Z7nPrqriGqab9esiCTLMr67PDlWQWiCceiJlFlbgfFac2TvpEn5kYt9r6CJpc0GBR2cVEVsvfwmG8al5s0J8JIUA0mhviPLTgYopHKdM5ViZmb1bd3aF9U0nYkMmNnfas31rILU3IMzmOtVvqcehO9C+jAHy8Lz/pZSyQeUhMhE9kwuSI01NmjwGQAus8HovbtK6IYKwhX0FBQ27KhE31aVOxuSd+JwXD/vFdj8AdmaEBs+ZfGzR2KJWJlNzMgxow8JWAnhaUlN+Sv X-OriginatorOrg: oppo.com X-MS-Exchange-CrossTenant-Network-Message-Id: 13e7c429-77f1-4b3a-143d-08db6af15c16 X-MS-Exchange-CrossTenant-AuthSource: SI2PR02MB5148.apcprd02.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 12 Jun 2023 03:01:46.9602 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: f1905eb1-c353-41c5-9516-62b4a54b5ee6 X-MS-Exchange-CrossTenant-MailboxType: HOSTED X-MS-Exchange-CrossTenant-UserPrincipalName: mgWw5wjkY7sxwyorLErmFc6VP/7e97rVTxegs4d31L6M0exywRVwEEJ8zlCNNzFDcIVG3jrftUgQAXZDK4iFKg== X-MS-Exchange-Transport-CrossTenantHeadersStamped: KL1PR02MB6259 X-Headers-End: 1q8Xoo-000MRd-S0 Subject: [f2fs-dev] [PATCH v4 3/6] f2fs: add helper to get inode chksum from inode page 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: Sheng Yong via Linux-f2fs-devel From: Sheng Yong Reply-To: Sheng Yong Cc: ebiggers@kernel.org, linux-kernel@vger.kernel.org, linux-f2fs-devel@lists.sourceforge.net Errors-To: linux-f2fs-devel-bounces@lists.sourceforge.net Signed-off-by: Sheng Yong Reviewed-by: Chao Yu --- fs/f2fs/f2fs.h | 2 ++ fs/f2fs/inode.c | 21 +++++++++++++++++++++ 2 files changed, 23 insertions(+) diff --git a/fs/f2fs/f2fs.h b/fs/f2fs/f2fs.h index 1b17bbe7e8656..a30c81ac7299d 100644 --- a/fs/f2fs/f2fs.h +++ b/fs/f2fs/f2fs.h @@ -3478,6 +3478,8 @@ int f2fs_pin_file_control(struct inode *inode, bool inc); void f2fs_set_inode_flags(struct inode *inode); bool f2fs_inode_chksum_verify(struct f2fs_sb_info *sbi, struct page *page); void f2fs_inode_chksum_set(struct f2fs_sb_info *sbi, struct page *page); +int f2fs_inode_chksum_get(struct f2fs_sb_info *sbi, struct inode *inode, + u32 *chksum); struct inode *f2fs_iget(struct super_block *sb, unsigned long ino); struct inode *f2fs_iget_retry(struct super_block *sb, unsigned long ino); int f2fs_try_to_free_nats(struct f2fs_sb_info *sbi, int nr_shrink); diff --git a/fs/f2fs/inode.c b/fs/f2fs/inode.c index 1e49009831c12..098d1ee72bfcb 100644 --- a/fs/f2fs/inode.c +++ b/fs/f2fs/inode.c @@ -204,6 +204,27 @@ void f2fs_inode_chksum_set(struct f2fs_sb_info *sbi, struct page *page) ri->i_inode_checksum = cpu_to_le32(f2fs_inode_chksum(sbi, page)); } +int f2fs_inode_chksum_get(struct f2fs_sb_info *sbi, + struct inode *inode, u32 *chksum) +{ + struct page *ipage; + struct f2fs_inode_info *fi = F2FS_I(inode); + struct f2fs_inode *ri; + + if (!f2fs_sb_has_inode_chksum(sbi) || + !f2fs_has_extra_attr(inode) || + !F2FS_FITS_IN_INODE(ri, fi->i_extra_isize, i_inode_checksum)) + return -EOPNOTSUPP; + + ipage = f2fs_get_node_page(sbi, inode->i_ino); + if (IS_ERR(ipage)) + return PTR_ERR(ipage); + + *chksum = f2fs_inode_chksum(sbi, ipage); + f2fs_put_page(ipage, true); + return 0; +} + static bool sanity_check_compress_inode(struct inode *inode, struct f2fs_inode *ri) { From patchwork Mon Jun 12 03:01:19 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Sheng Yong X-Patchwork-Id: 13275405 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 58003C7EE45 for ; Mon, 12 Jun 2023 03:02:26 +0000 (UTC) Received: from [127.0.0.1] (helo=sfs-ml-3.v29.lw.sourceforge.com) by sfs-ml-3.v29.lw.sourceforge.com with esmtp (Exim 4.95) (envelope-from ) id 1q8Xp3-0005de-JU; Mon, 12 Jun 2023 03:02:25 +0000 Received: from [172.30.20.202] (helo=mx.sourceforge.net) by sfs-ml-3.v29.lw.sourceforge.com with esmtps (TLS1.2) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.95) (envelope-from ) id 1q8Xou-0005dX-3b for linux-f2fs-devel@lists.sourceforge.net; Mon, 12 Jun 2023 03:02:20 +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=oG92vvId03jcIqR+clv2OcovvvNDrykZIFGmMQSR81A=; b=YYYyNgYpq4sB9YVG/HtfF4MRlp xVi+5F2eKGdGjSkTnoELd9bY/IMdop/zEaHPf+JsA7uXP3HZD2GmOK7G0P5gZERo7FNZB8pGkmYoa 8FTb+ZFRQK2SHpH3mWXjByuKfAAH0bqfJcPCAGEj2CN3hHNC1fNIEGJYD8XMqKIXNKS4=; 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=oG92vvId03jcIqR+clv2OcovvvNDrykZIFGmMQSR81A=; b=StmMWsTBr7WfFWypxLryYBdzcB cJzbBylh/vgBbUiImaMlexdnVLB9TrSDEqTz+1JSA63EG+vDBVjQ9x3E0THK46dIZ0c25ckZ3aLct lXgFInuFkMTon3Gt0XVkriSccHJlE1yL4CuTHkNmG+uNpUuQklko+npHKv6mSv9vHzzw=; Received: from mail-tyzapc01on2054.outbound.protection.outlook.com ([40.107.117.54] helo=APC01-TYZ-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 1q8Xos-000MRd-Qk for linux-f2fs-devel@lists.sourceforge.net; Mon, 12 Jun 2023 03:02:16 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=Hi8ouJTf2MQiqXpofTRTTLVLVXGl5wPQfflWzYzIRha8o9e6xTT3D4fiq/KezJZYVXYA7yXUt3TZBTP+PF2ma+oaUQ4IMe+LndnJa/pRI2Etk6aR0vnl0keeglGejvYDxMLzKQ/V0Egt6N8hTvYe3kjOmgGqnBmR/KJo+x8fGQti0Gp8RpyX/ZWFX7g+D7S+9t+iK3hkOEhOQNYCpvRTWgsmwl3nyZYW0sIkTWYulzrGRhaKEM2+wMKkDkxBK1NIk7gGRLtwlFbKCdnuVB/BwLFEhYaj2WLNLbuvaaPHPOAY6MjtqrRFyi78kZpdhqiv3I9otQrvZc3lGY/xdlc12Q== 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=oG92vvId03jcIqR+clv2OcovvvNDrykZIFGmMQSR81A=; b=TOX9WPIE6RsL/kiJJV6Y8kqrmQ7mqepThM+3IfaTmOfrZsmDfqUA1o2gqQYIzeXUQS38sjYX3Rl6fxEgoO8o1U3ZfngrH49WyREmmA0XU/FHV4t5OHYZTiB63+iTXG3PSQZCyNo6+2SkN+xfUVQuYnKD1JFRKcY/RMJ8sOQogEzu+BO03gC2RbCEVQFApY7EGmPfDIZ9ZsTxAbZppStifl9YyuAEYvj9wmJZQzsiSiaUVQNW6Vz/soPwtjjG560o0gwVaYJna9oz6OTH/ATXlvywvOqMqcfubnrZONCZRYbkQsplDc42Lo6VaLt0X+vcwQJv8fz7K71q+JQDBvkX0Q== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=oppo.com; dmarc=pass action=none header.from=oppo.com; dkim=pass header.d=oppo.com; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=oppo.com; s=selector1; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=oG92vvId03jcIqR+clv2OcovvvNDrykZIFGmMQSR81A=; b=BVe3vZ4VN3WYpIMIpoupjVwHcyWuye7e6lYu5JxaboFWs6sKcJs0IwM57oPncXYdclQzQ9vXN7tNz/blVB05ZDR2YIekwqZmG785oAyGTg3VVGAbgxu2ayNFoBV3WMtnu1YRQbo9dv87GOl9WLwc1/bdiERAAO1L40GLVuleeIA= Authentication-Results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=oppo.com; Received: from SI2PR02MB5148.apcprd02.prod.outlook.com (2603:1096:4:153::6) by KL1PR02MB6259.apcprd02.prod.outlook.com (2603:1096:820:dc::9) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6500.21; Mon, 12 Jun 2023 03:01:47 +0000 Received: from SI2PR02MB5148.apcprd02.prod.outlook.com ([fe80::6297:13a6:41f1:e471]) by SI2PR02MB5148.apcprd02.prod.outlook.com ([fe80::6297:13a6:41f1:e471%6]) with mapi id 15.20.6500.020; Mon, 12 Jun 2023 03:01:47 +0000 To: jaegeuk@kernel.org, chao@kernel.org Date: Mon, 12 Jun 2023 11:01:19 +0800 Message-Id: <20230612030121.2393541-5-shengyong@oppo.com> X-Mailer: git-send-email 2.40.1 In-Reply-To: <20230612030121.2393541-1-shengyong@oppo.com> References: <20230612030121.2393541-1-shengyong@oppo.com> X-ClientProxiedBy: SI1PR02CA0029.apcprd02.prod.outlook.com (2603:1096:4:1f4::20) To SI2PR02MB5148.apcprd02.prod.outlook.com (2603:1096:4:153::6) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: SI2PR02MB5148:EE_|KL1PR02MB6259:EE_ X-MS-Office365-Filtering-Correlation-Id: ad0beee5-9e97-4c5c-f3ce-08db6af15c9d X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: u1FR4hsGilKeqS8eUBauInsZCQyAPOUBukCX/sbthAhl3783utJaPBV7B7g7Yxs0VxkkXMaL5C0GhCegy3ZsD4LNv7zD6gTAA6DjlrqN9Cd4q/euUG2ALq5XBqIGenC/PGT57zCYSBcAx3SMmNP9D4V0sUTZTHp2SCzHeoXUiKBrEQw6UFj//LcwWcNHAjrG49zS1j0ptsVmw1BLWg9AZzV9eabbkKBTyQmoKM0hvNGxdN7qEgWQ/K9P+dNWoJNg7m2ZqqOAnJQ7EQojdM9sww+mrSy9/Izte+WPQWl5rsM/8kcPDawZALPgYdS0xNfCIMVMSRPR7nfLMBZd4XP9GdM833cH8n4cbKi8JoLCu5PjzDRTISfgAqpb/B/pwWuMKuUeUeY5A1F7HEfPY5dSr96nuZeAGGRYg+OWS2zVl1f3AZzVas4VVvcXtAi/LD40bIqNdWf1YD1BmnOeRvcXBiQejS9sbiSmpjnIYhm3D16pzsK4+LzUGce5t928+N5I6wMEBVey3Pnl7l1CGo/fPUolYH+CWaGKK0mQt3yX4cwdexG+XB/AFBu7ED4GL5jyrK70TPVs3MwB8SME8R2J7pFeVT9e08HfpzJU39IcYgkzqdV3FM9dVGZi+SwFFBSC X-Forefront-Antispam-Report: CIP:255.255.255.255; CTRY:; LANG:en; SCL:1; SRV:; IPV:NLI; SFV:NSPM; H:SI2PR02MB5148.apcprd02.prod.outlook.com; PTR:; CAT:NONE; SFS:(13230028)(4636009)(346002)(39860400002)(366004)(376002)(396003)(136003)(451199021)(66476007)(66556008)(8936002)(5660300002)(8676002)(36756003)(66946007)(4326008)(478600001)(6666004)(41300700001)(52116002)(6486002)(316002)(38100700002)(38350700002)(6512007)(6506007)(1076003)(26005)(186003)(2906002)(107886003)(2616005)(86362001)(83380400001); DIR:OUT; SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: iGaSLtmoQwSpPOwmZZIAp2yQGBQcbybmbdbb1x30Z10K6RgEokG/ngB/r60c2orGuBQjQAPWZGl3/9FM2wSnxq2676x+k2meMnvAgEaMbR/v3KkvyDOE3llmAMrYbZvADcID9rvcUVZDGCishDtlm/1SNNFvvuLNQNtUIhowRXXzgZgtmPMuQzjBsHeSBu7PP/t3e6XNQ2NPwHwwYepsCS9OJrj7qoEgxT2Xyw7ud89N0a3O2I9frcYPXrw928kX+gjkn+YrTxjWmP7LWFpX4gtDKjy2Z7S8Af2+219USGaSJSQ5FYoGlPOHz7pUL8812VlcKJgnJ6uENEutUrXuZCAaJdCluZRGI3QnzyrLUcXbKiktqGnwoss5ZlWS+D56vWxkB4SnE7ml7+e/36qSJsNtcHL1TL8oUVuE5CewzPyjpS6ArNbjppLXyLLEh1DKhdK2dzpuXhLh2TRfg7RGctXMUNqiUGy3XARHKAPIk5XTg5zMuPI0WrGFSO9wIrCZN3bSDSc/GehvSEppSWZCpkPr+mDR9IYQsQT9TlZYSi37Pc3n5DnJ0xtAN9K71loQKOG+NkynFT6MAT2eX83EiYnJ+NQEkz9qv5fmgvGnFCfHuyre3GywhuUO7JDdQyWOHCk/r2LL7FE05toT7crSabjURmBaP+RXlaJigbrSn8x7Z4fhlqHTErMgFwcl1g+EUrgfFsP+H/iQw8SZhPBOXgoS/vtfoDFLEJWFPXZ34gH+yQ6h7RErNzEApXX7h+lJOeiiDODqXNAczfhzzav0/z0tMCTc9QDYGNwE8mMwNEeTuKrGCCfbS3nl7lLAoTJuvbL+vGI4WPkMT9m5tUKgXm3nXN3PfFdVUbzkgWsf/I6g4pD1RqCKz3mxHDkNMnQSrtU3/9RSI1NlixKU777Idjtl0yAIDFosrEy1afJmAIeA4lSDRp1ZL8d2t8k7TT1uE2NVv+VnDyq9Ll4Y0YKJ2tVzxgppnIeSvZaNUOR6sJ5813eDb5GFX4qxvVUc2cp2paqq8+jbeX7OYiQ3hYtZ3SLV5ir9eh8pBZOTuROIuJrers5ZQHAcsOATaAYPygBgiDj3aox45g9SvRSgRqSaYDSjTGEycsgNdmYpHXL5ady4Qb+nG8uHQ//sS7dRcrRiUfkL8nSBN9bcvs4lsu5toeudzBGL1JMSaX/1wRcqM0F4V9Dj0bjRxG9w8fsiQYZ36zZp3B4Tqf3wbhiAW8P0K7XBfdux3BTvAbA+5I/mk4GTqM/gPb7BGGPav+4aQQD0hbRgbgEVYXJmvbAWCEldR2/9KxwK3E7tDx+Zr1i6if1/C+lSmgVsx8dB24obEXsNFp60Oz7CCsv8/ftfmR+tFtDwrrDjGz74lcy6OTDJHOPlk5OOjY3hDH3NQVlKCUYdscwVrF0ZZjjPRzz3+sqnKypLsUBSOhbx2TiStN1r9WZGryvcq0axKDOL8zWm+9ZynhCHDIX55t+yIk+1ivdEZ7vpO8uVqE06wnTrGTiOmqB+MySr8w9cMyTYg9SfWeqWB6q/4kkQBoto+QNKoOIHdkEhanltCA1O2OrV/25S7oQyT4w/x9O7kucb3FGCTOAn X-OriginatorOrg: oppo.com X-MS-Exchange-CrossTenant-Network-Message-Id: ad0beee5-9e97-4c5c-f3ce-08db6af15c9d X-MS-Exchange-CrossTenant-AuthSource: SI2PR02MB5148.apcprd02.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 12 Jun 2023 03:01:47.7954 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: f1905eb1-c353-41c5-9516-62b4a54b5ee6 X-MS-Exchange-CrossTenant-MailboxType: HOSTED X-MS-Exchange-CrossTenant-UserPrincipalName: c3Ta3GdLTDfWVSK7YexMSkibW90bqrc4XfgUJPKI1gpMltrhVMxjl1M7zld3gPkkL2MGG+3rfS0B28+5LytBSA== X-MS-Exchange-Transport-CrossTenantHeadersStamped: KL1PR02MB6259 X-Headers-End: 1q8Xos-000MRd-Qk Subject: [f2fs-dev] [PATCH v4 4/6] f2fs: add f2fs_ioc_get_compress_blocks 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: Sheng Yong via Linux-f2fs-devel From: Sheng Yong Reply-To: Sheng Yong Cc: ebiggers@kernel.org, linux-kernel@vger.kernel.org, linux-f2fs-devel@lists.sourceforge.net Errors-To: linux-f2fs-devel-bounces@lists.sourceforge.net This patch adds f2fs_ioc_get_compress_blocks() to provide a common f2fs_get_compress_blocks(). Signed-off-by: Sheng Yong Reviewed-by: Chao Yu --- fs/f2fs/file.c | 23 +++++++++++++++++------ 1 file changed, 17 insertions(+), 6 deletions(-) diff --git a/fs/f2fs/file.c b/fs/f2fs/file.c index 23c68ee946e58..f8aa842b5d233 100644 --- a/fs/f2fs/file.c +++ b/fs/f2fs/file.c @@ -3376,18 +3376,29 @@ static int f2fs_ioc_setfslabel(struct file *filp, unsigned long arg) return err; } -static int f2fs_get_compress_blocks(struct file *filp, unsigned long arg) +static int f2fs_get_compress_blocks(struct inode *inode, __u64 *blocks) { - struct inode *inode = file_inode(filp); - __u64 blocks; - if (!f2fs_sb_has_compression(F2FS_I_SB(inode))) return -EOPNOTSUPP; if (!f2fs_compressed_file(inode)) return -EINVAL; - blocks = atomic_read(&F2FS_I(inode)->i_compr_blocks); + *blocks = atomic_read(&F2FS_I(inode)->i_compr_blocks); + + return 0; +} + +static int f2fs_ioc_get_compress_blocks(struct file *filp, unsigned long arg) +{ + struct inode *inode = file_inode(filp); + __u64 blocks; + int ret; + + ret = f2fs_get_compress_blocks(inode, &blocks); + if (ret < 0) + return ret; + return put_user(blocks, (u64 __user *)arg); } @@ -4239,7 +4250,7 @@ static long __f2fs_ioctl(struct file *filp, unsigned int cmd, unsigned long arg) case FS_IOC_SETFSLABEL: return f2fs_ioc_setfslabel(filp, arg); case F2FS_IOC_GET_COMPRESS_BLOCKS: - return f2fs_get_compress_blocks(filp, arg); + return f2fs_ioc_get_compress_blocks(filp, arg); case F2FS_IOC_RELEASE_COMPRESS_BLOCKS: return f2fs_release_compress_blocks(filp, arg); case F2FS_IOC_RESERVE_COMPRESS_BLOCKS: From patchwork Mon Jun 12 03:01:20 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Sheng Yong X-Patchwork-Id: 13275401 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 15710C7EE23 for ; Mon, 12 Jun 2023 03:02:20 +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 1q8Xow-0002bN-Ox; Mon, 12 Jun 2023 03:02:19 +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 1q8Xou-0002bH-Ng for linux-f2fs-devel@lists.sourceforge.net; Mon, 12 Jun 2023 03:02:17 +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=GRcY7XIgJXp+hNexvFH7YBp7/dL6xWDdR/4H3MeDN3s=; b=DOUrLC8zabmrMenQcWmEM5ZJXW neVeyYGKXcE8Kyi2bSIix5FKGTVs8VeX4MEtssdqfudqDnIOhX5gTh7MfwTbt2D66ZOo2bgoU07ol uyE8mTqF14CUXGN8uX0re/Li70TLFy4E7nekzCLQgCPId5y3Ow2OVz5XyOoSuTIwFnoc=; 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=GRcY7XIgJXp+hNexvFH7YBp7/dL6xWDdR/4H3MeDN3s=; b=dqEc+l44lMpdKpT9TaeJnlW/Ih opS918funeu7k7Xz0xMzuQAVpnF2kbBXrTiuy0bfyb1VatxmiCMSyyyBOKuAm6cPXHFrOaZR1nGkZ XouowHm9zJNDwdyQWAyHh8Vdb8uPvVjNgJPkFrq0Dlbc8pN9QeHhiCOtXEIJ+OI3EwmM=; Received: from mail-tyzapc01on2054.outbound.protection.outlook.com ([40.107.117.54] helo=APC01-TYZ-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 1q8Xou-000MRd-PW for linux-f2fs-devel@lists.sourceforge.net; Mon, 12 Jun 2023 03:02:17 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=hOu2emvJb1VmRZHFZuGWicxfihOap46Yv/2xIJJH8e3tassfPvtMqZHYFrq7fnnRMEfnT+a2pnvPP67hLuyAhYIwF5upjLJ73oaP1deuuuZzlYNgyfNdb+KaxX/6V6vjM9ZTIBgWIdrFVYnhgZ1I61YqoL/rq9HhERVOqAqZwE2ZgSA54XCNVpSuEwYB9rIv6hCwq2oew9mhlwdFU+vqs/r4kDtLpWDSzf6OzTxI29sZE8MqkAJm49fiCwrL84gHdCjD6UmciTP6nmJgpYz7Wr6PlAhgRbkj76OYblvzHGbygKTuiFy6t/OHwYLVsqRVJcXfRsmPLEnblFSkgdASgg== 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=GRcY7XIgJXp+hNexvFH7YBp7/dL6xWDdR/4H3MeDN3s=; b=Br+VkzOS1kuiIPWRBPNl+EuHj2vNfxF8h3rzLkpyMHQDKUnzMrj+It2kBmaSI22klEI1WJ9nQmdn3anf6sFx5mjtf7tiURzvdd8OwQ1kiJVwNkMtBX8pyTsHcIFnoRABdRHDaXwbeHkGZth4VA+hwCqtywON+dyKlF6JCZUzVmUzX9w84mei72wZ1/TyhLWa7VodqNTn49dnmqVrDaTLfsG7bAwyfNeJLIbawaWpb7T58xxQvfcUMln7oRz0LbLK05WSC325rws74P50/Vx8ZfLMZjIYZ/g4r4XB+KVFWtIp07SBAj5t6vIGhdNE8H5kRHR4ADT7d/Tk1UdXOamP7w== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=oppo.com; dmarc=pass action=none header.from=oppo.com; dkim=pass header.d=oppo.com; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=oppo.com; s=selector1; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=GRcY7XIgJXp+hNexvFH7YBp7/dL6xWDdR/4H3MeDN3s=; b=ONJ8Jjyz2B9HAE1oRh41D/aji9DLLUiMVbA3UXVdpLQlp4UhsaxdWTg5jrmDTRRCX64cx3XRNBrYRO2A2eIkiBl7bD+8jUO4O3dWTMEapPmNPHUXKfLWGIjhk9JTcJcFDPN7ZbXjl0neS+0im4uYZCMQiEDMWQC7bv1jgrhycRo= Authentication-Results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=oppo.com; Received: from SI2PR02MB5148.apcprd02.prod.outlook.com (2603:1096:4:153::6) by KL1PR02MB6259.apcprd02.prod.outlook.com (2603:1096:820:dc::9) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6500.21; Mon, 12 Jun 2023 03:01:49 +0000 Received: from SI2PR02MB5148.apcprd02.prod.outlook.com ([fe80::6297:13a6:41f1:e471]) by SI2PR02MB5148.apcprd02.prod.outlook.com ([fe80::6297:13a6:41f1:e471%6]) with mapi id 15.20.6500.020; Mon, 12 Jun 2023 03:01:49 +0000 To: jaegeuk@kernel.org, chao@kernel.org Date: Mon, 12 Jun 2023 11:01:20 +0800 Message-Id: <20230612030121.2393541-6-shengyong@oppo.com> X-Mailer: git-send-email 2.40.1 In-Reply-To: <20230612030121.2393541-1-shengyong@oppo.com> References: <20230612030121.2393541-1-shengyong@oppo.com> X-ClientProxiedBy: SI1PR02CA0029.apcprd02.prod.outlook.com (2603:1096:4:1f4::20) To SI2PR02MB5148.apcprd02.prod.outlook.com (2603:1096:4:153::6) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: SI2PR02MB5148:EE_|KL1PR02MB6259:EE_ X-MS-Office365-Filtering-Correlation-Id: bd2b2fd8-2927-4d84-0f06-08db6af15d21 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: boPyc20m893HVloBn6RuZSNcS+lu9RPashWxU6mu11ym/OUtiWAshaeh9CZGkm8aghw2tMUNqQtuo2yeAZbI8dhzITQoCDjrPHJ69SYyxaGAMvYlKg6ZpQxvSUOP9X2Y5JOMeRe3c+tk4N3/JqYJKtWWuzLsXTSDSxsixZq6GaD/zevDFBWwAk3qn1GL8aPkxTZ5j+Z7/raz2euqGVEV67lDdm3MZ+ieSdPvfRyCMa2vD/hSMUp5xsA0Tgfv9CcrN3+4qnyKNf0lSQtPh8kLvBlO9zfYxh9BZCbcKUJO9YYKe7DM26W9Wee5PsUv6eneoRcSsOZhEt/+63OYjj2iQNC4w99b+1L4X2Sl93fTtQINwavW7P7QVUlfn98UT/X8YLPNpa3sUatwP5CMdCixi4fuTWHPD8G1NCYspw6ITrBnXe7MuZxaJbH2c/ShpQJ1BVQiAYZS4yXsL1YJ22GdtLW0X6bfa/8nQFCv5CugT0vQIt2ToaugVhDSZPtcb0RQslQMBREgJdJIu4jS8Fj9Nj02riNIyPuXm5NHo+VDfZd454k7qe0pq07UE1DVoAF+KeOgsoJ9XhTibsunIAHQ3uwf70ccvBdxYuDwmIUF09AWXPk6NO9N1QuqiE9ktKV9 X-Forefront-Antispam-Report: CIP:255.255.255.255; CTRY:; LANG:en; SCL:1; SRV:; IPV:NLI; SFV:NSPM; H:SI2PR02MB5148.apcprd02.prod.outlook.com; PTR:; CAT:NONE; SFS:(13230028)(4636009)(346002)(39860400002)(366004)(376002)(396003)(136003)(451199021)(66476007)(66556008)(8936002)(5660300002)(8676002)(36756003)(66946007)(4326008)(478600001)(6666004)(41300700001)(52116002)(6486002)(316002)(38100700002)(38350700002)(6512007)(6506007)(1076003)(26005)(186003)(2906002)(107886003)(2616005)(86362001)(83380400001); DIR:OUT; SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: nwvYdKHyqrLbbGj+z5WqeTCaJIkdZ3MkDXlE3EoiXhZrU26gbGq3KepjH+fUmNRlERRaqxFZCgDGAEvJTbgXcr6DmC0CnCEiPC3YzmN8yVYRhIPzd7RuFZbbIVy61WHorF6XhYVBy/gZI8SMlyThP1zgAEmM9hsvMvG4xfrh+GvUtWehKNsjIPSh0yQvyvQ4a9qqjxpqi93brIVzcmTL9PFEa6qvQctsJJ+vY9BOLSNdB+edYuESnWO0vw+uNA33i04EZhmzqadk7O1QqkAJPS/KsrIWUvd2qM51/sLHZbgxHFQIp/W79PmmxhiXUDEr3COv0EeESNtVb3CYVdrXAWkXnhs78sc9AMB3Gm6EX3xyRg0Mhj+/t1wbUnOJIHh8XGc3FsdDpmmNjvPrTj+Mnk4OsC13HPST6TI03YSzZOqzDpUeiCBHqDdhD/2LRSWAj9H97prKPYixXtFSwbXC+cUAx7PaDPwSx6pHdTrLxwrgPV8YABOaFuyQRKrWAowOuoVK1XLiEagng7K7bckQJI4Zjl1IM/51R0Z7KbauVFvDMbPjdzt3Teq0/Gi31Ixsyuh8mG3Y0vfIJGAGIpx6i6NIaKMrE4Q9clFNpHA+YlkHExMuk7q0tamRwW9B2WcOYabezrzoeqQfIdE2pvymg9khs/Zg0E+7AtWH3zu4mS/tP36VhqQSTuDsXUQ7jBBAr7Y56VkTQEnaABXbn59ujTGstZfj54Etgnc+1RCAOXaaB/GxidVq41SJ6Ho6y8guJ98sQkuh2xVVFhhvCVs9uKCDgmAl8SF+tFH9Q+iUoWSgo59+A2OJNs26H6utGgfcniWUDcK7yK7ZTaE23wTUnlRTjwdGCm93qxJgDzWD2owmLMSanMGaGAhejnPw+B1NmOaRPxJIWRO2GBUN+vSVzOhRGwKUyO3dfdzvmBm+Lob5Kr2VnfBAwMs0I/FoVtXi4WKf5uwADE3SsLHTpRSve2zz4s1tuCptKx12GJj32SijT3j+ldqZSzJTprEZ7dGiHL418yuDLKaITkFwN0DFnmnUgrj4Ups2a4acw7FaMBPd1ZWj4z2Gm65h2hLiDtAWMkKme/ciR+a5IGVU9+DwiM5k5eKK0aIQkDLoSCbGZ5OBWYQ2KGPy0OshsVQyOuDg3YRpLuRo2+oQKxMvcJsR7Q2Rf7hyIhf0+1uRMTLI4Wn9XYq+CzTFyq+R91W2AzxHCj9QfU0A6PscwcCCTQUFhDjdvaLjL/R0Jh0qJanfJIxOW+6bj6tzXWh3d/9niDM1SqML0bCUoengkqer4aIffyW+XikeJFfyfv/1YbiNLWvA0oFBqKqOsaWN/fftWs0/+j0Jf4JOL1MTN3tO2vNzjPeaL6+/N4LnZqfTY5pk8Mdg6yeJgP/Dt2OYfB7ECAlxsA61Bc/opiX39hAZ2QNM2crgRSbAUhQh2wyz587wr1lhuw9ijSj0s8T3sEKkj+fu74KK7vJSWYsOlh7E+XzePPJCOrBcYE0NOTtaBSwEjCSEf/3K0QfMszSluU0/19eCdFVl2df97K2VPuD/ZufXDfd7vrstF7WmKoQuYh33wnOK4KydELo58Ls7MtNDzViC X-OriginatorOrg: oppo.com X-MS-Exchange-CrossTenant-Network-Message-Id: bd2b2fd8-2927-4d84-0f06-08db6af15d21 X-MS-Exchange-CrossTenant-AuthSource: SI2PR02MB5148.apcprd02.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 12 Jun 2023 03:01:48.6708 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: f1905eb1-c353-41c5-9516-62b4a54b5ee6 X-MS-Exchange-CrossTenant-MailboxType: HOSTED X-MS-Exchange-CrossTenant-UserPrincipalName: CF8GmtYK18E6ACHGVN8x/nAmpIthzaFz6iXgt5VIimcXbSMpRxM6DJre4zS+30uJpjDAHUlueuINHYqOk2m69w== X-MS-Exchange-Transport-CrossTenantHeadersStamped: KL1PR02MB6259 X-Headers-End: 1q8Xou-000MRd-PW Subject: [f2fs-dev] [PATCH v4 5/6] f2fs: add f2fs_ioc_[get|set]_extra_attr 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: Sheng Yong via Linux-f2fs-devel From: Sheng Yong Reply-To: Sheng Yong Cc: ebiggers@kernel.org, linux-kernel@vger.kernel.org, linux-f2fs-devel@lists.sourceforge.net Errors-To: linux-f2fs-devel-bounces@lists.sourceforge.net This patch introduces two ioctls: * f2fs_ioc_get_extra_attr * f2fs_ioc_set_extra_attr to get or modify values in f2fs_inode's extra attribute area. The argument of these two ioctls is `struct f2fs_extra_attr', which has three members: * field: indicates which field in extra attribute area is handled * attr: value or userspace pointer * attr_size: size of `attr' The `field' member could help extend functionality of these two ioctls without modify or add new interfaces, if more fields are added into extra attributes ares in the feture. Signed-off-by: Sheng Yong --- fs/f2fs/file.c | 205 ++++++++++++++++++++++++++++++++++++++ include/uapi/linux/f2fs.h | 25 +++++ 2 files changed, 230 insertions(+) diff --git a/fs/f2fs/file.c b/fs/f2fs/file.c index f8aa842b5d233..39d04f8f0bb6b 100644 --- a/fs/f2fs/file.c +++ b/fs/f2fs/file.c @@ -4179,6 +4179,207 @@ static int f2fs_ioc_compress_file(struct file *filp) return ret; } +static bool extra_attr_fits_in_inode(struct inode *inode, int field) +{ + struct f2fs_inode_info *fi = F2FS_I(inode); + struct f2fs_inode *ri; + + switch (field) { + case F2FS_EXTRA_ATTR_TOTAL_SIZE: + case F2FS_EXTRA_ATTR_ISIZE: + case F2FS_EXTRA_ATTR_INLINE_XATTR_SIZE: + return true; + case F2FS_EXTRA_ATTR_PROJID: + if (!F2FS_FITS_IN_INODE(ri, fi->i_extra_isize, i_projid)) + return false; + return true; + case F2FS_EXTRA_ATTR_INODE_CHKSUM: + if (!F2FS_FITS_IN_INODE(ri, fi->i_extra_isize, i_inode_checksum)) + return false; + return true; + case F2FS_EXTRA_ATTR_CRTIME: + if (!F2FS_FITS_IN_INODE(ri, fi->i_extra_isize, i_crtime)) + return false; + return true; + case F2FS_EXTRA_ATTR_COMPR_BLOCKS: + case F2FS_EXTRA_ATTR_COMPR_OPTION: + if (!F2FS_FITS_IN_INODE(ri, fi->i_extra_isize, i_compr_blocks)) + return false; + return true; + default: + BUG_ON(1); + return false; + } +} + +static int f2fs_ioc_get_extra_attr(struct file *filp, unsigned long arg) +{ + struct inode *inode = file_inode(filp); + struct f2fs_inode_info *fi = F2FS_I(inode); + struct f2fs_sb_info *sbi = F2FS_I_SB(inode); + struct f2fs_extra_attr attr; + u32 chksum; + int ret = 0; + + if (!f2fs_has_extra_attr(inode)) + return -EOPNOTSUPP; + + if (copy_from_user(&attr, (void __user *)arg, sizeof(attr))) + return -EFAULT; + + if (attr.field >= F2FS_EXTRA_ATTR_MAX) + return -EINVAL; + + if (!extra_attr_fits_in_inode(inode, attr.field)) + return -EOPNOTSUPP; + + switch (attr.field) { + case F2FS_EXTRA_ATTR_TOTAL_SIZE: + attr.attr = F2FS_TOTAL_EXTRA_ATTR_SIZE; + break; + case F2FS_EXTRA_ATTR_ISIZE: + attr.attr = fi->i_extra_isize; + break; + case F2FS_EXTRA_ATTR_INLINE_XATTR_SIZE: + if (!f2fs_has_inline_xattr(inode)) + return -EOPNOTSUPP; + attr.attr = get_inline_xattr_addrs(inode); + break; + case F2FS_EXTRA_ATTR_PROJID: + if (!f2fs_sb_has_project_quota(F2FS_I_SB(inode))) + return -EOPNOTSUPP; + attr.attr = from_kprojid(&init_user_ns, fi->i_projid); + break; + case F2FS_EXTRA_ATTR_INODE_CHKSUM: + ret = f2fs_inode_chksum_get(sbi, inode, &chksum); + if (ret) + return ret; + attr.attr = chksum; + break; + case F2FS_EXTRA_ATTR_CRTIME: + if (!f2fs_sb_has_inode_crtime(sbi)) + return -EOPNOTSUPP; + if (attr.attr_size == sizeof(struct timespec64)) { + if (put_timespec64(&fi->i_crtime, + (void __user *)(uintptr_t)attr.attr)) + return -EFAULT; + } else if (attr.attr_size == sizeof(struct old_timespec32)) { + if (put_old_timespec32(&fi->i_crtime, + (void __user *)(uintptr_t)attr.attr)) + return -EFAULT; + } else { + return -EINVAL; + } + break; + case F2FS_EXTRA_ATTR_COMPR_BLOCKS: + if (attr.attr_size != sizeof(__u64)) + return -EINVAL; + ret = f2fs_get_compress_blocks(inode, &attr.attr); + break; + case F2FS_EXTRA_ATTR_COMPR_OPTION: + ret = f2fs_ioc_get_compress_option(filp, attr.attr); + break; + default: + return -EINVAL; + } + + if (ret < 0) + return ret; + + if (copy_to_user((void __user *)arg, &attr, sizeof(attr))) + return -EFAULT; + + return 0; +} + +static int f2fs_ioc_set_extra_attr(struct file *filp, unsigned long arg) +{ + struct inode *inode = file_inode(filp); + struct f2fs_sb_info *sbi = F2FS_I_SB(inode); + struct f2fs_extra_attr attr; + struct page *ipage; + void *inline_addr; + int ret; + + if (!f2fs_has_extra_attr(inode)) + return -EOPNOTSUPP; + + if (copy_from_user(&attr, (void __user *)arg, sizeof(attr))) + return -EFAULT; + + if (attr.field >= F2FS_EXTRA_ATTR_MAX) + return -EINVAL; + + if (!extra_attr_fits_in_inode(inode, attr.field)) + return -EOPNOTSUPP; + + switch (attr.field) { + case F2FS_EXTRA_ATTR_TOTAL_SIZE: + case F2FS_EXTRA_ATTR_ISIZE: + case F2FS_EXTRA_ATTR_PROJID: + case F2FS_EXTRA_ATTR_INODE_CHKSUM: + case F2FS_EXTRA_ATTR_CRTIME: + case F2FS_EXTRA_ATTR_COMPR_BLOCKS: + /* read only attribtues */ + return -EOPNOTSUPP; + case F2FS_EXTRA_ATTR_INLINE_XATTR_SIZE: + if (!f2fs_sb_has_flexible_inline_xattr(sbi) || + !f2fs_has_inline_xattr(inode)) + return -EOPNOTSUPP; + if (attr.attr < MIN_INLINE_XATTR_SIZE || + attr.attr > MAX_INLINE_XATTR_SIZE) + return -EINVAL; + inode_lock(inode); + f2fs_lock_op(sbi); + f2fs_down_write(&F2FS_I(inode)->i_xattr_sem); + if (i_size_read(inode) || F2FS_I(inode)->i_xattr_nid) { + /* + * it is not allowed to set this field if the inode + * has data or xattr node + */ + ret = -EFBIG; + goto xattr_out_unlock; + } + ipage = f2fs_get_node_page(sbi, inode->i_ino); + if (IS_ERR(ipage)) { + ret = PTR_ERR(ipage); + goto xattr_out_unlock; + } + inline_addr = inline_xattr_addr(inode, ipage); + if (!IS_XATTR_LAST_ENTRY(XATTR_FIRST_ENTRY(inline_addr))) { + ret = -EFBIG; + } else { + struct f2fs_xattr_header *hdr; + struct f2fs_xattr_entry *ent; + + F2FS_I(inode)->i_inline_xattr_size = (int)attr.attr; + inline_addr = inline_xattr_addr(inode, ipage); + hdr = XATTR_HDR(inline_addr); + ent = XATTR_FIRST_ENTRY(inline_addr); + hdr->h_magic = cpu_to_le32(F2FS_XATTR_MAGIC); + hdr->h_refcount = cpu_to_le32(1); + memset(ent, 0, attr.attr - sizeof(*hdr)); + set_page_dirty(ipage); + ret = 0; + } + f2fs_put_page(ipage, 1); +xattr_out_unlock: + f2fs_up_write(&F2FS_I(inode)->i_xattr_sem); + f2fs_unlock_op(sbi); + inode_unlock(inode); + if (!ret) + f2fs_balance_fs(sbi, true); + break; + case F2FS_EXTRA_ATTR_COMPR_OPTION: + ret = f2fs_ioc_set_compress_option(filp, attr.attr); + break; + default: + return -EINVAL; + } + + return ret; +} + static long __f2fs_ioctl(struct file *filp, unsigned int cmd, unsigned long arg) { switch (cmd) { @@ -4265,6 +4466,10 @@ static long __f2fs_ioctl(struct file *filp, unsigned int cmd, unsigned long arg) return f2fs_ioc_decompress_file(filp); case F2FS_IOC_COMPRESS_FILE: return f2fs_ioc_compress_file(filp); + case F2FS_IOC_GET_EXTRA_ATTR: + return f2fs_ioc_get_extra_attr(filp, arg); + case F2FS_IOC_SET_EXTRA_ATTR: + return f2fs_ioc_set_extra_attr(filp, arg); default: return -ENOTTY; } diff --git a/include/uapi/linux/f2fs.h b/include/uapi/linux/f2fs.h index 955d440be1046..2b53e90421bfc 100644 --- a/include/uapi/linux/f2fs.h +++ b/include/uapi/linux/f2fs.h @@ -43,6 +43,10 @@ #define F2FS_IOC_DECOMPRESS_FILE _IO(F2FS_IOCTL_MAGIC, 23) #define F2FS_IOC_COMPRESS_FILE _IO(F2FS_IOCTL_MAGIC, 24) #define F2FS_IOC_START_ATOMIC_REPLACE _IO(F2FS_IOCTL_MAGIC, 25) +#define F2FS_IOC_GET_EXTRA_ATTR _IOR(F2FS_IOCTL_MAGIC, 26, \ + struct f2fs_extra_attr) +#define F2FS_IOC_SET_EXTRA_ATTR _IOW(F2FS_IOCTL_MAGIC, 27, \ + struct f2fs_extra_attr) /* * should be same as XFS_IOC_GOINGDOWN. @@ -96,4 +100,25 @@ struct f2fs_comp_option { __u8 log_cluster_size; }; +enum { + F2FS_EXTRA_ATTR_TOTAL_SIZE, /* ro, size of extra attr area */ + F2FS_EXTRA_ATTR_ISIZE, /* ro, i_extra_isize */ + F2FS_EXTRA_ATTR_INLINE_XATTR_SIZE, /* rw, i_inline_xattr_size */ + F2FS_EXTRA_ATTR_PROJID, /* ro, i_projid */ + F2FS_EXTRA_ATTR_INODE_CHKSUM, /* ro, i_inode_chksum */ + F2FS_EXTRA_ATTR_CRTIME, /* ro, i_crtime, i_crtime_nsec */ + F2FS_EXTRA_ATTR_COMPR_BLOCKS, /* ro, i_compr_blocks */ + F2FS_EXTRA_ATTR_COMPR_OPTION, /* rw, i_compress_algorithm, + * i_log_cluster_size + */ + F2FS_EXTRA_ATTR_MAX, +}; + +struct f2fs_extra_attr { + __u8 field; /* F2FS_EXTRA_ATTR_* */ + __u8 rsvd1; + __u16 attr_size; /* size of @attr */ + __u32 rsvd2; + __u64 attr; /* attr value or pointer */ +}; #endif /* _UAPI_LINUX_F2FS_H */ From patchwork Mon Jun 12 03:01:21 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Sheng Yong X-Patchwork-Id: 13275403 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 78491C77B7A for ; Mon, 12 Jun 2023 03:02:25 +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 1q8Xp2-0005Ul-Ej; Mon, 12 Jun 2023 03:02:24 +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 1q8Xow-0005UX-4X for linux-f2fs-devel@lists.sourceforge.net; Mon, 12 Jun 2023 03:02:22 +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=/yS4TQai2mzZtvrjq0fu4KjMgTwIXAkvxkVkytra4b0=; b=mt0kethvHfjXR3mHq2lblczmum l0HG9/pO8Z0mffG3vLN+W4JxhgbxRiRVcPp6+fQw4Bwr+BlmnDn+srpdplajeLsRCF0DLn1yHy00W ywHvaqX7RTrCLaF5Zh5BbJ3unN4Wa3GUjpsLY5lntrJq4NASK0nO5QFJmc/mtp90089w=; 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=/yS4TQai2mzZtvrjq0fu4KjMgTwIXAkvxkVkytra4b0=; b=is372pGLF1KBwCXN4M+ggWvvu4 XIETdiB/B6tjOMLBYBmNSjwPNL6OROKMLiQeyC08Ktnaa6P5V7gA5TtEgB+PRxG09YQLAfoqptMjd /iQUr3I78QY30Gkjsall0MwljbT/8IQv90n3ke+QGvp4XoHQkd4G1V+IbZfsWbWqwAMs=; Received: from mail-tyzapc01on2054.outbound.protection.outlook.com ([40.107.117.54] helo=APC01-TYZ-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 1q8Xov-000MRd-UU for linux-f2fs-devel@lists.sourceforge.net; Mon, 12 Jun 2023 03:02:18 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=FLmwTGGpl49BfyipSvNrwDpR3gGXwt59AdCifewMscK5y1UyFFUoRTmJpmwp+XZPyrNP0lsTkFSloultFJAhlLwMxEQrP2BCuNHGLfLfhz0YNNF3X70ZVyI3OVp1gKj+5OFz2Q93ty5MZaet+oB5rSDmmSy4UgfLy+S3fFx4pLlvAJ3gMerH5xdAlqXeRIZ2TsG6rbiIKjsP+Lx+fRQI9F9RcDqjpyidhsvBSNHdOfVUYz2ucfV9fzekZ0BmOvsx/IcoLEjU0iffuK4IV5ibnd05mfMAvSmum18Xny/YTbmi0zVeHWqktjqJ0e9Vc7mz1p2S30hr9eXiSTm9XMPrsg== 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=/yS4TQai2mzZtvrjq0fu4KjMgTwIXAkvxkVkytra4b0=; b=UkECyUMLfE2QkY00RD7zoeEMpUX8xSY+KapO8x5+sfCHlSK4fvOhziSjRrQwUj/UPqpPNt20yUqZwjcjLu1U+hoKtIlDv1tjfjALEQVjsahRvfgWOI+hxx09z7NIb/2WjZZF9BWahiOWi0G5zjR9C0WeOrEjc/aB/SrEl8EzGfvG3Xw1KHIOuKQp3tXrSZeTQlMXygeTVlxsSNEOcMbvddiVjBxlPbgk+ZdnFNzOkhI9ZcGIdFsiZ1SQI+3/Ei0pDp5cIiPR/wDNfDtCbrI0fwoGvihrn1nMUOjNm5A9g2E9T8q7uu5gM8MhAKeOoUPTy7iygCiQJbqkcl0fCpee2g== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=oppo.com; dmarc=pass action=none header.from=oppo.com; dkim=pass header.d=oppo.com; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=oppo.com; s=selector1; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=/yS4TQai2mzZtvrjq0fu4KjMgTwIXAkvxkVkytra4b0=; b=qmP9AP7SXEWHt33zd2RMmiKPu3u1zaCOHLC8YI/EzjKT1cQ21AMEvO3Mvtkn/lkbuJjK/4Y5VBj8udGljH9gm1kQ/P68TvV70t+4DNDPMHOL2mexJP2Z5e9FQDGpMz/Zip0tL7kPgrZtz2J2SAwmso5jv8FV6aQ6Wnc+plZB1ro= Authentication-Results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=oppo.com; Received: from SI2PR02MB5148.apcprd02.prod.outlook.com (2603:1096:4:153::6) by KL1PR02MB6259.apcprd02.prod.outlook.com (2603:1096:820:dc::9) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6500.21; Mon, 12 Jun 2023 03:01:49 +0000 Received: from SI2PR02MB5148.apcprd02.prod.outlook.com ([fe80::6297:13a6:41f1:e471]) by SI2PR02MB5148.apcprd02.prod.outlook.com ([fe80::6297:13a6:41f1:e471%6]) with mapi id 15.20.6500.020; Mon, 12 Jun 2023 03:01:49 +0000 To: jaegeuk@kernel.org, chao@kernel.org Date: Mon, 12 Jun 2023 11:01:21 +0800 Message-Id: <20230612030121.2393541-7-shengyong@oppo.com> X-Mailer: git-send-email 2.40.1 In-Reply-To: <20230612030121.2393541-1-shengyong@oppo.com> References: <20230612030121.2393541-1-shengyong@oppo.com> X-ClientProxiedBy: SI1PR02CA0029.apcprd02.prod.outlook.com (2603:1096:4:1f4::20) To SI2PR02MB5148.apcprd02.prod.outlook.com (2603:1096:4:153::6) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: SI2PR02MB5148:EE_|KL1PR02MB6259:EE_ X-MS-Office365-Filtering-Correlation-Id: 1d5894b7-1d65-474b-2ac6-08db6af15da4 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: M8/ecebHq5MPLUCUQoYd1NhAdrcDHkYGdIohzcEq8bm6IlOdk5QSZqgfqtSlVybtuhUm9v+D6erQAGiAIFbqZkGCJs/6MKjf5bof1tE3ip8DqsTiJ7Joi3Jw6lBsbvbd9mp+iirV8RWWgRVuo3mJNctZtdk41SjihyOvvJvU8WyR+iNIyCGZ7sga7whAyQpOO/stA2hUyj+ZEP0gYCSQ/Nv+SvRPiFD3eQ8Km8PJTodxRq0p62F3R4pLmzAk5xozmZzVAETysIYzmasZwMNGTwpjCj1VHXQSsbphS6BQEVGLTSGxSahxVObICy8Fxm0sURtBpny9i1TBrAVF+Q08w6VzoYILVl79jjCz0zZhVjrRL10fZRUr0LcIVsIAXFL/ZwuH67xQoz0YgY0v9wCP+HGig6sxZFSeoGmHA/fUdEaShZySQX3nGuC+xfL93PeqrzROb8+5W8Nz1hxyQDG3UaMGVGIKEXtqvjIEPssuxAjvsGRDbeEBP6DBkepjn+HccKDqnbEKrg4HQ3AihSwlSpa+jcDYTODlE6f0K0jEbzA1cPv7xc+4Vztxj04KtPDGYOCD7LKpTmhdwYpToeouiAkgBIuHUYNPOTfV4ASqj0MlJSmifh7LMwudx7O/YSoI X-Forefront-Antispam-Report: CIP:255.255.255.255; CTRY:; LANG:en; SCL:1; SRV:; IPV:NLI; SFV:NSPM; H:SI2PR02MB5148.apcprd02.prod.outlook.com; PTR:; CAT:NONE; SFS:(13230028)(4636009)(346002)(39860400002)(366004)(376002)(396003)(136003)(451199021)(66476007)(66556008)(8936002)(5660300002)(8676002)(36756003)(66946007)(4326008)(478600001)(6666004)(41300700001)(52116002)(6486002)(316002)(38100700002)(38350700002)(6512007)(6506007)(1076003)(26005)(186003)(2906002)(107886003)(2616005)(86362001)(83380400001); DIR:OUT; SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: X0TLDxQrr1p/ubw59DbSKq5H9tUW+1s/V76bqxa9XDe1GR/Tt2UUEbnll4piOrony1q8PjFDXHC/JYKqBfVzfTjv+ZbGv/0UZmMUGrF6ajECmcoWy7jWVBrhIQB06EY/4/A3ecSHqY3KW9XU+CS6Swn/zQZ1foLo//BIzkLSgXEQswHyYDBtwov6BpLAw0G82HZOk6XgMSSHAwaVa0+C6lFffeiXb+vNVYN09pJwdwnA4BO9SHglS7AVIf7qcQkC2cFwD1+8R8PO6XfjZFI/xR5KqUlLdLyvs/gpZ11PCqQic5SyjnEsxh4+HkDXbwrWJe7juv/08jFhJpBgETdBOL7scKlgy0yPAhHn5u3MObnrfIcurT7puQfq/RBCeA/SlM5wS7XWhqi0dCFs9dO9mOkJe7rKddzSCTgb0x0IRsXqD0vKHS3RTqKIcwpPYVwp/CAhxf6bASwA8txwKwCOFBWgGrd5f68VS2a3cJoVW3OqDJL+Liwd5LAY8YjuzYxq48K3kJxOjVTgLyi0uoKBCcO48wQhcmgffI62JcF6amoK/gwYoBx6GCI0S1pY1KoNGQ2C7yaBWzi2ZMvr954Gg7ffaXco2VzhnlyNAbpQ2fO+OxU/PszKAP+6KTu1MCa9OA1niLzSCtkrGhzpvv/4IjJij/auVKcloXD+WC9JbmiJQ/9XPHeXq9Drst/qtdDoZeicEt2KxAjJzovX/9f7QxNbGnOuwxLn4jkpm91vjbtWqmcIdry+IVtwIj0I0baOoIkUZVfGtbkz0R3ikcdL2VkIYdTpbQDGb2wS0SmMS/JN9P1FCEET4/s+Dh3PpYYrKYueelnX1j7YpUDJXtuIGDD5Q8+K2rJsOjOAao1GjAYhaRH8rp2JDyIm0eeZW+ruqR2A7bqd7/pQRjCbxnKlaaQq+mNHh06H73IqKYc9ZHkj69T1/rPo2nMtpnhGsjY0BL7bb5lbfyCHm0RNuFh5g7GbjZCGxL9HV69+lBDU6bIj1zsg513ajVv5UgboGsne2cnOCj1vmIp1Klw4z2n1L6KPWtHhP0d+MnLftd/+LoADXE4bonIRu9jID5s8HTdzhXYEI7yrfq6+z6SUFbiTknP1HLvW8bO4uTJzhPd9ZifEcsXtprBgc+/+2IlMKjLSXAGQeXKEBDxKrPvDOO5FBGcNxrJ8sXRM2Ue7HyScFefkfvUEglW33q7F9nLEN6iSE2a2SRbbP4Y1floq2wmqcBt7AF8V1vix89QoFs8sudjgr07JAret1b8LgZpUpVyjr25e5yUFhc5aE1jjDZxeyiEBi9P509ZfIONrpCRazrGLHJl2jYUGhRDAwjjKI9R/eHNczdvbNhTg/sw+9a1e6mHt2//zzyEWf93TnEAyMtcM0EeN2+UKtyiWLFyhsT78i9LAmQm7UUeglGt2djZ9swxdUz1kwTZxllo7YucKP5GxqFq1bUSY0rA1wId/uOn6sEF42NxpuJ7h/iubCqNpWUxqhh+Ha/dH1eemroQNIHbnfeLeEUMiI0oZJ+Dfc4Fnxm9gfFYmMQWGBxxXS6nuTzSHaAcJuAT5/EyIQFN1ojTHc4aLQ8YZOsCsKxZGKRkJ X-OriginatorOrg: oppo.com X-MS-Exchange-CrossTenant-Network-Message-Id: 1d5894b7-1d65-474b-2ac6-08db6af15da4 X-MS-Exchange-CrossTenant-AuthSource: SI2PR02MB5148.apcprd02.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 12 Jun 2023 03:01:49.5210 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: f1905eb1-c353-41c5-9516-62b4a54b5ee6 X-MS-Exchange-CrossTenant-MailboxType: HOSTED X-MS-Exchange-CrossTenant-UserPrincipalName: xkCDMw/Kxm7Gv3qARvNt1PooHH40IsoI0SQ4sLeJcFas5P4GqNp9oId2n755kghwGoCsk496qeBH4ws1/PeGqA== X-MS-Exchange-Transport-CrossTenantHeadersStamped: KL1PR02MB6259 X-Headers-End: 1q8Xov-000MRd-UU Subject: [f2fs-dev] [PATCH v4 6/6] f2fs: access compression level and flags by extra attr ioctls 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: Sheng Yong via Linux-f2fs-devel From: Sheng Yong Reply-To: Sheng Yong Cc: ebiggers@kernel.org, linux-kernel@vger.kernel.org, linux-f2fs-devel@lists.sourceforge.net Errors-To: linux-f2fs-devel-bounces@lists.sourceforge.net Allow getting or setting compression level and flags through F2FS_IOC_GET_EXTRA_ATTR and F2FS_IOC_SET_EXTRA_ATTR. Signed-off-by: Sheng Yong --- fs/f2fs/file.c | 56 ++++++++++++++++++++++++++++++++------- include/uapi/linux/f2fs.h | 10 ++++++- 2 files changed, 55 insertions(+), 11 deletions(-) diff --git a/fs/f2fs/file.c b/fs/f2fs/file.c index 39d04f8f0bb6b..1ac73cd59db79 100644 --- a/fs/f2fs/file.c +++ b/fs/f2fs/file.c @@ -3916,10 +3916,14 @@ static int f2fs_sec_trim_file(struct file *filp, unsigned long arg) return ret; } -static int f2fs_ioc_get_compress_option(struct file *filp, unsigned long arg) +static int f2fs_get_compress_option_v2(struct file *filp, + unsigned long attr, __u16 *attr_size) { struct inode *inode = file_inode(filp); - struct f2fs_comp_option option; + struct f2fs_comp_option_v2 option; + + if (sizeof(option) < *attr_size) + *attr_size = sizeof(option); if (!f2fs_sb_has_compression(F2FS_I_SB(inode))) return -EOPNOTSUPP; @@ -3933,31 +3937,42 @@ static int f2fs_ioc_get_compress_option(struct file *filp, unsigned long arg) option.algorithm = F2FS_I(inode)->i_compress_algorithm; option.log_cluster_size = F2FS_I(inode)->i_log_cluster_size; + option.level = F2FS_I(inode)->i_compress_level; + option.flag = F2FS_I(inode)->i_compress_flag; inode_unlock_shared(inode); - if (copy_to_user((struct f2fs_comp_option __user *)arg, &option, - sizeof(option))) + if (copy_to_user((void __user *)attr, &option, *attr_size)) return -EFAULT; return 0; } -static int f2fs_ioc_set_compress_option(struct file *filp, unsigned long arg) +static int f2fs_ioc_get_compress_option(struct file *filp, unsigned long arg) +{ + __u16 size = sizeof(struct f2fs_comp_option); + + return f2fs_get_compress_option_v2(filp, arg, &size); +} + +static int f2fs_set_compress_option_v2(struct file *filp, + unsigned long attr, __u16 *attr_size) { struct inode *inode = file_inode(filp); struct f2fs_sb_info *sbi = F2FS_I_SB(inode); - struct f2fs_comp_option option; + struct f2fs_comp_option_v2 option; int ret = 0; + if (sizeof(option) < *attr_size) + *attr_size = sizeof(option); + if (!f2fs_sb_has_compression(sbi)) return -EOPNOTSUPP; if (!(filp->f_mode & FMODE_WRITE)) return -EBADF; - if (copy_from_user(&option, (struct f2fs_comp_option __user *)arg, - sizeof(option))) + if (copy_from_user(&option, (void __user *)attr, *attr_size)) return -EFAULT; if (!f2fs_compressed_file(inode) || @@ -3966,6 +3981,14 @@ static int f2fs_ioc_set_compress_option(struct file *filp, unsigned long arg) option.algorithm >= COMPRESS_MAX) return -EINVAL; + if (*attr_size == sizeof(struct f2fs_comp_option_v2)) { + if (!f2fs_is_compress_level_valid(option.algorithm, + option.level)) + return -EINVAL; + if (option.flag > BIT(COMPRESS_MAX_FLAG) - 1) + return -EINVAL; + } + file_start_write(filp); inode_lock(inode); @@ -3982,6 +4005,10 @@ static int f2fs_ioc_set_compress_option(struct file *filp, unsigned long arg) F2FS_I(inode)->i_compress_algorithm = option.algorithm; F2FS_I(inode)->i_log_cluster_size = option.log_cluster_size; F2FS_I(inode)->i_cluster_size = BIT(option.log_cluster_size); + if (*attr_size == sizeof(struct f2fs_comp_option_v2)) { + F2FS_I(inode)->i_compress_level = option.level; + F2FS_I(inode)->i_compress_flag = option.flag; + } f2fs_mark_inode_dirty_sync(inode, true); if (!f2fs_is_compress_backend_ready(inode)) @@ -3994,6 +4021,13 @@ static int f2fs_ioc_set_compress_option(struct file *filp, unsigned long arg) return ret; } +static int f2fs_ioc_set_compress_option(struct file *filp, unsigned long arg) +{ + __u16 size = sizeof(struct f2fs_comp_option); + + return f2fs_set_compress_option_v2(filp, arg, &size); +} + static int redirty_blocks(struct inode *inode, pgoff_t page_idx, int len) { DEFINE_READAHEAD(ractl, NULL, NULL, inode->i_mapping, page_idx); @@ -4277,7 +4311,8 @@ static int f2fs_ioc_get_extra_attr(struct file *filp, unsigned long arg) ret = f2fs_get_compress_blocks(inode, &attr.attr); break; case F2FS_EXTRA_ATTR_COMPR_OPTION: - ret = f2fs_ioc_get_compress_option(filp, attr.attr); + ret = f2fs_get_compress_option_v2(filp, attr.attr, + &attr.attr_size); break; default: return -EINVAL; @@ -4371,7 +4406,8 @@ static int f2fs_ioc_set_extra_attr(struct file *filp, unsigned long arg) f2fs_balance_fs(sbi, true); break; case F2FS_EXTRA_ATTR_COMPR_OPTION: - ret = f2fs_ioc_set_compress_option(filp, attr.attr); + ret = f2fs_set_compress_option_v2(filp, attr.attr, + &attr.attr_size); break; default: return -EINVAL; diff --git a/include/uapi/linux/f2fs.h b/include/uapi/linux/f2fs.h index 2b53e90421bfc..153a6395c5f35 100644 --- a/include/uapi/linux/f2fs.h +++ b/include/uapi/linux/f2fs.h @@ -100,6 +100,13 @@ struct f2fs_comp_option { __u8 log_cluster_size; }; +struct f2fs_comp_option_v2 { + __u8 algorithm; + __u8 log_cluster_size; + __u8 level; + __u8 flag; +}; + enum { F2FS_EXTRA_ATTR_TOTAL_SIZE, /* ro, size of extra attr area */ F2FS_EXTRA_ATTR_ISIZE, /* ro, i_extra_isize */ @@ -109,7 +116,8 @@ enum { F2FS_EXTRA_ATTR_CRTIME, /* ro, i_crtime, i_crtime_nsec */ F2FS_EXTRA_ATTR_COMPR_BLOCKS, /* ro, i_compr_blocks */ F2FS_EXTRA_ATTR_COMPR_OPTION, /* rw, i_compress_algorithm, - * i_log_cluster_size + * i_log_cluster_size, + * i_compress_flag */ F2FS_EXTRA_ATTR_MAX, };