#! /bin/bash
+# SPDX-License-Identifier: GPL-2.0
+# Copyright (c) 2016 Oracle. All Rights Reserved.
+#
# FS QA Test 124
#
# This test verify the RAID1 reconstruction on the reappeared
#
# Verify if all three checkpoints match
#
-#---------------------------------------------------------------------
-# Copyright (c) 2016 Oracle. All Rights Reserved.
-#
-# This program is free software; you can redistribute it and/or
-# modify it under the terms of the GNU General Public License as
-# published by the Free Software Foundation.
-#
-# This program is distributed in the hope that it would be useful,
-# but WITHOUT ANY WARRANTY; without even the implied warranty of
-# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-# GNU General Public License for more details.
-#
-# You should have received a copy of the GNU General Public License
-# along with this program; if not, write the Free Software Foundation,
-# Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
-#---------------------------------------------------------------------
-#
-
seq=`basename $0`
seqres=$RESULT_DIR/$seq
echo "QA output created by $seq"
{
cd /
rm -f $tmp.*
+ _btrfs_rescan_devices
}
# get standard environment, filters and checks
# 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
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
_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
_scratch_mount >> $seqres.full 2>&1
_run_btrfs_util_prog filesystem show
echo >> $seqres.full
-_run_btrfs_util_prog balance start ${SCRATCH_MNT}
+_run_btrfs_balance_start ${SCRATCH_MNT} >>$seqres.full
checkpoint2=`md5sum $SCRATCH_MNT/tf2`
echo $checkpoint2 >> $seqres.full 2>&1
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`
$UMOUNT_PROG $dev2
_scratch_dev_pool_put
+_btrfs_rescan_devices
_test_mount
status=0