diff mbox series

common/rc: Fix _check_s_dax()

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

Commit Message

Ira Weiny Dec. 2, 2020, 9:41 p.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 we
can allow either bit to indicate DAX and cover any kernel which may be
running.

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

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

I went ahead and used Christoph's suggestion regarding using both bits.

---
 common/rc | 23 ++++++++++++++++++-----
 1 file changed, 18 insertions(+), 5 deletions(-)

Comments

Christoph Hellwig Dec. 3, 2020, 8:15 a.m. UTC | #1
On Wed, Dec 02, 2020 at 01:41:45PM -0800, ira.weiny@intel.com wrote:
> 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 we
> can allow either bit to indicate DAX and cover any kernel which may be
> running.
> 
> [1] https://lore.kernel.org/lkml/3e28d2c7-fbe5-298a-13ba-dcd8fd504666@redhat.com/
> 
> Signed-off-by: Ira Weiny <ira.weiny@intel.com>
> ---
> 
> I went ahead and used Christoph's suggestion regarding using both bits.

That wasn't my suggestion.  I think we should always error out when
the bit value shared with STATX_ATTR_MOUNT_ROOT is seen.  Because that
means the kernel is not using or fixed ABI we agreed to use going
forward.
Eric Sandeen Dec. 3, 2020, 5:55 p.m. UTC | #2
On 12/3/20 2:15 AM, Christoph Hellwig wrote:
> On Wed, Dec 02, 2020 at 01:41:45PM -0800, ira.weiny@intel.com wrote:
>> 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 we
>> can allow either bit to indicate DAX and cover any kernel which may be
>> running.
>>
>> [1] https://lore.kernel.org/lkml/3e28d2c7-fbe5-298a-13ba-dcd8fd504666@redhat.com/
>>
>> Signed-off-by: Ira Weiny <ira.weiny@intel.com>
>> ---
>>
>> I went ahead and used Christoph's suggestion regarding using both bits.
> 
> That wasn't my suggestion.  I think we should always error out when
> the bit value shared with STATX_ATTR_MOUNT_ROOT is seen.  Because that
> means the kernel is not using or fixed ABI we agreed to use going
> forward.

*nod* and my suggestion was to explicitly test for the old/wrong value and
offer the test-runner a hint about why it may have been set (missing the
fix commit), but we should still ultimately fail the test when it is seen.

-Eric
Christoph Hellwig Dec. 3, 2020, 6:08 p.m. UTC | #3
On Thu, Dec 03, 2020 at 11:55:50AM -0600, Eric Sandeen wrote:
> *nod* and my suggestion was to explicitly test for the old/wrong value and
> offer the test-runner a hint about why it may have been set (missing the
> fix commit), but we should still ultimately fail the test when it is seen.

Yes, that's what I'd prefer.
Ira Weiny Dec. 4, 2020, 1:44 a.m. UTC | #4
On Thu, Dec 03, 2020 at 07:08:39PM +0100, Christoph Hellwig wrote:
> On Thu, Dec 03, 2020 at 11:55:50AM -0600, Eric Sandeen wrote:
> > *nod* and my suggestion was to explicitly test for the old/wrong value and
> > offer the test-runner a hint about why it may have been set (missing the
> > fix commit), but we should still ultimately fail the test when it is seen.
> 
> Yes, that's what I'd prefer.

Sorry for the misunderstanding.  V3 on it's way.

Ira
diff mbox series

Patch

diff --git a/common/rc b/common/rc
index b5a504e0dcb4..322e682e5239 100644
--- a/common/rc
+++ b/common/rc
@@ -3221,11 +3221,24 @@  _check_s_dax()
 	local exp_s_dax=$2
 
 	local attributes=$($XFS_IO_PROG -c 'statx -r' $target | awk '/stat.attributes / { print $3 }')
-	if [ $exp_s_dax -eq 0 ]; then
-		(( attributes & 0x2000 )) && echo "$target has unexpected S_DAX flag"
-	else
-		(( attributes & 0x2000 )) || echo "$target doesn't have expected S_DAX flag"
-	fi
+
+	# The 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, therefore we can allow either bit to indicate DAX
+	# and cover any kernel which may be running.
+
+        if [ $(( attributes & 0x00200000 )) -ne 0 ] || [ $(( attributes & 0x2000 )) -ne 0 ]; then
+                if [ $exp_s_dax -eq 0 ]; then
+                        echo "$target has unexpected S_DAX flag"
+                fi
+        else
+                if [ $exp_s_dax -ne 0 ]; then
+                        echo "$target doesn't have expected S_DAX flag"
+                fi
+        fi
 }
 
 _check_xflag()