common: use mount/umount helpers everywhere

Replace every explicit mount/umount of scratch or test devices with
helper functions. This allows the next patch to add in hooks to these
functions in order to set up & tear down overlayfs on every mount/umount

(also adds _test_unmount(), which didn't exist prior)

[Eryu Guan rebased the patch agains latest master and replaced more
mount/umount with helpers]

Signed-off-by: Eryu Guan <eguan@redhat.com>
Signed-off-by: Eric Sandeen <esandeen@redhat.com>
Reviewed-by: Dave Chinner <dchinner@redhat.com>
Signed-off-by: Dave Chinner <david@fromorbit.com>
This commit is contained in:
Eric Sandeen
2015-12-21 18:07:43 +11:00
committed by Dave Chinner
parent 4545386ca0
commit 27d077ec0b
136 changed files with 293 additions and 288 deletions
+5 -5
View File
@@ -439,7 +439,7 @@ for section in $HOST_OPTIONS_SECTIONS; do
if $RECREATE_TEST_DEV || [ "$OLD_FSTYP" != "$FSTYP" ]; then
echo "RECREATING -- $FSTYP on $TEST_DEV"
umount $TEST_DEV 2> /dev/null
_test_unmount 2> /dev/null
if ! _test_mkfs >$tmp.err 2>&1
then
echo "our local _test_mkfs routine ..."
@@ -456,7 +456,7 @@ for section in $HOST_OPTIONS_SECTIONS; do
fi
_prepare_test_list
elif [ "$OLD_MOUNT_OPTIONS" != "$MOUNT_OPTIONS" ]; then
umount $TEST_DEV 2> /dev/null
_test_unmount 2> /dev/null
out=`_mount_or_remount_rw "$MOUNT_OPTIONS" $TEST_DEV $TEST_DIR`
if [ $? -ne 1 ]; then
echo $out
@@ -486,7 +486,7 @@ for section in $HOST_OPTIONS_SECTIONS; do
needwrap=true
if [ ! -z "$SCRATCH_DEV" ]; then
umount $SCRATCH_DEV 2>/dev/null
_scratch_unmount 2> /dev/null
# call the overridden mkfs - make sure the FS is built
# the same as we'll create it later.
@@ -679,8 +679,8 @@ for section in $HOST_OPTIONS_SECTIONS; do
_wrapup
echo
umount $TEST_DEV 2> /dev/null
umount $SCRATCH_DEV 2> /dev/null
_test_unmount 2> /dev/null
_scratch_unmount 2> /dev/null
done
interrupt=false
+1 -1
View File
@@ -233,7 +233,7 @@ _require_noattr2()
{
_scratch_mkfs_xfs > /dev/null 2>&1 \
|| _fail "_scratch_mkfs_xfs failed on $SCRATCH_DEV"
_mount -o noattr2 $SCRATCH_DEV > /dev/null 2>&1 \
_scratch_mount -o noattr2 > /dev/null 2>&1 \
|| _notrun "noattr2 mount option not supported on $SCRATCH_DEV"
_scratch_unmount
}
+1 -1
View File
@@ -288,7 +288,7 @@ _cleanup()
_stable_fs()
{
_saveddir=`pwd`; cd /
umount $SCRATCH_MNT >>$seqres.full || _fail "unmount failed"
_scratch_unmount >>$seqres.full || _fail "unmount failed"
_scratch_mount >>$seqres.full || _fail "mount failed"
cd $_saveddir
}
+1 -1
View File
@@ -225,5 +225,5 @@ _cleanup_streams_umount()
{
cd /
rm -rf ${SCRATCH_MNT}/stream*
umount $SCRATCH_DEV 2>/dev/null
_scratch_unmount 2>/dev/null
}
+3 -3
View File
@@ -339,7 +339,7 @@ _create_log()
# unmount the FS
_full "umount"
umount $SCRATCH_DEV >>$seqres.full 2>&1
_scratch_unmount >>$seqres.full 2>&1
if [ $? -ne 0 ] ; then
_echofull "umount failed"
return 1
@@ -370,7 +370,7 @@ _create_log_sync()
# unmount the FS
_full "umount"
umount $SCRATCH_DEV >>$seqres.full 2>&1
_scratch_unmount >>$seqres.full 2>&1
if [ $? -ne 0 ] ; then
_echofull "umount failed"
return 1
@@ -482,7 +482,7 @@ _require_v2log()
# check after unmount to see if it is clean
# i.e. it is not a 6.5.25 buggy version checking kernel
touch $SCRATCH_MNT/file
umount $SCRATCH_DEV >>$seqres.full 2>&1
_scratch_unmount >>$seqres.full 2>&1
if _scratch_xfs_logprint -t | tee -a $seqres.full \
| head | grep -q "<DIRTY>"; then
_notrun "kernel does not support v2 logs"
+1 -1
View File
@@ -115,7 +115,7 @@ _test_punch() {
local filename=punch_test_file
cd /
umount $SCRATCH_MNT >/dev/null 2>&1
_scratch_unmount >/dev/null 2>&1
_scratch_mkfs_xfs -bsize=$blksize >/dev/null 2>&1 \
|| _fail "mkfs failed"
+1 -1
View File
@@ -167,7 +167,7 @@ _choose_prid()
_qmount()
{
umount $SCRATCH_DEV >/dev/null 2>&1
_scratch_unmount >/dev/null 2>&1
_scratch_mount || _fail "qmount failed"
chmod ugo+rwx $SCRATCH_MNT
}
+16 -11
View File
@@ -270,9 +270,14 @@ _test_mount()
_mount -t $FSTYP $TEST_OPTIONS $TEST_FS_MOUNT_OPTS $SELINUX_MOUNT_OPTIONS $* $TEST_DEV $TEST_DIR
}
_test_unmount()
{
$UMOUNT_PROG $TEST_DEV
}
_test_remount()
{
$UMOUNT_PROG $TEST_DEV
_test_unmount
_test_mount
}
@@ -326,7 +331,7 @@ _setup_large_xfs_fs()
$SCRATCH_MNT/.use_space 2>&1 > /dev/null
export NUM_SPACE_FILES=1
status=$?
umount $SCRATCH_MNT
_scratch_unmount
if [ $status -ne 0 ]; then
echo "large file prealloc failed"
cat $tmp_dir/mnt.err >&2
@@ -501,7 +506,7 @@ _setup_large_ext4_fs()
fi
export NUM_SPACE_FILES=$nfiles
umount $SCRATCH_MNT
_scratch_unmount
if [ $status -ne 0 ]; then
echo "large file prealloc failed"
cat $tmp_dir/mnt.err >&2
@@ -1178,7 +1183,7 @@ _require_scratch_nocheck()
exit 1
fi
# and then unmount it
if ! $UMOUNT_PROG $SCRATCH_DEV
if ! _scratch_unmount
then
echo "failed to unmount $SCRATCH_DEV"
exit 1
@@ -1422,7 +1427,7 @@ _require_xfs_crc()
_scratch_mkfs_xfs -m crc=1 >/dev/null 2>&1
_scratch_mount >/dev/null 2>&1 \
|| _notrun "Kernel doesn't support crc feature"
umount $SCRATCH_MNT
_scratch_unmount
}
# this test requires the ext4 kernel support crc feature on scratch device
@@ -1433,7 +1438,7 @@ _require_scratch_ext4_crc()
dumpe2fs -h $SCRATCH_DEV 2> /dev/null | grep -q metadata_csum || _notrun "metadata_csum not supported by this filesystem"
_scratch_mount >/dev/null 2>&1 \
|| _notrun "Kernel doesn't support metadata_csum feature"
umount $SCRATCH_MNT
_scratch_unmount
}
# this test requires the xfs kernel support crc feature on scratch device
@@ -1444,7 +1449,7 @@ _require_scratch_xfs_crc()
_scratch_mount >/dev/null 2>&1 \
|| _notrun "Kernel doesn't support crc feature"
xfs_info $SCRATCH_MNT | grep -q 'crc=1' || _notrun "crc feature not supported by this filesystem"
umount $SCRATCH_MNT
_scratch_unmount
}
# this test requires the bigalloc feature to be available in mkfs.ext4
@@ -1462,7 +1467,7 @@ _require_ext4_bigalloc()
$MKFS_EXT4_PROG -F -O bigalloc $SCRATCH_DEV 512m >/dev/null 2>&1
_scratch_mount >/dev/null 2>&1 \
|| _notrun "Ext4 kernel doesn't support bigalloc feature"
umount $SCRATCH_MNT
_scratch_unmount
}
# this test requires the finobt feature to be available in mkfs.xfs
@@ -1480,7 +1485,7 @@ _require_xfs_finobt()
_scratch_mkfs_xfs -m crc=1,finobt=1 >/dev/null 2>&1
_scratch_mount >/dev/null 2>&1 \
|| _notrun "Kernel doesn't support finobt feature"
umount $SCRATCH_MNT
_scratch_unmount
}
# this test requires xfs sysfs attribute support
@@ -1508,7 +1513,7 @@ _require_xfs_sparse_inodes()
_scratch_mkfs_xfs -m crc=1 -i sparse > /dev/null 2>&1
_scratch_mount >/dev/null 2>&1 \
|| _notrun "kernel does not support sparse inodes"
umount $SCRATCH_MNT
_scratch_unmount
}
# this test requires that external log/realtime devices are not in use
@@ -2824,7 +2829,7 @@ _require_meta_uuid()
_scratch_mount >/dev/null 2>&1 \
|| _notrun "Kernel doesn't support meta_uuid feature"
umount $SCRATCH_MNT
_scratch_unmount
}
_require_btrfs_dev_del_by_devid()
+2 -2
View File
@@ -114,7 +114,7 @@ _check_repair()
dd if=/bin/bash of=$SCRATCH_MNT/sh 2>&1 |_filter_dd
sync
rm -f $SCRATCH_MNT/sh
umount $SCRATCH_MNT
_scratch_unmount
_zero_position $value "$structure"
_scratch_xfs_repair 2>&1 | _filter_repair
@@ -127,7 +127,7 @@ _check_repair()
POSIXLY_CORRECT=yes \
dd if=$SCRATCH_MNT/sh of=/dev/null 2>&1 |_filter_dd #read
rm -f $SCRATCH_MNT/sh #unlink
umount $SCRATCH_MNT #umount
_scratch_unmount #umount
}
# make sure this script returns success
+3 -3
View File
@@ -29,7 +29,7 @@ status=1 # failure is the default!
_cleanup()
{
echo " *** umount"
umount $SCRATCH_DEV >/dev/null 2>&1
_scratch_unmount >/dev/null 2>&1
}
trap "_cleanup; exit \$status" 0 1 2 3 15
@@ -85,7 +85,7 @@ _log "*** (`date`)"
_log " *** init"
_log " *** unmounting scratch device"
umount $SCRATCH_DEV 2>&1 | _fix_malloc >>$FULL
_scratch_unmount 2>&1 | _fix_malloc >>$FULL
_log " *** clean scratch device"
@@ -128,7 +128,7 @@ do
_log " *** unmounting scratch device"
umount $SCRATCH_DEV 2>&1 | _logp \
_scratch_unmount 2>&1 | _logp \
|| _fail " !!! failed to umount"
let "pass = pass + 1"
+1 -1
View File
@@ -185,7 +185,7 @@ _save_checksum $SNAPNAME $tmp.$tname.sum
\rm -rf $firstvol/*
_verify_checksum $SNAPNAME $tmp.$tname.sum
umount $SCRATCH_DEV || _fail "unmount failed"
_scratch_unmount || _fail "unmount failed"
echo "Silence is golden"
status=0; exit
+8 -8
View File
@@ -36,7 +36,7 @@ _cleanup()
cd /
rm -f $tmp.*
if [ $dev_removed == 1 ]; then
umount $SCRATCH_MNT
_scratch_unmount
_devmgt_add "${DEVHTL}"
fi
}
@@ -63,7 +63,7 @@ _test_raid0()
_scratch_mount
dirp=`mktemp -duq $SCRATCH_MNT/dir.XXXXXX`
_populate_fs -n 1 -f 20 -d 10 -r $dirp -s 10
umount $SCRATCH_MNT
_scratch_unmount
}
_test_raid1()
@@ -73,7 +73,7 @@ _test_raid1()
_scratch_mount
dirp=`mktemp -duq $SCRATCH_MNT/dir.XXXXXX`
_populate_fs -n 1 -f 20 -d 10 -r $dirp -s 10
umount $SCRATCH_MNT
_scratch_unmount
}
_test_raid10()
@@ -83,7 +83,7 @@ _test_raid10()
_scratch_mount
dirp=`mktemp -duq $SCRATCH_MNT/dir.XXXXXX`
_populate_fs -n 1 -f 20 -d 10 -r $dirp -s 10
umount $SCRATCH_MNT
_scratch_unmount
}
_test_single()
@@ -93,7 +93,7 @@ _test_single()
_scratch_mount
dirp=`mktemp -duq $SCRATCH_MNT/dir.XXXXXX`
_populate_fs -n 1 -f 20 -d 10 -r $dirp -s 10
umount $SCRATCH_MNT
_scratch_unmount
}
_test_add()
@@ -115,7 +115,7 @@ _test_add()
$BTRFS_UTIL_PROG device add ${devs[$i]} $SCRATCH_MNT >> $seqres.full 2>&1 || _fail "device add failed"
done
$BTRFS_UTIL_PROG filesystem balance $SCRATCH_MNT >> $seqres.full 2>&1 || _fail "balance failed"
umount $SCRATCH_MNT
_scratch_unmount
}
_test_replace()
@@ -161,7 +161,7 @@ _test_replace()
$BTRFS_UTIL_PROG filesystem balance $SCRATCH_MNT >> $seqres.full 2>&1 || _fail "dev balance failed"
# cleaup. add the removed disk
umount $SCRATCH_MNT
_scratch_unmount
_devmgt_add "${DEVHTL}"
dev_removed=0
}
@@ -177,7 +177,7 @@ _test_remove()
dev_del=`echo ${SCRATCH_DEV_POOL} | awk '{print $NF}'`
$BTRFS_UTIL_PROG device delete $dev_del $SCRATCH_MNT || _fail "btrfs device delete failed"
$BTRFS_UTIL_PROG filesystem show $SCRATCH_DEV 2>&1 | grep $dev_del >> $seqres.full && _fail "btrfs still shows the deleted dev"
umount $SCRATCH_MNT
_scratch_unmount
}
_test_raid0
+3 -3
View File
@@ -180,7 +180,7 @@ workout()
snap_name=$4
do_bg_noise=$5
umount $SCRATCH_DEV >/dev/null 2>&1
_scratch_unmount >/dev/null 2>&1
echo "*** mkfs -dsize=$fsz" >>$seqres.full
echo "" >>$seqres.full
_scratch_mkfs_sized $fsz >>$seqres.full 2>&1 \
@@ -193,7 +193,7 @@ workout()
_run_btrfs_util_prog subvolume snapshot $SCRATCH_MNT \
$SCRATCH_MNT/$snap_name
run_check umount $SCRATCH_DEV >/dev/null 2>&1
run_check _scratch_unmount >/dev/null 2>&1
run_check _scratch_mount "-o compress=lzo"
# make some noise but ensure we're not touching existing data
@@ -207,7 +207,7 @@ workout()
# now make more files to get a higher tree
run_check $FSSTRESS_PROG -d $clean_dir -w -p $procs -n 2000 \
$FSSTRESS_AVOID
run_check umount $SCRATCH_DEV >/dev/null 2>&1
run_check _scratch_unmount >/dev/null 2>&1
run_check _scratch_mount "-o atime"
if [ $do_bg_noise -ne 0 ]; then
+2 -2
View File
@@ -106,12 +106,12 @@ _checksum()
_cleanup_defrag()
{
umount $SCRATCH_MNT > /dev/null 2>&1
_scratch_unmount > /dev/null 2>&1
}
_setup_defrag()
{
umount $SCRATCH_MNT > /dev/null 2>&1
_scratch_unmount > /dev/null 2>&1
_scratch_mkfs > /dev/null 2>&1
_scratch_mount
_create_file $1
+3 -3
View File
@@ -37,7 +37,7 @@ status=1
_cleanup()
{
echo "*** unmount"
umount $SCRATCH_MNT 2>/dev/null
_scratch_unmount 2>/dev/null
rm -f $tmp.*
}
trap "_cleanup; exit \$status" 0 1 2 3 15
@@ -61,7 +61,7 @@ workout()
fsz=$1
ops=$2
umount $SCRATCH_DEV >/dev/null 2>&1
_scratch_unmount >/dev/null 2>&1
echo "*** mkfs -dsize=$fsz" >>$seqres.full
echo "" >>$seqres.full
_scratch_mkfs_sized $fsz >>$seqres.full 2>&1 \
@@ -87,7 +87,7 @@ workout()
run_check $FSSUM_PROG -A -f -w $tmp/incr.fssum -x $SCRATCH_MNT/incr/base \
$SCRATCH_MNT/incr
umount $SCRATCH_DEV >/dev/null 2>&1
_scratch_unmount >/dev/null 2>&1
echo "*** mkfs -dsize=$fsz" >>$seqres.full
echo "" >>$seqres.full
_scratch_mkfs_sized $fsz >>$seqres.full 2>&1 \
+3 -3
View File
@@ -151,7 +151,7 @@ workout()
sync; sync
btrfs_replace_test $source_dev $target_dev "" $with_cancel $quick
umount $SCRATCH_MNT > /dev/null 2>&1
_scratch_unmount > /dev/null 2>&1
if echo $mkfs_options | egrep -qv "raid1|raid5|raid6|raid10" || \
[ "${with_cancel}Q" = "cancelQ" ]; then
@@ -201,7 +201,7 @@ workout()
fi
btrfs_replace_test $source_dev $target_dev "-r" $with_cancel $quick
umount $SCRATCH_MNT > /dev/null 2>&1
_scratch_unmount > /dev/null 2>&1
}
btrfs_replace_test()
@@ -264,7 +264,7 @@ btrfs_replace_test()
# because in /proc/mounts the 2nd device of the filesystem is
# shown after the replace operation. Let's just do the mount
# test manually after _check_btrfs_filesystem is finished.
umount $SCRATCH_MNT > /dev/null 2>&1
_scratch_unmount > /dev/null 2>&1
if [ "${with_cancel}Q" != "cancelQ" ]; then
# after the replace operation, use the target_dev for everything
_check_btrfs_filesystem $target_dev
+2 -2
View File
@@ -39,7 +39,7 @@ trap "_cleanup; exit \$status" 0 1 2 3 15
_cleanup()
{
umount $SCRATCH_MNT &>/dev/null
_scratch_unmount &>/dev/null
cd /
rm -f $tmp.*
}
@@ -104,7 +104,7 @@ _scratch_unmount
echo "test reflinks across different mountpoints of same device"
mount $TEST_DEV $SCRATCH_MNT || _fail "Couldn't double-mount $TEST_DEV"
_create_reflinks_to $DUAL_MOUNT_DIR
umount $SCRATCH_MNT
_scratch_unmount
# success, all done
status=0
+1 -1
View File
@@ -36,7 +36,7 @@ trap "_cleanup; exit \$status" 0 1 2 3 15
_cleanup()
{
umount $SCRATCH_MNT
_scratch_unmount
rm -rf $TESTDIR1
rm -rf $TESTDIR2
$BTRFS_UTIL_PROG subvolume delete $SUBVOL1 >> $seqres.full
+1 -1
View File
@@ -78,7 +78,7 @@ _check_ext4_eof_flag()
bit_set=1
# Unmount the ${TEST_DEV}
umount ${TEST_DEV}
_test_unmount
# Run debugfs to gather file_parameters - specifically iflags.
file_params=`debugfs ${TEST_DEV} -R "stat ${1}" 2>&1 | grep -e Flags:`
+1 -1
View File
@@ -112,7 +112,7 @@ _scratch_mkfs >> $seqres.full 2>&1
_scratch_mount
if ! _workout; then
umount $SCRATCH_DEV 2>/dev/null
_scratch_unmount 2>/dev/null
exit
fi

Some files were not shown because too many files have changed in this diff Show More