From patchwork Thu Jan 12 13:35:03 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: 42431 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a5d:4e01:0:0:0:0:0 with SMTP id p1csp3883574wrt; Thu, 12 Jan 2023 05:37:55 -0800 (PST) X-Google-Smtp-Source: AMrXdXu1b6sXR+9FalXH0KYx8mSCFMkDlS8iWWnul03fE8cN4v12ud2ZnfHY1miaUCn5hoxvMDgn X-Received: by 2002:a17:907:7e9f:b0:7c1:7d81:d2a8 with SMTP id qb31-20020a1709077e9f00b007c17d81d2a8mr79399554ejc.3.1673530675588; Thu, 12 Jan 2023 05:37:55 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1673530675; cv=pass; d=google.com; s=arc-20160816; b=Gk5TIvUEVT+cMfS+rwZpt4sHr0WjMALgCuWKUzeHastfKck40pLTHJBBMp5q81ZNGn /HIpr1KAm7EaEcH4mqgXVjFVjtnZE2FtvyzpdB3KluGzIKDivdbbJ4BIothbIvNtF16q V5vfNhXKaFV/RfC4iPrnr2MN0O6QULys6Cpe4bveEwOFLwGmu5zrrs/9OClGNTR0MPCx 0r62wn+MwVyoSuU2kW7GOzM2lSkhHu3WcbnhZgQ/iHq2DNJqC5/2QQJThto4oD1xF4qf yhutzFr7SeT9Zknn69Fr0aeaxkjKJaLLwwKKsDbNuXQ28XdGLYzodC+7C4DgAAy9ZuIy uLOQ== 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=jBoxDRRiNObZbWquwZAPXj1shSi9v5yIgx0Kejvjy5o=; b=Sg18/tIHP7NnZ/d0POZGOT4417tgPCHF0HX3i5oEsPZv9Rx27gQzfxkf9du9KiXPPQ xq80b4DXnRNMT9aztbZm38D1jHehx5/0071rPpMHLu2HLcZOmjl6dKbJmLAvDEBRAncX YQnau+cVePNWfEkhHSWlzXW02n2J8WhjyUT8bVHCSs53Kq1rfmnzTNtIeV8TPZ6rwSww mgLdXXV3ilBvNLH9x5gBmM6o3RqTf2Laico3PZwQ8zKt/obrV/Wz/0p3aa9CCdZ4+oTQ w+PnloNLxOe+Hc9tb5r8lceL0EgMjbkbzDzidpbVkuyknMc1Y6klQKONF/9kErti9Xfr xeBQ== ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@vivo.com header.s=selector2 header.b=QfNubbFm; 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 xh9-20020a170906da8900b008552e7765afsi8898585ejb.936.2023.01.12.05.37.32; Thu, 12 Jan 2023 05:37:55 -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=QfNubbFm; 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 S232334AbjALNf0 (ORCPT + 99 others); Thu, 12 Jan 2023 08:35:26 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:38256 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232317AbjALNfW (ORCPT ); Thu, 12 Jan 2023 08:35:22 -0500 Received: from APC01-TYZ-obe.outbound.protection.outlook.com (mail-tyzapc01on2106.outbound.protection.outlook.com [40.107.117.106]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 0B52E3FCBD for ; Thu, 12 Jan 2023 05:35:16 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=E3Iq50GI18yGgwoz6GfM87dLA9qaV63zc/BGCFQtgEatK7OP/zUzNYKjxRzU9nCTyx13tx3LBEyDr8pzyDgAYZ543LZtFdIVFB87ZiK/NgnaAYd3DJGrZDcyO9ZInddJaEWVZi2wNNbR7J7+BIG8Zv492PDoe8YDZK7nyHjtDaIkaB/HHSD+KfoTuErVsSO0E1yZDpnzCtyb24euWORRiCk4o5EhAm2DUbV1mRB4vNG89QouDQKXySX4bhzahNimrbWXjx7iVIU1bk9OPhrd0SsGYjkNrXx5KY2/ijhNd8TQI9U1q4K+GATX1rZywY+539NrlacWXeIz6QD2/dKKhQ== 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=jBoxDRRiNObZbWquwZAPXj1shSi9v5yIgx0Kejvjy5o=; b=KIArNDbQbtm7bV6dCMnVCK4wpgvsQl22Moij9BfSIIU2yaOTNVs01Vgp2gEIzwA/akBD3IcTjv9SUl1waepz7YygvgqLGuXDLPt164VhHIw8Y2qIxiekUwiCHkx8Cx1isXVChC9HtB+eYGGkvB5US2USiDjGNtvyRq+Pwj9MP8KyBcI2AbZ2IGvRYe/OJ/p+DH6yQRplEZJMW1XN6CISq91oewQTkB03XabClHOzbgm0Qx4WIGwG2cewM0jhAMFtEuflmTzmoCRg/+rrNbHzeOVhmbgkyd3kUURWycl0x+4X5KyCG7qcCqtGvgoMO6eP5pB+bcphSErJD+Q6xx3YnQ== 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=jBoxDRRiNObZbWquwZAPXj1shSi9v5yIgx0Kejvjy5o=; b=QfNubbFm7B7WmH3LlF+SVHPIDJ4oocLQvy4Jfmm3KVPJcv4C6o97eLMA9Ouw+I8+POcOn9M98w1sD4V4pNqE7Jt5FGlQtZ4aLBuN92ErLk1p0HBL8ZV5cDnVd+6H9foZ/sP2lp94jLWEklAlPYFxTYZTLlSkh3V3ybbsrN3ssfmdz6puVs6SEGS2KRIll9aVgy7W3hwJijZro6WxuRnzDbnLQi7b6WgrrTNgSmi3F68v9JgUevAiwl8370uMflNSvPBZQkLF7PJxwOLZAoP3iVV0MVDrPz+pchOyT7qKK6yifQUJ8B1AeAkpz0fV6P8rGLxG8Im8S597N5bTskPIQQ== 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:35: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:35: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 2/3] f2fs: add F2FS_IOC_SET_COMPRESS_OPTION_V2 ioctl Date: Thu, 12 Jan 2023 21:35:03 +0800 Message-Id: <20230112133503.16802-1-frank.li@vivo.com> X-Mailer: git-send-email 2.35.1 X-ClientProxiedBy: SI1PR02CA0058.apcprd02.prod.outlook.com (2603:1096:4:1f5::9) 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: e8d41b34-1742-4662-3eac-08daf4a1d5cd X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: 2k5miotvS21Xl5q9r4k+qbmfJpqefDDYs0CFnUk6W2rDJL0EZesZUxh4QIgmcoCfeZxZmkoPY6RZNb6wS8QRiLXnmzVAiKnRRD2F1garY4Zoa4Dp8qnhJqO8kZ6xiPqRp1G1X60KkfzvkMMPg2VTW/TekoBsjh0S8EgS/Ah6nct68gACs2Cw5JOQXPgpLlXu9Eugl/vMyOCrtMOY6NDTXPdaOd9/2mQhGpE+DtEpsvF3E/jYHtgz9fbUlx8VFVmZN4MezZuphPB37LKlgpfpEI9JHygq3gVSyQ9hW2az8QezEqCtdJUGQE7T16WxUNYrqZKID/P8t1aDcsZcqb9bDEW4pNwVRIKxpFct4MaZgCa9wZ7/u8DcgXIgG/s5Qawik+2rpIazKmSlQf5uwof3mp9LvTijU+NFByaFvcKkRQhw0McGpOYbFvZb3HMFJPgZby1bxvZIOKD+RU8MOMu2zfSmSivCIvzXhOt4da3qWQvDDmMGv/p7TX0ANWrclEIz9IJLIdVy5vdZpUjxH7bztR43j0CA6yiFMPNndAB9YdgEhYMFQ4hXX40tOrVJn8Y/Q30Y6HAJtK3KgDWUNMGyZN/FuglnTNV3ZzR1geuS0m70JPrHkJFZBfcOvfwJhzDtrpA5FA4P+2HN8PwCDuv10DCgpNuXUavjs4OqpFtXP724jw5WmtrH/xDb9871UdYxX3MM/yLkc0mk8KSeQIFqxw== 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: M1CCMffZIu7xzE7e+NmZk246+cez6X+JwPCbSPo8174KC0tguti6FX3YX/7WkVFbDXweeodwDobrJIjyGty+zvepq3rywpIBfWRCg52OgyZgjQenrOQibOLQeHdSc5pWaxj7tkrQRhLo+VDpKCrOG5Zp3LcN+vySy92C2UG06AphO1BsChNDmSF9o2iqtUGNoSKegTMcBjK5Iw7Wxlmamf2DZoEfeqNm3tKDbyey1PZQL8hl78fIypOQSibQX3e+ddtH58CNmg6CtybepjofPdShN+HAx1Mwc3z2azmJMvPGkDmlxOHnS2zYDoakJ/Evs9SqdAx2CWtcUWHoLMMhBRjwJEaOfZLjY6aXX+SegOqekUU7+2sHdjRfC7YcDoQY5jPjNRmDYajM7Q+n7hXWqZUNbZiP+YSiIpqPKxbo246FI0LqVS/x1JvPf7SiN8P9NSLz5QFZ4SNE8mmNFuac0CAl0s5pkAkvPJP58ey0rwFfX5ZVnbXVO9czPP9FxGOhuLpDlqYNdbXr4Omso6O2V4LBharEMhq+JuTVyFFWd2I2Cns9S+GS8oINAgsapDq91aKdzBG1K/RROksj7Gu9hEukTtRjfcBtLmT8mzxDMT/PSDcZeBvWEMoJ9Y5ZGdAvoiJC9appK5UboOVsHcozW7/90St1WgfS3pjTkwmGBTDARXFUEe+C7RXx0AslsSVUNu69AqIYFRkr1nl3l99/3ZaS2gmL4EskBxRvg3HNllWGCxR0LhzgWiZxsdTwo+zPszUn6ZUjpCRxS588nc6M3anGdDUpGrswR2GYkec6rHLVtcXeg1D1vBqoLDFLKrGQkDutNlrnzhNCNDKNj3jaEDsdto/racLC06d6kzMnBVZ8xBoGFP0mmYmT2Hbly5/gOr5e4PrCuE0QesQV8RSmC5sLmRYUgA6F/Drr5nqjEItUQV3sTMG0CJKn63lkYjvejEwz7L6QPMn075XN4rD2wtZcgQ6wPQoTaWRW6JjjWZOA9m8ZZe9RDPrSeM6JdyDcab+ys7v9Nx1oSZNSynmI3Jj1Gs+O8akqppcMvfRC20ePZDHwbrQF02YNMdBniqVqG/lccOdDr83C3DGIFWjYnVsgvaIPnKMG9Wgii1W4lEMO72mdjw+8FFbC3ntJaA1CQaVk1T2z2B/TraIw0DuRbIZPGYA2W4pnPTB5U+r1vmGoNPTwyPPQFmQPlrY3kpnVv9CstErPTZo1pMEBmTGdVFIOtcB30fV+8KbZGBVzPuhzCWeWsAHx0bAfgc9gvceprqrsCabuJ7ZQaL9Em9DXFmVDmd2YvJTcLSjHE2Z+RYrG1ttzQOyycUC3WX5UxgWKxZcFhU1jX3c8Zt0bEXvnDGdlaVgviUuKhpzKQA8ogw9rXiE6Ib4FMTlnTCdpItqisJyrdXUIelEVLdTFguwz1p73MrkBA9P0vnEalmS9jCTnwBtUlBT7oJVNrvOV6zu2bFBh37jIDHNj+GCYgDywf+0NOOB7VCyFfq1JYjY6BNG8anLSQCkf32ABytFPxJHyPFW80cciQRdi8oSl1V8BuT9Bw9TNgQ8Ns9fPVVZ+GurlpnEQCGc0W5mcveTWrZyj X-OriginatorOrg: vivo.com X-MS-Exchange-CrossTenant-Network-Message-Id: e8d41b34-1742-4662-3eac-08daf4a1d5cd 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:35:14.1506 (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: 67czQ1ZJxQ0zSlTLiI9e8XT7ukO1dDL+OeJ9Bi8W41KCXnUvThnx676ggvMP7QG9ukEIk704o7/fH5pP2D6xUg== 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?1754824101519841753?= X-GMAIL-MSGID: =?utf-8?q?1754824101519841753?= Added a new F2FS_IOC_SET_COMPRESS_OPTION_V2 ioctl to change 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; option.algorithm = 2; option.log_cluster_size = 2; option.compress_flag = (5 << COMPRESS_LEVEL_OFFSET) | BIT(COMPRESS_CHKSUM); ioctl(fd, F2FS_IOC_SET_COMPRESS_OPTION_V2, &option); Signed-off-by: Yangtao Li --- fs/f2fs/f2fs.h | 8 +------- fs/f2fs/file.c | 41 ++++++++++++++++++++++++++++++++------- include/uapi/linux/f2fs.h | 21 ++++++++++++++++++++ 3 files changed, 56 insertions(+), 14 deletions(-) diff --git a/fs/f2fs/f2fs.h b/fs/f2fs/f2fs.h index f3c5f7740c1a..c2267f44bcf8 100644 --- a/fs/f2fs/f2fs.h +++ b/fs/f2fs/f2fs.h @@ -25,6 +25,7 @@ #include #include #include +#include #include #include @@ -1501,11 +1502,6 @@ enum compress_algorithm_type { COMPRESS_MAX, }; -enum compress_flag { - COMPRESS_CHKSUM, - COMPRESS_MAX_FLAG, -}; - #define COMPRESS_WATERMARK 20 #define COMPRESS_PERCENT 20 @@ -1521,8 +1517,6 @@ struct compress_data { #define F2FS_COMPRESSED_PAGE_MAGIC 0xF5F2C000 -#define COMPRESS_LEVEL_OFFSET 8 - /* compress context */ struct compress_ctx { struct inode *inode; /* inode the context belong to */ diff --git a/fs/f2fs/file.c b/fs/f2fs/file.c index f5c1b7814954..719706ef0d46 100644 --- a/fs/f2fs/file.c +++ b/fs/f2fs/file.c @@ -25,6 +25,8 @@ #include #include #include +#include +#include #include "f2fs.h" #include "node.h" @@ -3910,12 +3912,13 @@ static int f2fs_ioc_get_compress_option(struct file *filp, unsigned long arg) return 0; } -static int f2fs_ioc_set_compress_option(struct file *filp, unsigned long arg) +static int f2fs_ioc_set_compress_option(struct file *filp, unsigned long arg, + unsigned int cmd) { struct inode *inode = file_inode(filp); struct f2fs_sb_info *sbi = F2FS_I_SB(inode); - struct f2fs_comp_option option; - int ret = 0; + struct f2fs_comp_option_v2 option; + int ret = 0, len; if (!f2fs_sb_has_compression(sbi)) return -EOPNOTSUPP; @@ -3923,8 +3926,12 @@ static int f2fs_ioc_set_compress_option(struct file *filp, unsigned long arg) if (!(filp->f_mode & FMODE_WRITE)) return -EBADF; - if (copy_from_user(&option, (struct f2fs_comp_option __user *)arg, - sizeof(option))) + if (cmd == F2FS_IOC_SET_COMPRESS_OPTION_V2) + len = sizeof(struct f2fs_comp_option_v2); + else + len = sizeof(struct f2fs_comp_option); + + if (copy_from_user(&option, (void __user *)arg, len)) return -EFAULT; if (!f2fs_compressed_file(inode) || @@ -3933,6 +3940,21 @@ static int f2fs_ioc_set_compress_option(struct file *filp, unsigned long arg) option.algorithm >= COMPRESS_MAX) return -EINVAL; + if (cmd == F2FS_IOC_SET_COMPRESS_OPTION_V2) { + unsigned int level = GET_COMPRESS_LEVEL(option.compress_flag); + + switch (option.algorithm) { + case COMPRESS_LZ4: + if (level < LZ4HC_MIN_CLEVEL || level > LZ4HC_MAX_CLEVEL) + return -EINVAL; + break; + case COMPRESS_ZSTD: + if (!level || level > zstd_max_clevel()) + return -EINVAL; + break; + } + } + file_start_write(filp); inode_lock(inode); @@ -3948,7 +3970,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 = 1 << option.log_cluster_size; + F2FS_I(inode)->i_cluster_size = BIT(option.log_cluster_size); + + if (cmd == F2FS_IOC_SET_COMPRESS_OPTION_V2) + F2FS_I(inode)->i_compress_flag = option.compress_flag & COMPRESS_OPTION_MASK; f2fs_mark_inode_dirty_sync(inode, true); if (!f2fs_is_compress_backend_ready(inode)) @@ -4221,7 +4246,9 @@ static long __f2fs_ioctl(struct file *filp, unsigned int cmd, unsigned long arg) case F2FS_IOC_GET_COMPRESS_OPTION: return f2fs_ioc_get_compress_option(filp, arg); case F2FS_IOC_SET_COMPRESS_OPTION: - return f2fs_ioc_set_compress_option(filp, arg); + return f2fs_ioc_set_compress_option(filp, arg, F2FS_IOC_SET_COMPRESS_OPTION); + case F2FS_IOC_SET_COMPRESS_OPTION_V2: + return f2fs_ioc_set_compress_option(filp, arg, F2FS_IOC_SET_COMPRESS_OPTION_V2); case F2FS_IOC_DECOMPRESS_FILE: return f2fs_ioc_decompress_file(filp, arg); case F2FS_IOC_COMPRESS_FILE: diff --git a/include/uapi/linux/f2fs.h b/include/uapi/linux/f2fs.h index 955d440be104..aaf7f55273fb 100644 --- a/include/uapi/linux/f2fs.h +++ b/include/uapi/linux/f2fs.h @@ -43,6 +43,8 @@ #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_SET_COMPRESS_OPTION_V2 _IOW(F2FS_IOCTL_MAGIC, 26, \ + struct f2fs_comp_option_v2) /* * should be same as XFS_IOC_GOINGDOWN. @@ -62,6 +64,15 @@ #define F2FS_TRIM_FILE_ZEROOUT 0x2 /* zero out */ #define F2FS_TRIM_FILE_MASK 0x3 +/* + * Flags used by F2FS_IOC_SET_COMPRESS_OPTION_V2 + */ +#define COMPRESS_CHKSUM 0x0 /* enable chksum for compress file */ +#define COMPRESS_LEVEL_OFFSET 8 +#define COMPRESS_LEVEL_MASK GENMASK(15, COMPRESS_LEVEL_OFFSET) +#define COMPRESS_OPTION_MASK (COMPRESS_LEVEL_MASK | BIT(COMPRESS_CHKSUM)) +#define GET_COMPRESS_LEVEL(x) (((x) & COMPRESS_LEVEL_MASK) >> COMPRESS_LEVEL_OFFSET) + struct f2fs_gc_range { __u32 sync; __u64 start; @@ -96,4 +107,14 @@ struct f2fs_comp_option { __u8 log_cluster_size; }; +struct f2fs_comp_option_v2 { + union { + struct { + __u8 algorithm; + __u8 log_cluster_size; + __u16 compress_flag; + }; + struct f2fs_comp_option option; + }; +}; #endif /* _UAPI_LINUX_F2FS_H */