fuse2fs: try to grab block device O_EXCL repeatedly
generic/646 keeps failing to mount in this fashion:
run fstests generic/646 at 2025-10-20 17:10:26
[U] FUSE2FS (sda4): mounted filesystem f8f21d10-2ec9-4aef-a509-b32659b4e6b0.
fuse: EXPERIMENTAL iomap feature enabled. Use at your own risk!
[U] FUSE2FS (sda4): shut down requested.
[U] FUSE2FS (sda4): unmounted filesystem f8f21d10-2ec9-4aef-a509-b32659b4e6b0.
[U] FUSE2FS (sda4): mounted filesystem 9efc6297-74c0-448c-b253-cecffd947239.
fuse: EXPERIMENTAL iomap feature enabled. Use at your own risk!
[U] FUSE2FS (sda4): shut down requested.
[U] FUSE2FS (sda4): unmounted filesystem 9efc6297-74c0-448c-b253-cecffd947239.
[U] FUSE2FS (sda4): mounted filesystem 9efc6297-74c0-448c-b253-cecffd947239.
[U] FUSE2FS (sda4): Warning: Mounting unchecked fs, running e2fsck is recommended.
[U] FUSE2FS (sda4): Device or resource busy.
[U] FUSE2FS (sda4): Please run e2fsck -fy.
[U] Mount failed while opening filesystem. Check dmesg(1) for details.
[U] FUSE2FS (sda4): unmounted filesystem 9efc6297-74c0-448c-b253-cecffd947239.
It turns out that one can mount a fuse filesystem and unmount it before
the kernel even has a chance to send FUSE_INIT to the fuse server. If
this occurs, the unmount code will abort the FUSE_INIT request and tear
down the fs mount immediately.
Unfortunately for fstests, the fuse server may have already opened the
block device with O_EXCL and will keep running with the bdev open until
libfuse notices that the connection to the kernel died and tells the
fuse server to destroy itself. That might not happen for a long time
after the unmount program exits, in which case a subsequent invocation
of the fuse server can race with the dying fuse server to open the block
device. When this happens, the new invocation fails with "Device or
resource busy".
This is exactly what's happening in this test, which is only noticeable
because it cycles the scratch mount so quickly.
Cc: <linux-ext4@vger.kernel.org> # v1.43
Fixes: 81cbf1ef4f5dab ("misc: add fuse2fs, a FUSE server for e2fsprogs")
Signed-off-by: "Darrick J. Wong" <djwong@kernel.org>
1 file changed