[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <175798161954.390496.13517440154976780084.stgit@frogsfrogsfrogs>
Date: Mon, 15 Sep 2025 18:02:08 -0700
From: "Darrick J. Wong" <djwong@...nel.org>
To: tytso@....edu
Cc: miklos@...redi.hu, neal@...pa.dev, linux-fsdevel@...r.kernel.org,
linux-ext4@...r.kernel.org, John@...ves.net, bernd@...ernd.com,
joannelkoong@...il.com
Subject: [PATCH 13/17] fuse2fs: set iomap-related inode flags
From: Darrick J. Wong <djwong@...nel.org>
Set FUSE_IFLAG_* when we do a getattr, so that all files will have iomap
enabled.
Signed-off-by: "Darrick J. Wong" <djwong@...nel.org>
---
fuse4fs/fuse4fs.c | 46 +++++++++++++++++++++++++++++++++++-----------
misc/fuse2fs.c | 20 ++++++++++++++++++++
2 files changed, 55 insertions(+), 11 deletions(-)
diff --git a/fuse4fs/fuse4fs.c b/fuse4fs/fuse4fs.c
index 47ad8215c3e1d1..37999d864a05e5 100644
--- a/fuse4fs/fuse4fs.c
+++ b/fuse4fs/fuse4fs.c
@@ -1685,6 +1685,7 @@ static void op_init(void *userdata, struct fuse_conn_info *conn)
struct fuse4fs_stat {
struct fuse_entry_param entry;
+ unsigned int iflags;
};
static int fuse4fs_stat_inode(struct fuse4fs *ff, ext2_ino_t ino,
@@ -1750,9 +1751,29 @@ static int fuse4fs_stat_inode(struct fuse4fs *ff, ext2_ino_t ino,
entry->attr_timeout = FUSE4FS_ATTR_TIMEOUT;
entry->entry_timeout = FUSE4FS_ATTR_TIMEOUT;
+ fstat->iflags = 0;
+#ifdef HAVE_FUSE_IOMAP
+ if (fuse4fs_iomap_enabled(ff))
+ fstat->iflags |= FUSE_IFLAG_IOMAP;
+#endif
+
return 0;
}
+#if FUSE_VERSION < FUSE_MAKE_VERSION(3, 99)
+#define fuse_reply_entry_iflags(req, entry, iflags) \
+ fuse_reply_entry((req), (entry))
+
+#define fuse_reply_attr_iflags(req, entry, iflags, timeout) \
+ fuse_reply_attr((req), (entry), (timeout))
+
+#define fuse_add_direntry_plus_iflags(req, buf, sz, name, iflags, entry, dirpos) \
+ fuse_add_direntry_plus((req), (buf), (sz), (name), (entry), (dirpos))
+
+#define fuse_reply_create_iflags(req, entry, iflags, fp) \
+ fuse_reply_create((req), (entry), (fp))
+#endif
+
static void op_lookup(fuse_req_t req, fuse_ino_t fino, const char *name)
{
struct fuse4fs_stat fstat;
@@ -1783,7 +1804,7 @@ static void op_lookup(fuse_req_t req, fuse_ino_t fino, const char *name)
if (ret)
fuse_reply_err(req, -ret);
else
- fuse_reply_entry(req, &fstat.entry);
+ fuse_reply_entry_iflags(req, &fstat.entry, fstat.iflags);
}
static void op_getattr(fuse_req_t req, fuse_ino_t fino,
@@ -1803,8 +1824,8 @@ static void op_getattr(fuse_req_t req, fuse_ino_t fino,
if (ret)
fuse_reply_err(req, -ret);
else
- fuse_reply_attr(req, &fstat.entry.attr,
- fstat.entry.attr_timeout);
+ fuse_reply_attr_iflags(req, &fstat.entry.attr, fstat.iflags,
+ fstat.entry.attr_timeout);
}
static void op_readlink(fuse_req_t req, fuse_ino_t fino)
@@ -2082,7 +2103,7 @@ static void fuse4fs_reply_entry(fuse_req_t req, ext2_ino_t ino,
return;
}
- fuse_reply_entry(req, &fstat.entry);
+ fuse_reply_entry_iflags(req, &fstat.entry, fstat.iflags);
}
static void op_mknod(fuse_req_t req, fuse_ino_t fino, const char *name,
@@ -4352,10 +4373,13 @@ static int op_readdir_iter(ext2_ino_t dir EXT2FS_ATTR((unused)),
namebuf[dirent->name_len & 0xFF] = 0;
if (i->readdirplus) {
- entrysize = fuse_add_direntry_plus(i->req, i->buf + i->bufused,
- i->bufsz - i->bufused,
- namebuf, &fstat.entry,
- i->dirpos);
+ entrysize = fuse_add_direntry_plus_iflags(i->req,
+ i->buf + i->bufused,
+ i->bufsz - i->bufused,
+ namebuf,
+ fstat.iflags,
+ &fstat.entry,
+ i->dirpos);
} else {
entrysize = fuse_add_direntry(i->req, i->buf + i->bufused,
i->bufsz - i->bufused, namebuf,
@@ -4580,7 +4604,7 @@ static void op_create(fuse_req_t req, fuse_ino_t fino, const char *name,
if (ret)
fuse_reply_err(req, -ret);
else
- fuse_reply_create(req, &fstat.entry, fp);
+ fuse_reply_create_iflags(req, &fstat.entry, fstat.iflags, fp);
}
#if FUSE_VERSION >= FUSE_MAKE_VERSION(3, 17)
@@ -4779,8 +4803,8 @@ static void op_setattr(fuse_req_t req, fuse_ino_t fino, struct stat *attr,
if (ret)
fuse_reply_err(req, -ret);
else
- fuse_reply_attr(req, &fstat.entry.attr,
- fstat.entry.attr_timeout);
+ fuse_reply_attr_iflags(req, &fstat.entry.attr, fstat.iflags,
+ fstat.entry.attr_timeout);
}
#define FUSE4FS_MODIFIABLE_IFLAGS \
diff --git a/misc/fuse2fs.c b/misc/fuse2fs.c
index 5dc0b0606112af..32fcada0426752 100644
--- a/misc/fuse2fs.c
+++ b/misc/fuse2fs.c
@@ -1619,6 +1619,23 @@ static int op_getattr(const char *path, struct stat *statbuf,
return ret;
}
+#if FUSE_VERSION >= FUSE_MAKE_VERSION(3, 99)
+static int op_getattr_iflags(const char *path, struct stat *statbuf,
+ unsigned int *iflags, struct fuse_file_info *fi)
+{
+ int ret = op_getattr(path, statbuf, fi);
+
+ if (ret)
+ return ret;
+
+ if (fuse_fs_can_enable_iomap(statbuf))
+ *iflags |= FUSE_IFLAG_IOMAP;
+
+ return 0;
+}
+#endif
+
+
static int op_readlink(const char *path, char *buf, size_t len)
{
struct fuse2fs *ff = fuse2fs_get();
@@ -6238,6 +6255,9 @@ static struct fuse_operations fs_ops = {
#ifdef SUPPORT_FALLOCATE
.fallocate = op_fallocate,
#endif
+#if FUSE_VERSION >= FUSE_MAKE_VERSION(3, 99)
+ .getattr_iflags = op_getattr_iflags,
+#endif
#ifdef HAVE_FUSE_IOMAP
.iomap_begin = op_iomap_begin,
.iomap_end = op_iomap_end,
Powered by blists - more mailing lists