[PATCH 01/10] fuse2fs: add strictatime/lazytime mount options

Darrick J. Wong
2025-09-16T01:03:42Z

In iomap mode, we can support the strictatime/lazytime mount options.
Add them to fuse2fs.

Signed-off-by: "Darrick J. Wong" <djwong@kernel.org>
---
fuse4fs/fuse4fs.1.in | 6 ++++++
fuse4fs/fuse4fs.c | 28 ++++++++++++++++++++++++++++
misc/fuse2fs.1.in | 6 ++++++
misc/fuse2fs.c | 28 ++++++++++++++++++++++++++++
4 files changed, 68 insertions(+)

diff --git a/fuse4fs/fuse4fs.1.in b/fuse4fs/fuse4fs.1.in
index 8855867d27101d..119cbcc903d8af 100644
--- a/fuse4fs/fuse4fs.1.in
+++ b/fuse4fs/fuse4fs.1.in
@@ -90,6 +90,9 @@ .SS "fuse4fs options:"
.I nosuid
) later.
.TP
+\fB-o\fR lazytime
+if iomap is enabled, enable lazy updates of timestamps
+.TP
\fB-o\fR lockfile=path
use this file to control access to the filesystem
.TP
@@ -98,6 +101,9 @@ .SS "fuse4fs options:"
.TP
\fB-o\fR norecovery
do not replay the journal and mount the file system read-only
+.TP
+\fB-o\fR strictatime
+if iomap is enabled, update atime on every access
.SS "FUSE options:"
.TP
\fB-d -o\fR debug
diff --git a/fuse4fs/fuse4fs.c b/fuse4fs/fuse4fs.c
index 3be19f59fc3976..bc2cf41085695f 100644
--- a/fuse4fs/fuse4fs.c
+++ b/fuse4fs/fuse4fs.c
@@ -267,6 +267,7 @@ struct fuse4fs {
int unmount_in_destroy;
int noblkdev;
int translate_inums;
+ int iomap_passthrough_options;

enum fuse4fs_opstate opstate;
int logfd;
@@ -1648,6 +1649,8 @@ static void fuse4fs_iomap_enable(struct fuse_conn_info *conn,
if (!fuse4fs_iomap_enabled(ff)) {
if (ff->iomap_want == FT_ENABLE)
err_printf(ff, "%s\n", _("Could not enable iomap."));
+ if (ff->iomap_passthrough_options)
+ err_printf(ff, "%s\n", _("Some mount options require iomap."));
return;
}
}
@@ -7070,6 +7073,7 @@ enum {
FUSE4FS_ERRORS_BEHAVIOR,
#ifdef HAVE_FUSE_IOMAP
FUSE4FS_IOMAP,
+ FUSE4FS_IOMAP_PASSTHROUGH,
#endif
};

@@ -7096,6 +7100,17 @@ static struct fuse_opt fuse4fs_opts[] = {
#endif
FUSE4FS_OPT("noblkdev", noblkdev, 1),

+#ifdef HAVE_FUSE_IOMAP
+#ifdef MS_LAZYTIME
+ FUSE_OPT_KEY("lazytime", FUSE4FS_IOMAP_PASSTHROUGH),
+ FUSE_OPT_KEY("nolazytime", FUSE4FS_IOMAP_PASSTHROUGH),
+#endif
+#ifdef MS_STRICTATIME
+ FUSE_OPT_KEY("strictatime", FUSE4FS_IOMAP_PASSTHROUGH),
+ FUSE_OPT_KEY("nostrictatime", FUSE4FS_IOMAP_PASSTHROUGH),
+#endif
+#endif
+
FUSE_OPT_KEY("user_xattr", FUSE4FS_IGNORED),
FUSE_OPT_KEY("noblock_validity", FUSE4FS_IGNORED),
FUSE_OPT_KEY("nodelalloc", FUSE4FS_IGNORED),
@@ -7122,6 +7137,12 @@ static int fuse4fs_opt_proc(void *data, const char *arg,
struct fuse4fs *ff = data;

switch (key) {
+#ifdef HAVE_FUSE_IOMAP
+ case FUSE4FS_IOMAP_PASSTHROUGH:
+ ff->iomap_passthrough_options = 1;
+ /* pass through to libfuse */
+ return 1;
+#endif
case FUSE4FS_DIRSYNC:
ff->dirsync = 1;
/* pass through to libfuse */
@@ -7515,6 +7536,13 @@ int main(int argc, char *argv[])
fctx.unmount_in_destroy = 1;
}

+ if (fctx.iomap_passthrough_options && !iomap_detected) {
+ err_printf(&fctx, "%s\n",
+ _("Some mount options require iomap."));
+ ret |= 1;
+ goto out;
+ }
+
if (iomap_detected) {
/*
* The root_nodeid mount option was added when iomap support
diff --git a/misc/fuse2fs.1.in b/misc/fuse2fs.1.in
index 2b55fa0e723966..0c0934f03c9543 100644
--- a/misc/fuse2fs.1.in
+++ b/misc/fuse2fs.1.in
@@ -90,6 +90,9 @@ .SS "fuse2fs options:"
.I nosuid
) later.
.TP
+\fB-o\fR lazytime
+if iomap is enabled, enable lazy updates of timestamps
+.TP
\fB-o\fR lockfile=path
use this file to control access to the filesystem
.TP
@@ -98,6 +101,9 @@ .SS "fuse2fs options:"
.TP
\fB-o\fR norecovery
do not replay the journal and mount the file system read-only
+.TP
+\fB-o\fR strictatime
+if iomap is enabled, update atime on every access
.SS "FUSE options:"
.TP
\fB-d -o\fR debug
diff --git a/misc/fuse2fs.c b/misc/fuse2fs.c
index 0832a758bdad79..8f7194f4f815ee 100644
--- a/misc/fuse2fs.c
+++ b/misc/fuse2fs.c
@@ -260,6 +260,7 @@ struct fuse2fs {
int dirsync;
int unmount_in_destroy;
int noblkdev;
+ int iomap_passthrough_options;

enum fuse2fs_opstate opstate;
int logfd;
@@ -1453,6 +1454,8 @@ static void fuse2fs_iomap_enable(struct fuse_conn_info *conn,
if (!fuse2fs_iomap_enabled(ff)) {
if (ff->iomap_want == FT_ENABLE)
err_printf(ff, "%s\n", _("Could not enable iomap."));
+ if (ff->iomap_passthrough_options)
+ err_printf(ff, "%s\n", _("Some mount options require iomap."));
return;
}
}
@@ -6590,6 +6593,7 @@ enum {
FUSE2FS_ERRORS_BEHAVIOR,
#ifdef HAVE_FUSE_IOMAP
FUSE2FS_IOMAP,
+ FUSE2FS_IOMAP_PASSTHROUGH,
#endif
};

@@ -6616,6 +6620,17 @@ static struct fuse_opt fuse2fs_opts[] = {
#endif
FUSE2FS_OPT("noblkdev", noblkdev, 1),

+#ifdef HAVE_FUSE_IOMAP
+#ifdef MS_LAZYTIME
+ FUSE_OPT_KEY("lazytime", FUSE2FS_IOMAP_PASSTHROUGH),
+ FUSE_OPT_KEY("nolazytime", FUSE2FS_IOMAP_PASSTHROUGH),
+#endif
+#ifdef MS_STRICTATIME
+ FUSE_OPT_KEY("strictatime", FUSE2FS_IOMAP_PASSTHROUGH),
+ FUSE_OPT_KEY("nostrictatime", FUSE2FS_IOMAP_PASSTHROUGH),
+#endif
+#endif
+
FUSE_OPT_KEY("user_xattr", FUSE2FS_IGNORED),
FUSE_OPT_KEY("noblock_validity", FUSE2FS_IGNORED),
FUSE_OPT_KEY("nodelalloc", FUSE2FS_IGNORED),
@@ -6642,6 +6657,12 @@ static int fuse2fs_opt_proc(void *data, const char *arg,
struct fuse2fs *ff = data;

switch (key) {
+#ifdef HAVE_FUSE_IOMAP
+ case FUSE2FS_IOMAP_PASSTHROUGH:
+ ff->iomap_passthrough_options = 1;
+ /* pass through to libfuse */
+ return 1;
+#endif
case FUSE2FS_DIRSYNC:
ff->dirsync = 1;
/* pass through to libfuse */
@@ -6934,6 +6955,13 @@ int main(int argc, char *argv[])
fctx.unmount_in_destroy = 1;
}

+ if (fctx.iomap_passthrough_options && !iomap_detected) {
+ err_printf(&fctx, "%s\n",
+ _("Some mount options require iomap."));
+ ret |= 1;
+ goto out;
+ }
+
if (!fctx.cache_size)
fctx.cache_size = default_cache_size();
if (fctx.cache_size) {