public inbox for linux-fsdevel@vger.kernel.org
 help / color / mirror / Atom feed
* [RFC PATCH v2 0/8] Introduce dcache_is_aliasing() to fix DAX regression
@ 2024-01-30 16:52 Mathieu Desnoyers
  2024-01-30 16:52 ` [RFC PATCH v2 1/8] dax: Introduce dax_is_supported() Mathieu Desnoyers
                   ` (5 more replies)
  0 siblings, 6 replies; 12+ messages in thread
From: Mathieu Desnoyers @ 2024-01-30 16:52 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, Arnd Bergmann, Russell King,
	linux-cxl, nvdimm, linux-fsdevel

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 dcache_is_aliasing() with the new Kconfig
option ARCH_HAS_CACHE_ALIASING and implements it for all architectures.
The implementation of dcache_is_aliasing() is either evaluated to a
constant at compile-time or a runtime check, which is what is needed on
ARM.

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

Note that the order of the series was completely changed based on the
feedback received on v1, cache_is_aliasing() is renamed to
dcache_is_aliasing(), ARCH_HAS_CACHE_ALIASING_DYNAMIC is gone,
dcache_is_aliasing() vs ARCH_HAS_CACHE_ALIASING relationship is
simplified, and the dax_is_supported() check was moved to its rightful
place in all filesystems.

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: Arnd Bergmann <arnd@arndb.de>
Cc: Russell King <linux@armlinux.org.uk>
Cc: linux-cxl@vger.kernel.org
Cc: nvdimm@lists.linux.dev
Cc: linux-fsdevel@vger.kernel.org

Mathieu Desnoyers (8):
  dax: Introduce dax_is_supported()
  erofs: Use dax_is_supported()
  ext2: Use dax_is_supported()
  ext4: Use dax_is_supported()
  fuse: Use dax_is_supported()
  xfs: Use dax_is_supported()
  Introduce dcache_is_aliasing() across all architectures
  dax: Fix incorrect list of dcache aliasing architectures

 arch/arc/Kconfig                    |  1 +
 arch/arc/include/asm/cachetype.h    |  9 +++++++++
 arch/arm/Kconfig                    |  1 +
 arch/arm/include/asm/cachetype.h    |  2 ++
 arch/csky/Kconfig                   |  1 +
 arch/csky/include/asm/cachetype.h   |  9 +++++++++
 arch/m68k/Kconfig                   |  1 +
 arch/m68k/include/asm/cachetype.h   |  9 +++++++++
 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/parisc/include/asm/cachetype.h |  9 +++++++++
 arch/sh/Kconfig                     |  1 +
 arch/sh/include/asm/cachetype.h     |  9 +++++++++
 arch/sparc/Kconfig                  |  1 +
 arch/sparc/include/asm/cachetype.h  | 14 ++++++++++++++
 arch/xtensa/Kconfig                 |  1 +
 arch/xtensa/include/asm/cachetype.h | 10 ++++++++++
 fs/Kconfig                          |  1 -
 fs/erofs/super.c                    |  5 ++++-
 fs/ext2/super.c                     |  6 +++++-
 fs/ext4/super.c                     |  5 ++++-
 fs/fuse/dax.c                       |  7 +++++++
 fs/xfs/xfs_iops.c                   |  2 +-
 include/linux/cacheinfo.h           |  6 ++++++
 include/linux/dax.h                 |  9 +++++++++
 mm/Kconfig                          |  6 ++++++
 29 files changed, 142 insertions(+), 5 deletions(-)
 create mode 100644 arch/arc/include/asm/cachetype.h
 create mode 100644 arch/csky/include/asm/cachetype.h
 create mode 100644 arch/m68k/include/asm/cachetype.h
 create mode 100644 arch/mips/include/asm/cachetype.h
 create mode 100644 arch/nios2/include/asm/cachetype.h
 create mode 100644 arch/parisc/include/asm/cachetype.h
 create mode 100644 arch/sh/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] 12+ messages in thread

* [RFC PATCH v2 1/8] dax: Introduce dax_is_supported()
  2024-01-30 16:52 [RFC PATCH v2 0/8] Introduce dcache_is_aliasing() to fix DAX regression Mathieu Desnoyers
@ 2024-01-30 16:52 ` Mathieu Desnoyers
  2024-01-31  2:38   ` Dave Chinner
  2024-01-30 16:52 ` [RFC PATCH v2 2/8] erofs: Use dax_is_supported() Mathieu Desnoyers
                   ` (4 subsequent siblings)
  5 siblings, 1 reply; 12+ messages in thread
