Skip to contentSkip to conversation

common/rc: not run swapfile test for DAX

PATCH In review XiaoLi Feng 2 participants 2 messages Apr 24, 2021 – Apr 28, 2021

lore
Share & tools
lore
#0 lore raw

PATCH v2 1/1 common/rc: not run swapfile test for DAX

From: Xiaoli Feng <[email protected]>

DAX doesn't support swapfile. Without this patch, _require_scratch_swapfile always returns fail for fsdax. Now change to notrun.

---
 common/rc | 13 +++++++++++--
 1 file changed, 11 insertions(+), 2 deletions(-)
common/rc +11 -2
index 11ff7635..c3c40f30 100644
@@ -2461,8 +2461,13 @@ _require_scratch_swapfile()
 	case "$FSTYP" in
 	ext2|ext3|ext4|xfs)
 		if ! swapon "$SCRATCH_MNT/swap" >/dev/null 2>&1; then
-			_scratch_unmount
-			_fail "swapon failed for $FSTYP"
+			if _check_s_dax "$SCRATCH_MNT/swap" 1 >/dev/null; then
+				_scratch_unmount
+				_notrun "swapfiles are not supported"
+			else
+				_scratch_unmount
+				_fail "swapon failed for $FSTYP"
+			fi
 		fi
 		;;
 	*)
@@ -3326,6 +3331,7 @@ _check_s_dax()
 {
 	local target=$1
 	local exp_s_dax=$2
+	local ret=0
 
 	local attributes=$($XFS_IO_PROG -c 'statx -r' $target | awk '/stat.attributes / { print $3 }')
 
@@ -3347,9 +3353,12 @@ _check_s_dax()
 
 	if [ $exp_s_dax -eq 0 ]; then
 		(( attributes & 0x00200000 )) && echo "$target has unexpected S_DAX flag"
+		(( attributes & 0x00200000 )) && ret=1
 	else
 		(( attributes & 0x00200000 )) || echo "$target doesn't have expected S_DAX flag"
+		(( attributes & 0x00200000 )) || ret=2
 	fi
+	return $ret
 }
 
 _check_xflag()
Signature · 1 line
2.18.1
Reviewed-by on v2 1/1
#1 lore raw
Quoted 7 lines · XiaoLi Feng

From: Xiaoli Feng <[email protected]>

DAX doesn't support swapfile. Without this patch, _require_scratch_swapfile always returns fail for fsdax. Now change to notrun.

Sorry about my earlier mutterings, I forgot that I'm (still) so far behind on sending fstests patches upstream that I hadn't actually gotten to the one that fixes this. Hence my earlier questions about "can't you just use the existing S_DAX check?" make no sense.

Quoted 33 lines
---
 common/rc | 13 +++++++++++--
 1 file changed, 11 insertions(+), 2 deletions(-)
common/rc +8 -2
index 11ff7635..c3c40f30 100644
@@ -2461,8 +2461,13 @@ _require_scratch_swapfile()
 	case "$FSTYP" in
 	ext2|ext3|ext4|xfs)
 		if ! swapon "$SCRATCH_MNT/swap" >/dev/null 2>&1; then
-			_scratch_unmount
-			_fail "swapon failed for $FSTYP"
+			if _check_s_dax "$SCRATCH_MNT/swap" 1 >/dev/null; then
+				_scratch_unmount
+				_notrun "swapfiles are not supported"
+			else
+				_scratch_unmount
+				_fail "swapon failed for $FSTYP"
+			fi
 		fi
 		;;
 	*)
@@ -3326,6 +3331,7 @@ _check_s_dax()
 {
 	local target=$1
 	local exp_s_dax=$2
+	local ret=0
 
 	local attributes=$($XFS_IO_PROG -c 'statx -r' $target | awk '/stat.attributes / { print $3 }')
 

common/rc _check_s_dax() · line 3359

Quoted 7 lines
common/rc +2 -0
@@ -3347,9 +3353,12 @@ _check_s_dax()
 
 	if [ $exp_s_dax -eq 0 ]; then
 		(( attributes & 0x00200000 )) && echo "$target has unexpected S_DAX flag"
+		(( attributes & 0x00200000 )) && ret=1
 	else
 		(( attributes & 0x00200000 )) || echo "$target doesn't have expected S_DAX flag"
+		(( attributes & 0x00200000 )) || ret=2

Though I suppose if we want to pick nits here, it's kind of silly to test this twice:

		if (( attributes & 0x00200000 )); then
			echo "$target doesn't have expected S_DAX_flag"
			return 2
		fi

OTOH, that's fairly minor so:

--D

Quoted 8 lines
common/rc +1 -0
 	fi
+	return $ret
 }
 
 _check_xflag()
Signature · 1 line
2.18.1