Skip to contentSkip to conversation

fstests: generic/730: exclude btrfs for now

PATCH Superseded Qu Wenruo 4 participants 6 messages Jun 4, 2025 – Jun 6, 2025 Btrfs file system

v1 of 2 Superseded Latest is v2 →

lore
Share & tools
lore

Qu Wenruo

author
#0 lore raw

PATCH 1/1 fstests: generic/730: exclude btrfs for now

The test case always fail for btrfs:

generic/730 - output mismatch (see /home/adam/xfstests-dev/results//generic/730.out.bad)

    --- tests/generic/730.out	2024-04-25 18:13:45.203549435 +0930
    +++ /home/adam/xfstests-dev/results//generic/730.out.bad	2025-06-04 15:10:39.062430952 +0930
    @@ -1,2 +1 @@
     QA output created by 730
    -cat: -: Input/output error
    ...

The root reasons are:

- Btrfs doesn't support shutdown callbacks

- The current shutdown callbacks are per-fs
Meanwhile btrfs is a multi-device fs, it needs to know which block device is triggerring shutdown, and needs to do extra evaluation (e.g. can the remaining devices support RW operations) before triggering a full fs shutdown.

I'm trying to improve the situation, but until then just exlucde btrfs from the test case for now.

---
 tests/generic/730 | 4 ++++
 1 file changed, 4 insertions(+)
tests/generic/730 +4 -0
index 6251980e..cae6489f 100755
@@ -26,6 +26,10 @@ _require_test
 _require_block_device $TEST_DEV
 _require_scsi_debug
 
+if [ "$FSTYP" = "btrfs" ]; then
+	_notrun "btrfs doesn't support per-fs shutdown yet"
+fi
+
 size=$(_small_fs_size_mb 256)
 SCSI_DEBUG_DEV=`_get_scsi_debug_dev 512 512 0 $size`
 test -b "$SCSI_DEBUG_DEV" || _notrun "Failed to initialize scsi debug device"
Signature · 1 line
2.49.0
#1 lore raw
Quoted 3 lines · Qu Wenruo

- Btrfs doesn't support shutdown callbacks

- The current shutdown callbacks are per-fs

The callsbacks are per-block device.

Quoted 4 lines

Meanwhile btrfs is a multi-device fs, it needs to know which block device is triggerring shutdown, and needs to do extra evaluation (e.g. can the remaining devices support RW operations) before triggering a full fs shutdown.

Exactly for that reason.

tests/generic/730 _require_test · line 31

Quoted 8 lines

+++ b/tests/generic/730

tests/generic/730 +3 -0
@@ -26,6 +26,10 @@ _require_test
 _require_block_device $TEST_DEV
 _require_scsi_debug
 
+if [ "$FSTYP" = "btrfs" ]; then
+	_notrun "btrfs doesn't support per-fs shutdown yet"
+fi

Please don't add these horrible fs excludes to tests. Add a helper in common to check if something is supported.

#2 lore raw
Quoted 5 lines · Christoph Hellwig
Quoted 3 lines · Qu Wenruo

- Btrfs doesn't support shutdown callbacks

- The current shutdown callbacks are per-fs

Quoted 8 lines

The callsbacks are per-block device.

Quoted 4 lines

Meanwhile btrfs is a multi-device fs, it needs to know which block device is triggerring shutdown, and needs to do extra evaluation (e.g. can the remaining devices support RW operations) before triggering a full fs shutdown.

Exactly for that reason.

Right, the ext4/xfs can go a superblock shutdown because they are single device fs (except the external journal device), and fs_holder_ops handles the single device failure by calling back into the super block shutdown call back.

For a multi-device fs, it should go through the blk_holder_ops, which btrfs doesn't provide when opening the devices.

Quoted 6 lines
Quoted 6 lines

+++ b/tests/generic/730

tests/generic/730 +0 -0
@@ -26,6 +26,10 @@ _require_test
  _require_block_device $TEST_DEV
  _require_scsi_debug
 
Quoted 6 lines

tests/generic/730 _require_test · line 31

Quoted 3 lines
tests/generic/730 +3 -0
+if [ "$FSTYP" = "btrfs" ]; then
+	_notrun "btrfs doesn't support per-fs shutdown yet"
+fi

Please don't add these horrible fs excludes to tests. Add a helper in common to check if something is supported.

Although there is the _require_scratch_shutdown, it's only checking the full fs shutdown ioctl.

I guess it means, if a fs supports per-bdev shutdown, it won't hurt to also provide a full-fs shutdown ioctl?

Thanks,
Qu

#3 lore raw
Quoted 2 lines · Qu Wenruo

Right, the ext4/xfs can go a superblock shutdown because they are single device fs (except the external journal device),

XFS also has a RT device in addition to that.

Quoted 6 lines

and fs_holder_ops handles
the single device failure by calling back into the super block shutdown call back.

For a multi-device fs, it should go through the blk_holder_ops, which btrfs doesn't provide when opening the devices.

Yes, btrfs would need it's own fs_ops. Alternatively we could add a new ->devloss super_operations method and change fs_bdev_mark_dead to something like:

	if (sb->s_op->devloss && sb->s_op->devloss(sb, bdev, surprise))
		goto done;

	<sync fs and stuff)
	if (sb->s_op->shutdown)
		sb->s_op->shutdown(sb);