From: Mathieu Desnoyers @ 2024-01-30 16:52 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, Arnd Bergmann, Russell King,
	nvdimm, linux-cxl, linux-fsdevel

Introduce a new dax_is_supported() static inline to check whether the
architecture supports DAX.

This replaces the following fs/Kconfig:FS_DAX dependency:

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

This is done in preparation for its use by each filesystem supporting
the dax mount option to validate whether dax is indeed supported.

This is done in preparation for using dcache_is_aliasing() in a
following change which will properly support architectures which detect
dcache aliasing at runtime.

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: Arnd Bergmann <arnd@arndb.de>
Cc: Russell King <linux@armlinux.org.uk>
Cc: nvdimm@lists.linux.dev
Cc: linux-cxl@vger.kernel.org
Cc: linux-fsdevel@vger.kernel.org
---
 fs/Kconfig          |  1 -
 include/linux/dax.h | 10 ++++++++++
 2 files changed, 10 insertions(+), 1 deletion(-)

diff --git a/fs/Kconfig b/fs/Kconfig
index 42837617a55b..e5efdb3b276b 100644
--- a/fs/Kconfig
+++ b/fs/Kconfig
@@ -56,7 +56,6 @@ endif # BLOCK
 config FS_DAX
 	bool "File system based Direct Access (DAX) support"
 	depends on MMU
-	depends on !(ARM || MIPS || SPARC)
 	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..cfc8cd4a3eae 100644
--- a/include/linux/dax.h
+++ b/include/linux/dax.h
@@ -78,6 +78,12 @@ 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 !IS_ENABLED(CONFIG_ARM) &&
+	       !IS_ENABLED(CONFIG_MIPS) &&
+	       !IS_ENABLED(CONFIG_SPARC);
+}
 #else
 static inline void *dax_holder(struct dax_device *dax_dev)
 {
@@ -122,6 +128,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] 12+ messages in thread

* [RFC PATCH v2 2/8] erofs: Use dax_is_supported()
  2024-01-30 16:52 [RFC PATCH v2 0/8] Introduce dcache_is_aliasing() to fix DAX regression Mathieu Desnoyers
  2024-01-30 16:52 ` [RFC PATCH v2 1/8] dax: Introduce dax_is_supported() Mathieu Desnoyers
@ 2024-01-30 16:52 ` Mathieu Desnoyers
  2024-01-30 16:52 ` [RFC PATCH v2 3/8] ext2: " Mathieu Desnoyers
                   ` (3 subsequent siblings)
  5 siblings, 0 replies; 12+ messages in thread
From: Mathieu Desnoyers @ 2024-01-30 16:52 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, Arnd Bergmann, Russell King, nvdimm,
	linux-cxl, linux-fsdevel

Use dax_is_supported() to validate whether the architecture has
virtually aliased data caches at mount time. Print an error and disable
DAX if dax=always is requested as a mount option on an architecture
which does not support DAX.

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

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: Arnd Bergmann <arnd@arndb.de>
Cc: Russell King <linux@armlinux.org.uk>
Cc: nvdimm@lists.linux.dev
Cc: linux-cxl@vger.kernel.org
Cc: linux-fsdevel@vger.kernel.org
---
 fs/erofs/super.c | 5 ++++-
 1 file changed, 4 insertions(+), 1 deletion(-)

diff --git a/fs/erofs/super.c b/fs/erofs/super.c
index 3789d6224513..82e569bd5889 100644
--- a/fs/erofs/super.c
+++ b/fs/erofs/super.c
@@ -644,7 +644,10 @@ static int erofs_fc_fill_super(struct super_block *sb, struct fs_context *fc)
 	}
 
 	if (test_opt(&sbi->opt, DAX_ALWAYS)) {
-		if (!sbi->dax_dev) {
+		if (!dax_is_supported()) {
+			errorfc(fc, "DAX unsupported by architecture. Turning off DAX.");
+			clear_opt(&sbi->opt, DAX_ALWAYS);
+		} else if (!sbi->dax_dev) {
 			errorfc(fc, "DAX unsupported by block device. Turning off DAX.");
 			clear_opt(&sbi->opt, DAX_ALWAYS);
 		} else if (sbi->blkszbits != PAGE_SHIFT) {
-- 
2.39.2


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

* [RFC PATCH v2 3/8] ext2: Use dax_is_supported()
  2024-01-30 16:52 [RFC PATCH v2 0/8] Introduce dcache_is_aliasing() to fix DAX regression Mathieu Desnoyers
  2024-01-30 16:52 ` [RFC PATCH v2 1/8] dax: Introduce dax_is_supported() Mathieu Desnoyers
  2024-01-30 16:52 ` [RFC PATCH v2 2/8] erofs: Use dax_is_supported() Mathieu Desnoyers
@ 2024-01-30 16:52 ` Mathieu Desnoyers
  2024-01-30 21:40   ` Jan Kara
  2024-01-30 16:52 ` [RFC PATCH v2 4/8] ext4: " Mathieu Desnoyers
                   ` (2 subsequent siblings)
  5 siblings, 1 reply; 12+ messages in thread
From: Mathieu Desnoyers @ 2024-01-30 16:52 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, Arnd Bergmann, Russell King, nvdimm, linux-cxl,
	linux-fsdevel

Use dax_is_supported() to validate whether the architecture has
virtually aliased data caches at mount time. Print an error and disable
DAX if dax=always is requested as a mount option on an architecture
which does not support DAX.

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

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: Arnd Bergmann <arnd@arndb.de>
Cc: Russell King <linux@armlinux.org.uk>
Cc: nvdimm@lists.linux.dev
Cc: linux-cxl@vger.kernel.org
Cc: linux-fsdevel@vger.kernel.org
---
 fs/ext2/super.c | 6 +++++-
 1 file changed, 5 insertions(+), 1 deletion(-)

diff --git a/fs/ext2/super.c b/fs/ext2/super.c
index 01f9addc8b1f..30ff57d47ed4 100644
--- a/fs/ext2/super.c
+++ b/fs/ext2/super.c
@@ -955,7 +955,11 @@ static int ext2_fill_super(struct super_block *sb, void *data, int silent)
 	blocksize = BLOCK_SIZE << le32_to_cpu(sbi->s_es->s_log_block_size);
 
 	if (test_opt(sb, DAX)) {
-		if (!sbi->s_daxdev) {
+		if (!dax_is_supported()) {
+			ext2_msg(sb, KERN_ERR,
+				"DAX unsupported by architecture. Turning off DAX.");
+			clear_opt(sbi->s_mount_opt, DAX);
+		} else if (!sbi->s_daxdev) {
 			ext2_msg(sb, KERN_ERR,
 				"DAX unsupported by block device. Turning off DAX.");
 			clear_opt(sbi->s_mount_opt, DAX);
-- 
2.39.2


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

* [RFC PATCH v2 4/8] ext4: Use dax_is_supported()
  2024-01-30 16:52 [RFC PATCH v2 0/8] Introduce dcache_is_aliasing() to fix DAX regression Mathieu Desnoyers
                   ` (2 preceding siblings ...)
  2024-01-30 16:52 ` [RFC PATCH v2 3/8] ext2: " Mathieu Desnoyers
@ 2024-01-30 16:52 ` Mathieu Desnoyers
  2024-01-30 16:52 ` [RFC PATCH v2 5/8] fuse: " Mathieu Desnoyers
  2024-01-30 16:52 ` [RFC PATCH v2 8/8] dax: Fix incorrect list of dcache aliasing architectures Mathieu Desnoyers
  5 siblings, 0 replies; 12+ messages in thread
From: Mathieu Desnoyers @ 2024-01-30 16:52 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, Arnd Bergmann, Russell King,
	nvdimm, linux-cxl, linux-fsdevel

Use dax_is_supported() to validate whether the architecture has
virtually aliased data caches at mount time. Mount fails if dax=always
is requested as a mount option on an architecture which does not support
DAX.

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

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: Arnd Bergmann <arnd@arndb.de>
Cc: Russell King <linux@armlinux.org.uk>
Cc: nvdimm@lists.linux.dev
Cc: linux-cxl@vger.kernel.org
Cc: linux-fsdevel@vger.kernel.org
---
 fs/ext4/super.c | 5 ++++-
 1 file changed, 4 insertions(+), 1 deletion(-)

diff --git a/fs/ext4/super.c b/fs/ext4/super.c
index c5fcf377ab1f..f2c11ae3ec29 100644
--- a/fs/ext4/super.c
+++ b/fs/ext4/super.c
@@ -4743,7 +4743,10 @@ static int ext4_check_feature_compatibility(struct super_block *sb,
 	}
 
 	if (sbi->s_mount_opt & EXT4_MOUNT_DAX_ALWAYS) {
-		if (ext4_has_feature_inline_data(sb)) {
+		if (!dax_is_supported()) {
+			ext4_msg(sb, KERN_ERR, "DAX unsupported by architecture.");
+			return -EINVAL;
+		} else if (ext4_has_feature_inline_data(sb)) {
 			ext4_msg(sb, KERN_ERR, "Cannot use DAX on a filesystem"
 					" that may contain inline data");
 			return -EINVAL;
-- 
2.39.2


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

* [RFC PATCH v2 5/8] fuse: Use dax_is_supported()
  2024-01-30 16:52 [RFC PATCH v2 0/8] Introduce dcache_is_aliasing() to fix DAX regression Mathieu Desnoyers
                   ` (3 preceding siblings ...)
  2024-01-30 16:52 ` [RFC PATCH v2 4/8] ext4: " Mathieu Desnoyers
@ 2024-01-30 16:52 ` Mathieu Desnoyers
  2024-01-30 16:52 ` [RFC PATCH v2 8/8] dax: Fix incorrect list of dcache aliasing architectures Mathieu Desnoyers
  5 siblings, 0 replies; 12+ messages in thread
From: Mathieu Desnoyers @ 2024-01-30 16:52 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, Arnd Bergmann, Russell King, nvdimm, linux-cxl

Use dax_is_supported() to validate whether the architecture has
virtually aliased data caches at mount time. Silently disable
DAX if dax=always is requested as a mount option on an architecture
which does not support DAX.

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

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: Arnd Bergmann <arnd@arndb.de>
Cc: Russell King <linux@armlinux.org.uk>
Cc: nvdimm@lists.linux.dev
Cc: linux-cxl@vger.kernel.org
---
 fs/fuse/dax.c | 7 +++++++
 1 file changed, 7 insertions(+)

diff --git a/fs/fuse/dax.c b/fs/fuse/dax.c
index 12ef91d170bb..36e1c1abbf8e 100644
--- a/fs/fuse/dax.c
+++ b/fs/fuse/dax.c
@@ -1336,6 +1336,13 @@ static bool fuse_should_enable_dax(struct inode *inode, unsigned int flags)
 	if (dax_mode == FUSE_DAX_NEVER)
 		return false;
 
+	/*
+	 * Silently fallback to 'never' mode if the architecture does
+	 * not support DAX.
+	 */
+	if (!dax_is_supported())
+		return false;
+
 	/*
 	 * fc->dax may be NULL in 'inode' mode when filesystem device doesn't
 	 * support DAX, in which case it will silently fallback to 'never' mode.
-- 
2.39.2


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

* [RFC PATCH v2 8/8] dax: Fix incorrect list of dcache aliasing architectures
  2024-01-30 16:52 [RFC PATCH v2 0/8] Introduce dcache_is_aliasing() to fix DAX regression Mathieu Desnoyers
                   ` (4 preceding siblings ...)
  2024-01-30 16:52 ` [RFC PATCH v2 5/8] fuse: " Mathieu Desnoyers
@ 2024-01-30 16:52 ` Mathieu Desnoyers
  2024-01-31  2:54   ` Dave Chinner
  5 siblings, 1 reply; 12+ messages in thread
From: Mathieu Desnoyers @ 2024-01-30 16:52 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, Arnd Bergmann, Russell King,
	nvdimm, linux-cxl, linux-fsdevel

commit d92576f1167c ("dax: does not work correctly with virtual aliasing caches")
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.

This was turned into the following implementation of dax_is_supported()
by a preparatory change:

        return !IS_ENABLED(CONFIG_ARM) &&
               !IS_ENABLED(CONFIG_MIPS) &&
               !IS_ENABLED(CONFIG_SPARC);

Use dcache_is_aliasing() instead to figure out whether the environment
has aliasing dcaches.

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: Arnd Bergmann <arnd@arndb.de>
Cc: Russell King <linux@armlinux.org.uk>
Cc: nvdimm@lists.linux.dev
Cc: linux-cxl@vger.kernel.org
Cc: linux-fsdevel@vger.kernel.org
---
 include/linux/dax.h | 5 ++---
 1 file changed, 2 insertions(+), 3 deletions(-)

diff --git a/include/linux/dax.h b/include/linux/dax.h
index cfc8cd4a3eae..f59e604662e4 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;
 
@@ -80,9 +81,7 @@ static inline bool daxdev_mapping_supported(struct vm_area_struct *vma,
 }
 static inline bool dax_is_supported(void)
 {
-	return !IS_ENABLED(CONFIG_ARM) &&
-	       !IS_ENABLED(CONFIG_MIPS) &&
-	       !IS_ENABLED(CONFIG_SPARC);
+	return !dcache_is_aliasing();
 }
 #else
 static inline void *dax_holder(struct dax_device *dax_dev)
-- 
2.39.2


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

* Re: [RFC PATCH v2 3/8] ext2: Use dax_is_supported()
  2024-01-30 16:52 ` [RFC PATCH v2 3/8] ext2: " Mathieu Desnoyers
@ 2024-01-30 21:40   ` Jan Kara
  0 siblings, 0 replies; 12+ messages in thread
From: Jan Kara @ 2024-01-30 21:40 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, Arnd Bergmann, Russell King, nvdimm, linux-cxl,
	linux-fsdevel

On Tue 30-01-24 11:52:50, Mathieu Desnoyers wrote:
> Use dax_is_supported() to validate whether the architecture has
> virtually aliased data caches at mount time. Print an error and disable
> DAX if dax=always is requested as a mount option on an architecture
> which does not support DAX.
> 
> This is relevant for architectures which require a dynamic check
> to validate whether they have virtually aliased data caches.
> 
> 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: Arnd Bergmann <arnd@arndb.de>
> Cc: Russell King <linux@armlinux.org.uk>
> Cc: nvdimm@lists.linux.dev
> Cc: linux-cxl@vger.kernel.org
> Cc: linux-fsdevel@vger.kernel.org

OK, yeah, this is better than v1. Feel free to add:

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

								Honza

> ---
>  fs/ext2/super.c | 6 +++++-
>  1 file changed, 5 insertions(+), 1 deletion(-)
> 
> diff --git a/fs/ext2/super.c b/fs/ext2/super.c
> index 01f9addc8b1f..30ff57d47ed4 100644
> --- a/fs/ext2/super.c
> +++ b/fs/ext2/super.c
> @@ -955,7 +955,11 @@ static int ext2_fill_super(struct super_block *sb, void *data, int silent)
>  	blocksize = BLOCK_SIZE << le32_to_cpu(sbi->s_es->s_log_block_size);
>  
>  	if (test_opt(sb, DAX)) {
> -		if (!sbi->s_daxdev) {
> +		if (!dax_is_supported()) {
> +			ext2_msg(sb, KERN_ERR,
> +				"DAX unsupported by architecture. Turning off DAX.");
> +			clear_opt(sbi->s_mount_opt, DAX);
> +		} else if (!sbi->s_daxdev) {
>  			ext2_msg(sb, KERN_ERR,
>  				"DAX unsupported by block device. Turning off DAX.");
>  			clear_opt(sbi->s_mount_opt, DAX);
> -- 
> 2.39.2
> 
-- 
Jan Kara <jack@suse.com>
SUSE Labs, CR

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

* Re: [RFC PATCH v2 1/8] dax: Introduce dax_is_supported()
  2024-01-30 16:52 ` [RFC PATCH v2 1/8] dax: Introduce dax_is_supported() Mathieu Desnoyers
@ 2024-01-31  2:38   ` Dave Chinner
  0 siblings, 0 replies; 12+ messages in thread
From: Dave Chinner @ 2024-01-31  2:38 UTC (permalink / raw)
  To: Mathieu Desnoyers
  Cc: Dan Williams, Vishal Verma, Dave Jiang, linux-kernel,
	Andrew Morton, Linus Torvalds, linux-mm, linux-arch,
	Matthew Wilcox, Arnd Bergmann, Russell King, nvdimm, linux-cxl,
	linux-fsdevel

On Tue, Jan 30, 2024 at 11:52:48AM -0500, Mathieu Desnoyers wrote:
> Introduce a new dax_is_supported() static inline to check whether the
> architecture supports DAX.
> 
> This replaces the following fs/Kconfig:FS_DAX dependency:
> 
>   depends on !(ARM || MIPS || SPARC)
> 
> This is done in preparation for its use by each filesystem supporting
> the dax mount option to validate whether dax is indeed supported.
> 
> This is done in preparation for using dcache_is_aliasing() in a
> following change which will properly support architectures which detect
> dcache aliasing at runtime.
> 
> 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: Arnd Bergmann <arnd@arndb.de>
> Cc: Russell King <linux@armlinux.org.uk>
> Cc: nvdimm@lists.linux.dev
> Cc: linux-cxl@vger.kernel.org
> Cc: linux-fsdevel@vger.kernel.org
> ---
>  fs/Kconfig          |  1 -
>  include/linux/dax.h | 10 ++++++++++
>  2 files changed, 10 insertions(+), 1 deletion(-)
> 
> diff --git a/fs/Kconfig b/fs/Kconfig
> index 42837617a55b..e5efdb3b276b 100644
> --- a/fs/Kconfig
> +++ b/fs/Kconfig
> @@ -56,7 +56,6 @@ endif # BLOCK
>  config FS_DAX
>  	bool "File system based Direct Access (DAX) support"
>  	depends on MMU
> -	depends on !(ARM || MIPS || SPARC)
>  	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..cfc8cd4a3eae 100644
> --- a/include/linux/dax.h
> +++ b/include/linux/dax.h
> @@ -78,6 +78,12 @@ 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 !IS_ENABLED(CONFIG_ARM) &&
> +	       !IS_ENABLED(CONFIG_MIPS) &&
> +	       !IS_ENABLED(CONFIG_SPARC);
> +}

Uh, ok. Now I see what dax_is_supported() does.

I think this should be folded into fs_dax_get_by_bdev(), which
currently returns NULL if CONFIG_FS_DAX=n and so should be cahnged
to return NULL if any of these platform configs is enabled.

Then I don't think you need to change a single line of filesystem
code - they'll all just do what they do now if the block device
doesn't support DAX....

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

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

* Re: [RFC PATCH v2 8/8] dax: Fix incorrect list of dcache aliasing architectures
  2024-01-30 16:52 ` [RFC PATCH v2 8/8] dax: Fix incorrect list of dcache aliasing architectures Mathieu Desnoyers
@ 2024-01-31  2:54   ` Dave Chinner
  2024-01-31  3:13     ` Dan Williams
  0 siblings, 1 reply; 12+ messages in thread
From: Dave Chinner @ 2024-01-31  2:54 UTC (permalink / raw)
  To: Mathieu Desnoyers
  Cc: Dan Williams, Vishal Verma, Dave Jiang, linux-kernel,
	Andrew Morton, Linus Torvalds, linux-mm, linux-arch,
	Matthew Wilcox, Arnd Bergmann, Russell King, nvdimm, linux-cxl,
	linux-fsdevel

On Tue, Jan 30, 2024 at 11:52:55AM -0500, Mathieu Desnoyers wrote:
> commit d92576f1167c ("dax: does not work correctly with virtual aliasing caches")
> 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.
> 
> This was turned into the following implementation of dax_is_supported()
> by a preparatory change:
> 
>         return !IS_ENABLED(CONFIG_ARM) &&
>                !IS_ENABLED(CONFIG_MIPS) &&
>                !IS_ENABLED(CONFIG_SPARC);
> 
> Use dcache_is_aliasing() instead to figure out whether the environment
> has aliasing dcaches.
> 
> 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: Arnd Bergmann <arnd@arndb.de>
> Cc: Russell King <linux@armlinux.org.uk>
> Cc: nvdimm@lists.linux.dev
> Cc: linux-cxl@vger.kernel.org
> Cc: linux-fsdevel@vger.kernel.org
> ---
>  include/linux/dax.h | 5 ++---
>  1 file changed, 2 insertions(+), 3 deletions(-)
> 
> diff --git a/include/linux/dax.h b/include/linux/dax.h
> index cfc8cd4a3eae..f59e604662e4 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;
>  
> @@ -80,9 +81,7 @@ static inline bool daxdev_mapping_supported(struct vm_area_struct *vma,
>  }
>  static inline bool dax_is_supported(void)
>  {
> -	return !IS_ENABLED(CONFIG_ARM) &&
> -	       !IS_ENABLED(CONFIG_MIPS) &&
> -	       !IS_ENABLED(CONFIG_SPARC);
> +	return !dcache_is_aliasing();

Yeah, if this is just a one liner should go into
fs_dax_get_by_bdev(), similar to the blk_queue_dax() check at the
start of the function.

I also noticed that device mapper uses fs_dax_get_by_bdev() to
determine if it can support DAX, but this patch set does not address
that case. Hence it really seems to me like fs_dax_get_by_bdev() is
the right place to put this check.

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

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

* Re: [RFC PATCH v2 8/8] dax: Fix incorrect list of dcache aliasing architectures
  2024-01-31  2:54   ` Dave Chinner
@ 2024-01-31  3:13     ` Dan Williams
  2024-01-31 15:14       ` Mathieu Desnoyers
  0 siblings, 1 reply; 12+ messages in thread
From: Dan Williams @ 2024-01-31  3:13 UTC (permalink / raw)
  To: Dave Chinner, Mathieu Desnoyers
  Cc: Dan Williams, Vishal Verma, Dave Jiang, linux-kernel,
	Andrew Morton, Linus Torvalds, linux-mm, linux-arch,
	Matthew Wilcox, Arnd Bergmann, Russell King, nvdimm, linux-cxl,
	linux-fsdevel

Dave Chinner wrote:
> On Tue, Jan 30, 2024 at 11:52:55AM -0500, Mathieu Desnoyers wrote:
> > commit d92576f1167c ("dax: does not work correctly with virtual aliasing caches")
> > 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.
> > 
> > This was turned into the following implementation of dax_is_supported()
> > by a preparatory change:
> > 
> >         return !IS_ENABLED(CONFIG_ARM) &&
> >                !IS_ENABLED(CONFIG_MIPS) &&
> >                !IS_ENABLED(CONFIG_SPARC);
> > 
> > Use dcache_is_aliasing() instead to figure out whether the environment
> > has aliasing dcaches.
> > 
> > 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: Arnd Bergmann <arnd@arndb.de>
> > Cc: Russell King <linux@armlinux.org.uk>
> > Cc: nvdimm@lists.linux.dev
> > Cc: linux-cxl@vger.kernel.org
> > Cc: linux-fsdevel@vger.kernel.org
> > ---
> >  include/linux/dax.h | 5 ++---
> >  1 file changed, 2 insertions(+), 3 deletions(-)
> > 
> > diff --git a/include/linux/dax.h b/include/linux/dax.h
> > index cfc8cd4a3eae..f59e604662e4 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;
> >  
> > @@ -80,9 +81,7 @@ static inline bool daxdev_mapping_supported(struct vm_area_struct *vma,
> >  }
> >  static inline bool dax_is_supported(void)
> >  {
> > -	return !IS_ENABLED(CONFIG_ARM) &&
> > -	       !IS_ENABLED(CONFIG_MIPS) &&
> > -	       !IS_ENABLED(CONFIG_SPARC);
> > +	return !dcache_is_aliasing();
> 
> Yeah, if this is just a one liner should go into
> fs_dax_get_by_bdev(), similar to the blk_queue_dax() check at the
> start of the function.
> 
> I also noticed that device mapper uses fs_dax_get_by_bdev() to
> determine if it can support DAX, but this patch set does not address
> that case. Hence it really seems to me like fs_dax_get_by_bdev() is
> the right place to put this check.

Oh, good catch. Yes, I agree this can definitely be pushed down, but
then I think it should be pushed down all the way to make alloc_dax()
fail. That will need some additional fixups like:

diff --git a/drivers/md/dm.c b/drivers/md/dm.c
index 8dcabf84d866..a35e60e62440 100644
--- a/drivers/md/dm.c
+++ b/drivers/md/dm.c
@@ -2126,12 +2126,12 @@ static struct mapped_device *alloc_dev(int minor)
                md->dax_dev = alloc_dax(md, &dm_dax_ops);
                if (IS_ERR(md->dax_dev)) {
                        md->dax_dev = NULL;
-                       goto bad;
+               } else {
+                       set_dax_nocache(md->dax_dev);
+                       set_dax_nomc(md->dax_dev);
+                       if (dax_add_host(md->dax_dev, md->disk))
+                               goto bad;
                }
-               set_dax_nocache(md->dax_dev);
-               set_dax_nomc(md->dax_dev);
-               if (dax_add_host(md->dax_dev, md->disk))
-                       goto bad;
        }
 
        format_dev_t(md->name, MKDEV(_major, minor));

...to make it not fatal to fail to register the dax_dev.

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

* Re: [RFC PATCH v2 8/8] dax: Fix incorrect list of dcache aliasing architectures
  2024-01-31  3:13     ` Dan Williams
@ 2024-01-31 15:14       ` Mathieu Desnoyers
  0 siblings, 0 replies; 12+ messages in thread
From: Mathieu Desnoyers @ 2024-01-31 15:14 UTC (permalink / raw)
  To: Dan Williams, Dave Chinner
  Cc: Vishal Verma, Dave Jiang, linux-kernel, Andrew Morton,
	Linus Torvalds, linux-mm, linux-arch, Matthew Wilcox,
	Arnd Bergmann, Russell King, nvdimm, linux-cxl, linux-fsdevel

On 2024-01-30 22:13, Dan Williams wrote:
> Dave Chinner wrote:
>> On Tue, Jan 30, 2024 at 11:52:55AM -0500, Mathieu Desnoyers wrote:
>>> commit d92576f1167c ("dax: does not work correctly with virtual aliasing caches")
>>> 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.
>>>
>>> This was turned into the following implementation of dax_is_supported()
>>> by a preparatory change:
>>>
>>>          return !IS_ENABLED(CONFIG_ARM) &&
>>>                 !IS_ENABLED(CONFIG_MIPS) &&
>>>                 !IS_ENABLED(CONFIG_SPARC);
>>>
>>> Use dcache_is_aliasing() instead to figure out whether the environment
>>> has aliasing dcaches.
>>>
>>> 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: Arnd Bergmann <arnd@arndb.de>
>>> Cc: Russell King <linux@armlinux.org.uk>
>>> Cc: nvdimm@lists.linux.dev
>>> Cc: linux-cxl@vger.kernel.org
>>> Cc: linux-fsdevel@vger.kernel.org
>>> ---
>>>   include/linux/dax.h | 5 ++---
>>>   1 file changed, 2 insertions(+), 3 deletions(-)
>>>
>>> diff --git a/include/linux/dax.h b/include/linux/dax.h
>>> index cfc8cd4a3eae..f59e604662e4 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;
>>>   
>>> @@ -80,9 +81,7 @@ static inline bool daxdev_mapping_supported(struct vm_area_struct *vma,
>>>   }
>>>   static inline bool dax_is_supported(void)
>>>   {
>>> -	return !IS_ENABLED(CONFIG_ARM) &&
>>> -	       !IS_ENABLED(CONFIG_MIPS) &&
>>> -	       !IS_ENABLED(CONFIG_SPARC);
>>> +	return !dcache_is_aliasing();
>>
>> Yeah, if this is just a one liner should go into
>> fs_dax_get_by_bdev(), similar to the blk_queue_dax() check at the
>> start of the function.
>>
>> I also noticed that device mapper uses fs_dax_get_by_bdev() to
>> determine if it can support DAX, but this patch set does not address
>> that case. Hence it really seems to me like fs_dax_get_by_bdev() is
>> the right place to put this check.
> 
> Oh, good catch. Yes, I agree this can definitely be pushed down, but
> then I think it should be pushed down all the way to make alloc_dax()
> fail. That will need some additional fixups like:
> 
> diff --git a/drivers/md/dm.c b/drivers/md/dm.c
> index 8dcabf84d866..a35e60e62440 100644
> --- a/drivers/md/dm.c
> +++ b/drivers/md/dm.c
> @@ -2126,12 +2126,12 @@ static struct mapped_device *alloc_dev(int minor)
>                  md->dax_dev = alloc_dax(md, &dm_dax_ops);
>                  if (IS_ERR(md->dax_dev)) {
>                          md->dax_dev = NULL;
> -                       goto bad;
> +               } else {
> +                       set_dax_nocache(md->dax_dev);
> +                       set_dax_nomc(md->dax_dev);
> +                       if (dax_add_host(md->dax_dev, md->disk))
> +                               goto bad;
>                  }
> -               set_dax_nocache(md->dax_dev);
> -               set_dax_nomc(md->dax_dev);
> -               if (dax_add_host(md->dax_dev, md->disk))
> -                       goto bad;
>          }
>   
>          format_dev_t(md->name, MKDEV(_major, minor));
> 
> ...to make it not fatal to fail to register the dax_dev.

I've had a quick look at other users of alloc_dax() and
alloc_dax_region(), and so far I figure that all of those
really want to bail out on alloc_dax failure. Is dm.c the
only special-case we need to fix to make it non-fatal ?

Thanks,

Mathieu

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


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

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

Thread overview: 12+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2024-01-30 16:52 [RFC PATCH v2 0/8] Introduce dcache_is_aliasing() to fix DAX regression Mathieu Desnoyers
2024-01-30 16:52 ` [RFC PATCH v2 1/8] dax: Introduce dax_is_supported() Mathieu Desnoyers
2024-01-31  2:38   ` Dave Chinner
2024-01-30 16:52 ` [RFC PATCH v2 2/8] erofs: Use dax_is_supported() Mathieu Desnoyers
2024-01-30 16:52 ` [RFC PATCH v2 3/8] ext2: " Mathieu Desnoyers
2024-01-30 21:40   ` Jan Kara
2024-01-30 16:52 ` [RFC PATCH v2 4/8] ext4: " Mathieu Desnoyers
2024-01-30 16:52 ` [RFC PATCH v2 5/8] fuse: " Mathieu Desnoyers
2024-01-30 16:52 ` [RFC PATCH v2 8/8] dax: Fix incorrect list of dcache aliasing architectures Mathieu Desnoyers
2024-01-31  2:54   ` Dave Chinner
2024-01-31  3:13     ` Dan Williams
2024-01-31 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