All of lore.kernel.org
 help / color / mirror / Atom feed
* [f2fs-dev] [PATCH 1/2] f2fs_io: support fadvise dontneed, random, and noreuse
@ 2025-02-13 18:01 Jaegeuk Kim via Linux-f2fs-devel
  2025-02-13 18:01 ` [f2fs-dev] [PATCH 2/2] f2fs_io: add ioprio command to give a io priority hint Jaegeuk Kim via Linux-f2fs-devel
  0 siblings, 1 reply; 4+ messages in thread
From: Jaegeuk Kim via Linux-f2fs-devel @ 2025-02-13 18:01 UTC (permalink / raw)
  To: linux-f2fs-devel; +Cc: Jaegeuk Kim

Signed-off-by: Jaegeuk Kim <jaegeuk@kernel.org>
---
 tools/f2fs_io/f2fs_io.c | 9 +++++++++
 1 file changed, 9 insertions(+)

diff --git a/tools/f2fs_io/f2fs_io.c b/tools/f2fs_io/f2fs_io.c
index fa01f8fd4809..e7ad22e08ba5 100644
--- a/tools/f2fs_io/f2fs_io.c
+++ b/tools/f2fs_io/f2fs_io.c
@@ -441,7 +441,10 @@ static void do_shutdown(int argc, char **argv, const struct cmd_desc *cmd)
 "fadvice given the file\n"					\
 "advice can be\n"						\
 " willneed\n"							\
+" dontneed\n"							\
+" noreuse\n"							\
 " sequential\n"							\
+" random\n"							\
 
 static void do_fadvise(int argc, char **argv, const struct cmd_desc *cmd)
 {
@@ -458,8 +461,14 @@ static void do_fadvise(int argc, char **argv, const struct cmd_desc *cmd)
 
 	if (!strcmp(argv[1], "willneed")) {
 		advice = POSIX_FADV_WILLNEED;
+	} else if (!strcmp(argv[1], "dontneed")) {
+		advice = POSIX_FADV_DONTNEED;
+	} else if (!strcmp(argv[1], "noreuse")) {
+		advice = POSIX_FADV_NOREUSE;
 	} else if (!strcmp(argv[1], "sequential")) {
 		advice = POSIX_FADV_SEQUENTIAL;
+	} else if (!strcmp(argv[1], "random")) {
+		advice = POSIX_FADV_RANDOM;
 	} else {
 		fputs("Wrong advice\n\n", stderr);
 		fputs(cmd->cmd_help, stderr);
-- 
2.48.1.601.g30ceb7b040-goog



_______________________________________________
Linux-f2fs-devel mailing list
Linux-f2fs-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/linux-f2fs-devel

^ permalink raw reply related	[flat|nested] 4+ messages in thread

* [f2fs-dev] [PATCH 2/2] f2fs_io: add ioprio command to give a io priority hint
  2025-02-13 18:01 [f2fs-dev] [PATCH 1/2] f2fs_io: support fadvise dontneed, random, and noreuse Jaegeuk Kim via Linux-f2fs-devel
@ 2025-02-13 18:01 ` Jaegeuk Kim via Linux-f2fs-devel
  0 siblings, 0 replies; 4+ messages in thread
From: Jaegeuk Kim via Linux-f2fs-devel @ 2025-02-13 18:01 UTC (permalink / raw)
  To: linux-f2fs-devel; +Cc: Jaegeuk Kim

This adds a command to call ioctl(F2FS_IOC_IO_PRIO).

Signed-off-by: Jaegeuk Kim <jaegeuk@kernel.org>
---
 tools/f2fs_io/f2fs_io.c | 35 +++++++++++++++++++++++++++++++++++
 tools/f2fs_io/f2fs_io.h |  7 +++++++
 2 files changed, 42 insertions(+)

diff --git a/tools/f2fs_io/f2fs_io.c b/tools/f2fs_io/f2fs_io.c
index e7ad22e08ba5..c4a0a6c4cf85 100644
--- a/tools/f2fs_io/f2fs_io.c
+++ b/tools/f2fs_io/f2fs_io.c
@@ -485,6 +485,40 @@ static void do_fadvise(int argc, char **argv, const struct cmd_desc *cmd)
 	exit(0);
 }
 
+#define ioprio_desc "ioprio"
+#define ioprio_help						\
+"f2fs_io ioprio [hint] [file]\n\n"				\
+"ioprio given the file\n"					\
+"hint can be\n"							\
+" ioprio_write\n"						\
+
+static void do_ioprio(int argc, char **argv, const struct cmd_desc *cmd)
+{
+	int fd, hint;
+
+	if (argc != 3) {
+		fputs("Excess arguments\n\n", stderr);
+		fputs(cmd->cmd_help, stderr);
+		exit(1);
+	}
+
+	fd = xopen(argv[2], O_RDWR, 0);
+
+	if (!strcmp(argv[1], "ioprio_write")) {
+		hint = F2FS_IOPRIO_WRITE;
+	} else {
+		fputs("Not supported hint\n\n", stderr);
+		fputs(cmd->cmd_help, stderr);
+		exit(1);
+	}
+
+	if (ioctl(fd, F2FS_IOC_IO_PRIO, &hint) != 0)
+		die_errno("ioprio failed");
+
+	printf("ioprio_hint %d to a file: %s\n", hint, argv[2]);
+	exit(0);
+}
+
 #define pinfile_desc "pin file control"
 #define pinfile_help						\
 "f2fs_io pinfile [get|set|unset] [file]\n\n"			\
