[PATCHSET 1/9] fuse2fs: fix locking problems

Darrick J. Wong
2025-11-06T22:27:53Z

Hi all,

Teach fuse2fs to flock the file(s) underlying the filesystem if the fs
is stored in a regular file, so that we don't have to create and
maintain separate lockfiles.

For block devices, fix a weird race between mount and unmount that is
causing testing failures by waiting a small amount of time to grab a
lock.

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-locking
---
Commits in this patchset:
* libext2fs: add POSIX advisory locking to the unix IO manager
* fuse2fs: try to lock filesystem image files before using them
* fuse2fs: quiet down write-protect warning
* fuse2fs: try to grab block device O_EXCL repeatedly
---
lib/ext2fs/ext2_io.h | 12 +++-
debian/libext2fs2t64.symbols | 2 +
lib/ext2fs/io_manager.c | 16 +++++
lib/ext2fs/unix_io.c | 71 +++++++++++++++++++++
misc/fuse2fs.c | 144 +++++++++++++++++++++++++++++++++++++++---
5 files changed, 232 insertions(+), 13 deletions(-)