Skip to content

Commit 27d077e

Browse files
Eric Sandeendchinner
Eric Sandeen
authored andcommitted
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 <[email protected]> Signed-off-by: Eric Sandeen <[email protected]> Reviewed-by: Dave Chinner <[email protected]> Signed-off-by: Dave Chinner <[email protected]>
1 parent 4545386 commit 27d077e

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

136 files changed

+293
-288
lines changed

check

+5-5
Original file line numberDiff line numberDiff line change
@@ -439,7 +439,7 @@ for section in $HOST_OPTIONS_SECTIONS; do
439439

440440
if $RECREATE_TEST_DEV || [ "$OLD_FSTYP" != "$FSTYP" ]; then
441441
echo "RECREATING -- $FSTYP on $TEST_DEV"
442-
umount $TEST_DEV 2> /dev/null
442+
_test_unmount 2> /dev/null
443443
if ! _test_mkfs >$tmp.err 2>&1
444444
then
445445
echo "our local _test_mkfs routine ..."
@@ -456,7 +456,7 @@ for section in $HOST_OPTIONS_SECTIONS; do
456456
fi
457457
_prepare_test_list
458458
elif [ "$OLD_MOUNT_OPTIONS" != "$MOUNT_OPTIONS" ]; then
459-
umount $TEST_DEV 2> /dev/null
459+
_test_unmount 2> /dev/null
460460
out=`_mount_or_remount_rw "$MOUNT_OPTIONS" $TEST_DEV $TEST_DIR`
461461
if [ $? -ne 1 ]; then
462462
echo $out
@@ -486,7 +486,7 @@ for section in $HOST_OPTIONS_SECTIONS; do
486486
needwrap=true
487487

488488
if [ ! -z "$SCRATCH_DEV" ]; then
489-
umount $SCRATCH_DEV 2>/dev/null
489+
_scratch_unmount 2> /dev/null
490490
# call the overridden mkfs - make sure the FS is built
491491
# the same as we'll create it later.
492492

@@ -679,8 +679,8 @@ for section in $HOST_OPTIONS_SECTIONS; do
679679
_wrapup
680680
echo
681681

682-
umount $TEST_DEV 2> /dev/null
683-
umount $SCRATCH_DEV 2> /dev/null
682+
_test_unmount 2> /dev/null
683+
_scratch_unmount 2> /dev/null
684684
done
685685

686686
interrupt=false

common/attr

+1-1
Original file line numberDiff line numberDiff line change
@@ -233,7 +233,7 @@ _require_noattr2()
233233
{
234234
_scratch_mkfs_xfs > /dev/null 2>&1 \
235235
|| _fail "_scratch_mkfs_xfs failed on $SCRATCH_DEV"
236-
_mount -o noattr2 $SCRATCH_DEV > /dev/null 2>&1 \
236+
_scratch_mount -o noattr2 > /dev/null 2>&1 \
237237
|| _notrun "noattr2 mount option not supported on $SCRATCH_DEV"
238238
_scratch_unmount
239239
}

common/dump

+1-1
Original file line numberDiff line numberDiff line change
@@ -288,7 +288,7 @@ _cleanup()
288288
_stable_fs()
289289
{
290290
_saveddir=`pwd`; cd /
291-
umount $SCRATCH_MNT >>$seqres.full || _fail "unmount failed"
291+
_scratch_unmount >>$seqres.full || _fail "unmount failed"
292292
_scratch_mount >>$seqres.full || _fail "mount failed"
293293
cd $_saveddir
294294
}

common/filestreams

+1-1
Original file line numberDiff line numberDiff line change
@@ -225,5 +225,5 @@ _cleanup_streams_umount()
225225
{
226226
cd /
227227
rm -rf ${SCRATCH_MNT}/stream*
228-
umount $SCRATCH_DEV 2>/dev/null
228+
_scratch_unmount 2>/dev/null
229229
}