@@ -1941,6 +1975,7 @@ const struct cmd_desc cmd_list[] = {
 	CMD(removexattr),
 	CMD(lseek),
 	CMD(get_advise),
+	CMD(ioprio),
 	{ NULL, NULL, NULL, NULL, 0 }
 };
 
diff --git a/tools/f2fs_io/f2fs_io.h b/tools/f2fs_io/f2fs_io.h
index 14c9dc1fda46..f2d0a0827ca5 100644
--- a/tools/f2fs_io/f2fs_io.h
+++ b/tools/f2fs_io/f2fs_io.h
@@ -94,6 +94,8 @@ typedef u32	__be32;
 #define F2FS_IOC_DECOMPRESS_FILE        _IO(F2FS_IOCTL_MAGIC, 23)
 #define F2FS_IOC_COMPRESS_FILE          _IO(F2FS_IOCTL_MAGIC, 24)
 #define F2FS_IOC_START_ATOMIC_REPLACE	_IO(F2FS_IOCTL_MAGIC, 25)
+#define F2FS_IOC_GET_DEV_ALIAS_FILE	_IOR(F2FS_IOCTL_MAGIC, 26, __u32)
+#define F2FS_IOC_IO_PRIO		_IOW(F2FS_IOCTL_MAGIC, 28, __u32)
 
 #ifndef FSCRYPT_POLICY_V1
 #define FSCRYPT_POLICY_V1		0
@@ -193,6 +195,11 @@ struct fsverity_enable_arg {
 #define FADVISE_VERITY_BIT	0x40
 #define FADVISE_TRUNC_BIT	0x80
 
+/* used for F2FS_IOC_IO_PRIO */
+enum {
+	F2FS_IOPRIO_WRITE = 1,  /* high write priority */
+};
+
 #ifndef FS_IMMUTABLE_FL
 #define FS_IMMUTABLE_FL			0x00000010 /* Immutable file */
 #endif
-- 
2.48.1.601.g30ceb7b040-goog



_______________________________________________
Linux-f2fs-devel mailing list
Linux-f2fs-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/linux-f2fs-devel

^ permalink raw reply related	[flat|nested] 4+ messages in thread

* [f2fs-dev] [PATCH 2/2] f2fs_io: add ioprio command to give a io priority hint
  2025-02-28 19:08 [f2fs-dev] [PATCH 1/2] f2fs_io: support fadvise dontneed, random, and noreuse Jaegeuk Kim via Linux-f2fs-devel
@ 2025-02-28 19:08 ` Jaegeuk Kim via Linux-f2fs-devel
  2025-03-03  3:18   ` Chao Yu via Linux-f2fs-devel
  0 siblings, 1 reply; 4+ messages in thread
From: Jaegeuk Kim via Linux-f2fs-devel @ 2025-02-28 19:08 UTC (permalink / raw)
  To: linux-f2fs-devel; +Cc: Jaegeuk Kim

This adds a command to call ioctl(F2FS_IOC_IO_PRIO).

Signed-off-by: Jaegeuk Kim <jaegeuk@kernel.org>
---
 man/f2fs_io.8           |  3 +++
 tools/f2fs_io/f2fs_io.c | 35 +++++++++++++++++++++++++++++++++++
 tools/f2fs_io/f2fs_io.h |  7 +++++++
 3 files changed, 45 insertions(+)

diff --git a/man/f2fs_io.8 b/man/f2fs_io.8
index 5def508e494f..b71965cf447a 100644
--- a/man/f2fs_io.8
+++ b/man/f2fs_io.8
@@ -181,6 +181,9 @@ Trigger gc to move data blocks from specified address range
 .TP
 \fBget_advise\fR \fI[file]\fR
 Get i_advise value and info in file
+.TP
+\fBioprio\fR \fI[hint] [file]\fR
+Set ioprio to the file. The ioprio can be ioprio_write.
 .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 05126c8b44a6..155d44f147ad 100644
--- a/tools/f2fs_io/f2fs_io.c
+++ b/tools/f2fs_io/f2fs_io.c
@@ -498,6 +498,40 @@ static void do_fadvise(int argc, char **argv, const struct cmd_desc *cmd)
 	exit(0);
 }
 
