]> git.apps.os.sepia.ceph.com Git - xfstests-dev.git/commitdiff
common: xfstests support overlay+tmpfs
authorBaokun Li <libaokun1@huawei.com>
Wed, 11 May 2022 08:34:04 +0000 (16:34 +0800)
committerZorro Lang <zlang@kernel.org>
Wed, 11 May 2022 09:12:45 +0000 (17:12 +0800)
The local.config of overlay+tmpfs is as follows:
```local.config.example
export FSTYP=tmpfs
export TEST_DEV=tmpfs_test
export TEST_DIR=/tmp/test
export SCRATCH_DEV=tmpfs_scratch
export SCRATCH_MNT=/tmp/scratch
```

Run `./check -overlay tests` to execute test case on overlay+tmpfs.

Signed-off-by: Baokun Li <libaokun1@huawei.com>
Reviewed-by: Amir Goldstein <amir73il@gmail.com>
Signed-off-by: Zorro Lang <zlang@kernel.org>
common/config
common/overlay
common/rc

index efcf12e953b6c0c571dc39a85960e555f4b0386b..c6428f90c7c7253aa1a2046c2f458190b3bbdd0d 100644 (file)
@@ -612,15 +612,15 @@ _overlay_config_override()
        [ ! -d "$TEST_DEV" ] || export OVL_BASE_TEST_DIR="$TEST_DEV"
        [ ! -d "$SCRATCH_DEV" ] || export OVL_BASE_SCRATCH_MNT="$SCRATCH_DEV"
 
+       # Config file may specify base fs type, but we obay -overlay flag
+       [ "$FSTYP" == overlay ] || export OVL_BASE_FSTYP="$FSTYP"
+       export FSTYP=overlay
+
        # 2. SCRATCH/TEST_DEV point to the base fs partitions.  In this case,
        #    the new OVL_BASE_SCRATCH/TEST_DEV/MNT vars are set to the values
        #    of the configured base fs and SCRATCH/TEST_DEV vars are set to the
        #    overlayfs base and mount dirs inside base fs mount.
-       [ -b "$TEST_DEV" ] || [ -c "$TEST_DEV" ] || return 0
-
-       # Config file may specify base fs type, but we obay -overlay flag
-       [ "$FSTYP" == overlay ] || export OVL_BASE_FSTYP="$FSTYP"
-       export FSTYP=overlay
+       [ -b "$TEST_DEV" ] || [ -c "$TEST_DEV" ] || [ "$OVL_BASE_FSTYP" == tmpfs ] || return 0
 
        # Store original base fs vars
        export OVL_BASE_TEST_DEV="$TEST_DEV"
@@ -636,7 +636,7 @@ _overlay_config_override()
        export TEST_DIR="$OVL_BASE_TEST_DIR/$OVL_MNT"
        export MOUNT_OPTIONS="$OVERLAY_MOUNT_OPTIONS"
 
-       [ -b "$SCRATCH_DEV" ] || [ -c "$SCRATCH_DEV" ] || return 0
+       [ -b "$SCRATCH_DEV" ] || [ -c "$SCRATCH_DEV" ] || [ "$OVL_BASE_FSTYP" == tmpfs ] || return 0
 
        # Store original base fs vars
        export OVL_BASE_SCRATCH_DEV="$SCRATCH_DEV"
index fff67ba12c1706fec29955e741f0b009df7c4c5b..c4e7ee5896b569e7f46ae197b39c4e88ee0141e1 100644 (file)
@@ -81,7 +81,7 @@ _overlay_base_mount()
                return 1
        fi
 
-       _mount $* $dev $mnt
+       _mount -t $OVL_BASE_FSTYP $* $dev $mnt
        _idmapped_mount $dev $mnt
 }
 
index e907e3629da1d4de9422d93fb8689b9472f1648f..9ba47d38482c6053dc694f70e8f0a35b546c7d26 100644 (file)
--- a/common/rc
+++ b/common/rc
@@ -409,15 +409,25 @@ _scratch_remount()
 _scratch_cycle_mount()
 {
     local opts="$1"
+    local unmounted
+
+    case "$FSTYP" in
+    tmpfs)
+        _scratch_remount "$opts"
+        return
+        ;;
+    overlay)
+        if [ "$OVL_BASE_FSTYP" = tmpfs ]; then
+            $UMOUNT_PROG $SCRATCH_MNT
+            unmounted=true
+        fi
+        ;;
+    esac
 
-    if [ "$FSTYP" = tmpfs ]; then
-       _scratch_remount "$opts"
-       return
-    fi
     if test -n "$opts"; then
        opts="-o $opts"
     fi
-    _scratch_unmount
+    [ "$unmounted" = true ] || _scratch_unmount
     _try_scratch_mount "$opts" || _fail "cycle mount failed"
 }
 
@@ -526,10 +536,21 @@ _test_unmount()
 
 _test_cycle_mount()
 {
-    if [ "$FSTYP" = tmpfs ]; then
-       return
-    fi
-    _test_unmount
+    local unmounted
+
+    case "$FSTYP" in
+    tmpfs)
+        return
+        ;;
+    overlay)
+        if [ "$OVL_BASE_FSTYP" = tmpfs ]; then
+            $UMOUNT_PROG $TEST_DIR
+            unmounted=true
+        fi
+        ;;
+    esac
+
+    [ "$unmounted" = true ] || _test_unmount
     _test_mount
 }