From patchwork Sat May 6 11:45:37 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Yangtao Li X-Patchwork-Id: 13233494 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 9336CC77B75 for ; Sat, 6 May 2023 11:46:02 +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 1pvGMT-00060v-Pz; Sat, 06 May 2023 11:46:01 +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 1pvGMT-00060k-AE for linux-f2fs-devel@lists.sourceforge.net; Sat, 06 May 2023 11:46:01 +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=VHPxFq/y6r98ls3ZbcSubmnR7k0Xqe92iYu7z7UGGSs=; b=C3/viVaKmIFOACobGckfvmE3wU HnpSGeeP6XxWVmtK1AcI8JIEVOaxjqfgysgtToVaI8Fh/4FhbryRJndwaLmY40n6QKSr43+O5qiUI jT0aZ3fRaD13+kEsRrOlj5dQipYHRoTyLCxEsjSYfy25cgu69Wv5CePIoblfZY/SzCQE=; 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=VHPxFq/y6r98ls3ZbcSubmnR7k0Xqe92iYu7z7UGGSs=; b=cazyuU+Q8YQybQvbVWamknlVd6 ZFJamoxhwWLaXoDLXmQBG8D28DOsBPjDYbE+osewZ7s4ewrWW2n9WM6ryuXvb3IgjYJiusTAY1FH+ JWLpBP4uc4nZvGJfepxx8nyhAFMZ10XEDcYXq9ThdMSa92SDRHtsbRqktI3ZsYjHOVKc=; Received: from mail-sgaapc01on2118.outbound.protection.outlook.com ([40.107.215.118] helo=APC01-SG2-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 1pvGMR-0005hS-OS for linux-f2fs-devel@lists.sourceforge.net; Sat, 06 May 2023 11:46:01 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=oQS2wL0jTbgkcpThRu0KJFuZ+eX+yBfN4gBud3+MmVMZ82Q6zM17//0zhGbzAqvK8NiGOi7icYXoijax0EgagGnXqzneqMrBNLrKyEOxRtXyFkezb3DE4sYz7HhxlYUD/qyELzZre71HaavoPHhzBltu2XsidMbm5/NL/uqJ3Q21kLo79abgdoXLz/gTeyxeiitmaCu8JqAMHUTyxX9dokcXm3rP5Rj22nZkIG/z2ZFrVh7qWO1+eZe3/QDofLcSctOeFbjVOwfdYCAqIn+yx8wkMul763r+SLHUpJlMoAsjuZ/84+skO1IlwtrGY1ISmTaKrOYP7DaFsS7+lJuUPA== 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=VHPxFq/y6r98ls3ZbcSubmnR7k0Xqe92iYu7z7UGGSs=; b=hxI027xRYG5U7GDNPYDlTpg1WIp0A2OSYqvV5ozpqW9WT+b2KndZUus4Ri0tYpvUTMlcqbDBkb3JScW9obFC3qpiMSUdYptMXWdKyRbtSGPQLfwrtUN9ajK3iUJYyIXlKFIbgcGSlQaI5bvcTz7ae5q365IvOGxeXu3d/iZr3VbtlrQ10XSOtm0CtmXkr32Oq39wBVmFgjRTvbqgTQAvqHExmHF7Ciikk3a80lOH+UDRbZsM+lPd+YPhIyg4ai6SX+iuGEn/k3OREtBBzvu3UBo3QVFgxNB191QkNrWAq1h3hIyB3vZEj3NwH71aAiPao0maL+2Eo9tuNW16VUTaKQ== 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=VHPxFq/y6r98ls3ZbcSubmnR7k0Xqe92iYu7z7UGGSs=; b=K4J+t+jGAIoyfxpPpLUeJ0OD/if0kanmA8vJYMZItvYUd7UohWnuNFh2Shk0LXGiNTbaMq5IL0qk8HlIDI2NNXTEddoQbZD1hlKNvHlp6M7RIcNyuH7DU7bST32Y5lquev2RdFDOaUIC2ak+Zrk8o4iLSNuChPiRWw3WLpC8KBliJMjjRjkFDMpMabYeqsqfnMVkQ8ue9ydBhgS2dS5Rkozjkn1zjBw3qR3bqxaI1bTHQ2m1v4/KbF3NrOqCYfzL+hBvUaTZ+1LJlvVrxdInrhreHusfoXls/vjdSaWuXVONHztRntJvXmxQZV0HtISQRPY2MVrqWS1/k3Kix4Stww== 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 SEYPR06MB6010.apcprd06.prod.outlook.com (2603:1096:101:dc::11) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6363.28; Sat, 6 May 2023 11:45:47 +0000 Received: from SEZPR06MB5269.apcprd06.prod.outlook.com ([fe80::76d6:4828:7e80:2965]) by SEZPR06MB5269.apcprd06.prod.outlook.com ([fe80::76d6:4828:7e80:2965%7]) with mapi id 15.20.6363.029; Sat, 6 May 2023 11:45:47 +0000 To: jaegeuk@kernel.org, chao@kernel.org Date: Sat, 6 May 2023 19:45:37 +0800 Message-Id: <20230506114537.49470-2-frank.li@vivo.com> X-Mailer: git-send-email 2.39.0 In-Reply-To: <20230506114537.49470-1-frank.li@vivo.com> References: <20230506114537.49470-1-frank.li@vivo.com> X-ClientProxiedBy: SI2PR02CA0046.apcprd02.prod.outlook.com (2603:1096:4:196::15) To SEZPR06MB5269.apcprd06.prod.outlook.com (2603:1096:101:78::6) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: SEZPR06MB5269:EE_|SEYPR06MB6010:EE_ X-MS-Office365-Filtering-Correlation-Id: 820d83dd-629f-4023-c730-08db4e276f07 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: Y9bfTRP9705OH81o0YxL++spE8mmKEDV4EFl0+t4V38FMGLWLm5Nay7BOqEaIwj3MkcNUgF4aG2vgREvkJeNJRtE7qtLAYkWxqaxyoXPTbKXS6e5wJ7bfBzdXFlBINWMj0u8zBOP43/qYtAOcr2sOOrqqgyOTxEF1cYh26eNx6OJ2Vwo5EL/zXNBvsbc9mSsybU0UxPPQVJYfFgzLdmQS9ftIyDw4S6snPW/bo8+HaOYw+QtgME15f2neWhCoMnK/BxSMSuEQTwpfILoyXghI5p+LR3PwTZDgkVWEWFHpV8Ml5whPEbzzQl42kUdvM8DHsR+5WFcr/QS8HUJlIc+cc9fFKmTiBvdeNBOeRjZDHCpFjmKSIyhjCQhmrpMDZ7LnfMrXtCVOxIwNMDf+8DWmFKy1USm4pvWVMunAPCtWG+LpbedNz3McA7XkgOTokQhFWaNzGm8vDyM5f0UfdLwrOHtc8iGKbPA2RC5hDUmxRHEjybuqmQRiXATQ7VAGnMhMKZaLpmpuOsAIspA2HL+Q+mpEwW2J5bZFvvK6h1+GL76r2sNo2GaPesiit5m0iyAQMwG+bxdNlBCNu6OuXDFCKM1W0rWStAZ8vl9vnfGi9LVPxWZ/SCA9uGnpnOExbft 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:(13230028)(4636009)(366004)(346002)(396003)(136003)(376002)(39860400002)(451199021)(36756003)(38350700002)(38100700002)(2906002)(8676002)(8936002)(5660300002)(316002)(86362001)(66556008)(66476007)(66946007)(4326008)(41300700001)(83380400001)(186003)(6512007)(6506007)(1076003)(26005)(52116002)(6486002)(6666004)(478600001)(107886003)(2616005); DIR:OUT; SFP:1102; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: owTdQtN5CN2YoGYPGS2DOw5cdwqjsgNr9wf3dq8G5AFl3vfqKWik6bXK/mJvVuEAv7WSqtuL+kRmJie+f+fL1f6eEPbNl7Rw1cAKleyzCC5/VgTpnZ7CGrlztM6DSlV3rLUNNAXKJ6QB2px7T4wdM7ItSOip2Ml6TAZjOBTjivtsk2PAV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yyk00LpK+NwWn+eLb7/z9f2DHbvsboDbVUYCFQZpWzA7A1MOcn+V5QRAzbzDPCBgQiwGQigoxh5TdMjK16c3H3zxj1CgEoAHh9Cm26BeiKZEeQjPFet/QfXatpioRrCZ9TvLmIJAvZ/mXu3/Qy8zvaJF3dEEMmxjQCufakf3Pzd3eVcWdSMi9RtTOJQSacpDxQX7ENSxOqz7fo0mdsFQTQYewumEY6Pxq0mSf3NNCYxLP1xHUv4JGzQWizorJaA/AqLVHzIN+SLlD0opHoE0fwViAeLnfZeKD+RQOqBD+TmeUOidX9FpT7va8HpciOlLkp0gznCU+jV9qIx36VS4dJ85ga5X0DMFnfwZfg X-OriginatorOrg: vivo.com X-MS-Exchange-CrossTenant-Network-Message-Id: 820d83dd-629f-4023-c730-08db4e276f07 X-MS-Exchange-CrossTenant-AuthSource: SEZPR06MB5269.apcprd06.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 06 May 2023 11:45:47.8045 (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: 4dGmEP3MmcFW3AxAZy1Jmac9N7oEHo5IKcSCy0PR47ZlwWMIm3eU/cBUJ0IpR2dIM268nFiRAo0rTqJzc3yC9g== X-MS-Exchange-Transport-CrossTenantHeadersStamped: SEYPR06MB6010 X-Headers-End: 1pvGMR-0005hS-OS Subject: [f2fs-dev] [PATCH] f2fs_io: expend fallocate command 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: Yangtao Li via Linux-f2fs-devel From: Yangtao Li Reply-To: Yangtao Li Cc: Yangtao Li , linux-f2fs-devel@lists.sourceforge.net Errors-To: linux-f2fs-devel-bounces@lists.sourceforge.net Expend fallocate command to support more flags. Signed-off-by: Yangtao Li --- tools/f2fs_io/f2fs_io.c | 37 ++++++++++++++++++++++++++++++++----- 1 file changed, 32 insertions(+), 5 deletions(-) diff --git a/tools/f2fs_io/f2fs_io.c b/tools/f2fs_io/f2fs_io.c index 126e1f9..1be8c9e 100644 --- a/tools/f2fs_io/f2fs_io.c +++ b/tools/f2fs_io/f2fs_io.c @@ -416,6 +416,10 @@ static void do_pinfile(int argc, char **argv, const struct cmd_desc *cmd) "f2fs_io fallocate [keep_size] [offset] [length] [file]\n\n" \ "fallocate given the file\n" \ " [keep_size] : 1 or 0\n" \ +" -p : punch hole\n" \ +" -c : collapse range\n" \ +" -z : zero range\n" \ +" -i : insert range\n" \ static void do_fallocate(int argc, char **argv, const struct cmd_desc *cmd) { @@ -423,20 +427,43 @@ static void do_fallocate(int argc, char **argv, const struct cmd_desc *cmd) off_t offset, length; struct stat sb; int mode = 0; + int c; - if (argc != 5) { + while ((c = getopt(argc, argv, "cipz")) != -1) { + switch (c) { + case 'c': + mode |= FALLOC_FL_COLLAPSE_RANGE; + break; + case 'i': + mode |= FALLOC_FL_INSERT_RANGE; + break; + case 'p': + mode |= FALLOC_FL_PUNCH_HOLE; + break; + case 'z': + mode |= FALLOC_FL_ZERO_RANGE; + break; + default: + fputs(cmd->cmd_help, stderr); + exit(2); + } + } + argc -= optind; + argv += optind; + + if (argc != 4) { fputs("Excess arguments\n\n", stderr); fputs(cmd->cmd_help, stderr); exit(1); } - if (!strcmp(argv[1], "1")) + if (!strcmp(argv[0], "1")) mode |= FALLOC_FL_KEEP_SIZE; - offset = atoi(argv[2]); - length = atoll(argv[3]); + offset = atoi(argv[1]); + length = atoll(argv[2]); - fd = xopen(argv[4], O_RDWR, 0); + fd = xopen(argv[3], O_RDWR, 0); if (fallocate(fd, mode, offset, length) != 0) die_errno("fallocate failed");