@@ -382,6 +382,25 @@ _scratch_cycle_mount()
_scratch_mount "$opts"
}
+_scratch_shutdown()
+{
+ if [ $FSTYP = "overlay" ]; then
+ # In lagacy overlay usage, it may specify directory as
+ # SCRATCH_DEV, in this case OVL_BASE_SCRATCH_DEV
+ # will be null, so check OVL_BASE_SCRATCH_DEV before
+ # running shutdown to avoid shutting down base fs accidently.
+ if [ -z $OVL_BASE_SCRATCH_DEV ]; then
+ _fail "Called _scratch_shutdown without validating " \
+ "\$OVL_BASE_SCRATCH_DEV, " \
+ "please call _require_scratch_shutdown first."
+ else
+ src/godown $* $OVL_BASE_SCRATCH_MNT
+ fi
+ else
+ src/godown $* $SCRATCH_MNT
+ fi
+}
+
_test_mount()
{
if [ "$FSTYP" == "overlay" ]; then
@@ -2906,10 +2925,25 @@ _require_scratch_shutdown()
{
[ -x src/godown ] || _notrun "src/godown executable not found"
- _scratch_mkfs > /dev/null 2>&1
- _scratch_mount
- src/godown -f $SCRATCH_MNT 2>&1 \
- || _notrun "$FSTYP does not support shutdown"
+ _scratch_mkfs > /dev/null 2>&1 || _notrun "_scratch_mkfs failed on $SCRATCH_DEV"
+ _scratch_mount || _notrun "_scratch_mount failed on $SCRATCH_MNT"
+
+ if [ $FSTYP = "overlay" ]; then
+ if [ -z $OVL_BASE_SCRATCH_DEV ]; then
+ # In lagacy overlay usage, it may specify directory as
+ # SCRATCH_DEV, in this case OVL_BASE_SCRATCH_DEV
+ # will be null, so check OVL_BASE_SCRATCH_DEV before
+ # running shutdown to avoid shutting down base fs accidently.
+ _notrun "$SCRATCH_DEV is not a block device"
+ else
+ src/godown -f $OVL_BASE_SCRATCH_MNT 2>&1 \
+ || _notrun "Underlying filesystem does not support shutdown"
+ fi
+ else
+ src/godown -f $SCRATCH_MNT 2>&1 \
+ || _notrun "$FSTYP does not support shutdown"
+ fi
+
_scratch_unmount
}
@@ -92,6 +92,7 @@ _require_xfs_io_command "fpunch"
_require_xfs_io_command "fzero"
_scratch_mkfs >/dev/null 2>&1
+_require_local_device $SCRATCH_DEV
_require_metadata_journaling $SCRATCH_DEV
_scratch_mount
@@ -63,7 +63,7 @@ done
# give the system a chance to write something out
sleep 10
-src/godown $SCRATCH_MNT
+_scratch_shutdown
_scratch_unmount
_scratch_mount
@@ -69,7 +69,7 @@ done
# give the system a chance to write something out
sleep 10
-src/godown $SCRATCH_MNT
+_scratch_shutdown
_scratch_unmount
_scratch_mount
@@ -69,7 +69,7 @@ done
# give the system a chance to write something out
sleep 10
-src/godown $SCRATCH_MNT
+_scratch_shutdown
_scratch_unmount
_scratch_mount
@@ -69,7 +69,7 @@ done
# give the system a chance to write something out
sleep 10
-src/godown $SCRATCH_MNT
+_scratch_shutdown
_scratch_unmount
_scratch_mount
@@ -92,7 +92,7 @@ do
done
# shutdown immediately after, then remount and test
-src/godown $SCRATCH_MNT
+_scratch_shutdown
_scratch_unmount
_scratch_mount
_scratch_unmount
@@ -96,7 +96,7 @@ done
# sync, then shutdown immediately after, then remount and test
sync
-src/godown $SCRATCH_MNT
+_scratch_shutdown
_scratch_unmount
_scratch_mount
_scratch_unmount
@@ -93,7 +93,7 @@ done
# sync, then shutdown immediately after, then remount and test
sync
-src/godown $SCRATCH_MNT
+_scratch_shutdown
_scratch_unmount
_scratch_mount
_scratch_unmount
@@ -44,6 +44,7 @@ trap "_cleanup; exit \$status" 0 1 2 3 15
_supported_fs generic
_supported_os Linux
+_require_local_device $SCRATCH_DEV
_require_scratch_nocheck
_require_scratch_shutdown
_require_norecovery
@@ -80,7 +80,7 @@ sync
# now shutdown and unmount
sleep 5
-$here/src/godown $load_dir
+_scratch_shutdown
$KILLALL_PROG -q $FSSTRESS_PROG
wait
@@ -63,7 +63,7 @@ echo "touch files"
touch $SCRATCH_MNT/{0,1,2,3,4,5,6,7,8,9}{0,1,2,3,4,5,6,7,8,9}
echo "godown"
-src/godown -v -f $SCRATCH_MNT >> $seqres.full
+_scratch_shutdown -v -f >> $seqres.full
echo "unmount"
_scratch_unmount
@@ -108,7 +108,7 @@ for s in sync nosync ; do
ls $SCRATCH_MNT | _filter_lostfound
_echofull "godown"
- src/godown -v -f $SCRATCH_MNT >> $seqres.full
+ _scratch_shutdown -v -f >> $seqres.full
_echofull "unmount"
_scratch_unmount >>$seqres.full 2>&1 \
@@ -118,7 +118,7 @@ do
ls -RF $SCRATCH_MNT >$tmp.ls1
_echofull "godown"
- src/godown -v -f $SCRATCH_MNT >> $seqres.full
+ _scratch_shutdown -v -f >> $seqres.full
_echofull "unmount"
_scratch_unmount >>$seqres.full 2>&1 \
@@ -54,6 +54,7 @@ _supported_fs generic
_supported_os Linux
_require_scratch
+_require_local_device $SCRATCH_DEV
_require_scratch_shutdown
_require_command "$KILLALL_PROG" "killall"
@@ -72,7 +73,7 @@ for i in $(seq 1 $((50 * TIME_FACTOR)) ); do
# purposely include 0 second sleeps to test shutdown immediately after
# recovery
sleep $((RANDOM % 3))
- ./src/godown $SCRATCH_MNT
+ _scratch_shutdown
ps -e | grep fsstress > /dev/null 2>&1
while [ $? -eq 0 ]; do
@@ -73,7 +73,7 @@ check_inode_metadata()
before=`stat "$stat_opt" $testfile`
$XFS_IO_PROG -c "$sync_mode" $testfile | _filter_xfs_io
- src/godown $SCRATCH_MNT | tee -a $seqres.full
+ _scratch_shutdown | tee -a $seqres.full
_scratch_cycle_mount
after=`stat "$stat_opt" $testfile`
@@ -75,7 +75,7 @@ function create_dirty_orphans() {
sleep 3
echo "godown"
- src/godown -v -f $SCRATCH_MNT >> $seqres.full
+ _scratch_shutdown -v -f >> $seqres.full
# kill the multi_open_unlink
kill $pid 2>/dev/null
@@ -68,7 +68,7 @@ sync
# now shutdown and unmount
sleep 5
-$here/src/godown $load_dir
+_scratch_shutdown
$KILLALL_PROG -q $FSSTRESS_PROG
wait
@@ -84,7 +84,7 @@ check_inode_metadata()
before=`stat "$stat_opt" $testfile`
$XFS_IO_PROG -c "$sync_mode" $testfile | _filter_xfs_io
- $here/src/godown $SCRATCH_MNT | tee -a $seqres.full
+ _scratch_shutdown | tee -a $seqres.full
_scratch_cycle_mount
after=`stat "$stat_opt" $testfile`
check -overlay overrides variable SCRATCH_MNT to it's own, so overlayfs can not be accepted by _require_scratch_shutdown. In order to test some cases which require shutdown on overlayfs, adjust shutdown target from SCRATCH_MNT to OVL_BASE_SCRATCH_MNT(underlaying filesystem) when detecting overlayfs to pass require check successfully. And in actual case, convert bare godown calling to a helper _scratch_shutdown which can recognize overlayfs and handle shutdown correctly for avoiding failure of original cases in the generic shutdown group except cases require local device. Signed-off-by: Chengguang Xu <cgxu519@icloud.com> --- Changes since v4: 1. Add return code check for _scratch_mkfs and _scratch_mount in _require_scratch_shutdown. 2. Change commit log. Changes since v3: 1. When _scratch_shutdown() detecting improper shutdown on overlayfs, prompt error message and exit immediately. 2. Convert godown to _scratch_shutdown for the cases overlayfs shuold run. 3. Add _require_local_device to the cases overlayfs should not run. Changes since v2: 1. Make option for _scratch_shutdown(), so caller can specify option when calling. 2. Add comment for why overlay requires special handling. 3. Add commit log. Changes since v1: _scratch_shutdown() does not call notrun. common/rc | 42 ++++++++++++++++++++++++++++++++++++++---- tests/generic/042 | 1 + tests/generic/043 | 2 +- tests/generic/044 | 2 +- tests/generic/045 | 2 +- tests/generic/046 | 2 +- tests/generic/047 | 2 +- tests/generic/048 | 2 +- tests/generic/049 | 2 +- tests/generic/050 | 1 + tests/generic/051 | 2 +- tests/generic/052 | 2 +- tests/generic/054 | 2 +- tests/generic/055 | 2 +- tests/generic/388 | 3 ++- tests/generic/392 | 2 +- tests/generic/417 | 2 +- tests/generic/461 | 2 +- tests/generic/468 | 2 +- 19 files changed, 57 insertions(+), 20 deletions(-)