btrfs: make sure we rescan all devices after unregistering
[xfstests-dev.git] / tests / btrfs / 124
index ce3ad6aa3a5895a86e2ce6590946c5f75b2ed3f4..4588264c35a826a771dc1827bbb0d28868cf8b77 100755 (executable)
@@ -35,6 +35,7 @@ _cleanup()
 {
        cd /
        rm -f $tmp.*
+       _btrfs_rescan_devices
 }
 
 # get standard environment, filters and checks
@@ -48,10 +49,9 @@ rm -f $seqres.full
 # real QA test starts here
 
 _supported_fs btrfs
-_supported_os Linux
 _require_scratch_dev_pool 2
 _test_unmount
-_require_loadable_fs_module "btrfs"
+_require_btrfs_forget_or_module_loadable
 
 _scratch_dev_pool_get 2
 
@@ -61,7 +61,7 @@ dev2=`echo $SCRATCH_DEV_POOL | awk '{print $2}'`
 dev1_sz=`blockdev --getsize64 $dev1`
 dev2_sz=`blockdev --getsize64 $dev2`
 # get min of both
-max_fs_sz=`echo -e "$dev1_sz\n$dev2_sz" | sort | head -1`
+max_fs_sz=`echo -e "$dev1_sz\n$dev2_sz" | sort -n | head -1`
 # Need disks with more than 2G.
 if [ $max_fs_sz -lt 2000000000 ]; then
        _scratch_dev_pool_put
@@ -86,7 +86,7 @@ echo "clean btrfs ko" >> $seqres.full
 _scratch_unmount
 
 # un-scan the btrfs devices
-_reload_fs_module "btrfs"
+_btrfs_forget_or_module_reload
 
 echo >> $seqres.full
 echo "-----Write degraded mount fill upto $max_fs_sz bytes-----" >> $seqres.full
@@ -114,7 +114,7 @@ _run_btrfs_util_prog device scan
 _scratch_mount >> $seqres.full 2>&1
 _run_btrfs_util_prog filesystem show
 echo >> $seqres.full
-_run_btrfs_balance_start ${SCRATCH_MNT}
+_run_btrfs_balance_start ${SCRATCH_MNT} >>$seqres.full
 
 checkpoint2=`md5sum $SCRATCH_MNT/tf2`
 echo $checkpoint2 >> $seqres.full 2>&1
@@ -125,7 +125,7 @@ echo
 echo "Mount degraded with the other dev"
 _scratch_unmount
 # un-scan the btrfs devices
-_reload_fs_module "btrfs"
+_btrfs_forget_or_module_reload
 _mount -o degraded $dev2 $SCRATCH_MNT >>$seqres.full 2>&1
 _run_btrfs_util_prog filesystem show
 checkpoint3=`md5sum $SCRATCH_MNT/tf2`
@@ -145,6 +145,7 @@ fi
 
 $UMOUNT_PROG $dev2
 _scratch_dev_pool_put
+_btrfs_rescan_devices
 _test_mount
 
 status=0