+#define ioprio_desc "ioprio"
+#define ioprio_help						\
+"f2fs_io ioprio [hint] [file]\n\n"				\
+"ioprio given the file\n"					\
+"hint can be\n"							\
+" ioprio_write\n"						\
+
+static void do_ioprio(int argc, char **argv, const struct cmd_desc *cmd)
+{
+	int fd, hint;
+
+	if (argc != 3) {
+		fputs("Excess arguments\n\n", stderr);
+		fputs(cmd->cmd_help, stderr);
+		exit(1);
+	}
+
+	fd = xopen(argv[2], O_RDWR, 0);
+
+	if (!strcmp(argv[1], "ioprio_write")) {
+		hint = F2FS_IOPRIO_WRITE;
+	} else {
+		fputs("Not supported hint\n\n", stderr);
+		fputs(cmd->cmd_help, stderr);
+		exit(1);
+	}
+
+	if (ioctl(fd, F2FS_IOC_IO_PRIO, &hint) != 0)
+		die_errno("ioprio failed");
+
+	printf("ioprio_hint %d to a file: %s\n", hint, argv[2]);
+	exit(0);
+}
+
 #define pinfile_desc "pin file control"
 #define pinfile_help						\
 "f2fs_io pinfile [get|set|unset] [file] {size}\n\n"		\
@@ -1966,6 +2000,7 @@ const struct cmd_desc cmd_list[] = {
 	CMD(removexattr),
 	CMD(lseek),
 	CMD(get_advise),
+	CMD(ioprio),
 	{ NULL, NULL, NULL, NULL, 0 }
 };
 
diff --git a/tools/f2fs_io/f2fs_io.h b/tools/f2fs_io/f2fs_io.h
index c32def72fe45..22102884faab 100644
--- a/tools/f2fs_io/f2fs_io.h
+++ b/tools/f2fs_io/f2fs_io.h
@@ -94,6 +94,8 @@ typedef u32	__be32;
 #define F2FS_IOC_DECOMPRESS_FILE        _IO(F2FS_IOCTL_MAGIC, 23)
 #define F2FS_IOC_COMPRESS_FILE          _IO(F2FS_IOCTL_MAGIC, 24)
 #define F2FS_IOC_START_ATOMIC_REPLACE	_IO(F2FS_IOCTL_MAGIC, 25)
+#define F2FS_IOC_GET_DEV_ALIAS_FILE	_IOR(F2FS_IOCTL_MAGIC, 26, __u32)
+#define F2FS_IOC_IO_PRIO		_IOW(F2FS_IOCTL_MAGIC, 28, __u32)
 
 #ifndef FSCRYPT_POLICY_V1
 #define FSCRYPT_POLICY_V1		0
@@ -193,6 +195,11 @@ struct fsverity_enable_arg {
 #define FADVISE_VERITY_BIT	0x40
 #define FADVISE_TRUNC_BIT	0x80
 
+/* used for F2FS_IOC_IO_PRIO */
+enum {
+	F2FS_IOPRIO_WRITE = 1,  /* high write priority */
+};
+
 #ifndef FS_IMMUTABLE_FL
 #define FS_IMMUTABLE_FL			0x00000010 /* Immutable file */
 #endif
-- 
2.48.1.711.g2feabab25a-goog



_______________________________________________
Linux-f2fs-devel mailing list
Linux-f2fs-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/linux-f2fs-devel

^ permalink raw reply related	[flat|nested] 4+ messages in thread

* Re: [f2fs-dev] [PATCH 2/2] f2fs_io: add ioprio command to give a io priority hint
  2025-02-28 19:08 ` [f2fs-dev] [PATCH 2/2] f2fs_io: add ioprio command to give a io priority hint Jaegeuk Kim via Linux-f2fs-devel
@ 2025-03-03  3:18   ` Chao Yu via Linux-f2fs-devel
  0 siblings, 0 replies; 4+ messages in thread
From: Chao Yu via Linux-f2fs-devel @ 2025-03-03  3:18 UTC (permalink / raw)
  To: Jaegeuk Kim, linux-f2fs-devel

On 3/1/25 03:08, Jaegeuk Kim via Linux-f2fs-devel wrote:
> This adds a command to call ioctl(F2FS_IOC_IO_PRIO).
> 
> Signed-off-by: Jaegeuk Kim <jaegeuk@kernel.org>

Reviewed-by: Chao Yu <chao@kernel.org>

Thanks,


_______________________________________________
Linux-f2fs-devel mailing list
Linux-f2fs-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/linux-f2fs-devel

^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2025-03-03  3:18 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2025-02-13 18:01 [f2fs-dev] [PATCH 1/2] f2fs_io: support fadvise dontneed, random, and noreuse Jaegeuk Kim via Linux-f2fs-devel
2025-02-13 18:01 ` [f2fs-dev] [PATCH 2/2] f2fs_io: add ioprio command to give a io priority hint Jaegeuk Kim via Linux-f2fs-devel
  -- strict thread matches above, loose matches on Subject: below --
2025-02-28 19:08 [f2fs-dev] [PATCH 1/2] f2fs_io: support fadvise dontneed, random, and noreuse Jaegeuk Kim via Linux-f2fs-devel
2025-02-28 19:08 ` [f2fs-dev] [PATCH 2/2] f2fs_io: add ioprio command to give a io priority hint Jaegeuk Kim via Linux-f2fs-devel
2025-03-03  3:18   ` Chao Yu via Linux-f2fs-devel

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.