common/log

+3-3
Original file line numberDiff line numberDiff line change
@@ -339,7 +339,7 @@ _create_log()
339339

340340
# unmount the FS
341341
_full "umount"
342-
umount $SCRATCH_DEV >>$seqres.full 2>&1
342+
_scratch_unmount >>$seqres.full 2>&1
343343
if [ $? -ne 0 ] ; then
344344
_echofull "umount failed"
345345
return 1
@@ -370,7 +370,7 @@ _create_log_sync()
370370

371371
# unmount the FS
372372
_full "umount"
373-
umount $SCRATCH_DEV >>$seqres.full 2>&1
373+
_scratch_unmount >>$seqres.full 2>&1
374374
if [ $? -ne 0 ] ; then
375375
_echofull "umount failed"
376376
return 1
@@ -482,7 +482,7 @@ _require_v2log()
482482
# check after unmount to see if it is clean
483483
# i.e. it is not a 6.5.25 buggy version checking kernel
484484
touch $SCRATCH_MNT/file
485-
umount $SCRATCH_DEV >>$seqres.full 2>&1
485+
_scratch_unmount >>$seqres.full 2>&1
486486
if _scratch_xfs_logprint -t | tee -a $seqres.full \
487487
| head | grep -q "<DIRTY>"; then
488488
_notrun "kernel does not support v2 logs"

common/punch

+1-1
Original file line numberDiff line numberDiff line change
@@ -115,7 +115,7 @@ _test_punch() {
115115
local filename=punch_test_file
116116

117117
cd /
118-
umount $SCRATCH_MNT >/dev/null 2>&1
118+
_scratch_unmount >/dev/null 2>&1
119119

120120
_scratch_mkfs_xfs -bsize=$blksize >/dev/null 2>&1 \
121121
|| _fail "mkfs failed"

common/quota

+1-1
Original file line numberDiff line numberDiff line change
@@ -167,7 +167,7 @@ _choose_prid()
167167

168168
_qmount()
169169
{
170-
umount $SCRATCH_DEV >/dev/null 2>&1
170+
_scratch_unmount >/dev/null 2>&1
171171
_scratch_mount || _fail "qmount failed"
172172
chmod ugo+rwx $SCRATCH_MNT
173173
}

common/rc

+16-11
Original file line numberDiff line numberDiff line change
@@ -270,9 +270,14 @@ _test_mount()
270270
_mount -t $FSTYP $TEST_OPTIONS $TEST_FS_MOUNT_OPTS $SELINUX_MOUNT_OPTIONS $* $TEST_DEV $TEST_DIR
271271
}
272272

273+
_test_unmount()
274+
{
275+
$UMOUNT_PROG $TEST_DEV
276+
}
277+
273278
_test_remount()
274279
{
275-
$UMOUNT_PROG $TEST_DEV
280+
_test_unmount
276281
_test_mount
277282
}
278283

@@ -326,7 +331,7 @@ _setup_large_xfs_fs()
326331
$SCRATCH_MNT/.use_space 2>&1 > /dev/null
327332
export NUM_SPACE_FILES=1
328333
status=$?
329-
umount $SCRATCH_MNT
334+
_scratch_unmount
330335
if [ $status -ne 0 ]; then
331336
echo "large file prealloc failed"
332337
cat $tmp_dir/mnt.err >&2
@@ -501,7 +506,7 @@ _setup_large_ext4_fs()
501506
fi
502507
export NUM_SPACE_FILES=$nfiles
503508

504-
umount $SCRATCH_MNT
509+
_scratch_unmount
505510
if [ $status -ne 0 ]; then
506511
echo "large file prealloc failed"
507512
cat $tmp_dir/mnt.err >&2
@@ -1178,7 +1183,7 @@ _require_scratch_nocheck()
11781183
exit 1
11791184
fi
11801185
# and then unmount it
1181-
if ! $UMOUNT_PROG $SCRATCH_DEV
1186+
if ! _scratch_unmount
11821187
then
11831188
echo "failed to unmount $SCRATCH_DEV"
11841189
exit 1
@@ -1422,7 +1427,7 @@ _require_xfs_crc()
14221427
_scratch_mkfs_xfs -m crc=1 >/dev/null 2>&1
14231428
_scratch_mount >/dev/null 2>&1 \
14241429
|| _notrun "Kernel doesn't support crc feature"
1425-
umount $SCRATCH_MNT
1430+
_scratch_unmount
14261431
}
14271432

14281433
# this test requires the ext4 kernel support crc feature on scratch device
@@ -1433,7 +1438,7 @@ _require_scratch_ext4_crc()
14331438
dumpe2fs -h $SCRATCH_DEV 2> /dev/null | grep -q metadata_csum || _notrun "metadata_csum not supported by this filesystem"
14341439
_scratch_mount >/dev/null 2>&1 \
14351440
|| _notrun "Kernel doesn't support metadata_csum feature"
1436-
umount $SCRATCH_MNT
1441+
_scratch_unmount
14371442
}
14381443

14391444
# this test requires the xfs kernel support crc feature on scratch device
@@ -1444,7 +1449,7 @@ _require_scratch_xfs_crc()
14441449
_scratch_mount >/dev/null 2>&1 \
14451450
|| _notrun "Kernel doesn't support crc feature"
14461451
xfs_info $SCRATCH_MNT | grep -q 'crc=1' || _notrun "crc feature not supported by this filesystem"
1447-
umount $SCRATCH_MNT
1452+
_scratch_unmount
14481453
}
14491454

14501455
# this test requires the bigalloc feature to be available in mkfs.ext4
@@ -1462,7 +1467,7 @@ _require_ext4_bigalloc()
14621467
$MKFS_EXT4_PROG -F -O bigalloc $SCRATCH_DEV 512m >/dev/null 2>&1
14631468
_scratch_mount >/dev/null 2>&1 \
14641469
|| _notrun "Ext4 kernel doesn't support bigalloc feature"
1465-
umount $SCRATCH_MNT
1470+
_scratch_unmount
14661471
}
14671472

14681473
# this test requires the finobt feature to be available in mkfs.xfs
@@ -1480,7 +1485,7 @@ _require_xfs_finobt()
14801485
_scratch_mkfs_xfs -m crc=1,finobt=1 >/dev/null 2>&1
14811486
_scratch_mount >/dev/null 2>&1 \
14821487
|| _notrun "Kernel doesn't support finobt feature"
1483-
umount $SCRATCH_MNT
1488+
_scratch_unmount
14841489
}
14851490

14861491
# this test requires xfs sysfs attribute support
@@ -1508,7 +1513,7 @@ _require_xfs_sparse_inodes()
15081513
_scratch_mkfs_xfs -m crc=1 -i sparse > /dev/null 2>&1
15091514
_scratch_mount >/dev/null 2>&1 \
15101515
|| _notrun "kernel does not support sparse inodes"
1511-
umount $SCRATCH_MNT
1516+
_scratch_unmount
15121517
}
15131518

15141519
# this test requires that external log/realtime devices are not in use
@@ -2824,7 +2829,7 @@ _require_meta_uuid()
28242829

28252830
_scratch_mount >/dev/null 2>&1 \
28262831
|| _notrun "Kernel doesn't support meta_uuid feature"
2827-
umount $SCRATCH_MNT
2832+
_scratch_unmount
28282833
}
28292834

28302835
_require_btrfs_dev_del_by_devid()

common/repair

+2-2
Original file line numberDiff line numberDiff line change
@@ -114,7 +114,7 @@ _check_repair()
114114
dd if=/bin/bash of=$SCRATCH_MNT/sh 2>&1 |_filter_dd
115115
sync
116116
rm -f $SCRATCH_MNT/sh
117-
umount $SCRATCH_MNT
117+
_scratch_unmount
118118

