public inbox for linux-ext4@vger.kernel.org
 help / color / mirror / Atom feed
* [PATCHSET 4/6] fuse2fs: use fuseblk mode
@ 2025-09-15 23:59 Darrick J. Wong
  2025-09-16  0:03 ` [PATCH 1/2] fuse2fs: mount norecovery if main block device is readonly Darrick J. Wong
  2025-09-16  0:03 ` [PATCH 2/2] fuse2fs: use fuseblk mode for mounting filesystems Darrick J. Wong
  0 siblings, 2 replies; 7+ messages in thread
From: Darrick J. Wong @ 2025-09-15 23:59 UTC (permalink / raw)
  To: tytso; +Cc: linux-ext4

Hi all,

While I was testing pre-iomap fuse2fs, I noticed a strange behavior of
fuse2fs.  When the filesystem is unmounted, the VFS mount goes away and
umount(3) returns before op_destroy is even called in fuse2fs.  As a
result, a subsequent fstest can try to format/mount the block device
even though fuse2fs hasn't even finished flushing dirty data to disk
or closed the block device.

This causes various weird test failures.  More alarmingly, this also
means that the age old advice that it's safe to yank a USB stick after
unmount returns is not actually true for fuse2fs.  This can lead to user
data loss.

There is a solution to this -- fuseblk mode.  In this scheme, fuse2fs
tells the kernel which block device it wants, the kernel opens the block
device, and it upcalls FUSE_DESTROY before releasing the block device
or the in-kernel super_block.  This gives us the desired property that
when unmount completes, it's safe to remove the device.

Unfortunately, this comes at a price.  Because the kernel insists upon
opening the fuseblk device in O_EXCL mode, we have to close the
filesystem before starting up fuse, and reopen it in op_init.  This
creates a largeish TOCTOU race window and increases mount times.  Worse
yet, if CONFIG_BLK_DEV_WRITE_MOUNTED=n, then this won't even work.

The last patch also registers fuse2fs as a process involved in memory
reclamation to prevent memory allocation deadlocks.

If you're going to start using this code, I strongly recommend pulling
from my git trees, which are linked below.

Comments and questions are, as always, welcome.

e2fsprogs git tree:
https://git.kernel.org/cgit/linux/kernel/git/djwong/e2fsprogs.git/log/?h=fuse2fs-use-fuseblk
---
Commits in this patchset:
 * fuse2fs: mount norecovery if main block device is readonly
 * fuse2fs: use fuseblk mode for mounting filesystems
---
 misc/fuse2fs.c |   55 +++++++++++++++++++++++++++++++++++++++++++++++++++++++
 1 file changed, 55 insertions(+)


^ permalink raw reply	[flat|nested] 7+ messages in thread

end of thread, other threads:[~2025-10-17 23:30 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2025-09-15 23:59 [PATCHSET 4/6] fuse2fs: use fuseblk mode Darrick J. Wong
2025-09-16  0:03 ` [PATCH 1/2] fuse2fs: mount norecovery if main block device is readonly Darrick J. Wong
2025-10-16 19:34   ` Dave Dykstra
2025-10-17 19:38     ` Darrick J. Wong
2025-10-17 20:20       ` Dave Dykstra
2025-10-17 23:30         ` Darrick J. Wong
2025-09-16  0:03 ` [PATCH 2/2] fuse2fs: use fuseblk mode for mounting filesystems Darrick J. Wong

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox