[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <176169818405.1430380.11194212025654719284.stgit@frogsfrogsfrogs>
Date: Tue, 28 Oct 2025 18:15:59 -0700
From: "Darrick J. Wong" <djwong@...nel.org>
To: tytso@....edu
Cc: linux-fsdevel@...r.kernel.org, joannelkoong@...il.com, bernd@...ernd.com,
neal@...pa.dev, miklos@...redi.hu, linux-ext4@...r.kernel.org
Subject: [PATCH 10/11] fuse2fs: set sync, immutable,
and append at file load time
From: Darrick J. Wong <djwong@...nel.org>
Convey these three inode flags to the kernel when we're loading a file.
This way the kernel can advertise and enforce those flags so that the
fuse server doesn't have to.
Signed-off-by: "Darrick J. Wong" <djwong@...nel.org>
---
fuse4fs/fuse4fs.c | 16 ++++++++++++++++
misc/fuse2fs.c | 53 ++++++++++++++++++++++++++++++++++++++---------------
2 files changed, 54 insertions(+), 15 deletions(-)
diff --git a/fuse4fs/fuse4fs.c b/fuse4fs/fuse4fs.c
index e6a96717dfe415..e08e127eb03563 100644
--- a/fuse4fs/fuse4fs.c
+++ b/fuse4fs/fuse4fs.c
@@ -2159,6 +2159,22 @@ static int fuse4fs_stat_inode(struct fuse4fs *ff, ext2_ino_t ino,
entry->entry_timeout = FUSE4FS_ATTR_TIMEOUT;
fstat->iflags = 0;
+
+#ifdef FUSE_IFLAG_SYNC
+ if (inodep->i_flags & EXT2_SYNC_FL)
+ fstat->iflags |= FUSE_IFLAG_SYNC;
+#endif
+
+#ifdef FUSE_IFLAG_IMMUTABLE
+ if (inodep->i_flags & EXT2_IMMUTABLE_FL)
+ fstat->iflags |= FUSE_IFLAG_IMMUTABLE;
+#endif
+
+#ifdef FUSE_IFLAG_APPEND
+ if (inodep->i_flags & EXT2_APPEND_FL)
+ fstat->iflags |= FUSE_IFLAG_APPEND;
+#endif
+
#ifdef HAVE_FUSE_IOMAP
if (fuse4fs_iomap_enabled(ff)) {
fstat->iflags |= FUSE_IFLAG_IOMAP;
diff --git a/misc/fuse2fs.c b/misc/fuse2fs.c
index 91b48f5d68b0db..c0e8fa35dcf8ed 100644
--- a/misc/fuse2fs.c
+++ b/misc/fuse2fs.c
@@ -1944,7 +1944,7 @@ static void *op_init(struct fuse_conn_info *conn,
}
static int fuse2fs_stat(struct fuse2fs *ff, ext2_ino_t ino,
- struct stat *statbuf)
+ struct stat *statbuf, unsigned int *iflags)
{
struct ext2_inode_large inode;
ext2_filsys fs = ff->fs;
@@ -2001,6 +2001,7 @@ static int fuse2fs_stat(struct fuse2fs *ff, ext2_ino_t ino,
statbuf->st_rdev = inode.i_block[1];
}
+ *iflags = inode.i_flags;
return ret;
}
@@ -2035,22 +2036,31 @@ static int __fuse2fs_file_ino(struct fuse2fs *ff, const char *path,
# define fuse2fs_file_ino(ff, path, fp, inop) \
__fuse2fs_file_ino((ff), (path), (fp), (inop), __func__, __LINE__)
+static int fuse2fs_getattr(struct fuse2fs *ff, const char *path,
+ struct stat *statbuf, struct fuse_file_info *fi,
+ unsigned int *iflags)
+{
+ ext2_ino_t ino;
+ int ret = 0;
+
+ FUSE2FS_CHECK_CONTEXT(ff);
+ fuse2fs_start(ff);
+ ret = fuse2fs_file_ino(ff, path, fi, &ino);
+ if (ret)
+ goto out;
+ ret = fuse2fs_stat(ff, ino, statbuf, iflags);
+out:
+ fuse2fs_finish(ff, ret);
+ return ret;
+}
+
static int op_getattr(const char *path, struct stat *statbuf,
struct fuse_file_info *fi)
{
struct fuse2fs *ff = fuse2fs_get();
- ext2_ino_t ino;
- int ret = 0;
+ unsigned int dontcare;
- FUSE2FS_CHECK_CONTEXT(ff);
- fuse2fs_start(ff);
- ret = fuse2fs_file_ino(ff, path, fi, &ino);
- if (ret)
- goto out;
- ret = fuse2fs_stat(ff, ino, statbuf);
-out:
- fuse2fs_finish(ff, ret);
- return ret;
+ return fuse2fs_getattr(ff, path, statbuf, fi, &dontcare);
}
#if FUSE_VERSION >= FUSE_MAKE_VERSION(3, 99)
@@ -2058,11 +2068,21 @@ static int op_getattr_iflags(const char *path, struct stat *statbuf,
unsigned int *iflags, struct fuse_file_info *fi)
{
struct fuse2fs *ff = fuse2fs_get();
- int ret = op_getattr(path, statbuf, fi);
+ unsigned int i_flags;
+ int ret = fuse2fs_getattr(ff, path, statbuf, fi, &i_flags);
if (ret)
return ret;
+ if (i_flags & EXT2_SYNC_FL)
+ *iflags |= FUSE_IFLAG_SYNC;
+
+ if (i_flags & EXT2_IMMUTABLE_FL)
+ *iflags |= FUSE_IFLAG_IMMUTABLE;
+
+ if (i_flags & EXT2_APPEND_FL)
+ *iflags |= FUSE_IFLAG_APPEND;
+
if (fuse_fs_can_enable_iomap(statbuf)) {
*iflags |= FUSE_IFLAG_IOMAP;
@@ -3832,12 +3852,13 @@ static int fuse2fs_punch_posteof(struct fuse2fs *ff, ext2_ino_t ino,
static int fuse2fs_file_uses_iomap(struct fuse2fs *ff, ext2_ino_t ino)
{
struct stat statbuf;
+ unsigned int dontcare;
int ret;
if (!fuse2fs_iomap_enabled(ff))
return 0;
- ret = fuse2fs_stat(ff, ino, &statbuf);
+ ret = fuse2fs_stat(ff, ino, &statbuf, &dontcare);
if (ret)
return ret;
@@ -4739,7 +4760,9 @@ static int op_readdir_iter(ext2_ino_t dir EXT2FS_ATTR((unused)),
(unsigned long long)i->dirpos);
if (i->flags == FUSE_READDIR_PLUS) {
- ret = fuse2fs_stat(i->ff, dirent->inode, &stat);
+ unsigned int dontcare;
+
+ ret = fuse2fs_stat(i->ff, dirent->inode, &stat, &dontcare);
if (ret)
return DIRENT_ABORT;
}
Powered by blists - more mailing lists