fstests: make sure we rescan all devices after unregistering
PATCH 1/1 fstests: make sure we rescan all devices after unregistering
There are some btrfs test cases utilizing _btrfs_forget_or_module_reload() to unregister all btrfs devices.
However _btrfs_forget_or_module_reload() will unregister all devices, meaning if TEST_DEV is part of a multi-device btrfs, after those test cases TEST_DEV will no longer be mountable.
This patch will introduce a new function, btrfs_rescan_devices() to undo the unregister, so that all later test cases can mount TEST_DEV without any problem.
Since we are here, also add a missing _require_btrfs_forget_or_module_loadable for btrfs/225.
--- common/btrfs | 8 ++++++++ tests/btrfs/124 | 2 ++ tests/btrfs/125 | 2 ++ tests/btrfs/163 | 2 ++ tests/btrfs/164 | 2 ++ tests/btrfs/219 | 2 ++ tests/btrfs/225 | 3 +++ 7 files changed, 21 insertions(+)
common/btrfs +8 -0
@@ -411,3 +411,11 @@ _btrfs_forget_or_module_reload() _reload_fs_module "btrfs" } + +# Test cases which utilized _btrfs_forget_or_module_reload() must call this +# to make sure TEST_DEV can still be mounted. As TEST_DEV can be part of a +# multi-device btrfs. +_btrfs_rescan_devices() +{ + $BTRFS_UTIL_PROG device scan &> /dev/null +}
tests/btrfs/124 +2 -0
@@ -35,6 +35,7 @@ _cleanup() { cd / rm -f $tmp.* + _btrfs_rescan_devices } # get standard environment, filters and checks
@@ -144,6 +145,7 @@ fi $UMOUNT_PROG $dev2 _scratch_dev_pool_put +_btrfs_rescan_devices _test_mount status=0
tests/btrfs/125 +2 -0
@@ -34,6 +34,7 @@ _cleanup() { cd / rm -f $tmp.* + _btrfs_rescan_devices } # get standard environment, filters and checks
@@ -161,6 +162,7 @@ fi $UMOUNT_PROG $dev2 _scratch_dev_pool_put +_btrfs_rescan_devices _test_mount status=0
tests/btrfs/163 +2 -0
@@ -26,6 +26,7 @@ _cleanup() { cd / rm -f $tmp.* + _btrfs_rescan_devices } # get standard environment, filters and checks
@@ -102,6 +103,7 @@ replace_sprout seed_is_mountable _scratch_dev_pool_put +_btrfs_rescan_devices status=0 exit
tests/btrfs/164 +2 -0
@@ -22,6 +22,7 @@ _cleanup() { cd / rm -f $tmp.* + _btrfs_rescan_devices } # get standard environment, filters and checks
@@ -90,6 +91,7 @@ delete_seed seed_is_mountable _scratch_dev_pool_put +_btrfs_rescan_devices status=0 exit
tests/btrfs/219 +2 -0
@@ -35,6 +35,7 @@ _cleanup() [ ! -z "$fs_img1" ] && rm -rf $fs_img1 [ ! -z "$fs_img2" ] && rm -rf $fs_img2 [ ! -z "$loop_dev" ] && _destroy_loop_device $loop_dev + _btrfs_rescan_devices } # get standard environment, filters and checks
@@ -97,6 +98,7 @@ _mount $loop_dev $loop_mnt > /dev/null 2>&1 || \ _mount -o loop $fs_img2 $loop_mnt1 > /dev/null 2>&1 && \ _fail "We were allowed to mount when we should have failed" +_btrfs_rescan_devices # success, all done echo "Silence is golden" status=0
tests/btrfs/225 +3 -0
@@ -25,6 +25,7 @@ _cleanup() { cd / rm -f $tmp.* + _btrfs_rescan_devices } # get standard environment, filters and checks
@@ -40,6 +41,7 @@ rm -f $seqres.full _supported_fs btrfs _require_test _require_scratch_dev_pool 2 +_require_btrfs_forget_or_module_loadable _scratch_dev_pool_get 2
@@ -76,6 +78,7 @@ od -x $SCRATCH_MNT/foo od -x $SCRATCH_MNT/bar _scratch_dev_pool_put +_btrfs_rescan_devices # success, all done status=0
Signature · 1 line
2.30.1
Quoted 11 lines · Qu Wenruo
There are some btrfs test cases utilizing
_btrfs_forget_or_module_reload()to unregister all btrfs devices.However
_btrfs_forget_or_module_reload()will unregister all devices, meaning ifTEST_DEVis part of a multi-device btrfs, after those test casesTEST_DEVwill no longer be mountable.This patch will introduce a new function,
btrfs_rescan_devices()to undo the unregister, so that all later test cases can mountTEST_DEVwithout any problem.
Quoted 5 lines
Since we are here, also add a missing
_require_btrfs_forget_or_module_loadablefor btrfs/225.Reported-by Eric Sandeen <[email protected]>Signed-off-by Qu Wenruo <[email protected]>
Thanks.
Quoted 155 lines
--- common/btrfs | 8 ++++++++ tests/btrfs/124 | 2 ++ tests/btrfs/125 | 2 ++ tests/btrfs/163 | 2 ++ tests/btrfs/164 | 2 ++ tests/btrfs/219 | 2 ++ tests/btrfs/225 | 3 +++ 7 files changed, 21 insertions(+)common/btrfs +8
-0@@ -411,3 +411,11 @@ _btrfs_forget_or_module_reload() _reload_fs_module "btrfs" } + +# Test cases which utilized _btrfs_forget_or_module_reload() must call this +# to make sure TEST_DEV can still be mounted. As TEST_DEV can be part of a +# multi-device btrfs. +_btrfs_rescan_devices() +{ + $BTRFS_UTIL_PROG device scan &> /dev/null +}tests/btrfs/124 +2
-0@@ -35,6 +35,7 @@ _cleanup() { cd / rm -f $tmp.* + _btrfs_rescan_devices } # get standard environment, filters and checks@@ -144,6 +145,7 @@ fi $UMOUNT_PROG $dev2 _scratch_dev_pool_put +_btrfs_rescan_devices _test_mount status=0tests/btrfs/125 +2
-0@@ -34,6 +34,7 @@ _cleanup() { cd / rm -f $tmp.* + _btrfs_rescan_devices } # get standard environment, filters and checks@@ -161,6 +162,7 @@ fi $UMOUNT_PROG $dev2 _scratch_dev_pool_put +_btrfs_rescan_devices _test_mount status=0tests/btrfs/163 +2
-0@@ -26,6 +26,7 @@ _cleanup() { cd / rm -f $tmp.* + _btrfs_rescan_devices } # get standard environment, filters and checks@@ -102,6 +103,7 @@ replace_sprout seed_is_mountable _scratch_dev_pool_put +_btrfs_rescan_devices status=0 exittests/btrfs/164 +2
-0@@ -22,6 +22,7 @@ _cleanup() { cd / rm -f $tmp.* + _btrfs_rescan_devices } # get standard environment, filters and checks@@ -90,6 +91,7 @@ delete_seed seed_is_mountable _scratch_dev_pool_put +_btrfs_rescan_devices status=0 exittests/btrfs/219 +2
-0@@ -35,6 +35,7 @@ _cleanup() [ ! -z "$fs_img1" ] && rm -rf $fs_img1 [ ! -z "$fs_img2" ] && rm -rf $fs_img2 [ ! -z "$loop_dev" ] && _destroy_loop_device $loop_dev + _btrfs_rescan_devices } # get standard environment, filters and checks@@ -97,6 +98,7 @@ _mount $loop_dev $loop_mnt > /dev/null 2>&1 || \ _mount -o loop $fs_img2 $loop_mnt1 > /dev/null 2>&1 && \ _fail "We were allowed to mount when we should have failed" +_btrfs_rescan_devices # success, all done echo "Silence is golden" status=0tests/btrfs/225 +3
-0@@ -25,6 +25,7 @@ _cleanup() { cd / rm -f $tmp.* + _btrfs_rescan_devices } # get standard environment, filters and checks@@ -40,6 +41,7 @@ rm -f $seqres.full _supported_fs btrfs _require_test _require_scratch_dev_pool 2 +_require_btrfs_forget_or_module_loadable _scratch_dev_pool_get 2@@ -76,6 +78,7 @@ od -x $SCRATCH_MNT/foo od -x $SCRATCH_MNT/bar _scratch_dev_pool_put +_btrfs_rescan_devices # success, all done status=0