Skip to contentSkip to conversation

overlay tests: generalize _check_overlay_feature for param-less mount options

PATCH New Prabhakar Pujeri 1 participant 4 messages Sep 21

lore
Share & tools
lore
#0 lore raw

v2 cover overlay tests: generalize _check_overlay_feature for param-less mount options

The overlay tests that need param-less overlayfs mount options (uuid, xino, verity) currently open-code their probes. Generalize _check_overlay_feature/_require_scratch_overlay_features once in common/overlay (1/3), fold the six open-coded xino probes onto the helper (2/3), and switch overlay/081's ad-hoc uuid=null probe to it (3/3).

Changes in v2 (per Amir Goldstein's review of v1, all three patches now carry his Reviewed-by):
- 1/3: drop fsync from the list of param-less mount options - it has no on/off values and cannot be validated with this helper; and replace the out-of-context comment in _require_scratch_overlay_ features with a simple 'Validate that mount option can be enabled.'
- 3/3: trim the verbose comment - the v6.6 requirement is already documented in the test description.
- 2/3: no code change.

v1: https://lore.kernel.org/fstests/[email protected]/
Suggested-by: Amir Goldstein (from the overlay/081 review thread)

Prabhakar Pujeri (3):
common/overlay: let _check_overlay_feature handle param-less options tests/overlay: use _require_scratch_overlay_features for xino overlay/081: require uuid via _require_scratch_overlay_features

common/overlay: let _check_overlay_feature handle param-less options tests/overlay: use _require_scratch_overlay_features for xino overlay/081: require uuid via _require_scratch_overlay_features

 common/overlay    | 16 ++++++++++------
 tests/overlay/041 |  6 ++----
 tests/overlay/043 |  6 ++----
 tests/overlay/044 |  6 ++----
 tests/overlay/067 |  4 ++--
 tests/overlay/070 |  7 ++-----
 tests/overlay/071 | 12 +++---------
 tests/overlay/081 |  5 +++--
 8 files changed, 26 insertions(+), 36 deletions(-)
Signature · 1 line
2.55.0
#1 lore raw

PATCH v2 1/3 common/overlay: let _check_overlay_feature handle param-less options

overlayfs mount options like uuid, xino and verity have no on/off module parameter of the same name, so _get_fs_module_param returns nothing for them and _require_scratch_overlay_features notruns before the probe mount is even tried.

Per Amir's suggestion on the overlay/081 review thread, a missing parameter for such options means 'defaults off' rather than 'unsupported': generalize _check_overlay_feature to treat a missing or non-boolean parameter as default N, and drop the parameter existence pre-check from _require_scratch_overlay_features. Support is then validated by the probe mount itself - a too-old kernel that does not know the option rejects it with EINVAL and the require notruns as before.

This lets tests require param-less options uniformly, e.g. _require_scratch_overlay_features xino / uuid.

---
Changes in v2 (per Amir Goldstein's review):
- Drop fsync from the list of param-less mount options; it has no on/off values and cannot be validated with this helper.
- Replace the out-of-context _require_scratch_overlay_features comment with a simple 'Validate that mount option can be enabled.'
- Add Amir's Reviewed-by.

 common/overlay | 16 ++++++++++------
 1 file changed, 10 insertions(+), 6 deletions(-)
common/overlay +10 -6
index d32f3219..b9a13c88 100644
@@ -172,8 +172,15 @@ _check_overlay_feature()
 	# parameter (the system default) and per mount by mount
 	# option ${feature}=[on|off].
 	local default=`_get_fs_module_param ${feature}`
-	[ "$default" = Y ] || [ "$default" = N ] || \
-		_notrun "feature '${feature}' not supported by ${FSTYP}"
+	if [ "$default" != Y ] && [ "$default" != N ]; then
+		# Some mount options (e.g. uuid, xino, verity) have no
+		# on/off module parameter of the same name.  For those,
+		# a missing (or non-boolean) parameter means that the
+		# feature defaults to off rather than that it is
+		# unsupported.  Unsupported options are rejected by the
+		# probe mount in _require_scratch_overlay_features.
+		default=N
+	fi
 
 	# Check options to be sure. For example, Overlayfs will fallback to
 	# index=off if underlying fs does not support file handles.
@@ -192,10 +199,7 @@ _require_scratch_overlay_features()
 	local opts="rw"
 
 	for feature in ${features[*]}; do
-		# If the module parameter does not exist then there is no
-		# point in checking the mount option.
-		_get_fs_module_param ${feature} > /dev/null 2>&1 || \
-			_notrun "feature '${feature}' not supported by overlay"
+		# Validate that mount option can be enabled.
 		opts+=",${feature}=on"
 	done
 
Signature · 1 line
2.55.0
#2 lore raw

PATCH v2 2/3 tests/overlay: use _require_scratch_overlay_features for xino

In reply to Prabhakar Pujeri

overlay/041, 043, 044, 067, 070 and 071 open-code their xino probes:
a mount with -o xino=on|off followed by a selective grep of the mount options. Now that _check_overlay_feature handles param-less options, fold all six onto _require_scratch_overlay_features xino and delete the open-coded variants. The behavior is unchanged - a kernel that does not support xino rejects the probe mount and the test notruns.

---
Changes in v2:
- No code change.
- Add Amir's Reviewed-by.

 tests/overlay/041 |  6 ++----
 tests/overlay/043 |  6 ++----
 tests/overlay/044 |  6 ++----
 tests/overlay/067 |  4 ++--
 tests/overlay/070 |  7 ++-----
 tests/overlay/071 | 12 +++---------
 6 files changed, 13 insertions(+), 28 deletions(-)
tests/overlay/041 +2 -4
index 36491b8f..4d2c830d 100755
@@ -23,6 +23,7 @@ _require_scratch_nocheck
 _require_test
 _require_attrs trusted
 _require_test_program "t_dir_type"
+_require_scratch_overlay_features xino
 
 lowerdir=$OVL_BASE_TEST_DIR/$seq-ovl-lower
 rm -rf $lowerdir
@@ -41,10 +42,7 @@ workdir=$OVL_BASE_SCRATCH_MNT/$OVL_WORK
 # not use bit 63 in inode number of the test files, because bit 63 is used by
 # overlayfs to indicate the layer. Let's just assume that this is true for all
 # tested filesystems and if we are wrong, the test may fail.
-_overlay_scratch_mount_dirs $lowerdir $upperdir $workdir -o xino=on || \
-	_notrun "cannot mount overlay with xino=on option"
-_fs_options $SCRATCH_DEV | grep -q "xino=on" || \
-	_notrun "cannot enable xino feature"
+_overlay_scratch_mount_dirs $lowerdir $upperdir $workdir -o xino=on
 
 test_dir=$SCRATCH_MNT/test_dir/
 
tests/overlay/043 +2 -4
index 7325c653..efb99cd5 100755
@@ -33,6 +33,7 @@ _require_test_program "af_unix"
 _require_test_program "t_dir_type"
 # Require redirect_dir for renaming a merge directory
 _require_scratch_feature redirect_dir
+_require_scratch_overlay_features xino
 
 lowerdir=$OVL_BASE_TEST_DIR/$seq-ovl-lower
 rm -rf $lowerdir
@@ -57,10 +58,7 @@ workdir=$OVL_BASE_SCRATCH_MNT/$OVL_WORK
 # not use bit 63 in inode number of the test files, because bit 63 is used by
 # overlayfs to indicate the layer. Let's just assume that this is true for all
 # tested filesystems and if we are wrong, the test may fail.
-_overlay_scratch_mount_dirs $lowerdir $upperdir $workdir -o redirect_dir=on,xino=on || \
-	_notrun "cannot mount overlay with xino=on option"
-_fs_options $SCRATCH_DEV | grep -q "xino=on" || \
-	_notrun "cannot enable xino feature"
+_overlay_scratch_mount_dirs $lowerdir $upperdir $workdir -o redirect_dir=on,xino=on
 
 FILES="dir file symlink chrdev blkdev fifo socket"
 
tests/overlay/044 +2 -4
index 4d04d883..08e38dfd 100755
@@ -26,6 +26,7 @@ _require_scratch_nocheck
 _require_test
 _require_scratch_feature index
 _require_test_program "t_dir_type"
+_require_scratch_overlay_features xino
 
 # Record inode numbers in format <ino> <nlink>
 function record_ino_nlink()
@@ -73,10 +74,7 @@ workdir=$OVL_BASE_SCRATCH_MNT/$OVL_WORK
 # not use bit 63 in inode number of the test files, because bit 63 is used by
 # overlayfs to indicate the layer. Let's just assume that this is true for all
 # tested filesystems and if we are wrong, the test may fail.
-_overlay_scratch_mount_dirs $lowerdir $upperdir $workdir -o index=on,xino=on || \
-	_notrun "cannot mount overlay with xino=on option"
-_fs_options $SCRATCH_DEV | grep -q "xino=on" || \
-	_notrun "cannot enable xino feature"
+_overlay_scratch_mount_dirs $lowerdir $upperdir $workdir -o index=on,xino=on
 
 rm -f $tmp.*
 
tests/overlay/067 +2 -2
index bb09a604..d3f98f17 100755
@@ -25,6 +25,7 @@ _fixed_by_kernel_commit 9c6d8f13e9da \
 # them explicity after test.
 _require_scratch_nocheck
 _require_test
+_require_scratch_overlay_features xino
 
 # Lower is on test partition
 lower=$OVL_BASE_TEST_DIR/$OVL_LOWER-$seq
@@ -47,8 +48,7 @@ echo wrong > $realfile
 # Mount an overlay on $SCRATCH_MNT with lower layer on test partition
 # and middle and upper layer on scratch partition.
 # Disable xino, so not all overlay inodes are on the same st_dev.
-_overlay_scratch_mount_dirs $middle:$lower $upper $work -o xino=off || \
-	_notrun "cannot mount overlay with xino=off option"
+_overlay_scratch_mount_dirs $middle:$lower $upper $work -o xino=off
 
 stat $realfile >>$seqres.full
 stat $testfile >>$seqres.full
tests/overlay/070 +2 -5
index 36991229..c64e7907 100755
@@ -41,7 +41,7 @@ _require_test_program "t_dir_type"
 _require_command "$FLOCK_PROG" "flock"
 # 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
+_require_scratch_overlay_features index nfs_export redirect_dir xino
 _require_loop
 
 lower=$OVL_BASE_SCRATCH_MNT/$OVL_LOWER
@@ -83,10 +83,7 @@ mount_dirs()
 	# overlayfs to indicate the layer. Let's just assume that this is true for all
 	# tested filesystems and if we are wrong, the test may fail.
 	_overlay_mount_dirs $SCRATCH_MNT $upper2 $work2 overlay2 $mnt2 \
-		-o "redirect_dir=on,index=on,xino=on" || \
-		_notrun "cannot mount nested overlay with xino=on option"
-	_fs_options overlay2 | grep -q "xino=on" || \
-		_notrun "cannot enable xino feature on nested overlay"
+		-o "redirect_dir=on,index=on,xino=on"
 }
 
 # Unmount the nested overlay mount and check underlying overlay layers
tests/overlay/071 +3 -9
index 2a631314..ef429d41 100755
@@ -45,7 +45,7 @@ _require_test_program "t_dir_type"
 _require_command "$FLOCK_PROG" "flock"
 # 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
+_require_scratch_overlay_features index nfs_export redirect_dir xino
 _require_loop
 
 # Lower overlay lower layer is on test fs, upper is on scratch fs
@@ -81,10 +81,7 @@ mount_dirs()
 {
 	# Mount the underlying overlay with file handle support
 	_overlay_mount_dirs $lower $upper $work overlay1 $SCRATCH_MNT \
-		-o "index=on,nfs_export=on,xino=on" || \
-                _notrun "cannot mount overlay with xino=on option"
-	_fs_options overlay1 | grep -q "xino=on" || \
-		_notrun "cannot enable xino feature on overlay"
+		-o "index=on,nfs_export=on,xino=on"
 
 	# Mount the nested overlay
 	# Enable redirect_dir for renaming a merge directory.
@@ -93,10 +90,7 @@ mount_dirs()
 	# overlayfs to indicate the layer. Let's just assume that this is true for all
 	# tested filesystems and if we are wrong, the test may fail.
 	_overlay_mount_dirs $SCRATCH_MNT $upper2 $work2 overlay2 $mnt2 \
-		-o "redirect_dir=on,index=on,xino=on" || \
-		_notrun "cannot mount nested overlay with xino=on option"
-	_fs_options overlay2 | grep -q "xino=on" || \
-		_notrun "cannot enable xino feature on nested overlay"
+		-o "redirect_dir=on,index=on,xino=on"
 }
 
 # Unmount the nested overlay mount and check underlying overlay layers
Signature · 1 line
2.55.0
#3 lore raw

PATCH v2 3/3 overlay/081: require uuid via _require_scratch_overlay_features

In reply to Prabhakar Pujeri

The ad-hoc check hid the mount output and treated any mount failure as 'overlayfs does not support uuid'. Route the requirement through the generalized helper instead: the probe mount still rejects on a pre-6.6 kernel with EINVAL, and the options check remains via mount options.

---
Changes in v2:
- Trim the verbose comment; the v6.6 requirement is already documented in the test description (Amir Goldstein).
- Add Amir's Reviewed-by.

 tests/overlay/081 | 5 +++--
 1 file changed, 3 insertions(+), 2 deletions(-)
tests/overlay/081 +3 -2
index 2270a047..9315125b 100755
@@ -14,6 +14,8 @@ _begin_fstest auto quick
 . ./common/filter
 . ./common/attr
 
+_require_scratch_overlay_features uuid
+
 
 _scratch_mkfs >>$seqres.full 2>&1
 
@@ -36,8 +38,7 @@ lower_fsid=$(stat -f -c '%i' $lowerdir)
 	echo "lower fs and upper fs fsid differ"
 
 # Test legacy behavior - ovl fsid inherited from upper fs
-_overlay_scratch_mount_dirs $lowerdir $upperdir $workdir -o uuid=null 2>/dev/null || \
-	_notrun "Overlayfs does not support unique fsid feature"
+_overlay_scratch_mount_dirs $lowerdir $upperdir $workdir -o uuid=null
 
 # Lookup of test_dir marks upper root as "impure", so following (uuid=auto) mounts
 # will NOT behave as first time mount of a new overlayfs
Signature · 1 line
2.55.0