@@ -135,6 +135,9 @@ Reserve free blocks to prepare decompressing blocks in the file.
.TP
\fBgc\fR \fI[sync_mode] [file]\fR
Trigger filesystem GC
+.TP
+\fBprecache_extents\fR \fI[file]\fR
+Trigger precache extents
.SH AUTHOR
This version of
.B f2fs_io
@@ -1311,6 +1311,29 @@ static void do_gc(int argc, char **argv, const struct cmd_desc *cmd)
exit(0);
}
+#define precache_extents_desc "trigger precache extents"
+#define precache_extents_help "f2fs_io precache_extents [file_path]\n\n"
+
+static void do_precache_extents(int argc, char **argv, const struct cmd_desc *cmd)
+{
+ int ret, fd;
+
+ if (argc != 2) {
+ fputs("Excess arguments\n\n", stderr);
+ fputs(cmd->cmd_help, stderr);
+ exit(1);
+ }
+
+ fd = xopen(argv[1], O_WRONLY, 0);
+
+ ret = ioctl(fd, F2FS_IOC_PRECACHE_EXTENTS);
+ if (ret < 0)
+ die_errno("F2FS_IOC_PRECACHE_EXTENTS failed");
+
+ printf("trigger precache extents 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 }
@@ -1343,6 +1366,7 @@ const struct cmd_desc cmd_list[] = {
CMD(get_filename_encrypt_mode),
CMD(rename),
CMD(gc),
+ CMD(precache_extents),
{ NULL, NULL, NULL, NULL, 0 }
};
This patch supports a new sub-command 'precache_extents' in f2fs_io to trigger precache extents via F2FS_IOC_PRECACHE_EXTENTS ioctl. Signed-off-by: Yangtao Li <frank.li@vivo.com> --- v2: -fix precache_extents_help man/f2fs_io.8 | 3 +++ tools/f2fs_io/f2fs_io.c | 24 ++++++++++++++++++++++++ 2 files changed, 27 insertions(+)