overlay: mount/unmount base fs before/after running tests

When TEST/SCRATCH_DEV are configured to the base fs block device,
use this information to mount base fs before running tests,
unmount it after running tests and cycle on _test_cycle_mount
along with the overlay mounts.

This helps catching overlayfs bugs related to leaking objects in
underlying (base) fs.

To preserve expected tests behavior, the semantics are:
- _scratch_mkfs mounts the base fs, cleans all files, creates
  lower/upper dirs and keeps base fs mounted
- _scratch_mount mounts base fs (if needed) and mounts overlay
- _scratch_unmount unmounts overlay and base fs

Tests that use _scratch_unmount to unmount a custom overlay mount
and expect to have access to overlay base dir, were fixed to use
explicit umount $SCRATCH_MNT instead.

The overlay test itself, does not support formatting the base fs,
so config options like MKFS_OPTIONS and FSCK_OPTIONS are ignored
on 'check -overlay'.
The config option MOUNT_OPTIONS is used to mount the base scratch fs.
The config option TEST_FS_MOUNT_OPTS is used to mount the base test fs.
The config option OVERLAY_MOUNT_OPTIONS is used to mount both test and
scratch overlay mounts.

Signed-off-by: Amir Goldstein <amir73il@gmail.com>
Reviewed-by: Eryu Guan <eguan@redhat.com>
Signed-off-by: Eryu Guan <eguan@redhat.com>
This commit is contained in:
Amir Goldstein
2017-02-28 14:18:36 +02:00
committed by Eryu Guan
parent bcba40e3df
commit 2ab614524d
5 changed files with 98 additions and 8 deletions
+3 -2
View File
@@ -73,7 +73,8 @@ mkdir -p $lowerdir1/testdir/d
_overlay_mount_dirs $lowerdir1 $lowerdir2 $workdir $SCRATCH_DEV $SCRATCH_MNT
rm -rf $SCRATCH_MNT/testdir
mkdir -p $SCRATCH_MNT/testdir/visibledir
_scratch_unmount
# unmount overlayfs but not base fs
$UMOUNT_PROG $SCRATCH_MNT
# mount overlay again, with lowerdir1 and lowerdir2 as multiple lowerdirs,
# and create a new file in testdir, triggers copyup from lowerdir,
@@ -84,7 +85,7 @@ touch $SCRATCH_MNT/testdir/visiblefile
# umount and mount overlay again, buggy kernel treats the copied-up dir as
# opaque, visibledir is not seen in merged dir.
_scratch_unmount
$UMOUNT_PROG $SCRATCH_MNT
_overlay_mount_dirs "$lowerdir2:$lowerdir1" $upperdir $workdir \
$SCRATCH_DEV $SCRATCH_MNT
ls $SCRATCH_MNT/testdir