]> git.apps.os.sepia.ceph.com Git - xfstests-dev.git/commit
btrfs: a new test case to verify mount behavior with background remounting
authorQu Wenruo <wqu@suse.com>
Wed, 6 Nov 2024 05:43:28 +0000 (16:13 +1030)
committerZorro Lang <zlang@kernel.org>
Sat, 9 Nov 2024 14:34:05 +0000 (22:34 +0800)
commit81477600d36391dcbdfefd0b258fa55c17ae6932
tree1f0b2ecf0ea6df38d803ff2354eba76161de6710
parent1e990ee9aaa05a4248a243be7385a6d7de6db724
btrfs: a new test case to verify mount behavior with background remounting

[BUG]
When there is a process in the background remounting a btrfs, switching
between RO/RW, then another process try to mount another subvolume of
the same btrfs read-only, we can hit a race causing the RW mount to fail
with -EBUSY:

[CAUSE]
During the btrfs mount, to support mounting different subvolumes with
different RO/RW flags, we have a small hack during the mount:

  Retry with matching RO flags if the initial mount fail with -EBUSY.

The problem is, during that retry we do not hold any super block lock
(s_umount), this meanings there can be a remount process changing the RO
flags of the original fs super block.

If so, we can have an EBUSY error during retry.
And this time we treat any failure as an error, without any retry and
cause the above EBUSY mount failure.

[FIX]
The fix is already sent to the mailing list.
The fix is to allow btrfs to have different RO flag between super block
and mount point during mount, and if the RO flag mismatch, reconfigure
the fs to RW with s_umount hold, so that there will be no race.

[TEST CASE]
The test case will create two processes:

- Remounting an existing subvolume mount point
  Switching between RO and RW

- Mounting another subvolume RW
  After a successful mount, unmount and retry.

This is enough to trigger the -EBUSY error in less than 5 seconds.
To be extra safe, the test case will run for 10 seconds at least, and
follow TIME_FACTOR for extra loads.

Signed-off-by: Qu Wenruo <wqu@suse.com>
Reviewed-by: Filipe Manana <fdmanana@suse.com>
Reviewed-by: Anand Jain <anand.jain@oracle.com>
Reviewed-by: Zorro Lang <zlang@redhat.com>
Signed-off-by: Zorro Lang <zlang@kernel.org>
tests/btrfs/326 [new file with mode: 0755]
tests/btrfs/326.out [new file with mode: 0644]