119119
_zero_position $value "$structure"
120120
_scratch_xfs_repair 2>&1 | _filter_repair
@@ -127,7 +127,7 @@ _check_repair()
127127
POSIXLY_CORRECT=yes \
128128
dd if=$SCRATCH_MNT/sh of=/dev/null 2>&1 |_filter_dd #read
129129
rm -f $SCRATCH_MNT/sh #unlink
130-
umount $SCRATCH_MNT #umount
130+
_scratch_unmount #umount
131131
}
132132

133133
# make sure this script returns success

soak

+3-3
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ status=1 # failure is the default!
2929
_cleanup()
3030
{
3131
echo " *** umount"
32-
umount $SCRATCH_DEV >/dev/null 2>&1
32+
_scratch_unmount >/dev/null 2>&1
3333
}
3434

3535
trap "_cleanup; exit \$status" 0 1 2 3 15
@@ -85,7 +85,7 @@ _log "*** (`date`)"
8585
_log " *** init"
8686
_log " *** unmounting scratch device"
8787

88-
umount $SCRATCH_DEV 2>&1 | _fix_malloc >>$FULL
88+
_scratch_unmount 2>&1 | _fix_malloc >>$FULL
8989

9090
_log " *** clean scratch device"
9191

@@ -128,7 +128,7 @@ do
128128

129129
_log " *** unmounting scratch device"
130130

131-
umount $SCRATCH_DEV 2>&1 | _logp \
131+
_scratch_unmount 2>&1 | _logp \
132132
|| _fail " !!! failed to umount"
133133

134134
let "pass = pass + 1"

tests/btrfs/002

