overlay: correct scratch dirs check
authorzhangyi (F) <yi.zhang@huawei.com>
Thu, 1 Mar 2018 12:13:47 +0000 (20:13 +0800)
committerEryu Guan <guaneryu@gmail.com>
Thu, 1 Mar 2018 15:02:48 +0000 (23:02 +0800)
Tests that use _overlay_scratch_mount_dirs instead of _scratch_mount
should use _require_scratch_nocheck instead of _require_scratch
because these tests are either mounting with multiple lower dirs or
mounting with non-default lower/upper/work dir, so
_check_overlay_scratch_fs won't handle these cases correctly. So we
introduce _overlay_check_scratch_dirs helper and should call this
helper with the correct dir arguments for these non-default cases.

This patch modify these tests to optionally call
_overlay_check_scratch_dirs at the end of the test or after
_scratch_umount to mount base filesystem only and run the checker.

Signed-off-by: zhangyi (F) <yi.zhang@huawei.com>
Reviewed-by: Amir Goldstein <amir73il@gmail.com>
Signed-off-by: Eryu Guan <guaneryu@gmail.com>
14 files changed:
common/overlay
tests/overlay/005
tests/overlay/010
tests/overlay/014
tests/overlay/035
tests/overlay/036
tests/overlay/037
tests/overlay/038
tests/overlay/041
tests/overlay/043
tests/overlay/044
tests/overlay/051
tests/overlay/053
tests/overlay/055

index 5d01e5e7b7e804f22fa46a54a8fdee199d26cdd1..441827b88fc68d1a2bf68be0b8cba59f6247c12f 100644 (file)
@@ -219,6 +219,35 @@ _overlay_check_dirs()
        return $err
 }
 
+# Check the same mnt/dev of _check_overlay_scratch_fs but non-default
+# underlying scratch dirs of overlayfs, it needs lower/upper/work dirs
+# provided as arguments, and it's useful for non-default setups such
+# as multiple lower layers
+_overlay_check_scratch_dirs()
+{
+       local lowerdir=$1
+       local upperdir=$2
+       local workdir=$3
+       shift 3
+
+       # Need to umount overlay for scratch dir check
+       local ovl_mounted=`_is_dir_mountpoint $SCRATCH_MNT`
+       [ -z "$ovl_mounted" ] || $UMOUNT_PROG $SCRATCH_MNT
+
+       # Check dirs with extra overlay options
+       _overlay_check_dirs $lowerdir $upperdir $workdir $*
+       local ret=$?
+
+       if [ $ret -eq 0 -a -n "$ovl_mounted" ]; then
+               # overlay was mounted, remount with extra mount options
+               _overlay_scratch_mount_dirs $lowerdir $upperdir \
+                                           $workdir $*
+               ret=$?
+       fi
+
+       return $ret
+}
+
 _overlay_check_fs()
 {
        # The first arguments is overlay mount point use for checking
index 17992a398054682c1a358190cf55b9bbe04d4067..87fc9bbc54fb3caf564c9ac545c6b42bb7b51a79 100755 (executable)
@@ -54,7 +54,9 @@ rm -f $seqres.full
 # Modify as appropriate.
 _supported_fs overlay
 _supported_os Linux
-_require_scratch
+# Use non-default scratch underlying overlay dirs, we need to check
+# them explicity after test.
+_require_scratch_nocheck
 _require_loop
 
 # Remove all files from previous tests
@@ -102,6 +104,9 @@ $XFS_IO_PROG -f -c "o" ${SCRATCH_MNT}/test_file \
 # unmount overlayfs
 $UMOUNT_PROG $SCRATCH_MNT
 
+# check overlayfs
+_overlay_check_scratch_dirs $lowerd $upperd $workd
+
 # unmount undelying xfs, this tiggers panic if memleak happens
 $UMOUNT_PROG ${OVL_BASE_SCRATCH_MNT}/uppermnt
 $UMOUNT_PROG ${OVL_BASE_SCRATCH_MNT}/lowermnt
index f55ebecf9afad13a32d1094b3918d0efcbcc0694..32af89c82fe044dbe83d5c7e7462e218b3c9dc78 100755 (executable)
@@ -48,7 +48,9 @@ rm -f $seqres.full
 # real QA test starts here
 _supported_fs overlay
 _supported_os Linux
-_require_scratch
+# Use non-default scratch underlying overlay dirs, we need to check
+# them explicity after test.
+_require_scratch_nocheck
 
 # Remove all files from previous tests
 _scratch_mkfs
@@ -70,6 +72,9 @@ mknod $lowerdir2/testdir/a c 0 0
 _overlay_scratch_mount_dirs "$lowerdir2:$lowerdir1" $upperdir $workdir
 rm -rf $SCRATCH_MNT/testdir
 
+# check overlayfs
+_overlay_check_scratch_dirs "$lowerdir2:$lowerdir1" $upperdir $workdir
+
 # success, all done
 echo "Silence is golden"
 status=0
index 9f308d3c5ff46c617fa675b90c34673c89a7dba7..67fad9fd6e306fd11a51b33312c4e93ca5bb73ba 100755 (executable)
@@ -53,7 +53,9 @@ rm -f $seqres.full
 # real QA test starts here
 _supported_fs overlay
 _supported_os Linux
-_require_scratch
+# Use non-default scratch underlying overlay dirs, we need to check
+# them explicity after test.
+_require_scratch_nocheck
 
 # Remove all files from previous tests
 _scratch_mkfs
@@ -78,6 +80,9 @@ mkdir -p $SCRATCH_MNT/testdir/visibledir
 # unmount overlayfs but not base fs
 $UMOUNT_PROG $SCRATCH_MNT
 
+# check overlayfs
+_overlay_check_scratch_dirs $lowerdir1 $lowerdir2 $workdir2
+
 # mount overlay again, with lowerdir1 and lowerdir2 as multiple lowerdirs,
 # and create a new file in testdir, triggers copyup from lowerdir,
 # copyup should not copy overlayfs private xattr
@@ -90,6 +95,9 @@ $UMOUNT_PROG $SCRATCH_MNT
 _overlay_scratch_mount_dirs "$lowerdir2:$lowerdir1" $upperdir $workdir
 ls $SCRATCH_MNT/testdir
 
+# check overlayfs
+_overlay_check_scratch_dirs "$lowerdir2:$lowerdir1" $upperdir $workdir
+
 # success, all done
 status=0
 exit
index 05447741a1ba89d9ee85540f27023d072104b913..d1b2c19b8becf8aa605ee73f720ad13f1141a566 100755 (executable)
@@ -51,7 +51,9 @@ rm -f $seqres.full
 # real QA test starts here
 _supported_fs overlay
 _supported_os Linux
-_require_scratch
+# Use non-default scratch underlying overlay dirs, we need to check
+# them explicity after test.
+_require_scratch_nocheck
 _require_chattr i
 
 # Remove all files from previous tests
@@ -81,6 +83,9 @@ _overlay_scratch_mount_dirs $lowerdir2 $upperdir $workdir
 touch $SCRATCH_MNT/bar 2>&1 | _filter_scratch
 _scratch_remount rw 2>&1 | _filter_ro_mount
 
+# check overlayfs
+_overlay_check_scratch_dirs $lowerdir2 $upperdir $workdir
+
 # success, all done
 status=0
 exit
index e04aaeee47b8585ce157a55bc3f08c1aecdcf24c..8d3ccf49cbbd1a2351ff14ca09c0e6725597b79a 100755 (executable)
@@ -69,7 +69,9 @@ rm -f $seqres.full
 # real QA test starts here
 _supported_fs overlay
 _supported_os Linux
-_require_scratch
+# Use non-default scratch underlying overlay dirs, we need to check
+# them explicity after test.
+_require_scratch_nocheck
 _require_scratch_feature index
 
 # Remove all files from previous tests
@@ -110,6 +112,8 @@ _overlay_mount_dirs $lowerdir $upperdir $workdir2 \
 _overlay_mount_dirs $lowerdir2 $upperdir2 $workdir \
            overlay3 $SCRATCH_MNT -oindex=on 2>&1 | _filter_busy_mount
 
+# check overlayfs
+_overlay_check_scratch_dirs $lowerdir $upperdir $workdir
 
 # success, all done
 status=0
index 6710ddaf4802b6c3a5e7d2789a5b2adcc6998ee6..4e2e5df943c47c3baef408f3e26095f68cb85357 100755 (executable)
@@ -55,7 +55,9 @@ rm -f $seqres.full
 # real QA test starts here
 _supported_fs overlay
 _supported_os Linux
-_require_scratch
+# Use non-default scratch underlying overlay dirs, we need to check
+# them explicity after test.
+_require_scratch_nocheck
 _require_scratch_feature index
 
 # Remove all files from previous tests
@@ -87,6 +89,9 @@ $UMOUNT_PROG $SCRATCH_MNT 2>/dev/null
 # Mount overlay with original lowerdir, upperdir, workdir and index=on - expect success
 _overlay_scratch_mount_dirs $lowerdir $upperdir $workdir -oindex=on
 
+# check overlayfs
+_overlay_check_scratch_dirs $lowerdir $upperdir $workdir -oindex=on
+
 # success, all done
 status=0
 exit
index bd87156c8205e083ea735da6289c5c738b9d4cab..972a16ea7e7f13ad0f5259b7ee3f2fd0b1c843af 100755 (executable)
@@ -46,7 +46,9 @@ _cleanup()
 # real QA test starts here
 _supported_fs overlay
 _supported_os Linux
-_require_scratch
+# Use non-default scratch underlying overlay dirs, we need to check
+# them explicity after test.
+_require_scratch_nocheck
 _require_attrs
 _require_test_program "t_dir_type"
 
@@ -163,6 +165,9 @@ subdir_d=$($here/src/t_dir_type $pure_lower_dir $pure_lower_subdir_st_ino)
 
 _scratch_unmount
 
+# check overlayfs
+_check_scratch_fs
+
 # Verify pure lower residing in dir which has another lower layer
 _scratch_mkfs
 
@@ -202,6 +207,9 @@ subdir_d=$($here/src/t_dir_type $pure_lower_dir $pure_lower_subdir_st_ino)
 [[ $subdir_d == "subdir d" ]] || \
        echo "Pure lower in dir which has another lower layer: Invalid d_ino reported for subdir"
 
+# check overlayfs
+_overlay_check_scratch_dirs "$middir:$lowerdir" $upperdir $workdir
+
 echo "Silence is golden"
 status=0
 exit
index 11efacbebe5f6e694cd999436796e86b9597f324..4e72348d3d5d5d8b646ef1576083886ab35a51b3 100755 (executable)
@@ -48,7 +48,9 @@ _cleanup()
 # real QA test starts here
 _supported_fs overlay
 _supported_os Linux
-_require_scratch
+# Use non-default scratch underlying overlay dirs, we need to check
+# them explicity after test.
+_require_scratch_nocheck
 _require_test
 _require_attrs
 _require_test_program "t_dir_type"
@@ -168,6 +170,9 @@ subdir_d=$($here/src/t_dir_type $pure_lower_dir $pure_lower_subdir_st_ino)
 
 _scratch_unmount
 
+# check overlayfs
+_overlay_check_scratch_dirs $lowerdir $upperdir $workdir
+
 # Verify pure lower residing in dir which has another lower layer
 middir=$OVL_BASE_TEST_DIR/$seq-ovl-mid
 lowerdir=$OVL_BASE_TEST_DIR/$seq-ovl-lower
@@ -206,6 +211,9 @@ subdir_d=$($here/src/t_dir_type $pure_lower_dir $pure_lower_subdir_st_ino)
 [[ $subdir_d == "subdir d" ]] || \
        echo "Pure lower in dir which has another lower layer: Invalid d_ino reported for subdir"
 
+# check overlayfs
+_overlay_check_scratch_dirs "$middir:$lowerdir" $upperdir $workdir
+
 echo "Silence is golden"
 status=0
 exit
index 699c4e16c6f0d02f3ddf8751433b68b0764e6faf..46df6866ac3ca4531a9b614652fac0dddf88fb66 100755 (executable)
@@ -56,7 +56,9 @@ _cleanup()
 # real QA test starts here
 _supported_fs overlay
 _supported_os Linux
-_require_scratch
+# Use non-default scratch underlying overlay dirs, we need to check
+# them explicity after test.
+_require_scratch_nocheck
 _require_test
 _require_test_program "af_unix"
 _require_test_program "t_dir_type"
@@ -153,6 +155,9 @@ _overlay_scratch_mount_dirs $lowerdir $upperdir $workdir
 # Compare inode numbers before/after mount cycle
 check_inode_numbers $testdir $tmp.after_move $tmp.after_cycle
 
+# check overlayfs
+_overlay_check_scratch_dirs $lowerdir $upperdir $workdir
+
 echo "Silence is golden"
 status=0
 exit
index e57f6f73ef4437a3732dc1597d1d08acaaeabd90..2ab3035eedf80587355a85daab2ffba9a2dac690 100755 (executable)
@@ -49,7 +49,9 @@ _cleanup()
 # real QA test starts here
 _supported_fs overlay
 _supported_os Linux
-_require_scratch
+# Use non-default scratch underlying overlay dirs, we need to check
+# them explicity after test.
+_require_scratch_nocheck
 _require_test
 _require_scratch_feature index
 _require_test_program "t_dir_type"
@@ -122,6 +124,7 @@ check_ino_nlink $SCRATCH_MNT $tmp.before $tmp.after_one
 
 # Verify that the hardlinks survive a mount cycle
 $UMOUNT_PROG $SCRATCH_MNT
+_overlay_check_scratch_dirs $lowerdir $upperdir $workdir -o index=on
 _overlay_scratch_mount_dirs $lowerdir $upperdir $workdir -o index=on
 
 echo "== After mount cycle =="
@@ -138,5 +141,8 @@ echo "== After write two =="
 cat $FILES
 check_ino_nlink $SCRATCH_MNT $tmp.after_one $tmp.after_two
 
+# check overlayfs
+_overlay_check_scratch_dirs $lowerdir $upperdir $workdir -o index=on
+
 status=0
 exit
index ae7844dce30daa1419f001922e3c93cf9f765005..04bd133801681368cabbd7d32d4ec827ae164e50 100755 (executable)
@@ -61,8 +61,10 @@ _cleanup()
 _supported_fs overlay
 _supported_os Linux
 _require_test
-_require_scratch
 _require_test_program "open_by_handle"
+# Use non-default scratch underlying overlay dirs, we need to check
+# them explicity after test.
+_require_scratch_nocheck
 # We need to require both features together, because nfs_export cannot
 # be enabled when index is disabled
 _require_scratch_overlay_features index nfs_export
@@ -122,10 +124,14 @@ mount_dirs()
                                -o "index=on,nfs_export=on"
 }
 
