From: Chao Yu <yuchao0@huawei.com>
To: Jaegeuk Kim <jaegeuk@kernel.org>
Cc: linux-f2fs-devel@lists.sourceforge.net
Subject: Re: [f2fs-dev] [PATCH v2] f2fs_io: support defrag_file
Date: Tue, 6 Aug 2019 10:02:40 +0800 [thread overview]
Message-ID: <d82b9447-f7ac-2bed-8119-176118583ea9@huawei.com> (raw)
In-Reply-To: <20190806012608.GC1029@jaegeuk-macbookpro.roam.corp.google.com>
On 2019/8/6 9:26, Jaegeuk Kim wrote:
> On 08/06, Chao Yu wrote:
>> On 2019/7/27 23:44, Chao Yu wrote:
>>> From: Chao Yu <yuchao0@huawei.com>
>>>
>>> Support 'defrag_file' sub command to trigger file based defragment via
>>> ioctl in f2fs.
>>>
>>> Signed-off-by: Chao Yu <yuchao0@huawei.com>
>>> ---
>>> v2:
>>> - remove unneeded debug info.
>>> - fix compile warning.
>>
>> Sorry I sent the old one...
>>
>> I add -v option, but w/o implement the details, because I just see generic/018
>> want this, also other filesystem utils have this option, not sure we should
>> remove this option... any thoughts?
>
> Ah, we don't need this option.
Let me update a new version, and change generic/018 testcase.
Thanks,
>
>>
>> "f2fs_io defrag_file [start] [length] [-v] [file_path]\n\n"
>>
>>> tools/f2fs_io/f2fs_io.c | 41 +++++++++++++++++++++++++++++++++++++++++
>>> 1 file changed, 41 insertions(+)
>>>
>>> diff --git a/tools/f2fs_io/f2fs_io.c b/tools/f2fs_io/f2fs_io.c
>>> index f087da4..59ef8a7 100644
>>> --- a/tools/f2fs_io/f2fs_io.c
>>> +++ b/tools/f2fs_io/f2fs_io.c
>>> @@ -442,6 +442,46 @@ static void do_gc_urgent(int argc, char **argv, const struct cmd_desc *cmd)
>>> }
>>> }
>>>
>>> +#define defrag_file_desc "do defragment on file"
>>> +#define defrag_file_help \
>>> +"f2fs_io defrag_file [start] [length] [-v] [file_path]\n\n" \
>>> +" start : start offset of defragment region, unit: bytes\n" \
>>> +" length : bytes number of defragment region\n" \
>>> +" -v : be verbose\n" \
>>> +
>>> +static void do_defrag_file(int argc, char **argv, const struct cmd_desc *cmd)
>>> +{
>>> + struct f2fs_defragment df;
>>> + u64 len;
>>> + int ret, fd;
>>> +
>>> + if (argc != 5) {
>>> + fputs("Excess arguments\n\n", stderr);
>>> + fputs(cmd->cmd_help, stderr);
>>> + exit(1);
>>> + }
>>> +
>>> + df.start = atoll(argv[1]);
>>> + df.len = len = atoll(argv[2]);
>>> +
>>> + fd = open(argv[4], O_RDWR);
>>> + if (fd == -1) {
>>> + fputs("Open failed\n\n", stderr);
>>> + fputs(cmd->cmd_help, stderr);
>>> + exit(1);
>>> + }
>>> +printf("%lu, %lu\n", df.start, df.len);
>>> + ret = ioctl(fd, F2FS_IOC_DEFRAGMENT, &df);
>>> + if (ret < 0) {
>>> + perror("F2FS_IOC_DEFRAGMENT");
>>> + exit(1);
>>> + }
>>> + printf("defrag %s in region[%lu, %lu]\n", argv[3],
>>> + df.start, df.start + len);
>>> + 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 }
>>> @@ -456,6 +496,7 @@ const struct cmd_desc cmd_list[] = {
>>> CMD(read),
>>> CMD(fiemap),
>>> CMD(gc_urgent),
>>> + CMD(defrag_file),
>>> { 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:[~2019-08-06 2:02 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2019-07-27 15:44 [f2fs-dev] [PATCH v2] f2fs_io: support defrag_file Chao Yu
2019-08-06 1:17 ` Chao Yu
2019-08-06 1:26 ` Jaegeuk Kim
2019-08-06 2:02 ` 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=d82b9447-f7ac-2bed-8119-176118583ea9@huawei.com \
--to=yuchao0@huawei.com \
--cc=jaegeuk@kernel.org \
--cc=linux-f2fs-devel@lists.sourceforge.net \
/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).