+1-1
Original file line numberDiff line numberDiff line change
@@ -185,7 +185,7 @@ _save_checksum $SNAPNAME $tmp.$tname.sum
185185
\rm -rf $firstvol/*
186186
_verify_checksum $SNAPNAME $tmp.$tname.sum
187187

188-
umount $SCRATCH_DEV || _fail "unmount failed"
188+
_scratch_unmount || _fail "unmount failed"
189189

190190
echo "Silence is golden"
191191
status=0; exit

tests/btrfs/003

+8-8
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ _cleanup()
3636
cd /
3737
rm -f $tmp.*
3838
if [ $dev_removed == 1 ]; then
39-
umount $SCRATCH_MNT
39+
_scratch_unmount
4040
_devmgt_add "${DEVHTL}"
4141
fi
4242
}
@@ -63,7 +63,7 @@ _test_raid0()
6363
_scratch_mount
6464
dirp=`mktemp -duq $SCRATCH_MNT/dir.XXXXXX`
6565
_populate_fs -n 1 -f 20 -d 10 -r $dirp -s 10
66-
umount $SCRATCH_MNT
66+
_scratch_unmount
6767
}
6868

6969
_test_raid1()
@@ -73,7 +73,7 @@ _test_raid1()
7373
_scratch_mount
7474
dirp=`mktemp -duq $SCRATCH_MNT/dir.XXXXXX`
7575
_populate_fs -n 1 -f 20 -d 10 -r $dirp -s 10
76-
umount $SCRATCH_MNT
76+
_scratch_unmount
7777
}
7878

7979
_test_raid10()
@@ -83,7 +83,7 @@ _test_raid10()
8383
_scratch_mount
8484
dirp=`mktemp -duq $SCRATCH_MNT/dir.XXXXXX`
8585
_populate_fs -n 1 -f 20 -d 10 -r $dirp -s 10
86-
umount $SCRATCH_MNT
86+
_scratch_unmount
8787
}
8888

8989
_test_single()
@@ -93,7 +93,7 @@ _test_single()
9393
_scratch_mount
9494
dirp=`mktemp -duq $SCRATCH_MNT/dir.XXXXXX`
9595
_populate_fs -n 1 -f 20 -d 10 -r $dirp -s 10
96-
umount $SCRATCH_MNT
96+
_scratch_unmount
9797
}
9898

9999
_test_add()
@@ -115,7 +115,7 @@ _test_add()
115115
$BTRFS_UTIL_PROG device add ${devs[$i]} $SCRATCH_MNT >> $seqres.full 2>&1 || _fail "device add failed"
116116
done
117117
$BTRFS_UTIL_PROG filesystem balance $SCRATCH_MNT >> $seqres.full 2>&1 || _fail "balance failed"
118-
umount $SCRATCH_MNT
118+
_scratch_unmount
119119
}
120120

121121
_test_replace()
@@ -161,7 +161,7 @@ _test_replace()
161161
$BTRFS_UTIL_PROG filesystem balance $SCRATCH_MNT >> $seqres.full 2>&1 || _fail "dev balance failed"
162162

163163
# cleaup. add the removed disk
164-
umount $SCRATCH_MNT
164+
_scratch_unmount
165165
_devmgt_add "${DEVHTL}"
166166
dev_removed=0
167167
}
@@ -177,7 +177,7 @@ _test_remove()
177177
dev_del=`echo ${SCRATCH_DEV_POOL} | awk '{print $NF}'`
178178
$BTRFS_UTIL_PROG device delete $dev_del $SCRATCH_MNT || _fail "btrfs device delete failed"
179179
$BTRFS_UTIL_PROG filesystem show $SCRATCH_DEV 2>&1 | grep $dev_del >> $seqres.full && _fail "btrfs still shows the deleted dev"
180-
umount $SCRATCH_MNT
180+
_scratch_unmount
181181
}
182182

183183
_test_raid0

tests/btrfs/004

+3-3
Original file line numberDiff line numberDiff line change
@@ -180,7 +180,7 @@ workout()
180180
snap_name=$4
181181
do_bg_noise=$5
182182

183-
umount $SCRATCH_DEV >/dev/null 2>&1
183+
_scratch_unmount >/dev/null 2>&1
184184
echo "*** mkfs -dsize=$fsz" >>$seqres.full
185185
echo "" >>$seqres.full
186186
_scratch_mkfs_sized $fsz >>$seqres.full 2>&1 \
@@ -193,7 +193,7 @@ workout()
193193
_run_btrfs_util_prog subvolume snapshot $SCRATCH_MNT \
194194
$SCRATCH_MNT/$snap_name
195195

196-
run_check umount $SCRATCH_DEV >/dev/null 2>&1
196+
run_check _scratch_unmount >/dev/null 2>&1
197197
run_check _scratch_mount "-o compress=lzo"
198198

199199
# make some noise but ensure we're not touching existing data
@@ -207,7 +207,7 @@ workout()
207207
# now make more files to get a higher tree
208208
run_check $FSSTRESS_PROG -d $clean_dir -w -p $procs -n 2000 \
209209
$FSSTRESS_AVOID
210-
run_check umount $SCRATCH_DEV >/dev/null 2>&1
210+
run_check _scratch_unmount >/dev/null 2>&1
211211
run_check _scratch_mount "-o atime"
212212

213213
if [ $do_bg_noise -ne 0 ]; then

tests/btrfs/005

+2-2
Original file line numberDiff line numberDiff line change
@@ -106,12 +106,12 @@ _checksum()
106106

107107
_cleanup_defrag()
108108
{
109-
umount $SCRATCH_MNT > /dev/null 2>&1
109+
_scratch_unmount > /dev/null 2>&1
110110
}
111111

112112
_setup_defrag()
113113
{
114-
umount $SCRATCH_MNT > /dev/null 2>&1
114+
_scratch_unmount > /dev/null 2>&1
115115
_scratch_mkfs > /dev/null 2>&1
116116
_scratch_mount
117117
_create_file $1

0 commit comments

Comments
 (0)