[PATCH] overlay/06[89]: fix test run with nfs_export feature enabled by default

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



The tests were checking that nfs_export feature was successfully enabled
by greping for nfs_export=on option in /proc/mounts.

This check was incorrect if the module default was nfs_export enabled
and caused test to not run with the message:
    cannot enable nfs_export feature on nested overlay

Use a helper that checks this condition correctly.

Reported-by: Chengguang Xu <cgxu519@xxxxxxxxxxxx>
Signed-off-by: Amir Goldstein <amir73il@xxxxxxxxx>
---
 common/overlay    | 14 ++++++++------
 tests/overlay/068 |  3 +--
 tests/overlay/069 |  3 +--
 3 files changed, 10 insertions(+), 10 deletions(-)

diff --git a/common/overlay b/common/overlay
index 65c639e9..f8e1e27f 100644
--- a/common/overlay
+++ b/common/overlay
@@ -137,9 +137,11 @@ _overlay_scratch_unmount()
 }
 
 # Check that a specific overlayfs feature is supported
-__check_scratch_overlay_feature()
+_check_overlay_feature()
 {
 	local feature=$1
+	local dev=$2
+	local mnt=$3
 
 	# overalyfs features (e.g. redirect_dir, index) are
 	# configurable from Kconfig (the build default), by module
@@ -153,10 +155,10 @@ __check_scratch_overlay_feature()
 	# index=off if underlying fs does not support file handles.
 	# Overlayfs only displays mount option if it differs from the default.
 	# Overlayfs may enable the feature, but fallback to read-only mount.
-	((( [ "$default" = N ] && _fs_options $SCRATCH_DEV | grep -q "${feature}=on" ) || \
-	  ( [ "$default" = Y ] && ! _fs_options $SCRATCH_DEV | grep -q "${feature}=off" )) && \
-	    touch $SCRATCH_MNT/foo 2>/dev/null ) || \
-	        _notrun "${FSTYP} feature '${feature}' cannot be enabled on ${SCRATCH_DEV}"
+	((( [ "$default" = N ] && _fs_options $dev | grep -q "${feature}=on" ) || \
+	  ( [ "$default" = Y ] && ! _fs_options $dev | grep -q "${feature}=off" )) && \
+	    touch $mnt/foo 2>/dev/null ) || \
+	        _notrun "${FSTYP} feature '${feature}' cannot be enabled on ${dev}"
 }
 
 # Require a set of overlayfs features
@@ -178,7 +180,7 @@ _require_scratch_overlay_features()
 	        _notrun "overlay features '${features[*]}' cannot be enabled on ${SCRATCH_DEV}"
 
 	for feature in ${features[*]}; do
-		__check_scratch_overlay_feature ${feature}
+		_check_overlay_feature ${feature} $SCRATCH_DEV $SCRATCH_MNT
 	done
 
 	_scratch_unmount
diff --git a/tests/overlay/068 b/tests/overlay/068
index 933768ba..7dfd6a73 100755
--- a/tests/overlay/068
+++ b/tests/overlay/068
@@ -102,8 +102,7 @@ mount_dirs()
 	_overlay_mount_dirs $SCRATCH_MNT $upper2 $work2 overlay2 $mnt2 \
 		-o "index=on,nfs_export=on,redirect_dir=on" 2>/dev/null ||
 		_notrun "cannot mount nested overlay with nfs_export=on option"
-	_fs_options overlay2 | grep -q "nfs_export=on" || \
-		_notrun "cannot enable nfs_export feature on nested overlay"
+	_check_overlay_feature nfs_export overlay2 $mnt2
 }
 
 # Unmount the nested overlay mount and check underlying overlay layers
diff --git a/tests/overlay/069 b/tests/overlay/069
index de7aa0d7..77dfce63 100755
--- a/tests/overlay/069
+++ b/tests/overlay/069
@@ -110,8 +110,7 @@ mount_dirs()
 	_overlay_mount_dirs $SCRATCH_MNT $upper2 $work2 overlay2 $mnt2 \
 		-o "index=on,nfs_export=on,redirect_dir=on" 2>/dev/null ||
 		_notrun "cannot mount nested overlay with nfs_export=on option"
-	_fs_options overlay2 | grep -q "nfs_export=on" || \
-		_notrun "cannot enable nfs_export feature on nested overlay"
+	_check_overlay_feature nfs_export overlay2 $mnt2
 }
 
 # Unmount the nested overlay mount and check underlying overlay layers
-- 
2.17.1




[Index of Archives]     [Linux Filesystems Devel]     [Linux NFS]     [Linux NILFS]     [Linux USB Devel]     [Linux Audio Users]     [Yosemite News]     [Linux Kernel]     [Linux SCSI]

  Powered by Linux