[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <175798162522.391272.2262955147071484342.stgit@frogsfrogsfrogs>
Date: Mon, 15 Sep 2025 18:06:02 -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 10/10] 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 | 10 ++++++++++
misc/fuse2fs.c | 53 ++++++++++++++++++++++++++++++++++++++---------------
2 files changed, 48 insertions(+), 15 deletions(-)
diff --git a/fuse4fs/fuse4fs.c b/fuse4fs/fuse4fs.c
index 4f5618e64a93c3..a7709a7e6fb699 100644
--- a/fuse4fs/fuse4fs.c
+++ b/fuse4fs/fuse4fs.c
@@ -1800,6 +1800,16 @@ static int fuse4fs_stat_inode(struct fuse4fs *ff, ext2_ino_t ino,
entry->entry_timeout = FUSE4FS_ATTR_TIMEOUT;
fstat->iflags = 0;
+
+ if (inodep->i_flags & EXT2_SYNC_FL)
+ fstat->iflags |= FUSE_IFLAG_SYNC;
+
+ if (inodep->i_flags & EXT2_IMMUTABLE_FL)
+ fstat->iflags |= FUSE_IFLAG_IMMUTABLE;
+
+ if (inodep->i_flags & EXT2_APPEND_FL)
+ fstat->iflags |= FUSE_IFLAG_APPEND;
+
#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 b193e0b2c06b69..260d1b77e3f24b 100644
--- a/misc/fuse2fs.c
+++ b/misc/fuse2fs.c
@@ -1584,7 +1584,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;
@@ -1641,6 +1641,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;
}
@@ -1675,22 +1676,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)
@@ -1698,11 +1708,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_IMMUTABLE_FL)
+ *iflags |= FUSE_IFLAG_IMMUTABLE;
+
+ if (i_flags & EXT2_SYNC_FL)
+ *iflags |= FUSE_IFLAG_SYNC;
+
+ if (i_flags & EXT2_APPEND_FL)
+ *iflags |= FUSE_IFLAG_APPEND;
+
if (fuse_fs_can_enable_iomap(statbuf)) {
*iflags |= FUSE_IFLAG_IOMAP;
@@ -3415,12 +3435,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;
@@ -4322,7 +4343,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