From patchwork Thu Jan 12 13:36:05 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: =?utf-8?b?5p2O5oms6Z+s?= X-Patchwork-Id: 42432 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a5d:4e01:0:0:0:0:0 with SMTP id p1csp3883885wrt; Thu, 12 Jan 2023 05:38:33 -0800 (PST) X-Google-Smtp-Source: AMrXdXv8xLscFOYe8+qzFJtuZb2AXxEmHw56TTsV/3MEz03u8QhEoOCGubeD4vv5nHnBqltahIaq X-Received: by 2002:a17:906:9f0a:b0:7ad:88f8:7663 with SMTP id fy10-20020a1709069f0a00b007ad88f87663mr86825592ejc.43.1673530713669; Thu, 12 Jan 2023 05:38:33 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1673530713; cv=pass; d=google.com; s=arc-20160816; b=LT5BJWBByuuPbq5j2eAey2MFl1d04mW+5JcnSNaffeB0NK2phBLolP58FDUvh7CDnV /Z4xnGuS9cUcxwRkC+e8nFxwDYnhFrtlEUj3Ixxep4g3GAttpjPwnjBYA/pYtctO5Z45 4+zShwPPz7vtxfzyE9Fhtrtr8mdtS+SwW85OatI8D4/cTSxCn7rtGst7jPhT7wuHdlBs VCZsNJkVll/DSwBfgwe0f1V+s8AQZZ2aD3q4iRBV6kNwd752brrYVGK4r6XvoKI6YY6B SKnzKefzC9FqjpK6WA/RsXoURtwVQi8aQrdZGMQdJzOTLt6e2z2x1IKw7qWgwaMD7RJg 5gEg== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:mime-version:content-transfer-encoding :message-id:date:subject:cc:to:from:dkim-signature; bh=duWOs/Ix8uyKICEfM8mPMrrqsEq4KNTHqbffA8TiPWs=; b=O2Fay0DoQ5OK9ALDI5Pd4Cz5aUeIaQfs+FiwOAu+dps0NKVSWVM3zSzMqpApdmnF0T NrCnk73/T6riGl3fPxMxxSxLWqLkG7y6CwVzyOzTpDj8bsLnJHMQqO+Y1Kkn13r2xiCB kN3C5HVaaORvmUu6r75sce3G78SP9ugoN6jzlZvswMTU0T/QyLKCnWCoYC7pY47U6SbU UX6a34buE8GBeJ9LBUYcE23UXX0Rorcv5/iuA8BH6OBkd3hAAJPByD0HMYFAR20dcnWI QmKoO9YWkzV+7BX7rp1164BN7+o9uyhkqX8VkNYpUrpyRT79qXGT2O/VQs43SYMSOIf7 a1Zg== ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@vivo.com header.s=selector2 header.b=S0YwLyDR; 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 du1-20020a17090772c100b0080f0493b9c8si19689277ejc.536.2023.01.12.05.38.09; Thu, 12 Jan 2023 05:38:33 -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=S0YwLyDR; 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 S229920AbjALNg2 (ORCPT + 99 others); Thu, 12 Jan 2023 08:36:28 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:39220 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232875AbjALNgS (ORCPT ); Thu, 12 Jan 2023 08:36:18 -0500 Received: from APC01-TYZ-obe.outbound.protection.outlook.com (mail-tyzapc01on2133.outbound.protection.outlook.com [40.107.117.133]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 7299C4731B for ; Thu, 12 Jan 2023 05:36:16 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=D0McbLsk0V25JRAbNBRRoWEI+7HoK0HVi/rcrweNfWQQ96CuS6+qx5uoCqvbH7dHzdxV1tAHkDUyvp8a/jUsyOC/BjqvUePuUUxsxAol2CppMBL9L0poIU9jUxqgDBmxfvxyahDqUTCyd+E1p7BKUuIf1CnL/oUWxFwDJ3QklED0IcAaftERBxQUtDOLkWt1rsttteW5QOCvEeRdFFnOsIT5tTe9OPeotIrawWtpo6sTKTxS71J8wJmo9aJDCvZfD37/dM3MSaZgbCgItanQA/sN/CVQih/GtalVrD5hddCFgAaQepBILiDe0CqRbpKclPFNIDgCKjKoQgBqr3e4Mw== 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=duWOs/Ix8uyKICEfM8mPMrrqsEq4KNTHqbffA8TiPWs=; b=j6eQqI4G8nCC3aKr6yC4JfMzIh2o4wEklo1+Cod64jVk3vdV6RBa6bq95ZoznRXA0KDsWn9SFA4UgkGc7RaqAq/uOUivQq5qr/3mO8NZ8GSwkGyGtcwAEtygmjqlaWLWtVOdIVazJDbuClB049vnWNLWYxA0c38gSJaYsVPPsIpXBuN0FZVfjrjW/TJ0a+4o0RBFBGRAFOPrfOp6OGZ/fRF6ICunuzaQKK2DbFntyu0Q3vbG0Te8SZrZPDslxii4L8uKh+ddDprwuFiSgHASJmwvM91Wm7+EizLE2NDacQ35SVTj2QbCKBFAqdFQ+b7UqGjpOx5f9PS6d5OkPVMcbQ== 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=duWOs/Ix8uyKICEfM8mPMrrqsEq4KNTHqbffA8TiPWs=; b=S0YwLyDRmeAy6DG/RJnPbp2vsaMt/Pz15HF9zifFm4Lnp5b6u9AugCWcG/GURxN5tYPpZVG0zQ6qi+ZGSC5rehpmFDiEQkOG2Xuv5gKLqW8z/hMDZHuguPhAOVV3R+HNrcIVnFtmSttD8FxQFWN19HvDmZ9pu1rer3esyHJ8bkyUtFmQ5YymKiaLxCq0fmgFW0YWbD7I76sGnTkjpfRvF0fnVUxhq1cO3O8WfrNPrbRKkrRWXC0efKfvshxcXStveZwuKIF77HfeIqEkX4reWoVWCdjs8gUMx4pljzG2G6nKsqk397QrZvJzAcFVzOZSwp3+pfDsI975qi9z2y4x0A== 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 SEZPR06MB5072.apcprd06.prod.outlook.com (2603:1096:101:38::5) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5944.19; Thu, 12 Jan 2023 13:36:14 +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; Thu, 12 Jan 2023 13:36:14 +0000 From: Yangtao Li To: jaegeuk@kernel.org, chao@kernel.org Cc: linux-f2fs-devel@lists.sourceforge.net, linux-kernel@vger.kernel.org, Yangtao Li Subject: [PATCH 3/3] f2fs: add F2FS_IOC_GET_COMPRESS_OPTION_V2 ioctl Date: Thu, 12 Jan 2023 21:36:05 +0800 Message-Id: <20230112133605.16957-1-frank.li@vivo.com> X-Mailer: git-send-email 2.35.1 X-ClientProxiedBy: SG3P274CA0010.SGPP274.PROD.OUTLOOK.COM (2603:1096:4:be::22) To SEZPR06MB5269.apcprd06.prod.outlook.com (2603:1096:101:78::6) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: SEZPR06MB5269:EE_|SEZPR06MB5072:EE_ X-MS-Office365-Filtering-Correlation-Id: 070f66d2-1999-47ad-0611-08daf4a1f9bc X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: WtDrrmbeiBq+B1MUGmC453aWbyEvC2WSH9p2205Y8/QFPNgS94IS03IRav448bkDgxk4KTNCvSczVxCmyh54PYiwuzLNPis0Us73RbQonEChr66btgVvi0VhnW0SX5bbgQqmAF7y3qGLQ/1ks858FjejaZNZLqaBkZ3e2w738/AZKp2h3FbDonMUKzchBq0z9N9yzUsPJvLRMvyb/BsPSY/6WVcon6/ZW3hiCSerWKS450NW9iUXwDcFwgk2QTH4iyFSsTMLSgVXenLvrD83tfnPhYiTNeza8szx4ho0Alq6yxRDGD5KulWh135djGxdySYHxSjmb4swsGX0jlolA5HCtkxoml6JzkNPiD5iVba94a0udPrn0m3VpSiRtc0OrQN24OZPA1on7TNYW/LahTwgf5REj1s4CPInJKdWnSr2Kbg0iikwnN+mQObQX5B7KeCLqb/UnqD9Sx6ZjfWb3aa3aaiUE+DLNuyHWJkGy8LtvMNVtETYVeqhBqpQG1Heq26SfGMxSaWnIkgsSXk11CFHc7D9eN0TAfCjbCs4Y2m9jBXHdJFOWoHxav2BSE3uHwOKeW4gqBxbIntIhm9SJYL4eQh0DeHEpncVTiHiBByOP3P7tmpbLqYuQCgm1ewvj7GjYTTgzWBkjRuvwmI/kW380ofyIEhqUXtfE4zm4aJW5OqzzSKDwhvyn9mkCLmUQ4yoQhlMv1X0F7JheIfojA== X-Forefront-Antispam-Report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:SEZPR06MB5269.apcprd06.prod.outlook.com;PTR:;CAT:NONE;SFS:(13230022)(4636009)(396003)(136003)(366004)(376002)(346002)(39860400002)(451199015)(107886003)(6666004)(478600001)(6506007)(6486002)(86362001)(2616005)(38100700002)(6512007)(186003)(52116002)(38350700002)(36756003)(83380400001)(26005)(1076003)(66946007)(8676002)(8936002)(66476007)(4326008)(66556008)(5660300002)(316002)(41300700001)(2906002);DIR:OUT;SFP:1102; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: dszGwjnXolIu0pMWhQj6Byf5Gs2ieG1lq0bHTGovf0/5S2RkwKYhrO4B9LiCcMRUlsF1NY5zolNLwlb9i3TCDp8dgi2lxsKCk89khVR799/iybiVj3f4jrt5PbZ/JpMKf0aWyQ+V6D7NXebtVnldFNREMxMOmoo1e3zyY4hdn3ztTXSQ8XcoFPwc6EI4nNvZ7uWpO1zItxQkpaGSKo2Mi1hXSeHsYX9GyzGBV4X36gmJAc4ugfW9B+vIaQiTOKYRYGzCpFwhhiz6xMyFmcYtPiIkXJEV4MC84QVUIJnDAL7O6k8beueCMzIlXFVeMSoKVeMovFwWEKEZnIF5kmqf5OW9huUGIekCCB9YwI6N3gXrqaGrRlCcDCmksdH59vK/wD9i4tAeZEZIp33Fnzped8e8/Ag2Ng+6vr6OZkY6Dvxsln12eD++adJR1mAgBXC93d50eJdfU3ycBoa+rIU3N/lVkOtRqIU2HCZu+/ruopxMUSf9PIeiY2nAabio/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/ X-OriginatorOrg: vivo.com X-MS-Exchange-CrossTenant-Network-Message-Id: 070f66d2-1999-47ad-0611-08daf4a1f9bc X-MS-Exchange-CrossTenant-AuthSource: SEZPR06MB5269.apcprd06.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 12 Jan 2023 13:36:14.4369 (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: 298oVOnn+GbBYEzm0vxpM1WIGjL1O4hhQMB6cMqN9tni2LrnmnuFn0fVbs3bFZ05U9mtTB4ZOZRnIseGPDZKaw== X-MS-Exchange-Transport-CrossTenantHeadersStamped: SEZPR06MB5072 X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_NONE, RCVD_IN_MSPIKE_H2,SPF_HELO_PASS,SPF_PASS autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1754824142054586157?= X-GMAIL-MSGID: =?utf-8?q?1754824142054586157?= Added a new F2FS_IOC_GET_COMPRESS_OPTION_V2 ioctl to get file compression option of a file. struct f2fs_comp_option_v2 { union { struct { __u8 algorithm; __u8 log_cluster_size; __u16 compress_flag; }; struct f2fs_comp_option option; }; }; struct f2fs_comp_option_v2 option; ioctl(fd, F2FS_IOC_GET_COMPRESS_OPTION_V2, &option); printf("compression algorithm:%u\n", option.algorithm); printf("compression cluster log size:%u\n", option.log_cluster_size); printf("compress level:%u\n", GET_COMPRESS_LEVEL(option.compress_flag)); printf("compress chksum:%s\n", (BIT(COMPRESS_CHKSUM) & option.compress_flag) ? "true" : "false"); Signed-off-by: Yangtao Li --- fs/f2fs/file.c | 20 +++++++++++++++----- include/uapi/linux/f2fs.h | 4 +++- 2 files changed, 18 insertions(+), 6 deletions(-) diff --git a/fs/f2fs/file.c b/fs/f2fs/file.c index 719706ef0d46..e011fb50ccc3 100644 --- a/fs/f2fs/file.c +++ b/fs/f2fs/file.c @@ -3885,10 +3885,12 @@ 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_ioc_get_compress_option(struct file *filp, unsigned long arg, + unsigned int cmd) { struct inode *inode = file_inode(filp); - struct f2fs_comp_option option; + struct f2fs_comp_option_v2 option; + int len; if (!f2fs_sb_has_compression(F2FS_I_SB(inode))) return -EOPNOTSUPP; @@ -3902,11 +3904,17 @@ 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; + if (cmd == F2FS_IOC_GET_COMPRESS_OPTION_V2) + option.compress_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 (cmd == F2FS_IOC_GET_COMPRESS_OPTION_V2) + len = sizeof(struct f2fs_comp_option_v2); + else + len = sizeof(struct f2fs_comp_option); + + if (copy_to_user((void __user *)arg, &option, len)) return -EFAULT; return 0; @@ -4244,7 +4252,9 @@ static long __f2fs_ioctl(struct file *filp, unsigned int cmd, unsigned long arg) case F2FS_IOC_SEC_TRIM_FILE: return f2fs_sec_trim_file(filp, arg); case F2FS_IOC_GET_COMPRESS_OPTION: - return f2fs_ioc_get_compress_option(filp, arg); + return f2fs_ioc_get_compress_option(filp, arg, F2FS_IOC_GET_COMPRESS_OPTION); + case F2FS_IOC_GET_COMPRESS_OPTION_V2: + return f2fs_ioc_get_compress_option(filp, arg, F2FS_IOC_GET_COMPRESS_OPTION_V2); case F2FS_IOC_SET_COMPRESS_OPTION: return f2fs_ioc_set_compress_option(filp, arg, F2FS_IOC_SET_COMPRESS_OPTION); case F2FS_IOC_SET_COMPRESS_OPTION_V2: diff --git a/include/uapi/linux/f2fs.h b/include/uapi/linux/f2fs.h index aaf7f55273fb..b42f6b322b8b 100644 --- a/include/uapi/linux/f2fs.h +++ b/include/uapi/linux/f2fs.h @@ -45,6 +45,8 @@ #define F2FS_IOC_START_ATOMIC_REPLACE _IO(F2FS_IOCTL_MAGIC, 25) #define F2FS_IOC_SET_COMPRESS_OPTION_V2 _IOW(F2FS_IOCTL_MAGIC, 26, \ struct f2fs_comp_option_v2) +#define F2FS_IOC_GET_COMPRESS_OPTION_V2 _IOW(F2FS_IOCTL_MAGIC, 27, \ + struct f2fs_comp_option_v2) /* * should be same as XFS_IOC_GOINGDOWN. @@ -65,7 +67,7 @@ #define F2FS_TRIM_FILE_MASK 0x3 /* - * Flags used by F2FS_IOC_SET_COMPRESS_OPTION_V2 + * Flags used by F2FS_IOC_SET_COMPRESS_OPTION_V2 and F2FS_IOC_GET_COMPRESS_OPTION */ #define COMPRESS_CHKSUM 0x0 /* enable chksum for compress file */ #define COMPRESS_LEVEL_OFFSET 8