From: Christoph Hellwig <hch@lst.de>
To: Zorro Lang <zlang@kernel.org>
Cc: "Darrick J. Wong" <djwong@kernel.org>,
Hans Holmberg <hans.holmberg@wdc.com>,
fstests@vger.kernel.org, linux-xfs@vger.kernel.org
Subject: [PATCH 02/15] add a new rw_hint helper
Date: Wed, 7 May 2025 07:12:22 +0200 [thread overview]
Message-ID: <20250507051249.3898395-3-hch@lst.de> (raw)
In-Reply-To: <20250507051249.3898395-1-hch@lst.de>
Add a tool to set the life time hint via fcntl.
Signed-off-by: Christoph Hellwig <hch@lst.de>
Reviewed-by: "Darrick J. Wong" <djwong@kernel.org>
---
.gitignore | 1 +
src/Makefile | 3 ++-
src/rw_hint.c | 48 ++++++++++++++++++++++++++++++++++++++++++++++++
3 files changed, 51 insertions(+), 1 deletion(-)
create mode 100644 src/rw_hint.c
diff --git a/.gitignore b/.gitignore
index 4fd817243dca..f22cff8fb6c4 100644
--- a/.gitignore
+++ b/.gitignore
@@ -203,6 +203,7 @@ tags
/src/aio-dio-regress/aio-last-ref-held-by-io
/src/aio-dio-regress/aiocp
/src/aio-dio-regress/aiodio_sparse2
+/src/rw_hint
/src/vfs/vfstest
/src/vfs/mount-idmapped
/src/log-writes/replay-log
diff --git a/src/Makefile b/src/Makefile
index 6ac72b366257..2cc1fb40d9f1 100644
--- a/src/Makefile
+++ b/src/Makefile
@@ -35,7 +35,8 @@ LINUX_TARGETS = xfsctl bstat t_mtab getdevicesize preallo_rw_pattern_reader \
attr_replace_test swapon mkswap t_attr_corruption t_open_tmpfiles \
fscrypt-crypt-util bulkstat_null_ocount splice-test chprojid_fail \
detached_mounts_propagation ext4_resize t_readdir_3 splice2pipe \
- uuid_ioctl t_snapshot_deleted_subvolume fiemap-fault min_dio_alignment
+ uuid_ioctl t_snapshot_deleted_subvolume fiemap-fault min_dio_alignment \
+ rw_hint
EXTRA_EXECS = dmerror fill2attr fill2fs fill2fs_check scaleread.sh \
btrfs_crc32c_forged_name.py popdir.pl popattr.py \
diff --git a/src/rw_hint.c b/src/rw_hint.c
new file mode 100644
index 000000000000..d4290e4ae369
--- /dev/null
+++ b/src/rw_hint.c
@@ -0,0 +1,48 @@
+// SPDX-License-Identifier: GPL-2.0
+/*
+ * Copyright (c) 2024 Christoph Hellwig
+ */
+#include <stdint.h>
+#include <stdio.h>
+#include <string.h>
+#include <fcntl.h>
+
+int main(int argc, char **argv)
+{
+ uint64_t hint = -1;
+ int fd;
+
+ if (argc < 3) {
+ fprintf(stderr,
+"usage: %s file not_set|none|short|medium|long|extreme\n",
+ argv[0]);
+ return 1;
+ }
+
+ if (!strcmp(argv[2], "not_set"))
+ hint = RWH_WRITE_LIFE_NOT_SET;
+ else if (!strcmp(argv[2], "none"))
+ hint = RWH_WRITE_LIFE_NONE;
+ else if (!strcmp(argv[2], "short"))
+ hint = RWH_WRITE_LIFE_SHORT;
+ else if (!strcmp(argv[2], "medium"))
+ hint = RWH_WRITE_LIFE_MEDIUM;
+ else if (!strcmp(argv[2], "long"))
+ hint = RWH_WRITE_LIFE_LONG;
+ else if (!strcmp(argv[2], "extreme"))
+ hint = RWH_WRITE_LIFE_EXTREME;
+
+ if (hint == -1) {
+ fprintf(stderr, "invalid hint %s\n", argv[2]);
+ return 1;
+ }
+
+ fd = open(argv[1], O_WRONLY);
+ if (fd < 0) {
+ perror("open");
+ return 1;
+ }
+ if (fcntl(fd, F_SET_RW_HINT, &hint))
+ perror("fcntl");
+ return 0;
+}
--
2.47.2
next prev parent reply other threads:[~2025-05-07 5:12 UTC|newest]
Thread overview: 17+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-05-07 5:12 new tests for zoned xfs v2 Christoph Hellwig
2025-05-07 5:12 ` [PATCH 01/15] common: add a _filter_rgno helper Christoph Hellwig
2025-05-07 21:06 ` Darrick J. Wong
2025-05-07 5:12 ` Christoph Hellwig [this message]
2025-05-07 5:12 ` [PATCH 03/15] xfs: add a test for zoned block accounting after remount Christoph Hellwig
2025-05-07 5:12 ` [PATCH 04/15] xfs: add a zoned growfs test Christoph Hellwig
2025-05-07 5:12 ` [PATCH 05/15] xfs: add test to check for block layer reordering Christoph Hellwig
2025-05-07 5:12 ` [PATCH 06/15] xfs: add a test to check that data growfs fails with internal rt device Christoph Hellwig
2025-05-07 5:12 ` [PATCH 07/15] xfs: add a test for write lifetime hints Christoph Hellwig
2025-05-07 5:12 ` [PATCH 08/15] xfs: add a test for writeback after close Christoph Hellwig
2025-05-07 5:12 ` [PATCH 09/15] xfs: test zone stream separation for two direct writers Christoph Hellwig
2025-05-07 5:12 ` [PATCH 10/15] xfs: test zone stream separation for two buffered writers Christoph Hellwig
2025-05-07 5:12 ` [PATCH 11/15] xfs: test zoned ENOSPC behavior with multiple writers Christoph Hellwig
2025-05-07 5:12 ` [PATCH 12/15] xfs: test zoned GC file defragmentation for sequential writers Christoph Hellwig
2025-05-07 5:12 ` [PATCH 13/15] xfs: test zoned GC file defragmentation for random writers Christoph Hellwig
2025-05-07 5:12 ` [PATCH 14/15] xfs: test that xfs_repair does not mess up the zone used counter Christoph Hellwig
2025-05-07 5:12 ` [PATCH 15/15] xfs: test that truncate does not spuriously return ENOSPC Christoph Hellwig
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=20250507051249.3898395-3-hch@lst.de \
--to=hch@lst.de \
--cc=djwong@kernel.org \
--cc=fstests@vger.kernel.org \
--cc=hans.holmberg@wdc.com \
--cc=linux-xfs@vger.kernel.org \
--cc=zlang@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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).