diff mbox series

[f2fs-dev] f2fs_io: support F2FS_NOLINEAR_LOOKUP_FLAG

Message ID 20250303034658.1355526-1-chao@kernel.org (mailing list archive)
State New
Headers show
Series [f2fs-dev] f2fs_io: support F2FS_NOLINEAR_LOOKUP_FLAG | expand

Commit Message

Chao Yu March 3, 2025, 3:46 a.m. UTC
Support F2FS_NOLINEAR_LOOKUP_FLAG in f2fs_io {get,set,clear}flags.

Signed-off-by: Chao Yu <chao@kernel.org>
Signed-off-by: Jaegeuk Kim <jaegeuk@kernel.org>
---
 man/f2fs_io.8           |  4 ++--
 tools/f2fs_io/f2fs_io.c | 19 ++++++++++++++++---
 tools/f2fs_io/f2fs_io.h |  5 +++++
 3 files changed, 23 insertions(+), 5 deletions(-)
diff mbox series

Patch

diff --git a/man/f2fs_io.8 b/man/f2fs_io.8
index 2ff22f7..97a893b 100644
--- a/man/f2fs_io.8
+++ b/man/f2fs_io.8
@@ -22,11 +22,11 @@  Get the flags associated with the specified file.
 .TP
 \fBsetflags\fR \fI[flag] [file]\fR
 Set an f2fs file on specified file.  The flag can be casefold,
-compression, nocompression, immutable, and nocow.
+compression, nocompression, immutable, nocow, and nolinear_lookup.
 .TP
 \fBclearflags\fR \fI[flag] [file]\fR
 Clear the specified flag on the target file, which can be compression,
- nocompression, immutable, and nocow.
+ nocompression, immutable, nocow, and nolinear_lookup.
 .TP
 \fBshutdown\fR \fIshutdown filesystem\fR
 Freeze and stop all IOs for the file system mounted on
diff --git a/tools/f2fs_io/f2fs_io.c b/tools/f2fs_io/f2fs_io.c
index fa01f8f..c0c54e2 100644
--- a/tools/f2fs_io/f2fs_io.c
+++ b/tools/f2fs_io/f2fs_io.c
@@ -240,7 +240,8 @@  static void do_set_verity(int argc, char **argv, const struct cmd_desc *cmd)
 "  casefold\n"							\
 "  compression\n"						\
 "  nocompression\n"						\
-"  immutable\n"
+"  immutable\n"							\
+"  nolinear_lookup\n"
 
 static void do_getflags(int argc, char **argv, const struct cmd_desc *cmd)
 {
@@ -304,6 +305,12 @@  static void do_getflags(int argc, char **argv, const struct cmd_desc *cmd)
 		printf("immutable");
 		exist = 1;
 	}
+	if (flag & F2FS_NOLINEAR_LOOKUP_FLAG) {
+		if (exist)
+			printf(",");
+		printf("nolinear_lookup");
+		exist = 1;
+	}
 	if (!exist)
 		printf("none");
 	printf("\n");
@@ -319,7 +326,8 @@  static void do_getflags(int argc, char **argv, const struct cmd_desc *cmd)
 "  compression\n"						\
 "  nocompression\n"						\
 "  immutable\n"							\
-"  nocow\n"
+"  nocow\n"							\
+"  nolinear_lookup\n"
 
 static void do_setflags(int argc, char **argv, const struct cmd_desc *cmd)
 {
@@ -349,6 +357,8 @@  static void do_setflags(int argc, char **argv, const struct cmd_desc *cmd)
 		flag |= FS_IMMUTABLE_FL;
 	else if (!strcmp(argv[1], "nocow"))
 		flag |= FS_NOCOW_FL;
+	else if (!strcmp(argv[1], "nolinear_lookup"))
+		flag |= F2FS_NOLINEAR_LOOKUP_FLAG;
 
 	ret = ioctl(fd, F2FS_IOC_SETFLAGS, &flag);
 	printf("set a flag on %s ret=%d, flags=%s\n", argv[2], ret, argv[1]);
@@ -363,7 +373,8 @@  static void do_setflags(int argc, char **argv, const struct cmd_desc *cmd)
 "  compression\n"						\
 "  nocompression\n"						\
 "  immutable\n"							\
-"  nocow\n"
+"  nocow\n"							\
+"  nolinear_lookup\n"
 
 static void do_clearflags(int argc, char **argv, const struct cmd_desc *cmd)
 {
@@ -391,6 +402,8 @@  static void do_clearflags(int argc, char **argv, const struct cmd_desc *cmd)
 		flag &= ~FS_IMMUTABLE_FL;
 	else if (!strcmp(argv[1], "nocow"))
 		flag &= ~FS_NOCOW_FL;
+	else if (!strcmp(argv[1], "nolinear_lookup"))
+		flag &= ~F2FS_NOLINEAR_LOOKUP_FLAG;
 
 	ret = ioctl(fd, F2FS_IOC_SETFLAGS, &flag);
 	printf("clear a flag on %s ret=%d, flags=%s\n", argv[2], ret, argv[1]);
diff --git a/tools/f2fs_io/f2fs_io.h b/tools/f2fs_io/f2fs_io.h
index 14c9dc1..c32def7 100644
--- a/tools/f2fs_io/f2fs_io.h
+++ b/tools/f2fs_io/f2fs_io.h
@@ -246,3 +246,8 @@  struct f2fs_comp_option {
 	u8 algorithm;
 	u8 log_cluster_size;
 };
+
+/* for F2FS_IOC_{GET,SET,CLEAR}_FLAGS_EX */
+enum {
+	F2FS_NOLINEAR_LOOKUP_FLAG = 0x08000000,
+};