[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <176169810743.1424854.229610268963069051.stgit@frogsfrogsfrogs>
Date: Tue, 28 Oct 2025 17:49:38 -0700
From: "Darrick J. Wong" <djwong@...nel.org>
To: djwong@...nel.org, miklos@...redi.hu
Cc: joannelkoong@...il.com, bernd@...ernd.com, neal@...pa.dev,
linux-ext4@...r.kernel.org, linux-fsdevel@...r.kernel.org
Subject: [PATCH 18/31] fuse: advertise support for iomap
From: Darrick J. Wong <djwong@...nel.org>
Advertise our new IO paths programmatically by creating an ioctl that
can return the capabilities of the kernel.
Signed-off-by: "Darrick J. Wong" <djwong@...nel.org>
---
fs/fuse/fuse_i.h | 4 ++++
include/uapi/linux/fuse.h | 9 +++++++++
fs/fuse/dev.c | 3 +++
fs/fuse/file_iomap.c | 13 +++++++++++++
4 files changed, 29 insertions(+)
diff --git a/fs/fuse/fuse_i.h b/fs/fuse/fuse_i.h
index 5451b0a2b3dc19..590c0fa6763d1e 100644
--- a/fs/fuse/fuse_i.h
+++ b/fs/fuse/fuse_i.h
@@ -1784,6 +1784,9 @@ int fuse_iomap_fallocate(struct file *file, int mode, loff_t offset,
loff_t length, loff_t new_size);
int fuse_iomap_flush_unmap_range(struct inode *inode, loff_t pos,
loff_t endpos);
+
+int fuse_dev_ioctl_iomap_support(struct file *file,
+ struct fuse_iomap_support __user *argp);
#else
# define fuse_iomap_enabled(...) (false)
# define fuse_has_iomap(...) (false)
@@ -1807,6 +1810,7 @@ int fuse_iomap_flush_unmap_range(struct inode *inode, loff_t pos,
# define fuse_iomap_setsize_start(...) (-ENOSYS)
# define fuse_iomap_fallocate(...) (-ENOSYS)
# define fuse_iomap_flush_unmap_range(...) (-ENOSYS)
+# define fuse_dev_ioctl_iomap_support(...) (-EOPNOTSUPP)
#endif
#endif /* _FS_FUSE_I_H */
diff --git a/include/uapi/linux/fuse.h b/include/uapi/linux/fuse.h
index e02c474ed04bc2..c798aaa6d60884 100644
--- a/include/uapi/linux/fuse.h
+++ b/include/uapi/linux/fuse.h
@@ -1151,6 +1151,13 @@ struct fuse_backing_map {
uint64_t padding;
};
+/* basic file I/O functionality through iomap */
+#define FUSE_IOMAP_SUPPORT_FILEIO (1ULL << 0)
+struct fuse_iomap_support {
+ uint64_t flags;
+ uint64_t padding;
+};
+
/* Device ioctls: */
#define FUSE_DEV_IOC_MAGIC 229
#define FUSE_DEV_IOC_CLONE _IOR(FUSE_DEV_IOC_MAGIC, 0, uint32_t)
@@ -1158,6 +1165,8 @@ struct fuse_backing_map {
struct fuse_backing_map)
#define FUSE_DEV_IOC_BACKING_CLOSE _IOW(FUSE_DEV_IOC_MAGIC, 2, uint32_t)
#define FUSE_DEV_IOC_SYNC_INIT _IO(FUSE_DEV_IOC_MAGIC, 3)
+#define FUSE_DEV_IOC_IOMAP_SUPPORT _IOR(FUSE_DEV_IOC_MAGIC, 99, \
+ struct fuse_iomap_support)
struct fuse_lseek_in {
uint64_t fh;
diff --git a/fs/fuse/dev.c b/fs/fuse/dev.c
index 12cc673df99151..7aa7bf2f8348d2 100644
--- a/fs/fuse/dev.c
+++ b/fs/fuse/dev.c
@@ -2719,6 +2719,9 @@ static long fuse_dev_ioctl(struct file *file, unsigned int cmd,
case FUSE_DEV_IOC_SYNC_INIT:
return fuse_dev_ioctl_sync_init(file);
+ case FUSE_DEV_IOC_IOMAP_SUPPORT:
+ return fuse_dev_ioctl_iomap_support(file, argp);
+
default:
return -ENOTTY;
}
diff --git a/fs/fuse/file_iomap.c b/fs/fuse/file_iomap.c
index a9bacaa0991afa..21f7227c351b89 100644
--- a/fs/fuse/file_iomap.c
+++ b/fs/fuse/file_iomap.c
@@ -1716,3 +1716,16 @@ fuse_iomap_fallocate(
file_update_time(file);
return 0;
}
+
+int fuse_dev_ioctl_iomap_support(struct file *file,
+ struct fuse_iomap_support __user *argp)
+{
+ struct fuse_iomap_support ios = { };
+
+ if (fuse_iomap_enabled())
+ ios.flags = FUSE_IOMAP_SUPPORT_FILEIO;
+
+ if (copy_to_user(argp, &ios, sizeof(ios)))
+ return -EFAULT;
+ return 0;
+}
Powered by blists - more mailing lists