diff mbox series

[V3] common/rc: Fix _check_s_dax()

Message ID 20201204014550.1736306-1-ira.weiny@intel.com (mailing list archive)
State New, archived
Headers show
Series [V3] common/rc: Fix _check_s_dax() | expand

Commit Message

Ira Weiny Dec. 4, 2020, 1:45 a.m. UTC
From: Ira Weiny <ira.weiny@intel.com>

There is a conflict with the user visible statx bits 'mount root' and
'dax'.  The kernel is changing the dax bit to correct this conflict.[1]

Adjust _check_s_dax() to use the new bit.  Because DAX tests do not run
on root mounts, STATX_ATTR_MOUNT_ROOT should always be 0.  Therefore,
check for the old flag and fail the test if that occurs.

[1] https://lore.kernel.org/lkml/3e28d2c7-fbe5-298a-13ba-dcd8fd504666@redhat.com/

Signed-off-by: Ira Weiny <ira.weiny@intel.com>

---
Changes from V2:
	As suggested by Christoph and Eric:
		Fail the test with a hint as to why the wrong bit may be set.

 common/rc | 21 +++++++++++++++++++--
 1 file changed, 19 insertions(+), 2 deletions(-)

Comments

Christoph Hellwig Dec. 4, 2020, 9:47 a.m. UTC | #1
Looks good,

Reviewed-by: Christoph Hellwig <hch@lst.de>
diff mbox series

Patch

diff --git a/common/rc b/common/rc
index b5a504e0dcb4..5911a6c89a78 100644
--- a/common/rc
+++ b/common/rc
@@ -3221,10 +3221,27 @@  _check_s_dax()
 	local exp_s_dax=$2
 
 	local attributes=$($XFS_IO_PROG -c 'statx -r' $target | awk '/stat.attributes / { print $3 }')
+
+	# The original attribute bit value, STATX_ATTR_DAX (0x2000), conflicted
+	# with STATX_ATTR_MOUNT_ROOT.  Therefore, STATX_ATTR_DAX was changed to
+	# 0x00200000.
+	#
+	# Because DAX tests do not run on root mounts, STATX_ATTR_MOUNT_ROOT
+	# should always be 0.  Check for the old flag and fail the test if that
+	# occurs.
+
+	if [ $(( attributes & 0x2000 )) -ne 0 ]; then
+		echo "$target has an unexpected STATX_ATTR_MOUNT_ROOT flag set"
+		echo "which used to be STATX_ATTR_DAX"
+		echo "     This test should not be running on the root inode..."
+		echo "     Does the kernel have the following patch?"
+		echo "     72d1249e2ffd uapi: fix statx attribute value overlap for DAX & MOUNT_ROOT"
+	fi
+
 	if [ $exp_s_dax -eq 0 ]; then
-		(( attributes & 0x2000 )) && echo "$target has unexpected S_DAX flag"
+		(( attributes & 0x00200000 )) && echo "$target has unexpected S_DAX flag"
 	else
-		(( attributes & 0x2000 )) || echo "$target doesn't have expected S_DAX flag"
+		(( attributes & 0x00200000 )) || echo "$target doesn't have expected S_DAX flag"
 	fi
 }