From patchwork Thu May 4 14:44:06 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: 90120 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:b0ea:0:b0:3b6:4342:cba0 with SMTP id b10csp389178vqo; Thu, 4 May 2023 08:05:46 -0700 (PDT) X-Google-Smtp-Source: ACHHUZ6HLOqlDSLWgGbf3FHWMHH6sg579Y14nghDPiJ3/+DUPiGYQXrR0xEU1btvUnBXSl6zJaey X-Received: by 2002:a6b:3bd0:0:b0:760:f293:12d8 with SMTP id i199-20020a6b3bd0000000b00760f29312d8mr8606ioa.7.1683212746089; Thu, 04 May 2023 08:05:46 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1683212746; cv=pass; d=google.com; s=arc-20160816; b=aKxAM3xcBPp4nkO9KctR2W5oDbwiZ56aBJJ8m7HRHkAJSshbgETh86B8mdMEV38Iqy lRXI5NvnzymNN9m2gE/UQ4inSLlCWw1CY+bf2bO6jV99ViE+frpq9mlCLttQrlYKMKlz Zio3S94Eg7GNzEiR74Ql3NviszJHytMoMpZFq/lcX/UqF5WFiNAo6W3P2kFoYCAk+Dxy OUAztmAiSP+vt06kZsZB1XQPy85w3hDTnLOjhtlLVn4jlr3+Zlno+cjaUkJdw3clZuvS L1zw6aeFPXLW0n8HtLQkEZkBp0yMpcajwLwjI5s3+gKy/GMWZ0s+7/15ebWLw/ckzwz3 e8Tg== 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=58WzU6uCQfB+vCcXe3oAuOzMFVi6wl7k0PK7KYH2dnU=; b=rvqlwcLj5PoNF9Kg7MU1LeG8QyERHeT89kUzbCERy2f1O3LIGYfXQHLpwOfYfyP/mQ LtUjDDwswW2Y4azl/kXhHgij3crVTVzAknsANfDx0DoXP8FrvTo35H8fdh/jhffYHNY+ DT12E4IG0WBVuU030UxNrtmbyS8rYFwNWehuuRohWSGl5BzN/Z1fc3G/svH97INjWbRZ vqzMB4kgibOOfZw0xk0QFfn89ACsbptjpm+2PDJ9QAgXsKO1bAG1i3QPrr06cg88BVst sRPwSXiNm1w2VQFxw7t0IY3cAT3v2Dw7nAAN7C8C1YBpEx78nEVG/c0zp7a29NP/mTcF Zkog== ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@vivo.com header.s=selector2 header.b=ndqXD4he; 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 i18-20020a05663813d200b0040faa822c8esi29692108jaj.39.2023.05.04.08.05.30; Thu, 04 May 2023 08:05:45 -0700 (PDT) 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=ndqXD4he; 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 S230508AbjEDOo1 (ORCPT + 99 others); Thu, 4 May 2023 10:44:27 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:41684 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230416AbjEDOoY (ORCPT ); Thu, 4 May 2023 10:44:24 -0400 Received: from APC01-PSA-obe.outbound.protection.outlook.com (mail-psaapc01on2125.outbound.protection.outlook.com [40.107.255.125]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 5B30ACD for ; Thu, 4 May 2023 07:44:23 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=T6XnvMfXxeJ/EasPRbIlK06f71APRD+0Vg5rJJ5FY/QM7T4PMorkNiiaMnLlMAJ8aMOiPnoNdpG6oDrDwNAxLIeoPXWSW59cYQ+8DtCpjwvAY/UboXWHmhzXt22lKx+gB3H81RzSmG4tU1UEXzU6z5T/MfVsIr+TRb6anCOQdqKyy+vNJslvu+54meQ9g+hhrSc3mVyN1BT2dSnJ3H1ObUWou6NEJ+HA2B9vjejaOjJhUXku75QZqO7t5IBMjQcq66qkMZPAq0wHdgXw7TEfAqMo7YBw/lqqCntKv3/bE7jVGuElW10Cw93RCTUjo3dzqhw4nygjHchtyyaTbb+D4g== 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=58WzU6uCQfB+vCcXe3oAuOzMFVi6wl7k0PK7KYH2dnU=; b=CmtbALFVhZTgrkKLfONJjkE2Q1gQXLw6Gfj77Epj6+dk1j5pwKilUW1K9NlmsqgKie8uTgBcYmDra0lYoyVTQGf1JfYn+x7I6i0LM97hHOXNKMs2aS1zD53zqTG62W1OUoeNBz5VcYIpJWtfKPnNzXc4wR/5QX0YxwiE4d2AABY8yX161GiVTjIx7CdQa6yoIkxlJnnkwqeN8JglNQ7edWAeSdjSJbLB5pkLG/SnFJn1POEW4haqKvjLxbivEMS4QsPfc3Z1Py0CpSXagVw3pyO/POpEU5DlmNQykC4YVMi91uXFk0qJX88RHM9/9ONkFBlpJyXKk2EqHTz3SIs9jw== 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=58WzU6uCQfB+vCcXe3oAuOzMFVi6wl7k0PK7KYH2dnU=; b=ndqXD4heNnmVotNbvAUTbMZjdH4o1WXP7zzQ07UFL+Pd/M5sR/BOeriVDEqtMm37NGbCxERed+G8Y/6nxw/Epp0WcwteBVUaRBD3uK4l4LWezhvS7FC7BWgH6aI0ZAZStLME8+FOUPvl1/cN8FOorO+1giqJYSE8KihTc4k5bO3ZYmT/R9HycNT4sIkYPVVXC1jgyDy1c8xROHIlXX5xNGDKkRuqfkRjM05uxHwM87f6dx8F1MJkcb97ozXlGAklqHOrpUiq+f/oDVD/iqgxT0eS6qovqMcNksBGrkZbbtBWLXHMKVDz0fGqkD7rnAhr0F8yVHKPI2kq0vlHlJGHSw== 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 TY0PR06MB5258.apcprd06.prod.outlook.com (2603:1096:400:205::13) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6363.26; Thu, 4 May 2023 14:44:19 +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.021; Thu, 4 May 2023 14:44:19 +0000 From: Yangtao Li To: jaegeuk@kernel.org Cc: chao@kernel.org, linux-f2fs-devel@lists.sourceforge.net, Yangtao Li , linux-kernel@vger.kernel.org Subject: [PATCH] f2fs_io: support move_range command Date: Thu, 4 May 2023 22:44:06 +0800 Message-Id: <20230504144406.33713-1-frank.li@vivo.com> X-Mailer: git-send-email 2.39.0 X-ClientProxiedBy: SG2PR02CA0047.apcprd02.prod.outlook.com (2603:1096:3:18::35) To SEZPR06MB5269.apcprd06.prod.outlook.com (2603:1096:101:78::6) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: SEZPR06MB5269:EE_|TY0PR06MB5258:EE_ X-MS-Office365-Filtering-Correlation-Id: 2ba3e74b-adee-41e8-d426-08db4cae0a88 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: i/+DvSTMM0Bz79/lG4AeIDPTnQ5JWvRPxkDUm+iG850Lv5X6fIPNpZBj9PDqDq7vmKJYCEPZdYNNn2cWPPZCMEJBHMreug/Nu2kyXOlKbdkkmiemqcmyO15Wz7DDEXzU6PJdfMYvuPLi1wYoCIiOJ0oKw4wiHgqL57f3QwhX4WMi0AC3q56nK/cjopeapwd0rzzAdPsjbILlEpRIIopq8jmc0iwRJHTI2uIkvCsZbOgGXPOv8rfpVLFBronCaask2+vArxP368I0pkpJuickmuARV8pDB0Lq95cyowIRqytIp/9vQYMXuDkclYITnkJEmQGa5g+8UDxkMUtosSDI704Fehh6hYysBGD13SxMBkN9Om7Sw778EGTW/32LdjzQ9HrFUW+apqLYDtwgHcCK33J8LAn2ZtAOGQJcrQWHgsRX1l1KACDe2Z2d/d+2cwk9pFwypvdwDp65GdkAhPSzVuBHoOKuKo1QEds41hqc/vsUqstRqKjD/oNB2YcR57ync2zIfcYCQt4mjBnK8Yl8tNAdZTsoDse0loHShKGcJzbgxuwOWs6f7Mj1ym9KHjw9nmuEl7BGXWxfN6VGgHanK3TIz6o2xgIHYtrwUskxH8REyiQTXO2e9CqN5AuD/tWr 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)(39860400002)(366004)(396003)(346002)(136003)(376002)(451199021)(2616005)(6506007)(1076003)(6512007)(26005)(478600001)(2906002)(83380400001)(186003)(38350700002)(66476007)(66556008)(66946007)(38100700002)(5660300002)(8676002)(8936002)(41300700001)(36756003)(86362001)(6916009)(52116002)(6486002)(316002)(4326008)(6666004);DIR:OUT;SFP:1102; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: muj4pde9pl4U9hc0yt7giuKU+6HV/5NFLcJSvpMAEDnvIU2qjzGP2JdyDT/CoMiGKKQqDKK+KTjB4HfZKFArTCU0PEXMu6UBDVoAgwA+bIzt5pWmmg1hxGxlnhZhD175WxojY4ZosG8T+E0CEx2OpAfPNvfq6nwHnrN5v/eBA+2heIj8ivXOF5ad5anyz5kGVubV6DQ6cDfukbq3urrJTgrq3rOiZcAbCHobQdAIJwCp4pjGimuFxDacQY5zG7RX0a9GXlntbIH3lAq8elsTIfHF3i3ZY1IBxUnhZ28gFppkPVJTrQRjXzYR4HFQFpukbiS/l+cJMgN/7I4AK76uBiR9z5vuAoDuGBuIHZ3O35OU0AdO7TzoYlQUsEfUxHY6x9MtcMBojEuCDcBFvpFf4KSHJ/MN2fDv9lUDZeL1G8xeEs/Cl1XylN1uQm+8RoA45VIPzYbztgziWvtbSdo3lZcPFzENfz8k8SxaK1T/y6Lnjh75FsrFyLpSFW5jefrQ4Inp/F2ET4wJCAeqgFZfurha6hk6yUoM7Q4gSNVeeWkLjWAbpM1I9kHg5Wqj5RR02Thw5cokNuQldZ/0UiYzoAf8ebwM6etR66x7ibC4ox4RVEObZc0DLm7kiH9VV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SEZPR06MB5269.apcprd06.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 04 May 2023 14:44:18.9315 (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: Iat2orIySzOsPlZGLJj9joCzwf0K4UrX2H0blQagQoiusG4W92CjutOC15Hm07IHFY+jDJdJsl/CMcx4qodsgg== X-MS-Exchange-Transport-CrossTenantHeadersStamped: TY0PR06MB5258 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,T_SCC_BODY_TEXT_LINE, URIBL_BLOCKED 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?1764976488149694573?= X-GMAIL-MSGID: =?utf-8?q?1764976488149694573?= This patch supports a new sub-command 'move_range' in f2fs_io to move a range of data blocks from source file to destination file via F2FS_IOC_MOVE_RANGE ioctl. Signed-off-by: Yangtao Li --- man/f2fs_io.8 | 4 ++++ tools/f2fs_io/f2fs_io.c | 35 +++++++++++++++++++++++++++++++++++ 2 files changed, 39 insertions(+) diff --git a/man/f2fs_io.8 b/man/f2fs_io.8 index 13d4bf3..b25f807 100644 --- a/man/f2fs_io.8 +++ b/man/f2fs_io.8 @@ -138,8 +138,12 @@ Trigger filesystem GC .TP \fBcheckpoint\fR \fI[file]\fR Trigger filesystem checkpoint +.TP \fBprecache_extents\fR \fI[file]\fR Trigger precache extents +.TP +\fBmove_range\fR \fI[src_path] [dst_path] [src_start] [dst_start] [length]\fR +Move a range of data blocks from source file to destination file .SH AUTHOR This version of .B f2fs_io diff --git a/tools/f2fs_io/f2fs_io.c b/tools/f2fs_io/f2fs_io.c index ac7b588..d545d8e 100644 --- a/tools/f2fs_io/f2fs_io.c +++ b/tools/f2fs_io/f2fs_io.c @@ -1357,6 +1357,40 @@ static void do_precache_extents(int argc, char **argv, const struct cmd_desc *cm exit(0); } +#define move_range_desc "moving a range of data blocks from source file to destination file" +#define move_range_help \ +"f2fs_io move_range [src_path] [dst_path] [src_start] [dst_start] [length]\n\n" \ +" src_path : path to source file\n" \ +" dst_path : path to destination file\n" \ +" src_start : start offset of src file move region, unit: bytes\n" \ +" dst_start : start offset of dst file move region, unit: bytes\n" \ +" length : size to move\n" \ + +static void do_move_range(int argc, char **argv, const struct cmd_desc *cmd) +{ + struct f2fs_move_range range; + int ret, fd; + + if (argc != 6) { + fputs("Excess arguments\n\n", stderr); + fputs(cmd->cmd_help, stderr); + exit(1); + } + + fd = xopen(argv[1], O_RDWR, 0); + range.dst_fd = xopen(argv[2], O_RDWR | O_CREAT, 0644); + range.pos_in = atoi(argv[3]); + range.pos_out = atoi(argv[4]); + range.len = atoi(argv[5]); + + ret = ioctl(fd, F2FS_IOC_MOVE_RANGE, &range); + if (ret < 0) + die_errno("F2FS_IOC_MOVE_RANGE failed"); + + printf("move range ret=%d\n", ret); + exit(0); +} + #define CMD_HIDDEN 0x0001 #define CMD(name) { #name, do_##name, name##_desc, name##_help, 0 } #define _CMD(name) { #name, do_##name, NULL, NULL, CMD_HIDDEN } @@ -1391,6 +1425,7 @@ const struct cmd_desc cmd_list[] = { CMD(gc), CMD(checkpoint), CMD(precache_extents), + CMD(move_range), { NULL, NULL, NULL, NULL, 0 } };