Use dax_is_supported() to validate whether the architecture has
virtually aliased caches at mount time.

This is relevant for architectures which require a dynamic check
to validate whether they have virtually aliased data caches
(ARCH_HAS_CACHE_ALIASING_DYNAMIC=y).

Fixes: d92576f1167c ("dax: does not work correctly with virtual aliasing 
caches")
Signed-off-by: Mathieu Desnoyers <[email protected]>
Cc: Chandan Babu R <[email protected]>
Cc: Darrick J. Wong <[email protected]>
Cc: [email protected]
Cc: Andrew Morton <[email protected]>
Cc: Linus Torvalds <[email protected]>
Cc: [email protected]
Cc: [email protected]
Cc: Dan Williams <[email protected]>
Cc: Vishal Verma <[email protected]>
Cc: Dave Jiang <[email protected]>
Cc: Matthew Wilcox <[email protected]>
Cc: [email protected]
Cc: [email protected]
---
 fs/xfs/xfs_super.c | 20 ++++++++++++++------
 1 file changed, 14 insertions(+), 6 deletions(-)

diff --git a/fs/xfs/xfs_super.c b/fs/xfs/xfs_super.c
index 764304595e8b..b27ecb11db66 100644
--- a/fs/xfs/xfs_super.c
+++ b/fs/xfs/xfs_super.c
@@ -1376,14 +1376,22 @@ xfs_fs_parse_param(
        case Opt_nodiscard:
                parsing_mp->m_features &= ~XFS_FEAT_DISCARD;
                return 0;
-#ifdef CONFIG_FS_DAX
        case Opt_dax:
-               xfs_mount_set_dax_mode(parsing_mp, XFS_DAX_ALWAYS);
-               return 0;
+               if (dax_is_supported()) {
+                       xfs_mount_set_dax_mode(parsing_mp, XFS_DAX_ALWAYS);
+                       return 0;
+               } else {
+                       xfs_warn(parsing_mp, "dax option not supported.");
+                       return -EINVAL;
+               }
        case Opt_dax_enum:
-               xfs_mount_set_dax_mode(parsing_mp, result.uint_32);
-               return 0;
-#endif
+               if (dax_is_supported()) {
+                       xfs_mount_set_dax_mode(parsing_mp, result.uint_32);
+                       return 0;
+               } else {
+                       xfs_warn(parsing_mp, "dax option not supported.");
+                       return -EINVAL;
+               }
        /* Following mount options will be removed in September 2025 */
        case Opt_ikeep:
                xfs_fs_warn_deprecated(fc, param, XFS_FEAT_IKEEP, true);
-- 
2.39.2


Reply via email to