common/rc: Fix _check_s_dax()
PATCH 1/1 common/rc: Fix _check_s_dax()
From: Ira Weiny <[email protected]>
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/[email protected]/
---
I went ahead and used Christoph's suggestion regarding using both bits.
--- common/rc | 23 ++++++++++++++++++----- 1 file changed, 18 insertions(+), 5 deletions(-)
common/rc +18 -5
@@ -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()
Signature · 1 line
2.28.0.rc0.12.gb6a658bd00c9
PATCH v2 1/1 common/rc: Fix _check_s_dax()
From: Ira Weiny <[email protected]>
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/[email protected]/
---
Changes for V2:
Fix bad indentation whitespace.
common/rc | 19 ++++++++++++++++--- 1 file changed, 16 insertions(+), 3 deletions(-)
common/rc +16 -3
@@ -3221,10 +3221,23 @@ _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" + + # 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 - (( attributes & 0x2000 )) || echo "$target doesn't have expected S_DAX flag" + if [ $exp_s_dax -ne 0 ]; then + echo "$target doesn't have expected S_DAX flag" + fi fi }
Signature · 1 line
2.28.0.rc0.12.gb6a658bd00c9
PATCH v3 1/1 common/rc: Fix _check_s_dax()
From: Ira Weiny <[email protected]>
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/[email protected]/
---
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(-)
common/rc +19 -2
@@ -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 }
Signature · 1 line
2.28.0.rc0.12.gb6a658bd00c9
Looks good,
Quoted 10 lines · On Wed, Dec 02, 2020 at 01:41:45PM -0800, [email protected] wrote:
From: Ira Weiny <[email protected]>
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_ROOTshould always be 0, therefore we can allow either bit to indicate DAX and cover any kernel which may be running.
Quoted 6 lines
[1] https://lore.kernel.org/lkml/[email protected]/
Signed-off-by Ira Weiny <[email protected]>---
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.
Quoted 16 lines · Christoph Hellwig
Quoted 15 lines · On Wed, Dec 02, 2020 at 01:41:45PM -0800, [email protected] wrote:
From: Ira Weiny <[email protected]>
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_ROOTshould 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/[email protected]/
Signed-off-by Ira Weiny <[email protected]>---
Quoted 6 lines
Quoted 1 line
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_ROOTis 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
Quoted 3 lines · Eric Sandeen
*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.
Quoted 6 lines · Christoph Hellwig
Quoted 3 lines · Eric Sandeen
*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