From: Chao Yu <chao@kernel.org>
To: Yangtao Li <frank.li@vivo.com>, jaegeuk@kernel.org
Cc: linux-kernel@vger.kernel.org, linux-f2fs-devel@lists.sourceforge.net
Subject: Re: [f2fs-dev] [PATCH] f2fs_io: support move_range command
Date: Fri, 5 May 2023 20:32:58 +0800 [thread overview]
Message-ID: <d853431a-897c-71b2-d97f-5572bd7f79cb@kernel.org> (raw)
In-Reply-To: <20230504144406.33713-1-frank.li@vivo.com>
On 2023/5/4 22:44, Yangtao Li wrote:
> 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 <frank.li@vivo.com>
> ---
> 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" \
It's better to wrap the long line as below?
#define move_range_help \
"f2fs_io move_range [src_path] [dst_path] [src_start] [dst_start] " \
"[length]\n\n" \
Thanks,
> +" 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 }
> };
>
_______________________________________________
Linux-f2fs-devel mailing list
Linux-f2fs-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/linux-f2fs-devel
prev parent reply other threads:[~2023-05-05 12:33 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-05-04 14:44 [f2fs-dev] [PATCH] f2fs_io: support move_range command Yangtao Li via Linux-f2fs-devel
2023-05-05 12:32 ` Chao Yu [this message]
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=d853431a-897c-71b2-d97f-5572bd7f79cb@kernel.org \
--to=chao@kernel.org \
--cc=frank.li@vivo.com \
--cc=jaegeuk@kernel.org \
--cc=linux-f2fs-devel@lists.sourceforge.net \
--cc=linux-kernel@vger.kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).