* [PATCH v3] f2fs_io: add dev_alias command for dynamic device aliasing management
@ 2026-08-03 16:29 Daeho Jeong
2026-08-04 0:43 ` [f2fs-dev] " Chao Yu
0 siblings, 1 reply; 2+ messages in thread
From: Daeho Jeong @ 2026-08-03 16:29 UTC (permalink / raw)
To: linux-kernel, linux-f2fs-devel, kernel-team; +Cc: Daeho Jeong
From: Daeho Jeong <daehojeong@google.com>
This commit adds a new 'dev_alias' command to f2fs_io tool to support
dynamic release, reservation and status querying of device alias ranges.
Signed-off-by: Daeho Jeong <daehojeong@google.com>
---
v3: renamed the interfaces for dev_alias.
v2: remove a f2fs specific flag from getflags.
---
tools/f2fs_io/f2fs_io.c | 46 +++++++++++++++++++++++++++++++++++++++++
tools/f2fs_io/f2fs_io.h | 7 +++++++
2 files changed, 53 insertions(+)
diff --git a/tools/f2fs_io/f2fs_io.c b/tools/f2fs_io/f2fs_io.c
index c977f4d..1a219b8 100644
--- a/tools/f2fs_io/f2fs_io.c
+++ b/tools/f2fs_io/f2fs_io.c
@@ -2509,6 +2509,51 @@ static void do_test_lookup_perf(int argc, char **argv, const struct cmd_desc *cm
exit(0);
}
+#define dev_alias_desc "device alias control"
+#define dev_alias_help \
+"f2fs_io dev_alias [release|reserve|status] [file]\n\n" \
+"release, reserve or status a range of device alias given the file\n"
+
+static void do_dev_alias(int argc, char **argv, const struct cmd_desc *cmd)
+{
+ int fd, ret;
+
+ 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], "reserve")) {
+ ret = ioctl(fd, F2FS_IOC_RESERVE_DEV_ALIAS);
+ if (ret < 0)
+ die_errno("F2FS_IOC_RESERVE_DEV_ALIAS failed");
+ printf("%s device alias range of %s\n", argv[1], argv[2]);
+ } else if (!strcmp(argv[1], "release")) {
+ ret = ioctl(fd, F2FS_IOC_RELEASE_DEV_ALIAS);
+ if (ret < 0)
+ die_errno("F2FS_IOC_RELEASE_DEV_ALIAS failed");
+ printf("%s device alias range of %s\n", argv[1], argv[2]);
+ } else if (!strcmp(argv[1], "status")) {
+ u32 status = 0;
+
+ ret = ioctl(fd, F2FS_IOC_GET_DEV_ALIAS_STATUS, &status);
+ if (ret < 0)
+ die_errno("F2FS_IOC_GET_DEV_ALIAS_STATUS failed");
+
+ printf("device alias status of %s: %s\n", argv[2],
+ status == F2FS_DEV_ALIAS_STATUS_RESERVED ? "reserved" : "released");
+ } else {
+ fputs("Wrong request type\n\n", stderr);
+ fputs(cmd->cmd_help, stderr);
+ exit(1);
+ }
+
+ exit(0);
+}
+
#define freeze_desc "freeze filesystem"
#define freeze_help "f2fs_io freeze [directory_path]\n\n"
@@ -2603,6 +2648,7 @@ const struct cmd_desc cmd_list[] = {
CMD(get_advise),
CMD(ioprio),
CMD(ftruncate),
+ CMD(dev_alias),
CMD(test_create_perf),
CMD(test_lookup_perf),
CMD(freeze),
diff --git a/tools/f2fs_io/f2fs_io.h b/tools/f2fs_io/f2fs_io.h
index b0d4099..41387f2 100644
--- a/tools/f2fs_io/f2fs_io.h
+++ b/tools/f2fs_io/f2fs_io.h
@@ -96,6 +96,9 @@ typedef u32 __be32;
#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, 27, __u32)
+#define F2FS_IOC_RESERVE_DEV_ALIAS _IO(F2FS_IOCTL_MAGIC, 28)
+#define F2FS_IOC_RELEASE_DEV_ALIAS _IO(F2FS_IOCTL_MAGIC, 29)
+#define F2FS_IOC_GET_DEV_ALIAS_STATUS _IOR(F2FS_IOCTL_MAGIC, 30, __u32)
#ifndef FSCRYPT_POLICY_V1
#define FSCRYPT_POLICY_V1 0
@@ -200,6 +203,10 @@ enum {
F2FS_IOPRIO_WRITE = 1, /* high write priority */
};
+/* for F2FS_IOC_GET_DEV_ALIAS_STATUS */
+#define F2FS_DEV_ALIAS_STATUS_RELEASED 0
+#define F2FS_DEV_ALIAS_STATUS_RESERVED 1
+
#ifndef FS_IMMUTABLE_FL
#define FS_IMMUTABLE_FL 0x00000010 /* Immutable file */
#endif
--
2.55.0.571.g244d577d93-goog
^ permalink raw reply related [flat|nested] 2+ messages in thread
end of thread, other threads:[~2026-08-04 0:43 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-08-03 16:29 [PATCH v3] f2fs_io: add dev_alias command for dynamic device aliasing management Daeho Jeong
2026-08-04 0:43 ` [f2fs-dev] " Chao Yu
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox