linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [RFC PATCH 0/7] Introduce cache_is_aliasing() to fix DAX regression
@ 2024-01-29 21:06 Mathieu Desnoyers
  2024-01-29 21:06 ` [RFC PATCH 1/7] Introduce cache_is_aliasing() across all architectures Mathieu Desnoyers
                   ` (7 more replies)
  0 siblings, 8 replies; 14+ messages in thread
From: Mathieu Desnoyers @ 2024-01-29 21:06 UTC (permalink / raw)
  To: Dan Williams, Vishal Verma, Dave Jiang
  Cc: linux-kernel, Mathieu Desnoyers, Andrew Morton, Linus Torvalds,
	linux-mm, linux-arch, Matthew Wilcox, linux-cxl, nvdimm

This commit introduced in v5.13 prevents building FS_DAX on 32-bit ARM,
even on ARMv7 which does not have virtually aliased dcaches:

commit d92576f1167c ("dax: does not work correctly with virtual aliasing caches")

It used to work fine before: I have customers using dax over pmem on
ARMv7, but this regression will likely prevent them from upgrading their
kernel.

The root of the issue here is the fact that DAX was never designed to
handle virtually aliased dcache (VIVT and VIPT with aliased dcache). It
touches the pages through their linear mapping, which is not consistent
with the userspace mappings on virtually aliased dcaches. 

This patch series introduces cache_is_aliasing() with new Kconfig
options:

  * ARCH_HAS_CACHE_ALIASING
  * ARCH_HAS_CACHE_ALIASING_DYNAMIC

and implements it for all architectures. The "DYNAMIC" implementation
implements cache_is_aliasing() as a runtime check, which is what is
needed on architectures like 32-bit ARMV6 and ARMV6K.

With this we can basically narrow down the list of architectures which
are unsupported by DAX to those which are really affected.

Feedback is welcome,

Thanks,

Mathieu

Cc: Andrew Morton <akpm@linux-foundation.org>
Cc: Linus Torvalds <torvalds@linux-foundation.org>
Cc: linux-mm@kvack.org
Cc: linux-arch@vger.kernel.org
Cc: Dan Williams <dan.j.williams@intel.com>
Cc: Vishal Verma <vishal.l.verma@intel.com>
Cc: Dave Jiang <dave.jiang@intel.com>
Cc: Matthew Wilcox <willy@infradead.org>
Cc: linux-cxl@vger.kernel.org
Cc: nvdimm@lists.linux.dev

Mathieu Desnoyers (7):
  Introduce cache_is_aliasing() across all architectures
  dax: Fix incorrect list of cache aliasing architectures
  erofs: Use dax_is_supported()
  ext2: Use dax_is_supported()
  ext4: Use dax_is_supported()
  fuse: Introduce fuse_dax_is_supported()
  xfs: Use dax_is_supported()

 arch/arc/Kconfig                    |  1 +
 arch/arm/include/asm/cachetype.h    |  3 ++
 arch/arm/mm/Kconfig                 |  2 ++
 arch/csky/Kconfig                   |  1 +
 arch/m68k/Kconfig                   |  1 +
 arch/mips/Kconfig                   |  1 +
 arch/mips/include/asm/cachetype.h   |  9 +++++
 arch/nios2/Kconfig                  |  1 +
 arch/nios2/include/asm/cachetype.h  | 10 ++++++
 arch/parisc/Kconfig                 |  1 +
 arch/sh/Kconfig                     |  1 +
 arch/sparc/Kconfig                  |  1 +
 arch/sparc/include/asm/cachetype.h  | 14 ++++++++
 arch/xtensa/Kconfig                 |  1 +
 arch/xtensa/include/asm/cachetype.h | 10 ++++++
 fs/Kconfig                          |  2 +-
 fs/erofs/super.c                    | 10 +++---
 fs/ext2/super.c                     | 14 ++++----
 fs/ext4/super.c                     | 52 ++++++++++++++---------------
 fs/fuse/file.c                      |  2 +-
 fs/fuse/fuse_i.h                    | 36 +++++++++++++++++++-
 fs/fuse/inode.c                     | 47 +++++++++++++-------------
 fs/fuse/virtio_fs.c                 |  4 +--
 fs/xfs/xfs_super.c                  | 20 +++++++----
 include/linux/cacheinfo.h           |  8 +++++
 include/linux/dax.h                 |  9 +++++
 mm/Kconfig                          | 10 ++++++
 27 files changed, 198 insertions(+), 73 deletions(-)
 create mode 100644 arch/mips/include/asm/cachetype.h
 create mode 100644 arch/nios2/include/asm/cachetype.h
 create mode 100644 arch/sparc/include/asm/cachetype.h
 create mode 100644 arch/xtensa/include/asm/cachetype.h

-- 
2.39.2


^ permalink raw reply	[flat|nested] 14+ messages in thread

* [RFC PATCH 1/7] Introduce cache_is_aliasing() across all architectures
  2024-01-29 21:06 [RFC PATCH 0/7] Introduce cache_is_aliasing() to fix DAX regression Mathieu Desnoyers
@ 2024-01-29 21:06 ` Mathieu Desnoyers
  2024-01-29 21:06 ` [RFC PATCH 2/7] dax: Fix incorrect list of cache aliasing architectures Mathieu Desnoyers
                   ` (6 subsequent siblings)
  7 siblings, 0 replies; 14+ messages in thread
From: Mathieu Desnoyers @ 2024-01-29 21:06 UTC (permalink / raw)
  To: Dan Williams, Vishal Verma, Dave Jiang
  Cc: linux-kernel, Mathieu Desnoyers, Andrew Morton, Linus Torvalds,
	linux-mm, linux-arch, Matthew Wilcox, linux-cxl, nvdimm

Introduce a generic way to query whether the dcache is virtually aliased
on all architectures. Its purpose is to ensure that subsystems which
are incompatible with virtually aliased caches (e.g. FS_DAX) can
reliably query this.

For dcache aliasing, there are three scenarios dependending on the
architecture. Here is a breakdown based on my understanding:

A) The dcache is always aliasing:
   (ARCH_HAS_CACHE_ALIASING=y)

* arm V4, V5 (CPU_CACHE_VIVT)
* arc
* csky
* m68k (note: shared memory mappings are incoherent ? SHMLBA is missing there.)
* sh
* parisc

B) The dcache aliasing depends on querying CPU state at runtime:
   (ARCH_HAS_CACHE_ALIASING_DYNAMIC=y)

* arm V6, V6K (CPU_CACHE_VIPT) (cache_is_vipt_aliasing())
* mips (cpu_has_dc_aliases)
* nios2 (NIOS2_DCACHE_SIZE > PAGE_SIZE)
* sparc32 (vac_cache_size > PAGE_SIZE)
* sparc64 (L1DCACHE_SIZE > PAGE_SIZE)
* xtensa (DCACHE_WAY_SIZE > PAGE_SIZE)

C) The dcache is never aliasing:

* arm V7, V7M (unless ARM V6 or V6K are also present) (CPU_CACHE_VIPT)
* alpha
* arm64 (aarch64)
* hexagon
* loongarch (but with incoherent write buffers, which are disabled since
             commit d23b7795 ("LoongArch: Change SHMLBA from SZ_64K to PAGE_SIZE"))
* microblaze
* openrisc
* powerpc
* riscv
* s390
* um
* x86

Link: https://lore.kernel.org/lkml/20030910210416.GA24258@mail.jlokier.co.uk/
Signed-off-by: Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
Cc: Andrew Morton <akpm@linux-foundation.org>
Cc: Linus Torvalds <torvalds@linux-foundation.org>
Cc: linux-mm@kvack.org
Cc: linux-arch@vger.kernel.org
Cc: Dan Williams <dan.j.williams@intel.com>
Cc: Vishal Verma <vishal.l.verma@intel.com>
Cc: Dave Jiang <dave.jiang@intel.com>
Cc: Matthew Wilcox <willy@infradead.org>
Cc: linux-cxl@vger.kernel.org
Cc: nvdimm@lists.linux.dev
---
 arch/arc/Kconfig                    |  1 +
 arch/arm/include/asm/cachetype.h    |  3 +++
 arch/arm/mm/Kconfig                 |  2 ++
 arch/csky/Kconfig                   |  1 +
 arch/m68k/Kconfig                   |  1 +
 arch/mips/Kconfig                   |  1 +
 arch/mips/include/asm/cachetype.h   |  9 +++++++++
 arch/nios2/Kconfig                  |  1 +
 arch/nios2/include/asm/cachetype.h  | 10 ++++++++++
 arch/parisc/Kconfig                 |  1 +
 arch/sh/Kconfig                     |  1 +
 arch/sparc/Kconfig                  |  1 +
 arch/sparc/include/asm/cachetype.h  | 14 ++++++++++++++
 arch/xtensa/Kconfig                 |  1 +
 arch/xtensa/include/asm/cachetype.h | 10 ++++++++++
 include/linux/cacheinfo.h           |  8 ++++++++
 mm/Kconfig                          | 10 ++++++++++
 17 files changed, 75 insertions(+)
 create mode 100644 arch/mips/include/asm/cachetype.h
 create mode 100644 arch/nios2/include/asm/cachetype.h
 create mode 100644 arch/sparc/include/asm/cachetype.h
 create mode 100644 arch/xtensa/include/asm/cachetype.h

diff --git a/arch/arc/Kconfig b/arch/arc/Kconfig
index 1b0483c51cc1..969e6740bcf7 100644
--- a/arch/arc/Kconfig
+++ b/arch/arc/Kconfig
@@ -6,6 +6,7 @@
 config ARC
 	def_bool y
 	select ARC_TIMERS
+	select ARCH_HAS_CACHE_ALIASING
 	select ARCH_HAS_CACHE_LINE_SIZE
 	select ARCH_HAS_DEBUG_VM_PGTABLE
 	select ARCH_HAS_DMA_PREP_COHERENT
diff --git a/arch/arm/include/asm/cachetype.h b/arch/arm/include/asm/cachetype.h
index e8c30430be33..b03054b35c74 100644
--- a/arch/arm/include/asm/cachetype.h
+++ b/arch/arm/include/asm/cachetype.h
@@ -16,6 +16,9 @@ extern unsigned int cacheid;
 #define cache_is_vipt()			cacheid_is(CACHEID_VIPT)
 #define cache_is_vipt_nonaliasing()	cacheid_is(CACHEID_VIPT_NONALIASING)
 #define cache_is_vipt_aliasing()	cacheid_is(CACHEID_VIPT_ALIASING)
+#ifdef CONFIG_ARCH_HAS_CACHE_ALIASING_DYNAMIC
+#define cache_is_aliasing()		cache_is_vipt_aliasing()
+#endif
 #define icache_is_vivt_asid_tagged()	cacheid_is(CACHEID_ASID_TAGGED)
 #define icache_is_vipt_aliasing()	cacheid_is(CACHEID_VIPT_I_ALIASING)
 #define icache_is_pipt()		cacheid_is(CACHEID_PIPT)
diff --git a/arch/arm/mm/Kconfig b/arch/arm/mm/Kconfig
index c164cde50243..23af93cdc03d 100644
--- a/arch/arm/mm/Kconfig
+++ b/arch/arm/mm/Kconfig
@@ -539,9 +539,11 @@ config CPU_CACHE_NOP
 	bool
 
 config CPU_CACHE_VIVT
+	select ARCH_HAS_CACHE_ALIASING
 	bool
 
 config CPU_CACHE_VIPT
+	select ARCH_HAS_CACHE_ALIASING_DYNAMIC if CPU_V6 || CPU_V6K
 	bool
 
 config CPU_CACHE_FA
diff --git a/arch/csky/Kconfig b/arch/csky/Kconfig
index cf2a6fd7dff8..439d7640deb8 100644
--- a/arch/csky/Kconfig
+++ b/arch/csky/Kconfig
@@ -2,6 +2,7 @@
 config CSKY
 	def_bool y
 	select ARCH_32BIT_OFF_T
+	select ARCH_HAS_CACHE_ALIASING
 	select ARCH_HAS_DMA_PREP_COHERENT
 	select ARCH_HAS_GCOV_PROFILE_ALL
 	select ARCH_HAS_SYNC_DMA_FOR_CPU
diff --git a/arch/m68k/Kconfig b/arch/m68k/Kconfig
index 4b3e93cac723..216338704f0a 100644
--- a/arch/m68k/Kconfig
+++ b/arch/m68k/Kconfig
@@ -3,6 +3,7 @@ config M68K
 	bool
 	default y
 	select ARCH_32BIT_OFF_T
+	select ARCH_HAS_CACHE_ALIASING
 	select ARCH_HAS_BINFMT_FLAT
 	select ARCH_HAS_CPU_FINALIZE_INIT if MMU
 	select ARCH_HAS_CURRENT_STACK_POINTER
diff --git a/arch/mips/Kconfig b/arch/mips/Kconfig
index 797ae590ebdb..46981c507ceb 100644
--- a/arch/mips/Kconfig
+++ b/arch/mips/Kconfig
@@ -4,6 +4,7 @@ config MIPS
 	default y
 	select ARCH_32BIT_OFF_T if !64BIT
 	select ARCH_BINFMT_ELF_STATE if MIPS_FP_SUPPORT
+	select ARCH_HAS_CACHE_ALIASING_DYNAMIC
 	select ARCH_HAS_CPU_FINALIZE_INIT
 	select ARCH_HAS_CURRENT_STACK_POINTER if !CC_IS_CLANG || CLANG_VERSION >= 140000
 	select ARCH_HAS_DEBUG_VIRTUAL if !64BIT
diff --git a/arch/mips/include/asm/cachetype.h b/arch/mips/include/asm/cachetype.h
new file mode 100644
index 000000000000..ce16ccde1841
--- /dev/null
+++ b/arch/mips/include/asm/cachetype.h
@@ -0,0 +1,9 @@
+/* SPDX-License-Identifier: GPL-2.0 */
+#ifndef __ASM_MIPS_CACHETYPE_H
+#define __ASM_MIPS_CACHETYPE_H
+
+#include <asm/cpu-features.h>
+
+#define cache_is_aliasing()		cpu_has_dc_aliases
+
+#endif
diff --git a/arch/nios2/Kconfig b/arch/nios2/Kconfig
index d54464021a61..949dcf99e147 100644
--- a/arch/nios2/Kconfig
+++ b/arch/nios2/Kconfig
@@ -2,6 +2,7 @@
 config NIOS2
 	def_bool y
 	select ARCH_32BIT_OFF_T
+	select ARCH_HAS_CACHE_ALIASING_DYNAMIC
 	select ARCH_HAS_DMA_PREP_COHERENT
 	select ARCH_HAS_SYNC_DMA_FOR_CPU
 	select ARCH_HAS_SYNC_DMA_FOR_DEVICE
diff --git a/arch/nios2/include/asm/cachetype.h b/arch/nios2/include/asm/cachetype.h
new file mode 100644
index 000000000000..f52a16cdb496
--- /dev/null
+++ b/arch/nios2/include/asm/cachetype.h
@@ -0,0 +1,10 @@
+/* SPDX-License-Identifier: GPL-2.0 */
+#ifndef __ASM_NIOS2_CACHETYPE_H
+#define __ASM_NIOS2_CACHETYPE_H
+
+#include <asm/page.h>
+#include <asm/cache.h>
+
+#define cache_is_aliasing()		(NIOS2_DCACHE_SIZE > PAGE_SIZE)
+
+#endif
diff --git a/arch/parisc/Kconfig b/arch/parisc/Kconfig
index d14ccc948a29..e8c217744d83 100644
--- a/arch/parisc/Kconfig
+++ b/arch/parisc/Kconfig
@@ -8,6 +8,7 @@ config PARISC
 	select HAVE_FUNCTION_GRAPH_TRACER
 	select HAVE_SYSCALL_TRACEPOINTS
 	select ARCH_WANT_FRAME_POINTERS
+	select ARCH_HAS_CACHE_ALIASING
 	select ARCH_HAS_DMA_ALLOC if PA11
 	select ARCH_HAS_ELF_RANDOMIZE
 	select ARCH_HAS_STRICT_KERNEL_RWX
diff --git a/arch/sh/Kconfig b/arch/sh/Kconfig
index 7500521b2b98..6465ef80c055 100644
--- a/arch/sh/Kconfig
+++ b/arch/sh/Kconfig
@@ -2,6 +2,7 @@
 config SUPERH
 	def_bool y
 	select ARCH_32BIT_OFF_T
+	select ARCH_HAS_CACHE_ALIASING
 	select ARCH_ENABLE_MEMORY_HOTPLUG if SPARSEMEM && MMU
 	select ARCH_ENABLE_MEMORY_HOTREMOVE if SPARSEMEM && MMU
 	select ARCH_HAVE_NMI_SAFE_CMPXCHG if (GUSA_RB || CPU_SH4A)
diff --git a/arch/sparc/Kconfig b/arch/sparc/Kconfig
index 49849790e66d..a5edcbfaf6f8 100644
--- a/arch/sparc/Kconfig
+++ b/arch/sparc/Kconfig
@@ -13,6 +13,7 @@ config 64BIT
 config SPARC
 	bool
 	default y
+	select ARCH_HAS_CACHE_ALIASING_DYNAMIC
 	select ARCH_MIGHT_HAVE_PC_PARPORT if SPARC64 && PCI
 	select ARCH_MIGHT_HAVE_PC_SERIO
 	select DMA_OPS
diff --git a/arch/sparc/include/asm/cachetype.h b/arch/sparc/include/asm/cachetype.h
new file mode 100644
index 000000000000..8871e461cf23
--- /dev/null
+++ b/arch/sparc/include/asm/cachetype.h
@@ -0,0 +1,14 @@
+/* SPDX-License-Identifier: GPL-2.0 */
+#ifndef __ASM_SPARC_CACHETYPE_H
+#define __ASM_SPARC_CACHETYPE_H
+
+#include <asm/page.h>
+
+#ifdef CONFIG_SPARC32
+extern int vac_cache_size;
+#define cache_is_aliasing()		(vac_cache_size > PAGE_SIZE)
+#else
+#define cache_is_aliasing()		(L1DCACHE_SIZE > PAGE_SIZE)
+#endif
+
+#endif
diff --git a/arch/xtensa/Kconfig b/arch/xtensa/Kconfig
index 7d792077e5fd..ae99aa88595a 100644
--- a/arch/xtensa/Kconfig
+++ b/arch/xtensa/Kconfig
@@ -2,6 +2,7 @@
 config XTENSA
 	def_bool y
 	select ARCH_32BIT_OFF_T
+	select ARCH_HAS_CACHE_ALIASING_DYNAMIC
 	select ARCH_HAS_BINFMT_FLAT if !MMU
 	select ARCH_HAS_CURRENT_STACK_POINTER
 	select ARCH_HAS_DEBUG_VM_PGTABLE
diff --git a/arch/xtensa/include/asm/cachetype.h b/arch/xtensa/include/asm/cachetype.h
new file mode 100644
index 000000000000..4329c885fe5f
--- /dev/null
+++ b/arch/xtensa/include/asm/cachetype.h
@@ -0,0 +1,10 @@
+/* SPDX-License-Identifier: GPL-2.0 */
+#ifndef __ASM_XTENSA_CACHETYPE_H
+#define __ASM_XTENSA_CACHETYPE_H
+
+#include <asm/cache.h>
+#include <asm/page.h>
+
+#define cache_is_aliasing()		(DCACHE_WAY_SIZE > PAGE_SIZE)
+
+#endif
diff --git a/include/linux/cacheinfo.h b/include/linux/cacheinfo.h
index d504eb4b49ab..86f9a099fd5d 100644
--- a/include/linux/cacheinfo.h
+++ b/include/linux/cacheinfo.h
@@ -138,4 +138,12 @@ static inline int get_cpu_cacheinfo_id(int cpu, int level)
 #define use_arch_cache_info()	(false)
 #endif
 
+#ifdef CONFIG_ARCH_HAS_CACHE_ALIASING
+#define cache_is_aliasing()	true
+#elif defined(CONFIG_ARCH_HAS_CACHE_ALIASING_DYNAMIC)
+#include <asm/cachetype.h>
+#else
+#define cache_is_aliasing()	false
+#endif
+
 #endif /* _LINUX_CACHEINFO_H */
diff --git a/mm/Kconfig b/mm/Kconfig
index 57cd378c73d6..08f6ca0b465a 100644
--- a/mm/Kconfig
+++ b/mm/Kconfig
@@ -1016,6 +1016,16 @@ config IDLE_PAGE_TRACKING
 	  See Documentation/admin-guide/mm/idle_page_tracking.rst for
 	  more details.
 
+# Architectures which alias the data cache (VIVT or VIPT with dcache
+# aliasing) need to select this.
+config ARCH_HAS_CACHE_ALIASING
+	bool
+
+# Architectures which need to query at runtime whether the data cache is
+# aliased need to select this.
+config ARCH_HAS_CACHE_ALIASING_DYNAMIC
+	bool
+
 config ARCH_HAS_CACHE_LINE_SIZE
 	bool
 
-- 
2.39.2


^ permalink raw reply related	[flat|nested] 14+ messages in thread

* [RFC PATCH 2/7] dax: Fix incorrect list of cache aliasing architectures
  2024-01-29 21:06 [RFC PATCH 0/7] Introduce cache_is_aliasing() to fix DAX regression Mathieu Desnoyers
  2024-01-29 21:06 ` [RFC PATCH 1/7] Introduce cache_is_aliasing() across all architectures Mathieu Desnoyers
@ 2024-01-29 21:06 ` Mathieu Desnoyers
  2024-01-29 21:06 ` [RFC PATCH 3/7] erofs: Use dax_is_supported() Mathieu Desnoyers
                   ` (5 subsequent siblings)
  7 siblings, 0 replies; 14+ messages in thread
From: Mathieu Desnoyers @ 2024-01-29 21:06 UTC (permalink / raw)
  To: Dan Williams, Vishal Verma, Dave Jiang
  Cc: linux-kernel, Mathieu Desnoyers, Andrew Morton, Linus Torvalds,
	linux-mm, linux-arch, Matthew Wilcox, nvdimm, linux-cxl

fs/Kconfig:FS_DAX prevents DAX from building on architectures with
virtually aliased dcache with:

  depends on !(ARM || MIPS || SPARC)

This check is too broad (e.g. recent ARMv7 don't have virtually aliased
dcaches), and also misses many other architectures with virtually
aliased dcache.

This is a regression introduced in the v5.13 Linux kernel where the
dax mount option is removed for 32-bit ARMv7 boards which have no dcache
aliasing, and therefore should work fine with FS_DAX.

Use this instead in Kconfig to prevent FS_DAX from being built on
architectures with virtually aliased dcache:

  depends on !ARCH_HAS_CACHE_ALIASING

For architectures which detect dcache aliasing at runtime, introduce
a new dax_is_supported() static inline which uses "cache_is_aliasing()"
to figure out whether the environment has aliasing dcaches.

This new dax_is_supported() helper will be used in each filesystem
supporting the dax mount option to validate whether dax is indeed
supported.

Fixes: d92576f1167c ("dax: does not work correctly with virtual aliasing caches")
Signed-off-by: Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
Cc: Andrew Morton <akpm@linux-foundation.org>
Cc: Linus Torvalds <torvalds@linux-foundation.org>
Cc: linux-mm@kvack.org
Cc: linux-arch@vger.kernel.org
Cc: Dan Williams <dan.j.williams@intel.com>
Cc: Vishal Verma <vishal.l.verma@intel.com>
Cc: Dave Jiang <dave.jiang@intel.com>
Cc: Matthew Wilcox <willy@infradead.org>
Cc: nvdimm@lists.linux.dev
Cc: linux-cxl@vger.kernel.org
---
 fs/Kconfig          | 2 +-
 include/linux/dax.h | 9 +++++++++
 2 files changed, 10 insertions(+), 1 deletion(-)

diff --git a/fs/Kconfig b/fs/Kconfig
index 42837617a55b..6746fe403761 100644
--- a/fs/Kconfig
+++ b/fs/Kconfig
@@ -56,7 +56,7 @@ endif # BLOCK
 config FS_DAX
 	bool "File system based Direct Access (DAX) support"
 	depends on MMU
-	depends on !(ARM || MIPS || SPARC)
+	depends on !ARCH_HAS_CACHE_ALIASING
 	depends on ZONE_DEVICE || FS_DAX_LIMITED
 	select FS_IOMAP
 	select DAX
diff --git a/include/linux/dax.h b/include/linux/dax.h
index b463502b16e1..8c595b04deeb 100644
--- a/include/linux/dax.h
+++ b/include/linux/dax.h
@@ -5,6 +5,7 @@
 #include <linux/fs.h>
 #include <linux/mm.h>
 #include <linux/radix-tree.h>
+#include <linux/cacheinfo.h>
 
 typedef unsigned long dax_entry_t;
 
@@ -78,6 +79,10 @@ static inline bool daxdev_mapping_supported(struct vm_area_struct *vma,
 		return false;
 	return dax_synchronous(dax_dev);
 }
+static inline bool dax_is_supported(void)
+{
+	return !cache_is_aliasing();
+}
 #else
 static inline void *dax_holder(struct dax_device *dax_dev)
 {
@@ -122,6 +127,10 @@ static inline size_t dax_recovery_write(struct dax_device *dax_dev,
 {
 	return 0;
 }
+static inline bool dax_is_supported(void)
+{
+	return false;
+}
 #endif
 
 void set_dax_nocache(struct dax_device *dax_dev);
-- 
2.39.2


^ permalink raw reply related	[flat|nested] 14+ messages in thread

* [RFC PATCH 3/7] erofs: Use dax_is_supported()
  2024-01-29 21:06 [RFC PATCH 0/7] Introduce cache_is_aliasing() to fix DAX regression Mathieu Desnoyers
  2024-01-29 21:06 ` [RFC PATCH 1/7] Introduce cache_is_aliasing() across all architectures Mathieu Desnoyers
  2024-01-29 21:06 ` [RFC PATCH 2/7] dax: Fix incorrect list of cache aliasing architectures Mathieu Desnoyers
@ 2024-01-29 21:06 ` Mathieu Desnoyers
  2024-01-29 21:06 ` [RFC PATCH 4/7] ext2: " Mathieu Desnoyers
                   ` (4 subsequent siblings)
  7 siblings, 0 replies; 14+ messages in thread
From: Mathieu Desnoyers @ 2024-01-29 21:06 UTC (permalink / raw)
  To: Dan Williams, Vishal Verma, Dave Jiang
  Cc: linux-kernel, Mathieu Desnoyers, Gao Xiang, Chao Yu, Yue Hu,
	Jeffle Xu, linux-erofs, Andrew Morton, Linus Torvalds, linux-mm,
	linux-arch, Matthew Wilcox, nvdimm, linux-cxl

Use dax_is_supported() to validate whether the architecture has
virtually aliased data 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 <mathieu.desnoyers@efficios.com>
Cc: Gao Xiang <xiang@kernel.org>
Cc: Chao Yu <chao@kernel.org>
Cc: Yue Hu <huyue2@coolpad.com>
Cc: Jeffle Xu <jefflexu@linux.alibaba.com>
Cc: linux-erofs@lists.ozlabs.org
Cc: Andrew Morton <akpm@linux-foundation.org>
Cc: Linus Torvalds <torvalds@linux-foundation.org>
Cc: linux-mm@kvack.org
Cc: linux-arch@vger.kernel.org
Cc: Dan Williams <dan.j.williams@intel.com>
Cc: Vishal Verma <vishal.l.verma@intel.com>
Cc: Dave Jiang <dave.jiang@intel.com>
Cc: Matthew Wilcox <willy@infradead.org>
Cc: nvdimm@lists.linux.dev
Cc: linux-cxl@vger.kernel.org
---
 fs/erofs/super.c | 10 +++++-----
 1 file changed, 5 insertions(+), 5 deletions(-)

diff --git a/fs/erofs/super.c b/fs/erofs/super.c
index 3789d6224513..bd88221f1ad7 100644
--- a/fs/erofs/super.c
+++ b/fs/erofs/super.c
@@ -419,9 +419,13 @@ static const struct fs_parameter_spec erofs_fs_parameters[] = {
 
 static bool erofs_fc_set_dax_mode(struct fs_context *fc, unsigned int mode)
 {
-#ifdef CONFIG_FS_DAX
 	struct erofs_fs_context *ctx = fc->fs_private;
 
+	if (!dax_is_supported()) {
+		errorfc(fc, "dax options not supported");
+		return false;
+	}
+
 	switch (mode) {
 	case EROFS_MOUNT_DAX_ALWAYS:
 		warnfc(fc, "DAX enabled. Warning: EXPERIMENTAL, use at your own risk");
@@ -436,10 +440,6 @@ static bool erofs_fc_set_dax_mode(struct fs_context *fc, unsigned int mode)
 		DBG_BUGON(1);
 		return false;
 	}
-#else
-	errorfc(fc, "dax options not supported");
-	return false;
-#endif
 }
 
 static int erofs_fc_parse_param(struct fs_context *fc,
-- 
2.39.2


^ permalink raw reply related	[flat|nested] 14+ messages in thread

* [RFC PATCH 4/7] ext2: Use dax_is_supported()
  2024-01-29 21:06 [RFC PATCH 0/7] Introduce cache_is_aliasing() to fix DAX regression Mathieu Desnoyers
                   ` (2 preceding siblings ...)
  2024-01-29 21:06 ` [RFC PATCH 3/7] erofs: Use dax_is_supported() Mathieu Desnoyers
@ 2024-01-29 21:06 ` Mathieu Desnoyers
  2024-01-30 11:33   ` Jan Kara
  2024-01-29 21:06 ` [RFC PATCH 5/7] ext4: " Mathieu Desnoyers
                   ` (3 subsequent siblings)
  7 siblings, 1 reply; 14+ messages in thread
From: Mathieu Desnoyers @ 2024-01-29 21:06 UTC (permalink / raw)
  To: Dan Williams, Vishal Verma, Dave Jiang
  Cc: linux-kernel, Mathieu Desnoyers, Jan Kara, linux-ext4,
	Andrew Morton, Linus Torvalds, linux-mm, linux-arch,
	Matthew Wilcox, nvdimm, linux-cxl

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 <mathieu.desnoyers@efficios.com>
Cc: Jan Kara <jack@suse.com>
Cc: linux-ext4@vger.kernel.org
Cc: Andrew Morton <akpm@linux-foundation.org>
Cc: Linus Torvalds <torvalds@linux-foundation.org>
Cc: linux-mm@kvack.org
Cc: linux-arch@vger.kernel.org
Cc: Dan Williams <dan.j.williams@intel.com>
Cc: Vishal Verma <vishal.l.verma@intel.com>
Cc: Dave Jiang <dave.jiang@intel.com>
Cc: Matthew Wilcox <willy@infradead.org>
Cc: nvdimm@lists.linux.dev
Cc: linux-cxl@vger.kernel.org
---
 fs/ext2/super.c | 14 +++++++-------
 1 file changed, 7 insertions(+), 7 deletions(-)

diff --git a/fs/ext2/super.c b/fs/ext2/super.c
index 01f9addc8b1f..0398e7a90eb6 100644
--- a/fs/ext2/super.c
+++ b/fs/ext2/super.c
@@ -585,13 +585,13 @@ static int parse_options(char *options, struct super_block *sb,
 			set_opt(opts->s_mount_opt, XIP);
 			fallthrough;
 		case Opt_dax:
-#ifdef CONFIG_FS_DAX
-			ext2_msg(sb, KERN_WARNING,
-		"DAX enabled. Warning: EXPERIMENTAL, use at your own risk");
-			set_opt(opts->s_mount_opt, DAX);
-#else
-			ext2_msg(sb, KERN_INFO, "dax option not supported");
-#endif
+			if (dax_is_supported()) {
+				ext2_msg(sb, KERN_WARNING,
+					 "DAX enabled. Warning: EXPERIMENTAL, use at your own risk");
+				set_opt(opts->s_mount_opt, DAX);
+			} else {
+				ext2_msg(sb, KERN_INFO, "dax option not supported");
+			}
 			break;
 
 #if defined(CONFIG_QUOTA)
-- 
2.39.2


^ permalink raw reply related	[flat|nested] 14+ messages in thread

* [RFC PATCH 5/7] ext4: Use dax_is_supported()
  2024-01-29 21:06 [RFC PATCH 0/7] Introduce cache_is_aliasing() to fix DAX regression Mathieu Desnoyers
                   ` (3 preceding siblings ...)
  2024-01-29 21:06 ` [RFC PATCH 4/7] ext2: " Mathieu Desnoyers
@ 2024-01-29 21:06 ` Mathieu Desnoyers
  2024-01-29 21:06 ` [RFC PATCH 6/7] fuse: Introduce fuse_dax_is_supported() Mathieu Desnoyers
                   ` (2 subsequent siblings)
  7 siblings, 0 replies; 14+ messages in thread
From: Mathieu Desnoyers @ 2024-01-29 21:06 UTC (permalink / raw)
  To: Dan Williams, Vishal Verma, Dave Jiang
  Cc: linux-kernel, Mathieu Desnoyers, Theodore Ts'o,
	Andreas Dilger, linux-ext4, Andrew Morton, Linus Torvalds,
	linux-mm, linux-arch, Matthew Wilcox, nvdimm, linux-cxl

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 <mathieu.desnoyers@efficios.com>
Cc: "Theodore Ts'o" <tytso@mit.edu>
Cc: Andreas Dilger <adilger.kernel@dilger.ca>
Cc: linux-ext4@vger.kernel.org
Cc: Andrew Morton <akpm@linux-foundation.org>
Cc: Linus Torvalds <torvalds@linux-foundation.org>
Cc: linux-mm@kvack.org
Cc: linux-arch@vger.kernel.org
Cc: Dan Williams <dan.j.williams@intel.com>
Cc: Vishal Verma <vishal.l.verma@intel.com>
Cc: Dave Jiang <dave.jiang@intel.com>
Cc: Matthew Wilcox <willy@infradead.org>
Cc: nvdimm@lists.linux.dev
Cc: linux-cxl@vger.kernel.org
---
 fs/ext4/super.c | 52 ++++++++++++++++++++++++-------------------------
 1 file changed, 25 insertions(+), 27 deletions(-)

diff --git a/fs/ext4/super.c b/fs/ext4/super.c
index c5fcf377ab1f..9e0606289239 100644
--- a/fs/ext4/super.c
+++ b/fs/ext4/super.c
@@ -2359,34 +2359,32 @@ static int ext4_parse_param(struct fs_context *fc, struct fs_parameter *param)
 		return ext4_parse_test_dummy_encryption(param, ctx);
 	case Opt_dax:
 	case Opt_dax_type:
-#ifdef CONFIG_FS_DAX
-	{
-		int type = (token == Opt_dax) ?
-			   Opt_dax : result.uint_32;
-
-		switch (type) {
-		case Opt_dax:
-		case Opt_dax_always:
-			ctx_set_mount_opt(ctx, EXT4_MOUNT_DAX_ALWAYS);
-			ctx_clear_mount_opt2(ctx, EXT4_MOUNT2_DAX_NEVER);
-			break;
-		case Opt_dax_never:
-			ctx_set_mount_opt2(ctx, EXT4_MOUNT2_DAX_NEVER);
-			ctx_clear_mount_opt(ctx, EXT4_MOUNT_DAX_ALWAYS);
-			break;
-		case Opt_dax_inode:
-			ctx_clear_mount_opt(ctx, EXT4_MOUNT_DAX_ALWAYS);
-			ctx_clear_mount_opt2(ctx, EXT4_MOUNT2_DAX_NEVER);
-			/* Strictly for printing options */
-			ctx_set_mount_opt2(ctx, EXT4_MOUNT2_DAX_INODE);
-			break;
+		if (dax_is_supported()) {
+			int type = (token == Opt_dax) ?
+				   Opt_dax : result.uint_32;
+
+			switch (type) {
+			case Opt_dax:
+			case Opt_dax_always:
+				ctx_set_mount_opt(ctx, EXT4_MOUNT_DAX_ALWAYS);
+				ctx_clear_mount_opt2(ctx, EXT4_MOUNT2_DAX_NEVER);
+				break;
+			case Opt_dax_never:
+				ctx_set_mount_opt2(ctx, EXT4_MOUNT2_DAX_NEVER);
+				ctx_clear_mount_opt(ctx, EXT4_MOUNT_DAX_ALWAYS);
+				break;
+			case Opt_dax_inode:
+				ctx_clear_mount_opt(ctx, EXT4_MOUNT_DAX_ALWAYS);
+				ctx_clear_mount_opt2(ctx, EXT4_MOUNT2_DAX_NEVER);
+				/* Strictly for printing options */
+				ctx_set_mount_opt2(ctx, EXT4_MOUNT2_DAX_INODE);
+				break;
+			}
+			return 0;
+		} else {
+			ext4_msg(NULL, KERN_INFO, "dax option not supported");
+			return -EINVAL;
 		}
-		return 0;
-	}
-#else
-		ext4_msg(NULL, KERN_INFO, "dax option not supported");
-		return -EINVAL;
-#endif
 	case Opt_data_err:
 		if (result.uint_32 == Opt_data_err_abort)
 			ctx_set_mount_opt(ctx, m->mount_opt);
-- 
2.39.2


^ permalink raw reply related	[flat|nested] 14+ messages in thread

* [RFC PATCH 6/7] fuse: Introduce fuse_dax_is_supported()
  2024-01-29 21:06 [RFC PATCH 0/7] Introduce cache_is_aliasing() to fix DAX regression Mathieu Desnoyers
                   ` (4 preceding siblings ...)
  2024-01-29 21:06 ` [RFC PATCH 5/7] ext4: " Mathieu Desnoyers
@ 2024-01-29 21:06 ` Mathieu Desnoyers
  2024-01-29 21:06 ` [RFC PATCH 7/7] xfs: Use dax_is_supported() Mathieu Desnoyers
  2024-01-29 21:22 ` [RFC PATCH 0/7] Introduce cache_is_aliasing() to fix DAX regression Dan Williams
  7 siblings, 0 replies; 14+ messages in thread
From: Mathieu Desnoyers @ 2024-01-29 21:06 UTC (permalink / raw)
  To: Dan Williams, Vishal Verma, Dave Jiang
  Cc: linux-kernel, Mathieu Desnoyers, Miklos Szeredi, linux-fsdevel,
	Andrew Morton, Linus Torvalds, linux-mm, linux-arch,
	Matthew Wilcox, nvdimm, linux-cxl

Use dax_is_supported() in addition to IS_ENABLED(CONFIG_FUSE_DAX) to
validate whether CONFIG_FUSE_DAX is enabled and the architecture does
not have virtually aliased caches.

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 <mathieu.desnoyers@efficios.com>
Cc: Miklos Szeredi <miklos@szeredi.hu>
Cc: linux-fsdevel@vger.kernel.org
Cc: Andrew Morton <akpm@linux-foundation.org>
Cc: Linus Torvalds <torvalds@linux-foundation.org>
Cc: linux-mm@kvack.org
Cc: linux-arch@vger.kernel.org
Cc: Dan Williams <dan.j.williams@intel.com>
Cc: Vishal Verma <vishal.l.verma@intel.com>
Cc: Dave Jiang <dave.jiang@intel.com>
Cc: Matthew Wilcox <willy@infradead.org>
Cc: nvdimm@lists.linux.dev
Cc: linux-cxl@vger.kernel.org
---
 fs/fuse/file.c      |  2 +-
 fs/fuse/fuse_i.h    | 36 +++++++++++++++++++++++++++++++++-
 fs/fuse/inode.c     | 47 +++++++++++++++++++++++----------------------
 fs/fuse/virtio_fs.c |  4 ++--
 4 files changed, 62 insertions(+), 27 deletions(-)

diff --git a/fs/fuse/file.c b/fs/fuse/file.c
index a660f1f21540..133ac8524064 100644
--- a/fs/fuse/file.c
+++ b/fs/fuse/file.c
@@ -3247,6 +3247,6 @@ void fuse_init_file_inode(struct inode *inode, unsigned int flags)
 	init_waitqueue_head(&fi->page_waitq);
 	fi->writepages = RB_ROOT;
 
-	if (IS_ENABLED(CONFIG_FUSE_DAX))
+	if (fuse_dax_is_supported())
 		fuse_dax_inode_init(inode, flags);
 }
diff --git a/fs/fuse/fuse_i.h b/fs/fuse/fuse_i.h
index 1df83eebda92..1cbe37106669 100644
--- a/fs/fuse/fuse_i.h
+++ b/fs/fuse/fuse_i.h
@@ -31,6 +31,7 @@
 #include <linux/pid_namespace.h>
 #include <linux/refcount.h>
 #include <linux/user_namespace.h>
+#include <linux/dax.h>
 
 /** Default max number of pages that can be used in a single read request */
 #define FUSE_DEFAULT_MAX_PAGES_PER_REQ 32
@@ -979,6 +980,38 @@ static inline void fuse_sync_bucket_dec(struct fuse_sync_bucket *bucket)
 	rcu_read_unlock();
 }
 
+#ifdef CONFIG_FUSE_DAX
+static inline struct fuse_inode_dax *fuse_inode_get_dax(struct fuse_inode *inode)
+{
+	return inode->dax;
+}
+
+static inline enum fuse_dax_mode fuse_conn_get_dax_mode(struct fuse_conn *fc)
+{
+	return fc->dax_mode;
+}
+
+static inline struct fuse_conn_dax *fuse_conn_get_dax(struct fuse_conn *fc)
+{
+	return fc->dax;
+}
+#else
+static inline struct fuse_inode_dax *fuse_inode_get_dax(struct fuse_inode *inode)
+{
+	return NULL;
+}
+
+static inline enum fuse_dax_mode fuse_conn_get_dax_mode(struct fuse_conn *fc)
+{
+	return FUSE_DAX_INODE_DEFAULT;
+}
+
+static inline struct fuse_conn_dax *fuse_conn_get_dax(struct fuse_conn *fc)
+{
+	return NULL;
+}
+#endif
+
 /** Device operations */
 extern const struct file_operations fuse_dev_operations;
 
@@ -1324,7 +1357,8 @@ void fuse_free_conn(struct fuse_conn *fc);
 
 /* dax.c */
 
-#define FUSE_IS_DAX(inode) (IS_ENABLED(CONFIG_FUSE_DAX) && IS_DAX(inode))
+#define fuse_dax_is_supported()	(IS_ENABLED(CONFIG_FUSE_DAX) && dax_is_supported())
+#define FUSE_IS_DAX(inode) (fuse_dax_is_supported() && IS_DAX(inode))
 
 ssize_t fuse_dax_read_iter(struct kiocb *iocb, struct iov_iter *to);
 ssize_t fuse_dax_write_iter(struct kiocb *iocb, struct iov_iter *from);
diff --git a/fs/fuse/inode.c b/fs/fuse/inode.c
index 2a6d44f91729..030e6ce5486d 100644
--- a/fs/fuse/inode.c
+++ b/fs/fuse/inode.c
@@ -108,7 +108,7 @@ static struct inode *fuse_alloc_inode(struct super_block *sb)
 	if (!fi->forget)
 		goto out_free;
 
-	if (IS_ENABLED(CONFIG_FUSE_DAX) && !fuse_dax_inode_alloc(sb, fi))
+	if (fuse_dax_is_supported() && !fuse_dax_inode_alloc(sb, fi))
 		goto out_free_forget;
 
 	return &fi->inode;
@@ -126,9 +126,8 @@ static void fuse_free_inode(struct inode *inode)
 
 	mutex_destroy(&fi->mutex);
 	kfree(fi->forget);
-#ifdef CONFIG_FUSE_DAX
-	kfree(fi->dax);
-#endif
+	if (fuse_dax_is_supported())
+		kfree(fuse_inode_get_dax(fi));
 	kmem_cache_free(fuse_inode_cachep, fi);
 }
 
@@ -361,7 +360,7 @@ void fuse_change_attributes(struct inode *inode, struct fuse_attr *attr,
 			invalidate_inode_pages2(inode->i_mapping);
 	}
 
-	if (IS_ENABLED(CONFIG_FUSE_DAX))
+	if (fuse_dax_is_supported())
 		fuse_dax_dontcache(inode, attr->flags);
 }
 
@@ -856,14 +855,16 @@ static int fuse_show_options(struct seq_file *m, struct dentry *root)
 		if (sb->s_bdev && sb->s_blocksize != FUSE_DEFAULT_BLKSIZE)
 			seq_printf(m, ",blksize=%lu", sb->s_blocksize);
 	}
-#ifdef CONFIG_FUSE_DAX
-	if (fc->dax_mode == FUSE_DAX_ALWAYS)
-		seq_puts(m, ",dax=always");
-	else if (fc->dax_mode == FUSE_DAX_NEVER)
-		seq_puts(m, ",dax=never");
-	else if (fc->dax_mode == FUSE_DAX_INODE_USER)
-		seq_puts(m, ",dax=inode");
-#endif
+	if (fuse_dax_is_supported()) {
+		enum fuse_dax_mode dax_mode = fuse_conn_get_dax_mode(fc);
+
+		if (dax_mode == FUSE_DAX_ALWAYS)
+			seq_puts(m, ",dax=always");
+		else if (dax_mode == FUSE_DAX_NEVER)
+			seq_puts(m, ",dax=never");
+		else if (dax_mode == FUSE_DAX_INODE_USER)
+			seq_puts(m, ",dax=inode");
+	}
 
 	return 0;
 }
@@ -936,7 +937,7 @@ void fuse_conn_put(struct fuse_conn *fc)
 		struct fuse_iqueue *fiq = &fc->iq;
 		struct fuse_sync_bucket *bucket;
 
-		if (IS_ENABLED(CONFIG_FUSE_DAX))
+		if (fuse_dax_is_supported())
 			fuse_dax_conn_free(fc);
 		if (fiq->ops->release)
 			fiq->ops->release(fiq);
@@ -1264,7 +1265,7 @@ static void process_init_reply(struct fuse_mount *fm, struct fuse_args *args,
 					min_t(unsigned int, fc->max_pages_limit,
 					max_t(unsigned int, arg->max_pages, 1));
 			}
-			if (IS_ENABLED(CONFIG_FUSE_DAX)) {
+			if (fuse_dax_is_supported()) {
 				if (flags & FUSE_MAP_ALIGNMENT &&
 				    !fuse_dax_check_alignment(fc, arg->map_alignment)) {
 					ok = false;
@@ -1331,12 +1332,12 @@ void fuse_send_init(struct fuse_mount *fm)
 		FUSE_HANDLE_KILLPRIV_V2 | FUSE_SETXATTR_EXT | FUSE_INIT_EXT |
 		FUSE_SECURITY_CTX | FUSE_CREATE_SUPP_GROUP |
 		FUSE_HAS_EXPIRE_ONLY | FUSE_DIRECT_IO_ALLOW_MMAP;
-#ifdef CONFIG_FUSE_DAX
-	if (fm->fc->dax)
-		flags |= FUSE_MAP_ALIGNMENT;
-	if (fuse_is_inode_dax_mode(fm->fc->dax_mode))
-		flags |= FUSE_HAS_INODE_DAX;
-#endif
+	if (fuse_dax_is_supported()) {
+		if (fuse_conn_get_dax(fm->fc))
+			flags |= FUSE_MAP_ALIGNMENT;
+		if (fuse_is_inode_dax_mode(fuse_conn_get_dax_mode(fm->fc)))
+			flags |= FUSE_HAS_INODE_DAX;
+	}
 	if (fm->fc->auto_submounts)
 		flags |= FUSE_SUBMOUNTS;
 
@@ -1643,7 +1644,7 @@ int fuse_fill_super_common(struct super_block *sb, struct fuse_fs_context *ctx)
 
 	sb->s_subtype = ctx->subtype;
 	ctx->subtype = NULL;
-	if (IS_ENABLED(CONFIG_FUSE_DAX)) {
+	if (fuse_dax_is_supported()) {
 		err = fuse_dax_conn_alloc(fc, ctx->dax_mode, ctx->dax_dev);
 		if (err)
 			goto err;
@@ -1709,7 +1710,7 @@ int fuse_fill_super_common(struct super_block *sb, struct fuse_fs_context *ctx)
 	if (fud)
 		fuse_dev_free(fud);
  err_free_dax:
-	if (IS_ENABLED(CONFIG_FUSE_DAX))
+	if (fuse_dax_is_supported())
 		fuse_dax_conn_free(fc);
  err:
 	return err;
diff --git a/fs/fuse/virtio_fs.c b/fs/fuse/virtio_fs.c
index 5f1be1da92ce..99f8f2a18ee4 100644
--- a/fs/fuse/virtio_fs.c
+++ b/fs/fuse/virtio_fs.c
@@ -801,7 +801,7 @@ static int virtio_fs_setup_dax(struct virtio_device *vdev, struct virtio_fs *fs)
 	struct dev_pagemap *pgmap;
 	bool have_cache;
 
-	if (!IS_ENABLED(CONFIG_FUSE_DAX))
+	if (fuse_dax_is_supported())
 		return 0;
 
 	/* Get cache region */
@@ -1366,7 +1366,7 @@ static void virtio_fs_conn_destroy(struct fuse_mount *fm)
 	/* Stop dax worker. Soon evict_inodes() will be called which
 	 * will free all memory ranges belonging to all inodes.
 	 */
-	if (IS_ENABLED(CONFIG_FUSE_DAX))
+	if (fuse_dax_is_supported())
 		fuse_dax_cancel_work(fc);
 
 	/* Stop forget queue. Soon destroy will be sent */
-- 
2.39.2


^ permalink raw reply related	[flat|nested] 14+ messages in thread

* [RFC PATCH 7/7] xfs: Use dax_is_supported()
  2024-01-29 21:06 [RFC PATCH 0/7] Introduce cache_is_aliasing() to fix DAX regression Mathieu Desnoyers
                   ` (5 preceding siblings ...)
  2024-01-29 21:06 ` [RFC PATCH 6/7] fuse: Introduce fuse_dax_is_supported() Mathieu Desnoyers
@ 2024-01-29 21:06 ` Mathieu Desnoyers
  2024-01-30  2:38   ` Dave Chinner
  2024-01-29 21:22 ` [RFC PATCH 0/7] Introduce cache_is_aliasing() to fix DAX regression Dan Williams
  7 siblings, 1 reply; 14+ messages in thread
From: Mathieu Desnoyers @ 2024-01-29 21:06 UTC (permalink / raw)
  To: Dan Williams, Vishal Verma, Dave Jiang
  Cc: linux-kernel, Mathieu Desnoyers, Chandan Babu R,
	Darrick J . Wong, linux-xfs, Andrew Morton, Linus Torvalds,
	linux-mm, linux-arch, Matthew Wilcox, nvdimm, linux-cxl

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 <mathieu.desnoyers@efficios.com>
Cc: Chandan Babu R <chandan.babu@oracle.com>
Cc: Darrick J. Wong <djwong@kernel.org>
Cc: linux-xfs@vger.kernel.org
Cc: Andrew Morton <akpm@linux-foundation.org>
Cc: Linus Torvalds <torvalds@linux-foundation.org>
Cc: linux-mm@kvack.org
Cc: linux-arch@vger.kernel.org
Cc: Dan Williams <dan.j.williams@intel.com>
Cc: Vishal Verma <vishal.l.verma@intel.com>
Cc: Dave Jiang <dave.jiang@intel.com>
Cc: Matthew Wilcox <willy@infradead.org>
Cc: nvdimm@lists.linux.dev
Cc: linux-cxl@vger.kernel.org
---
 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


^ permalink raw reply related	[flat|nested] 14+ messages in thread

* Re: [RFC PATCH 0/7] Introduce cache_is_aliasing() to fix DAX regression
  2024-01-29 21:06 [RFC PATCH 0/7] Introduce cache_is_aliasing() to fix DAX regression Mathieu Desnoyers
                   ` (6 preceding siblings ...)
  2024-01-29 21:06 ` [RFC PATCH 7/7] xfs: Use dax_is_supported() Mathieu Desnoyers
@ 2024-01-29 21:22 ` Dan Williams
  2024-01-30 15:14   ` Mathieu Desnoyers
  7 siblings, 1 reply; 14+ messages in thread
From: Dan Williams @ 2024-01-29 21:22 UTC (permalink / raw)
  To: Mathieu Desnoyers, Dan Williams, Vishal Verma, Dave Jiang
  Cc: linux-kernel, Mathieu Desnoyers, Andrew Morton, Linus Torvalds,
	linux-mm, linux-arch, Matthew Wilcox, linux-cxl, nvdimm

Mathieu Desnoyers wrote:
> This commit introduced in v5.13 prevents building FS_DAX on 32-bit ARM,
> even on ARMv7 which does not have virtually aliased dcaches:
> 
> commit d92576f1167c ("dax: does not work correctly with virtual aliasing caches")
> 
> It used to work fine before: I have customers using dax over pmem on
> ARMv7, but this regression will likely prevent them from upgrading their
> kernel.
> 
> The root of the issue here is the fact that DAX was never designed to
> handle virtually aliased dcache (VIVT and VIPT with aliased dcache). It
> touches the pages through their linear mapping, which is not consistent
> with the userspace mappings on virtually aliased dcaches. 
> 
> This patch series introduces cache_is_aliasing() with new Kconfig
> options:
> 
>   * ARCH_HAS_CACHE_ALIASING
>   * ARCH_HAS_CACHE_ALIASING_DYNAMIC
> 
> and implements it for all architectures. The "DYNAMIC" implementation
> implements cache_is_aliasing() as a runtime check, which is what is
> needed on architectures like 32-bit ARMV6 and ARMV6K.
> 
> With this we can basically narrow down the list of architectures which
> are unsupported by DAX to those which are really affected.
> 
> Feedback is welcome,

Hi Mathieu, this looks good overall, just some quibbling about the
ordering.

I would introduce dax_is_supported() with the current overly broad
interpretation of "!(ARM || MIPS || SPARC)" using IS_ENABLED(), then
fixup the filesystems to use the new helper, and finally go back and
convert dax_is_supported() to use cache_is_aliasing() internally.

Separately, it is not clear to me why ARCH_HAS_CACHE_ALIASING_DYNAMIC
needs to exist. As long as all paths that care are calling
cache_is_aliasing() then whether it is dynamic or not is something only
the compiler cares about. If those dynamic archs do not want to pay the
.text size increase they can always do CONFIG_FS_DAX=n, right?

^ permalink raw reply	[flat|nested] 14+ messages in thread

* Re: [RFC PATCH 7/7] xfs: Use dax_is_supported()
  2024-01-29 21:06 ` [RFC PATCH 7/7] xfs: Use dax_is_supported() Mathieu Desnoyers
@ 2024-01-30  2:38   ` Dave Chinner
  2024-01-30 15:19     ` Mathieu Desnoyers
  0 siblings, 1 reply; 14+ messages in thread
From: Dave Chinner @ 2024-01-30  2:38 UTC (permalink / raw)
  To: Mathieu Desnoyers
  Cc: Dan Williams, Vishal Verma, Dave Jiang, linux-kernel,
	Chandan Babu R, Darrick J . Wong, linux-xfs, Andrew Morton,
	Linus Torvalds, linux-mm, linux-arch, Matthew Wilcox, nvdimm,
	linux-cxl

On Mon, Jan 29, 2024 at 04:06:31PM -0500, Mathieu Desnoyers wrote:
> 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).

Where's the rest of this patchset? I have no idea what
dax_is_supported() actually does, how it interacts with
CONFIG_FS_DAX, etc.

If you are changing anything to do with FSDAX, the cc-ing the
-entire- patchset to linux-fsdevel is absolutely necessary so the
entire patchset lands in our inboxes and not just a random patch
from the middle of a bigger change.

> Fixes: d92576f1167c ("dax: does not work correctly with virtual aliasing caches")
> Signed-off-by: Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
> Cc: Chandan Babu R <chandan.babu@oracle.com>
> Cc: Darrick J. Wong <djwong@kernel.org>
> Cc: linux-xfs@vger.kernel.org
> Cc: Andrew Morton <akpm@linux-foundation.org>
> Cc: Linus Torvalds <torvalds@linux-foundation.org>
> Cc: linux-mm@kvack.org
> Cc: linux-arch@vger.kernel.org
> Cc: Dan Williams <dan.j.williams@intel.com>
> Cc: Vishal Verma <vishal.l.verma@intel.com>
> Cc: Dave Jiang <dave.jiang@intel.com>
> Cc: Matthew Wilcox <willy@infradead.org>
> Cc: nvdimm@lists.linux.dev
> Cc: linux-cxl@vger.kernel.org
> ---
>  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;
> +		}

Assuming that I understand what dax_is_supported() is doing, this
change isn't right.  We're just setting the DAX configuration flags
from the mount options here, we don't validate them until 
we've parsed all options and eliminated conflicts and rejected
conflicting options. We validate whether the options are
appropriate for the underlying hardware configuration later in the
mount process.

dax=always suitability is check in xfs_setup_dax_always() called
later in the mount process when we have enough context and support
to open storage devices and check them for DAX support. If the
hardware does not support DAX then we simply we turn off DAX
support, we do not reject the mount as this change does.

dax=inode and dax=never are valid options on all configurations,
even those with without FSDAX support or have hardware that is not
capable of using DAX. dax=inode only affects how an inode is
instantiated in cache - if the inode has a flag that says "use DAX"
and dax is suppoortable by the hardware, then the turn on DAX for
that inode. Otherwise we just use the normal non-dax IO paths.

Again, we don't error out the filesystem if DAX is not supported,
we just don't turn it on. This check is done in
xfs_inode_should_enable_dax() and I think all you need to do is
replace the IS_ENABLED(CONFIG_FS_DAX) with a dax_is_supported()
call...

-Dave.
-- 
Dave Chinner
david@fromorbit.com

^ permalink raw reply	[flat|nested] 14+ messages in thread

* Re: [RFC PATCH 4/7] ext2: Use dax_is_supported()
  2024-01-29 21:06 ` [RFC PATCH 4/7] ext2: " Mathieu Desnoyers
@ 2024-01-30 11:33   ` Jan Kara
  2024-01-30 15:21     ` Mathieu Desnoyers
  0 siblings, 1 reply; 14+ messages in thread
From: Jan Kara @ 2024-01-30 11:33 UTC (permalink / raw)
  To: Mathieu Desnoyers
  Cc: Dan Williams, Vishal Verma, Dave Jiang, linux-kernel, Jan Kara,
	linux-ext4, Andrew Morton, Linus Torvalds, linux-mm, linux-arch,
	Matthew Wilcox, nvdimm, linux-cxl

On Mon 29-01-24 16:06:28, Mathieu Desnoyers wrote:
> 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 <mathieu.desnoyers@efficios.com>
> Cc: Jan Kara <jack@suse.com>
> Cc: linux-ext4@vger.kernel.org
> Cc: Andrew Morton <akpm@linux-foundation.org>
> Cc: Linus Torvalds <torvalds@linux-foundation.org>
> Cc: linux-mm@kvack.org
> Cc: linux-arch@vger.kernel.org
> Cc: Dan Williams <dan.j.williams@intel.com>
> Cc: Vishal Verma <vishal.l.verma@intel.com>
> Cc: Dave Jiang <dave.jiang@intel.com>
> Cc: Matthew Wilcox <willy@infradead.org>
> Cc: nvdimm@lists.linux.dev
> Cc: linux-cxl@vger.kernel.org

Looks good to me (although I share Dave's opinion it would be nice to CC
the whole series to fsdevel - luckily we have lore these days so it is not
that tedious to find the whole series :)). Feel free to add:

Acked-by: Jan Kara <jack@suse.cz>

								Honza

> ---
>  fs/ext2/super.c | 14 +++++++-------
>  1 file changed, 7 insertions(+), 7 deletions(-)
> 
> diff --git a/fs/ext2/super.c b/fs/ext2/super.c
> index 01f9addc8b1f..0398e7a90eb6 100644
> --- a/fs/ext2/super.c
> +++ b/fs/ext2/super.c
> @@ -585,13 +585,13 @@ static int parse_options(char *options, struct super_block *sb,
>  			set_opt(opts->s_mount_opt, XIP);
>  			fallthrough;
>  		case Opt_dax:
> -#ifdef CONFIG_FS_DAX
> -			ext2_msg(sb, KERN_WARNING,
> -		"DAX enabled. Warning: EXPERIMENTAL, use at your own risk");
> -			set_opt(opts->s_mount_opt, DAX);
> -#else
> -			ext2_msg(sb, KERN_INFO, "dax option not supported");
> -#endif
> +			if (dax_is_supported()) {
> +				ext2_msg(sb, KERN_WARNING,
> +					 "DAX enabled. Warning: EXPERIMENTAL, use at your own risk");
> +				set_opt(opts->s_mount_opt, DAX);
> +			} else {
> +				ext2_msg(sb, KERN_INFO, "dax option not supported");
> +			}
>  			break;
>  
>  #if defined(CONFIG_QUOTA)
> -- 
> 2.39.2
> 
-- 
Jan Kara <jack@suse.com>
SUSE Labs, CR

^ permalink raw reply	[flat|nested] 14+ messages in thread

* Re: [RFC PATCH 0/7] Introduce cache_is_aliasing() to fix DAX regression
  2024-01-29 21:22 ` [RFC PATCH 0/7] Introduce cache_is_aliasing() to fix DAX regression Dan Williams
@ 2024-01-30 15:14   ` Mathieu Desnoyers
  0 siblings, 0 replies; 14+ messages in thread
From: Mathieu Desnoyers @ 2024-01-30 15:14 UTC (permalink / raw)
  To: Dan Williams, Vishal Verma, Dave Jiang
  Cc: linux-kernel, Andrew Morton, Linus Torvalds, linux-mm,
	linux-arch, Matthew Wilcox, linux-cxl, nvdimm, Linux-Fsdevel

On 2024-01-29 16:22, Dan Williams wrote:
> Mathieu Desnoyers wrote:
>> This commit introduced in v5.13 prevents building FS_DAX on 32-bit ARM,
>> even on ARMv7 which does not have virtually aliased dcaches:
>>
>> commit d92576f1167c ("dax: does not work correctly with virtual aliasing caches")
>>
>> It used to work fine before: I have customers using dax over pmem on
>> ARMv7, but this regression will likely prevent them from upgrading their
>> kernel.
>>
>> The root of the issue here is the fact that DAX was never designed to
>> handle virtually aliased dcache (VIVT and VIPT with aliased dcache). It
>> touches the pages through their linear mapping, which is not consistent
>> with the userspace mappings on virtually aliased dcaches.
>>
>> This patch series introduces cache_is_aliasing() with new Kconfig
>> options:
>>
>>    * ARCH_HAS_CACHE_ALIASING
>>    * ARCH_HAS_CACHE_ALIASING_DYNAMIC
>>
>> and implements it for all architectures. The "DYNAMIC" implementation
>> implements cache_is_aliasing() as a runtime check, which is what is
>> needed on architectures like 32-bit ARMV6 and ARMV6K.
>>
>> With this we can basically narrow down the list of architectures which
>> are unsupported by DAX to those which are really affected.
>>
>> Feedback is welcome,
> 
> Hi Mathieu, this looks good overall, just some quibbling about the
> ordering.

Thanks for having a look !

> 
> I would introduce dax_is_supported() with the current overly broad
> interpretation of "!(ARM || MIPS || SPARC)" using IS_ENABLED(), then
> fixup the filesystems to use the new helper, and finally go back and
> convert dax_is_supported() to use cache_is_aliasing() internally.

Will do.

> 
> Separately, it is not clear to me why ARCH_HAS_CACHE_ALIASING_DYNAMIC
> needs to exist. As long as all paths that care are calling
> cache_is_aliasing() then whether it is dynamic or not is something only
> the compiler cares about. If those dynamic archs do not want to pay the
> .text size increase they can always do CONFIG_FS_DAX=n, right?

Good point. It will help reduce complexity and improve test coverage.

I also intend to rename "cache_is_aliasing()" to "dcache_is_aliasing()",
so if we introduce an "icache_is_aliasing()" in the future, it won't be
confusing. Having aliasing icache-dcache but not dcache-dcache seems to
be fairly common.

So basically:

If an arch selects ARCH_HAS_CACHE_ALIASING, it implements
dcache_is_aliasing() (for now), and eventually we can implement
icache_is_aliasing() as well.

Thanks,

Mathieu


-- 
Mathieu Desnoyers
EfficiOS Inc.
https://www.efficios.com


^ permalink raw reply	[flat|nested] 14+ messages in thread

* Re: [RFC PATCH 7/7] xfs: Use dax_is_supported()
  2024-01-30  2:38   ` Dave Chinner
@ 2024-01-30 15:19     ` Mathieu Desnoyers
  0 siblings, 0 replies; 14+ messages in thread
From: Mathieu Desnoyers @ 2024-01-30 15:19 UTC (permalink / raw)
  To: Dave Chinner
  Cc: Dan Williams, Vishal Verma, Dave Jiang, linux-kernel,
	Chandan Babu R, Darrick J . Wong, linux-xfs, Andrew Morton,
	Linus Torvalds, linux-mm, linux-arch, Matthew Wilcox, nvdimm,
	linux-cxl

On 2024-01-29 21:38, Dave Chinner wrote:
> On Mon, Jan 29, 2024 at 04:06:31PM -0500, Mathieu Desnoyers wrote:
>> 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).
> 
> Where's the rest of this patchset? I have no idea what
> dax_is_supported() actually does, how it interacts with
> CONFIG_FS_DAX, etc.
> 
> If you are changing anything to do with FSDAX, the cc-ing the
> -entire- patchset to linux-fsdevel is absolutely necessary so the
> entire patchset lands in our inboxes and not just a random patch
> from the middle of a bigger change.

Sorry, I will Cc linux-fsdevel on all patches for the next round.

Meanwhile you can find the whole series on lore:

https://lore.kernel.org/lkml/20240129210631.193493-1-mathieu.desnoyers@efficios.com/

[...]

> 
> Assuming that I understand what dax_is_supported() is doing, this
> change isn't right.  We're just setting the DAX configuration flags
> from the mount options here, we don't validate them until
> we've parsed all options and eliminated conflicts and rejected
> conflicting options. We validate whether the options are
> appropriate for the underlying hardware configuration later in the
> mount process.
> 
> dax=always suitability is check in xfs_setup_dax_always() called
> later in the mount process when we have enough context and support
> to open storage devices and check them for DAX support. If the
> hardware does not support DAX then we simply we turn off DAX
> support, we do not reject the mount as this change does.
> 
> dax=inode and dax=never are valid options on all configurations,
> even those with without FSDAX support or have hardware that is not
> capable of using DAX. dax=inode only affects how an inode is
> instantiated in cache - if the inode has a flag that says "use DAX"
> and dax is suppoortable by the hardware, then the turn on DAX for
> that inode. Otherwise we just use the normal non-dax IO paths.
> 
> Again, we don't error out the filesystem if DAX is not supported,
> we just don't turn it on. This check is done in
> xfs_inode_should_enable_dax() and I think all you need to do is
> replace the IS_ENABLED(CONFIG_FS_DAX) with a dax_is_supported()
> call...

Thanks a lot for the detailed explanation. You are right, I will
move the dax_is_supported() check to xfs_inode_should_enable_dax().

Mathieu


-- 
Mathieu Desnoyers
EfficiOS Inc.
https://www.efficios.com


^ permalink raw reply	[flat|nested] 14+ messages in thread

* Re: [RFC PATCH 4/7] ext2: Use dax_is_supported()
  2024-01-30 11:33   ` Jan Kara
@ 2024-01-30 15:21     ` Mathieu Desnoyers
  0 siblings, 0 replies; 14+ messages in thread
From: Mathieu Desnoyers @ 2024-01-30 15:21 UTC (permalink / raw)
  To: Jan Kara
  Cc: Dan Williams, Vishal Verma, Dave Jiang, linux-kernel, Jan Kara,
	linux-ext4, Andrew Morton, Linus Torvalds, linux-mm, linux-arch,
	Matthew Wilcox, nvdimm, linux-cxl

On 2024-01-30 06:33, Jan Kara wrote:
> On Mon 29-01-24 16:06:28, Mathieu Desnoyers wrote:
>> 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 <mathieu.desnoyers@efficios.com>
>> Cc: Jan Kara <jack@suse.com>
>> Cc: linux-ext4@vger.kernel.org
>> Cc: Andrew Morton <akpm@linux-foundation.org>
>> Cc: Linus Torvalds <torvalds@linux-foundation.org>
>> Cc: linux-mm@kvack.org
>> Cc: linux-arch@vger.kernel.org
>> Cc: Dan Williams <dan.j.williams@intel.com>
>> Cc: Vishal Verma <vishal.l.verma@intel.com>
>> Cc: Dave Jiang <dave.jiang@intel.com>
>> Cc: Matthew Wilcox <willy@infradead.org>
>> Cc: nvdimm@lists.linux.dev
>> Cc: linux-cxl@vger.kernel.org
> 
> Looks good to me (although I share Dave's opinion it would be nice to CC
> the whole series to fsdevel - luckily we have lore these days so it is not
> that tedious to find the whole series :)). Feel free to add:
> 
> Acked-by: Jan Kara <jack@suse.cz>

Hi Jan,

Thanks for looking at it! I will do significant changes for v2, so
I will hold on before integrating your acked-by if it's OK with you.

Thanks!

Mathieu

> 
> 								Honza
> 
>> ---
>>   fs/ext2/super.c | 14 +++++++-------
>>   1 file changed, 7 insertions(+), 7 deletions(-)
>>
>> diff --git a/fs/ext2/super.c b/fs/ext2/super.c
>> index 01f9addc8b1f..0398e7a90eb6 100644
>> --- a/fs/ext2/super.c
>> +++ b/fs/ext2/super.c
>> @@ -585,13 +585,13 @@ static int parse_options(char *options, struct super_block *sb,
>>   			set_opt(opts->s_mount_opt, XIP);
>>   			fallthrough;
>>   		case Opt_dax:
>> -#ifdef CONFIG_FS_DAX
>> -			ext2_msg(sb, KERN_WARNING,
>> -		"DAX enabled. Warning: EXPERIMENTAL, use at your own risk");
>> -			set_opt(opts->s_mount_opt, DAX);
>> -#else
>> -			ext2_msg(sb, KERN_INFO, "dax option not supported");
>> -#endif
>> +			if (dax_is_supported()) {
>> +				ext2_msg(sb, KERN_WARNING,
>> +					 "DAX enabled. Warning: EXPERIMENTAL, use at your own risk");
>> +				set_opt(opts->s_mount_opt, DAX);
>> +			} else {
>> +				ext2_msg(sb, KERN_INFO, "dax option not supported");
>> +			}
>>   			break;
>>   
>>   #if defined(CONFIG_QUOTA)
>> -- 
>> 2.39.2
>>

-- 
Mathieu Desnoyers
EfficiOS Inc.
https://www.efficios.com


^ permalink raw reply	[flat|nested] 14+ messages in thread

end of thread, other threads:[~2024-01-30 15:21 UTC | newest]

Thread overview: 14+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2024-01-29 21:06 [RFC PATCH 0/7] Introduce cache_is_aliasing() to fix DAX regression Mathieu Desnoyers
2024-01-29 21:06 ` [RFC PATCH 1/7] Introduce cache_is_aliasing() across all architectures Mathieu Desnoyers
2024-01-29 21:06 ` [RFC PATCH 2/7] dax: Fix incorrect list of cache aliasing architectures Mathieu Desnoyers
2024-01-29 21:06 ` [RFC PATCH 3/7] erofs: Use dax_is_supported() Mathieu Desnoyers
2024-01-29 21:06 ` [RFC PATCH 4/7] ext2: " Mathieu Desnoyers
2024-01-30 11:33   ` Jan Kara
2024-01-30 15:21     ` Mathieu Desnoyers
2024-01-29 21:06 ` [RFC PATCH 5/7] ext4: " Mathieu Desnoyers
2024-01-29 21:06 ` [RFC PATCH 6/7] fuse: Introduce fuse_dax_is_supported() Mathieu Desnoyers
2024-01-29 21:06 ` [RFC PATCH 7/7] xfs: Use dax_is_supported() Mathieu Desnoyers
2024-01-30  2:38   ` Dave Chinner
2024-01-30 15:19     ` Mathieu Desnoyers
2024-01-29 21:22 ` [RFC PATCH 0/7] Introduce cache_is_aliasing() to fix DAX regression Dan Williams
2024-01-30 15:14   ` Mathieu Desnoyers

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).