common: xfstests support overlay+tmpfs
RFC v3 1/1 common: xfstests support overlay+tmpfs
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.
---V1->V2:
Fix the bug in version V1 and fix the issue in cycle_mount.V2->V3:
Merge two patches into one completed patch.
V1: https://patchwork.kernel.org/project/fstests/patch/[email protected]/
V2: https://patchwork.kernel.org/project/fstests/cover/[email protected]/
common/config | 12 ++++++------ common/overlay | 2 +- common/rc | 31 ++++++++++++++++++++++++------- 3 files changed, 31 insertions(+), 14 deletions(-)
common/config +6 -6
@@ -610,15 +610,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"
@@ -634,7 +634,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"
common/overlay +1 -1
@@ -81,7 +81,7 @@ _overlay_base_mount() return 1 fi - _mount $* $dev $mnt + _mount -t $OVL_BASE_FSTYP $* $dev $mnt _idmapped_mount $dev $mnt }
common/rc +24 -7
@@ -410,10 +410,19 @@ _scratch_cycle_mount() { local opts="$1" - if [ "$FSTYP" = tmpfs ]; then - _scratch_remount "$opts" - return - fi + case "$FSTYP" in + tmpfs) + _scratch_remount "$opts" + return + ;; + overlay) + if [ "$OVL_BASE_FSTYP" = tmpfs ]; then + _scratch_remount "$opts" + return + fi + ;; + esac + if test -n "$opts"; then opts="-o $opts" fi
@@ -522,9 +531,17 @@ _test_unmount() _test_cycle_mount() { - if [ "$FSTYP" = tmpfs ]; then - return - fi + case "$FSTYP" in + tmpfs) + return + ;; + overlay) + if [ "$OVL_BASE_FSTYP" = tmpfs ]; then + return + fi + ;; + esac + _test_unmount _test_mount }
Signature · 1 line
2.31.1
Quoted 84 lines · Baokun Li
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 teststo execute test case on overlay+tmpfs.Signed-off-by Baokun Li <[email protected]>---
V1->V2:
Fix the bug in version V1 and fix the issue incycle_mount.V2->V3:
Merge two patches into one completed patch.V1: https://patchwork.kernel.org/project/fstests/patch/[email protected]/
V2: https://patchwork.kernel.org/project/fstests/cover/[email protected]/common/config | 12 ++++++------ common/overlay | 2 +- common/rc | 31 ++++++++++++++++++++++++------- 3 files changed, 31 insertions(+), 14 deletions(-)common/config +6
-6@@ -610,15 +610,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"@@ -634,7 +634,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"common/overlay +1
-1@@ -81,7 +81,7 @@ _overlay_base_mount() return 1 fi - _mount $* $dev $mnt + _mount -t $OVL_BASE_FSTYP $* $dev $mnt _idmapped_mount $dev $mnt }common/rc +0
-2@@ -410,10 +410,19 @@ _scratch_cycle_mount() { local opts="$1" - if [ "$FSTYP" = tmpfs ]; then - _scratch_remount "$opts"
common/rc _scratch_cycle_mount() · line 420
Quoted 10 lines
common/rc +8
-2- return - fi + case "$FSTYP" in + tmpfs) + _scratch_remount "$opts" + return + ;; + overlay) + if [ "$OVL_BASE_FSTYP" = tmpfs ]; then + _scratch_remount "$opts"
That doesn't look right._scrtach_cycle_mount is important for several overlay tests and there is no reason to
skip it if base fs is tmpfs.
What you need to do is cycle mount the overlay without cycle mounting the base fs.
You could do something like this:
local unmounted
...
overlay)
if [ "$OVL_BASE_FSTYP" = tmpfs ]; then
$UMOUNT_PROG $SCRATCH_MNT unmounted=true
fi
;;
esac
...
[ "$unmounted" = true ] || _scratch_unmount
_try_scratch_mount "$opts" || _fail "cycle mount failed"
}There are some overlay tests that open code this pattern like overlay/077:
# Remove the lower directory and mount overlay again to create
# a "former merge dir" $UMOUNT_PROG $SCRATCH_MNT rm -rf $lowerdir/former _scratch_mount
So _scratch_mount is expected to work just fine when base fs is already mounted assuming that _check_mounted_on works correctly with tmpfs.
Thanks,
Amir.
Quoted 126 lines · Amir Goldstein
Quoted 83 lines · Baokun Li
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 teststo execute test case on overlay+tmpfs.Signed-off-by Baokun Li <[email protected]>---
V1->V2:
Fix the bug in version V1 and fix the issue incycle_mount.V2->V3:
Merge two patches into one completed patch.V1: https://patchwork.kernel.org/project/fstests/patch/[email protected]/
V2: https://patchwork.kernel.org/project/fstests/cover/[email protected]/common/config | 12 ++++++------ common/overlay | 2 +- common/rc | 31 ++++++++++++++++++++++++------- 3 files changed, 31 insertions(+), 14 deletions(-)common/config +6
-6@@ -610,15 +610,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"@@ -634,7 +634,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"common/overlay +1
-1@@ -81,7 +81,7 @@ _overlay_base_mount() return 1 fi - _mount $* $dev $mnt + _mount -t $OVL_BASE_FSTYP $* $dev $mnt _idmapped_mount $dev $mnt }common/rc +0
-2@@ -410,10 +410,19 @@ _scratch_cycle_mount() { local opts="$1" - if [ "$FSTYP" = tmpfs ]; then - _scratch_remount "$opts"common/rc _scratch_cycle_mount() · line 420
Quoted 10 lines
common/rc +8
-2- return - fi + case "$FSTYP" in + tmpfs) + _scratch_remount "$opts" + return + ;; + overlay) + if [ "$OVL_BASE_FSTYP" = tmpfs ]; then + _scratch_remount "$opts"That doesn't look right.
_scrtach_cycle_mountis important for several overlay tests and there is no reason to
skip it if base fs is tmpfs.
What you need to do is cycle mount the overlay without cycle mounting the base fs.
You could do something like this:local unmounted
...overlay)
if [ "$OVL_BASE_FSTYP" = tmpfs ]; then
$UMOUNT_PROG $SCRATCH_MNT unmounted=true
fi
;;
esac
...[ "$unmounted" = true ] || _scratch_unmount _try_scratch_mount "$opts" || _fail "cycle mount failed" }There are some overlay tests that open code this pattern like overlay/077:
# Remove the lower directory and mount overlay again to create
# a "former merge dir" $UMOUNT_PROG $SCRATCH_MNT rm -rf $lowerdir/former _scratch_mount
Quoted 6 lines
So
_scratch_mountis expected to work just fine when base fs is already mounted assuming that_check_mounted_onworks correctly with tmpfs.Thanks,
Amir.
.
Thank you very much for your advice.
I will send a patch V4 with the changes suggested by you.
Signature · 4 lines
With Best Regards, Baokun Li .
Quoted 131 lines · libaokun (A)
Quoted 129 lines · Amir Goldstein
Quoted 83 lines · Baokun Li
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 teststo execute test case on overlay+tmpfs.Signed-off-by Baokun Li <[email protected]>---
V1->V2:
Fix the bug in version V1 and fix the issue incycle_mount.V2->V3:
Merge two patches into one completed patch.V1: https://patchwork.kernel.org/project/fstests/patch/[email protected]/
V2: https://patchwork.kernel.org/project/fstests/cover/[email protected]/common/config | 12 ++++++------ common/overlay | 2 +- common/rc | 31 ++++++++++++++++++++++++------- 3 files changed, 31 insertions(+), 14 deletions(-)common/config +6
-6@@ -610,15 +610,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"@@ -634,7 +634,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"common/overlay +1
-1@@ -81,7 +81,7 @@ _overlay_base_mount() return 1 fi - _mount $* $dev $mnt + _mount -t $OVL_BASE_FSTYP $* $dev $mnt _idmapped_mount $dev $mnt }common/rc +0
-2@@ -410,10 +410,19 @@ _scratch_cycle_mount() { local opts="$1" - if [ "$FSTYP" = tmpfs ]; then - _scratch_remount "$opts"common/rc _scratch_cycle_mount() · line 420
Quoted 10 lines
common/rc +8
-2- return - fi + case "$FSTYP" in + tmpfs) + _scratch_remount "$opts" + return + ;; + overlay) + if [ "$OVL_BASE_FSTYP" = tmpfs ]; then + _scratch_remount "$opts"That doesn't look right.
_scrtach_cycle_mountis important for several overlay tests and there is no reason to
skip it if base fs is tmpfs.
What you need to do is cycle mount the overlay without cycle mounting the base fs.
You could do something like this:local unmounted
...overlay)
if [ "$OVL_BASE_FSTYP" = tmpfs ]; then
$UMOUNT_PROG $SCRATCH_MNT unmounted=true
fi
;;
esac
...[ "$unmounted" = true ] || _scratch_unmount _try_scratch_mount "$opts" || _fail "cycle mount failed" }There are some overlay tests that open code this pattern like overlay/077:
# Remove the lower directory and mount overlay again to create
# a "former merge dir" $UMOUNT_PROG $SCRATCH_MNT rm -rf $lowerdir/former _scratch_mountSo
_scratch_mountis expected to work just fine when base fs is already mounted assuming that_check_mounted_onworks correctly with tmpfs.
Quoted 7 lines
Quoted 3 lines
Thanks,
Amir.
.Thank you very much for your advice.
I will send a patch V4 with the changes suggested by you.
To state the obvious that I did not say, please do the same with _test_cycle_mount
Thanks,
Amir.
Quoted 135 lines · Amir Goldstein
Quoted 134 lines · libaokun (A)
Quoted 125 lines · Amir Goldstein
Quoted 83 lines · Baokun Li
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 teststo execute test case on overlay+tmpfs.Signed-off-by Baokun Li <[email protected]>---
V1->V2:
Fix the bug in version V1 and fix the issue incycle_mount.V2->V3:
Merge two patches into one completed patch.V1: https://patchwork.kernel.org/project/fstests/patch/[email protected]/
V2: https://patchwork.kernel.org/project/fstests/cover/[email protected]/common/config | 12 ++++++------ common/overlay | 2 +- common/rc | 31 ++++++++++++++++++++++++------- 3 files changed, 31 insertions(+), 14 deletions(-)common/config +6
-6@@ -610,15 +610,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"@@ -634,7 +634,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"common/overlay +1
-1@@ -81,7 +81,7 @@ _overlay_base_mount() return 1 fi - _mount $* $dev $mnt + _mount -t $OVL_BASE_FSTYP $* $dev $mnt _idmapped_mount $dev $mnt }common/rc +0
-2@@ -410,10 +410,19 @@ _scratch_cycle_mount() { local opts="$1" - if [ "$FSTYP" = tmpfs ]; then - _scratch_remount "$opts"common/rc _scratch_cycle_mount() · line 420
Quoted 10 lines
common/rc +8
-2- return - fi + case "$FSTYP" in + tmpfs) + _scratch_remount "$opts" + return + ;; + overlay) + if [ "$OVL_BASE_FSTYP" = tmpfs ]; then + _scratch_remount "$opts"That doesn't look right.
_scrtach_cycle_mountis important for several overlay tests and there is no reason to
skip it if base fs is tmpfs.
What you need to do is cycle mount the overlay without cycle mounting the base fs.
You could do something like this:local unmounted
...overlay)
if [ "$OVL_BASE_FSTYP" = tmpfs ]; then
$UMOUNT_PROG $SCRATCH_MNT unmounted=true
fi
;;
esac
...[ "$unmounted" = true ] || _scratch_unmount _try_scratch_mount "$opts" || _fail "cycle mount failed" }There are some overlay tests that open code this pattern like overlay/077:
# Remove the lower directory and mount overlay again to create
# a "former merge dir" $UMOUNT_PROG $SCRATCH_MNT rm -rf $lowerdir/former _scratch_mountQuoted 6 lines
So
_scratch_mountis expected to work just fine when base fs is already mounted assuming that_check_mounted_onworks correctly with tmpfs.Thanks,
Amir.
.Thank you very much for your advice.
Quoted 7 lines
Quoted 1 line
I will send a patch V4 with the changes suggested by you.
To state the obvious that I did not say, please do the same with
_test_cycle_mountThanks,
Amir.
.
Ok, got it! Thank a milion!
Signature · 3 lines
With Best Regards, Baokun Li .