mirror of
https://gitee.com/openharmony/third_party_f2fs-tools
synced 2024-11-23 01:59:54 +00:00
f2fs_io: support triggering filesystem GC via ioctl
Support 'gc' sub command to trigger filesystem GC via ioctl in f2fs. Signed-off-by: Chao Yu <chao.yu@oppo.com> Signed-off-by: Jaegeuk Kim <jaegeuk@kernel.org>
This commit is contained in:
parent
434d856c8c
commit
aaf8c8720b
@ -132,6 +132,9 @@ Release compressed blocks to get free space.
|
||||
.TP
|
||||
\fBreserve_cblocks\fR \fI[file]\fR
|
||||
Reserve free blocks to prepare decompressing blocks in the file.
|
||||
.TP
|
||||
\fBgc\fR \fI[sync_mode] [file]\fR
|
||||
Trigger filesystem GC
|
||||
.SH AUTHOR
|
||||
This version of
|
||||
.B f2fs_io
|
||||
|
@ -1270,6 +1270,33 @@ static void do_rename(int argc, char **argv, const struct cmd_desc *cmd)
|
||||
exit(0);
|
||||
}
|
||||
|
||||
#define gc_desc "trigger filesystem GC"
|
||||
#define gc_help "f2fs_io gc sync_mode [file_path]\n\n"
|
||||
|
||||
static void do_gc(int argc, char **argv, const struct cmd_desc *cmd)
|
||||
{
|
||||
u32 sync;
|
||||
int ret, fd;
|
||||
|
||||
if (argc != 3) {
|
||||
fputs("Excess arguments\n\n", stderr);
|
||||
fputs(cmd->cmd_help, stderr);
|
||||
exit(1);
|
||||
}
|
||||
|
||||
sync = atoi(argv[1]);
|
||||
|
||||
fd = xopen(argv[2], O_RDONLY, 0);
|
||||
|
||||
ret = ioctl(fd, F2FS_IOC_GARBAGE_COLLECT, &sync);
|
||||
if (ret < 0)
|
||||
die_errno("F2FS_IOC_GARBAGE_COLLECT failed");
|
||||
|
||||
printf("trigger %s gc ret=%d\n",
|
||||
sync ? "synchronous" : "asynchronous", 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 }
|
||||
@ -1301,6 +1328,7 @@ const struct cmd_desc cmd_list[] = {
|
||||
CMD(compress),
|
||||
CMD(get_filename_encrypt_mode),
|
||||
CMD(rename),
|
||||
CMD(gc),
|
||||
{ NULL, NULL, NULL, NULL, 0 }
|
||||
};
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user