lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <175798161918.390496.869367698720142079.stgit@frogsfrogsfrogs>
Date: Mon, 15 Sep 2025 18:01:36 -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 11/17] fuse2fs: avoid fuseblk mode if fuse-iomap support is
 likely

From: Darrick J. Wong <djwong@...nel.org>

Since fuse in iomap mode guarantees that op_destroy will be called
before umount returns, we don't need to use fuseblk mode to get that
guarantee.  Disable fuseblk mode, which saves us the trouble of closing
and reopening the device.

Signed-off-by: "Darrick J. Wong" <djwong@...nel.org>
---
 fuse4fs/fuse4fs.c |   20 +++++++++++++++++++-
 misc/fuse2fs.c    |   20 +++++++++++++++++++-
 2 files changed, 38 insertions(+), 2 deletions(-)


diff --git a/fuse4fs/fuse4fs.c b/fuse4fs/fuse4fs.c
index e482b00f14d572..8965edbaf9b834 100644
--- a/fuse4fs/fuse4fs.c
+++ b/fuse4fs/fuse4fs.c
@@ -273,6 +273,7 @@ struct fuse4fs {
 	enum fuse4fs_feature_toggle iomap_want;
 	enum fuse4fs_iomap_state iomap_state;
 	uint32_t iomap_dev;
+	uint64_t iomap_cap;
 #endif
 	unsigned int blockmask;
 	unsigned long offset;
@@ -1240,6 +1241,8 @@ static errcode_t fuse4fs_open(struct fuse4fs *ff, int libext2_flags)
 	if (ff->directio)
 		flags |= EXT2_FLAG_DIRECT_IO;
 
+	dbg_printf(ff, "opening with flags=0x%x\n", flags);
+
 	err = ext2fs_open2(ff->device, options, flags, 0, 0, unix_io_manager,
 			   &ff->fs);
 	if (err == EPERM) {
@@ -6930,6 +6933,19 @@ static unsigned long long default_cache_size(void)
 	return ret;
 }
 
+#ifdef HAVE_FUSE_IOMAP
+static inline bool fuse4fs_discover_iomap(struct fuse4fs *ff)
+{
+	if (ff->iomap_want == FT_DISABLE)
+		return false;
+
+	ff->iomap_cap = fuse_lowlevel_discover_iomap(-1);
+	return ff->iomap_cap & FUSE_IOMAP_SUPPORT_FILEIO;
+}
+#else
+# define fuse4fs_discover_iomap(...)	(false)
+#endif
+
 static inline bool fuse4fs_want_fuseblk(const struct fuse4fs *ff)
 {
 	if (ff->noblkdev)
@@ -7071,6 +7087,7 @@ int main(int argc, char *argv[])
 	errcode_t err;
 	FILE *orig_stderr = stderr;
 	char extra_args[BUFSIZ];
+	bool iomap_detected = false;
 	int ret;
 
 	ret = fuse_opt_parse(&args, &fctx, fuse4fs_opts, fuse4fs_opt_proc);
@@ -7144,7 +7161,8 @@ int main(int argc, char *argv[])
 		goto out;
 	}
 
-	if (fuse4fs_want_fuseblk(&fctx)) {
+	iomap_detected = fuse4fs_discover_iomap(&fctx);
+	if (!iomap_detected && fuse4fs_want_fuseblk(&fctx)) {
 		/*
 		 * If this is a block device, we want to close the fs, reopen
 		 * the block device in non-exclusive mode, and start the fuse
diff --git a/misc/fuse2fs.c b/misc/fuse2fs.c
index c13bd6c3baf9c9..7fa4070dee0367 100644
--- a/misc/fuse2fs.c
+++ b/misc/fuse2fs.c
@@ -267,6 +267,7 @@ struct fuse2fs {
 	enum fuse2fs_feature_toggle iomap_want;
 	enum fuse2fs_iomap_state iomap_state;
 	uint32_t iomap_dev;
+	uint64_t iomap_cap;
 #endif
 	unsigned int blockmask;
 	unsigned long offset;
@@ -1052,6 +1053,8 @@ static errcode_t fuse2fs_open(struct fuse2fs *ff, int libext2_flags)
 	if (ff->directio)
 		flags |= EXT2_FLAG_DIRECT_IO;
 
+	dbg_printf(ff, "opening with flags=0x%x\n", flags);
+
 	err = ext2fs_open2(ff->device, options, flags, 0, 0, unix_io_manager,
 			   &ff->fs);
 	if (err == EPERM) {
@@ -6426,6 +6429,19 @@ static unsigned long long default_cache_size(void)
 	return ret;
 }
 
+#ifdef HAVE_FUSE_IOMAP
+static inline bool fuse2fs_discover_iomap(struct fuse2fs *ff)
+{
+	if (ff->iomap_want == FT_DISABLE)
+		return false;
+
+	ff->iomap_cap = fuse_lowlevel_discover_iomap(-1);
+	return ff->iomap_cap & FUSE_IOMAP_SUPPORT_FILEIO;
+}
+#else
+# define fuse2fs_discover_iomap(...)	(false)
+#endif
+
 static inline bool fuse2fs_want_fuseblk(const struct fuse2fs *ff)
 {
 	if (ff->noblkdev)
@@ -6466,6 +6482,7 @@ int main(int argc, char *argv[])
 	errcode_t err;
 	FILE *orig_stderr = stderr;
 	char extra_args[BUFSIZ];
+	bool iomap_detected = false;
 	int ret;
 
 	ret = fuse_opt_parse(&args, &fctx, fuse2fs_opts, fuse2fs_opt_proc);
@@ -6539,7 +6556,8 @@ int main(int argc, char *argv[])
 		goto out;
 	}
 
-	if (fuse2fs_want_fuseblk(&fctx)) {
+	iomap_detected = fuse2fs_discover_iomap(&fctx);
+	if (!iomap_detected && fuse2fs_want_fuseblk(&fctx)) {
 		/*
 		 * If this is a block device, we want to close the fs, reopen
 		 * the block device in non-exclusive mode, and start the fuse


Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