-# Unmount the overlay without unmounting base fs
+# Unmount the overlay without unmounting base fs and check the
+# underlying dirs
 unmount_dirs()
 {
        $UMOUNT_PROG $SCRATCH_MNT
+
+       _overlay_check_scratch_dirs $middle:$lower $upper $work \
+                               -o "index=on,nfs_export=on"
 }
 
 # Check non-stale file handles of lower/upper files and verify
index d4fdcde63a9484128baa096b4d1ed5af7aeace53..d766cde7f48c87d9980514395d4a35cce229d283 100755 (executable)
@@ -63,8 +63,10 @@ _cleanup()
 _supported_fs overlay
 _supported_os Linux
 _require_test
-_require_scratch
 _require_test_program "open_by_handle"
+# Use non-default scratch underlying overlay dirs, we need to check
+# them explicity after test.
+_require_scratch_nocheck
 # We need to require all features together, because nfs_export cannot
 # be enabled when index is disabled
 _require_scratch_overlay_features index nfs_export redirect_dir
@@ -118,10 +120,14 @@ mount_dirs()
                                -o "index=on,nfs_export=on,redirect_dir=on"
 }
 
-# Unmount the overlay without unmounting base fs
+# Unmount the overlay without unmounting base fs and check the
+# underlying dirs
 unmount_dirs()
 {
        $UMOUNT_PROG $SCRATCH_MNT
+
+       _overlay_check_scratch_dirs $middle:$lower $upper $work \
+                               -o "index=on,nfs_export=on,redirect_dir=on"
 }
 
 # Check non-stale file handles of lower/upper moved files
index 70fe6ac86a9ce14dddf14c8a187e1c4cdb6007b0..02da6ef10d2e3aeea6121c71384e1ab974dc674e 100755 (executable)
@@ -67,8 +67,10 @@ _cleanup()
 _supported_fs overlay
 _supported_os Linux
 _require_test
-_require_scratch
 _require_test_program "open_by_handle"
+# Use non-default scratch underlying overlay dirs, we need to check
+# them explicity after test.
+_require_scratch_nocheck
 # We need to require all features together, because nfs_export cannot
 # be enabled when index is disabled
 _require_scratch_overlay_features index nfs_export redirect_dir
@@ -122,10 +124,14 @@ mount_dirs()
                                -o "index=on,nfs_export=on,redirect_dir=on"
 }
 
-# Unmount the overlay without unmounting base fs
+# Unmount the overlay without unmounting base fs and check the
+# underlying dirs
 unmount_dirs()
 {
        $UMOUNT_PROG $SCRATCH_MNT
+
+       _overlay_check_scratch_dirs $middle:$lower $upper $work \
+                               -o "index=on,nfs_export=on,redirect_dir=on"
 }
 
 # Check file handles of dir with ancestor under lower redirect