From: Jaegeuk Kim via Linux-f2fs-devel <linux-f2fs-devel@lists.sourceforge.net>
To: linux-f2fs-devel@lists.sourceforge.net
Subject: Re: [f2fs-dev] [PATCH 1/2 v2] f2fs_io: support xattr(large_folio)
Date: Fri, 8 May 2026 19:23:19 +0000 [thread overview]
Message-ID: <af44Jz7JO2ZC502T@google.com> (raw)
In-Reply-To: <20260409134630.3693274-1-jaegeuk@kernel.org>
[Script]
dd if=/dev/zero of=/mnt/test/test bs=1M count=1024
f2fs_io setxattr user.fadvise 1 /mnt/test/test
chmod 0400 /mnt/test/test
sync -f /mnt/test/test
echo 3 > /proc/sys/vm/drop_caches
f2fs_io read 1 0 100000 mmap 0 1 /mnt/test/test
f2fs_io get_fadvise /mnt/test/test
[Output]
1024+0 records in
1024+0 records out
1073741824 bytes (1.1 GB, 1.0 GiB) copied, 0.520712 s, 2.1 GB/s
setxattr /mnt/test/test CREATE: name: user.fadvise, value: 1: ret=0
Read 409600000 bytes total_time = 106757 us, BW = 4286 MB/s, IO time = 95577 us, mlock time = 11173 us, print 1 bytes:
00000000 : 00
fadvise=0x1, advise_type: largefolio
Reviewed-by: Daeho Jeong <daehojeong@google.com>
Signed-off-by: Jaegeuk Kim <jaegeuk@kernel.org>
---
man/f2fs_io.8 | 8 ++++++++
tools/f2fs_io/f2fs_io.c | 32 ++++++++++++++++++++++++++++++++
tools/f2fs_io/f2fs_io.h | 6 ++++++
3 files changed, 46 insertions(+)
diff --git a/man/f2fs_io.8 b/man/f2fs_io.8
index 51ccfaf238cb..81608aa0f655 100644
--- a/man/f2fs_io.8
+++ b/man/f2fs_io.8
@@ -53,10 +53,18 @@ going down with fsck mark
\fBpinfile\fR \fI[get|set|unset] [file]\fR
Get or set the pinning status on a file.
.TP
+\fBsetxattr\fR \fI[name] [value] [file]\fR
+Call setxattr to the file. The supported
+.I name
+are system.advise and user.fadvise.
+.TP
\fBfadvise\fR \fI[advice] [offset] [length] [file]\fR
Pass an advice to the specified file. The advice can be willneed, dontneed,
noreuse, sequential, random.
.TP
+\fBget_fadvise\fR \fI[file]\fR
+Show the activated fadvise flags.
+.TP
\fBfallocate\fR \fI[-c] [-i] [-p] [-z] [keep_size] [offset] [length] [file]\fR
Request that space be allocated on a file. The
.I keep_size
diff --git a/tools/f2fs_io/f2fs_io.c b/tools/f2fs_io/f2fs_io.c
index 680c06218394..8b9f9ef22eef 100644
--- a/tools/f2fs_io/f2fs_io.c
+++ b/tools/f2fs_io/f2fs_io.c
@@ -2084,6 +2084,7 @@ static void do_setxattr(int argc, char **argv, const struct cmd_desc *cmd)
int ret, len;
char *value;
unsigned char tmp;
+ unsigned int tmp_u;
if (argc != 4) {
fputs("Excess arguments\n\n", stderr);
@@ -2095,6 +2096,10 @@ static void do_setxattr(int argc, char **argv, const struct cmd_desc *cmd)
tmp = strtoul(argv[2], NULL, 0);
value = (char *)&tmp;
len = 1;
+ } else if (!strcmp(argv[1], F2FS_USER_FADVISE_NAME)) {
+ tmp_u = strtoul(argv[2], NULL, 0);
+ value = (char *)&tmp_u;
+ len = sizeof(unsigned int);
} else {
value = argv[2];
len = strlen(value);
@@ -2217,6 +2222,32 @@ static void do_get_advise(int argc, char **argv, const struct cmd_desc *cmd)
printf("\n");
}
+#define get_fadvise_desc "get_fadvise"
+#define get_fadvise_help "f2fs_io get_fadvise [file_path]\n\n"
+
+static void do_get_fadvise(int argc, char **argv, const struct cmd_desc *cmd)
+{
+ int ret;
+ unsigned int value;
+
+ if (argc != 2) {
+ fputs("Excess arguments\n\n", stderr);
+ fputs(cmd->cmd_help, stderr);
+ exit(1);
+ }
+
+ ret = getxattr(argv[1], F2FS_USER_FADVISE_NAME, &value, sizeof(value));
+ if (ret != sizeof(value)) {
+ perror("getxattr");
+ exit(1);
+ }
+
+ printf("fadvise=0x%x, advise_type: ", value);
+ if (value & (1 << F2FS_XATTR_FADV_LARGEFOLIO))
+ printf("largefolio");
+ printf("\n");
+}
+
#define ftruncate_desc "ftruncate a file"
#define ftruncate_help \
"f2fs_io ftruncate [length] [file_path]\n\n" \
@@ -2626,6 +2657,7 @@ const struct cmd_desc cmd_list[] = {
CMD(removexattr),
CMD(lseek),
CMD(get_advise),
+ CMD(get_fadvise),
CMD(ioprio),
CMD(ftruncate),
CMD(test_create_perf),
diff --git a/tools/f2fs_io/f2fs_io.h b/tools/f2fs_io/f2fs_io.h
index b0d40996f302..539964fc27d3 100644
--- a/tools/f2fs_io/f2fs_io.h
+++ b/tools/f2fs_io/f2fs_io.h
@@ -186,6 +186,7 @@ struct fsverity_enable_arg {
#define F2FS_IOC_FSSETXATTR FS_IOC_FSSETXATTR
#define F2FS_SYSTEM_ADVISE_NAME "system.advise"
+#define F2FS_USER_FADVISE_NAME "user.fadvise"
#define FADVISE_COLD_BIT 0x01
#define FADVISE_LOST_PINO_BIT 0x02
#define FADVISE_ENCRYPT_BIT 0x04
@@ -195,6 +196,11 @@ struct fsverity_enable_arg {
#define FADVISE_VERITY_BIT 0x40
#define FADVISE_TRUNC_BIT 0x80
+/* used for F2FS_USER_FADVISE_NAME */
+enum {
+ F2FS_XATTR_FADV_LARGEFOLIO,
+};
+
/* used for F2FS_IOC_IO_PRIO */
enum {
F2FS_IOPRIO_WRITE = 1, /* high write priority */
--
2.54.0.563.g4f69b47b94-goog
_______________________________________________
Linux-f2fs-devel mailing list
Linux-f2fs-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/linux-f2fs-devel
next prev parent reply other threads:[~2026-05-08 19:23 UTC|newest]
Thread overview: 10+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-04-09 13:46 [f2fs-dev] [PATCH 1/2] f2fs_io: support xattr(large_folio) Jaegeuk Kim via Linux-f2fs-devel
2026-04-09 13:46 ` [f2fs-dev] [PATCH 2/2] f2fs_io: user O_RDONLY for fadvise Jaegeuk Kim via Linux-f2fs-devel
2026-05-01 14:02 ` Daeho Jeong
2026-05-03 8:55 ` Chao Yu via Linux-f2fs-devel
2026-05-08 19:12 ` [f2fs-dev] [PATCH 2/2 v2] f2fs_io: use " Jaegeuk Kim via Linux-f2fs-devel
2026-05-09 8:32 ` Chao Yu via Linux-f2fs-devel
2026-05-01 14:12 ` [f2fs-dev] [PATCH 1/2] f2fs_io: support xattr(large_folio) Daeho Jeong
2026-05-03 8:53 ` Chao Yu via Linux-f2fs-devel
2026-05-08 19:23 ` Jaegeuk Kim via Linux-f2fs-devel [this message]
2026-05-09 8:32 ` [f2fs-dev] [PATCH 1/2 v2] " Chao Yu via Linux-f2fs-devel
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=af44Jz7JO2ZC502T@google.com \
--to=linux-f2fs-devel@lists.sourceforge.net \
--cc=jaegeuk@kernel.org \
/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 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.