done:
	super_unlock_shared(sb);

so that btrfs or other multi-device file systems don't have to duplicate the logic.

Quoted 2 lines

I guess it means, if a fs supports per-bdev shutdown, it won't hurt to also provide a full-fs shutdown ioctl?

Supporting it is a good idea in general as it enables a lot of good test coverage in xfstests.

#4 lore raw
Quoted 26 lines · Christoph Hellwig
Quoted 2 lines · Qu Wenruo

Right, the ext4/xfs can go a superblock shutdown because they are single device fs (except the external journal device),

XFS also has a RT device in addition to that.

Quoted 6 lines

and fs_holder_ops handles
the single device failure by calling back into the super block shutdown call back.

For a multi-device fs, it should go through the blk_holder_ops, which btrfs doesn't provide when opening the devices.

Yes, btrfs would need it's own fs_ops. Alternatively we could add a new ->devloss super_operations method and change fs_bdev_mark_dead to something like:

	if (sb->s_op->devloss && sb->s_op->devloss(sb, bdev, surprise))
		goto done;

	<sync fs and stuff)
	if (sb->s_op->shutdown)
		sb->s_op->shutdown(sb);
done:
	super_unlock_shared(sb);
Quoted 2 lines

so that btrfs or other multi-device file systems don't have to duplicate the logic.

I learnt this the hard way.

I tried to implement a btrfs specific blk_holder_ops, and just use btrfs_fs_info as the holder.

Test case generic/085 easily crash the kernel with freeze/thaw and mount/unmount races.

Bcachefs is doing its own blk_holder_ops but with extra protection with similar refcount and locks.

Considering btrfs doesn't got through the regular setup_bdev_super() patch, I guess for now we have to duplicate the logic for now.

Thanks,
Qu

Quoted 7 lines
Quoted 3 lines

I guess it means, if a fs supports per-bdev shutdown, it won't hurt to also provide a full-fs shutdown ioctl?

Supporting it is a good idea in general as it enables a lot of good test coverage in xfstests.

#5 lore raw
In reply to Qu Wenruo
Quoted 33 lines · Qu Wenruo

The test case always fail for btrfs:

generic/730 - output mismatch (see /home/adam/xfstests-dev/results//generic/730.out.bad)

    --- tests/generic/730.out	2024-04-25 18:13:45.203549435 +0930
    +++ /home/adam/xfstests-dev/results//generic/730.out.bad	2025-06-04 15:10:39.062430952 +0930
    @@ -1,2 +1 @@
     QA output created by 730
    -cat: -: Input/output error
    ...

The root reasons are:

- Btrfs doesn't support shutdown callbacks

- The current shutdown callbacks are per-fs
Meanwhile btrfs is a multi-device fs, it needs to know which block device is triggerring shutdown, and needs to do extra evaluation (e.g. can the remaining devices support RW operations) before triggering a full fs shutdown.

I'm trying to improve the situation, but until then just exlucde btrfs from the test case for now.

---
 tests/generic/730 | 4 ++++
 1 file changed, 4 insertions(+)
tests/generic/730 +0 -0
index 6251980e..cae6489f 100755

tests/generic/730 _require_test · line 32

Quoted 7 lines
tests/generic/730 +4 -0
@@ -26,6 +26,10 @@ _require_test
 _require_block_device $TEST_DEV
 _require_scsi_debug
 
+if [ "$FSTYP" = "btrfs" ]; then
+	_notrun "btrfs doesn't support per-fs shutdown yet"
+fi
+

Please use _exclude_fs btrfs, if you still hope to _notrun it on btrfs later :)

Quoted 7 lines
tests/generic/730 +0 -0
 size=$(_small_fs_size_mb 256)
 SCSI_DEBUG_DEV=`_get_scsi_debug_dev 512 512 0 $size`
 test -b "$SCSI_DEBUG_DEV" || _notrun "Failed to initialize scsi debug device"
Signature · 1 line
2.49.0