Skip to contentSkip to conversation

common/overlay: fix _check_overlay_feature for default-on param-less options

PATCH In review Amir Goldstein 2 participants 2 messages Nov 6 – Nov 21

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 common/overlay: fix _check_overlay_feature for default-on param-less options

Overlayfs only displays a mount option if it differs from the default. Commit 73a018cb treated a feature without a module parameter of the same name (e.g. xino) as default off and required "${feature}=on" in the mount options. On a samefs xfs setup xino is on by default and is not displayed, so tests requiring xino (e.g. overlay/041, 043, 044, 067, 070, 071) were wrongly skipped.

For features without a boolean module parameter, assume the feature may be on by default and only verify that the mount options do not show it with a value other than "on", same as for features that default to Y.

Fixes 73a018cbf57b ("common/overlay: let _check_overlay_feature handle param-less options")
Cc Prabhakar Pujeri <[email protected]>
---
 common/overlay | 22 +++++++++-------------
 1 file changed, 9 insertions(+), 13 deletions(-)
common/overlay +9 -13
index 132b2bf7..0cf6db2d 100644
@@ -172,24 +172,20 @@ _check_overlay_feature()
 	# parameter (the system default) and per mount by mount
 	# option ${feature}=[on|off].
 	local default=`_get_fs_module_param ${feature}`
-	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
+	local value=`_fs_options $dev | tr ',' '\n' | grep "^${feature}=" | cut -d= -f2`
 
 	# Check options to be sure. For example, Overlayfs will fallback to
 	# index=off if underlying fs does not support file handles.
 	# Overlayfs only displays mount option if it differs from the default.
+	# Without a module param of the same name (e.g. xino), the feature
+	# may be on by default, so only require it is not shown as non-on.
 	# Overlayfs may enable the feature, but fallback to read-only mount.
-	((( [ "$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}"
+	if [ "$default" = N ]; then
+		[ "$value" = on ]
+	else
+		[ -z "$value" -o "$value" = on ]
+	fi && touch $mnt/foo 2>/dev/null || \
+		_notrun "${FSTYP} feature '${feature}' cannot be enabled on ${dev}"
 }
 
 # Require a set of overlayfs features
Signature · 1 line
2.55.0
Reviewed-by on v1 1/1
#1 lore raw
Quoted 7 lines · Amir Goldstein

Overlayfs only displays a mount option if it differs from the default. Commit 73a018cb treated a feature without a module parameter of the same name (e.g. xino) as default off and required "${feature}=on" in the mount options. On a samefs xfs setup xino is on by default and is not displayed, so tests requiring xino (e.g. overlay/041, 043, 044, 067, 070, 071) were wrongly skipped.

Quoted 8 lines

For features without a boolean module parameter, assume the feature may be on by default and only verify that the mount options do not show it with a value other than "on", same as for features that default to Y.

Fixes 73a018cbf57b ("common/overlay: let _check_overlay_feature handle param-less options")
Cc Prabhakar Pujeri <[email protected]>

---

Looks good to me!

Quoted 44 lines
 common/overlay | 22 +++++++++-------------
 1 file changed, 9 insertions(+), 13 deletions(-)
common/overlay +9 -13
index 132b2bf7..0cf6db2d 100644
@@ -172,24 +172,20 @@ _check_overlay_feature()
 	# parameter (the system default) and per mount by mount
 	# option ${feature}=[on|off].
 	local default=`_get_fs_module_param ${feature}`
-	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
+	local value=`_fs_options $dev | tr ',' '\n' | grep "^${feature}=" | cut -d= -f2`
 
 	# Check options to be sure. For example, Overlayfs will fallback to
 	# index=off if underlying fs does not support file handles.
 	# Overlayfs only displays mount option if it differs from the default.
+	# Without a module param of the same name (e.g. xino), the feature
+	# may be on by default, so only require it is not shown as non-on.
 	# Overlayfs may enable the feature, but fallback to read-only mount.
-	((( [ "$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}"
+	if [ "$default" = N ]; then
+		[ "$value" = on ]
+	else
+		[ -z "$value" -o "$value" = on ]
+	fi && touch $mnt/foo 2>/dev/null || \
+		_notrun "${FSTYP} feature '${feature}' cannot be enabled on ${dev}"
 }
 
 # Require a set of overlayfs features
Signature · 1 line
2.55.0