Skip to contentSkip to conversation

dm: writecache: add DAX dependency

PATCH In review Arnd Bergmann 5 participants 11 messages May 28, 2018 – May 30, 2018

Subsystems (3)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 dm: writecache: add DAX dependency

The new dm-writecache driver inconditionally uses the dax subsystem, leading to link errors in some configurations:

drivers/md/dm-writecache.o: In function `writecache_ctr':
dm-writecache.c:(.text+0x1fdc): undefined reference to dax_read_lock' dm-writecache.c:(.text+0x2004): undefined reference to dax_direct_access' dm-writecache.c:(.text+0x21cc): undefined reference to `dax_read_unlock'

It seems wrong to require DAX in order to build the writecache driver, but that at least avoids randconfig build errors.

Fixes bb15b431d650 ("dm: add writecache target")
---
 drivers/md/Kconfig | 1 +
 1 file changed, 1 insertion(+)
drivers/md/Kconfig +1 -0
index 852c7ebe2902..f8ecf2da1edf 100644
@@ -338,6 +338,7 @@ config DM_CACHE_SMQ
 config DM_WRITECACHE
 	tristate "Writecache target"
 	depends on BLK_DEV_DM
+	depends on DAX
 	---help---
 	   The writecache target caches writes on persistent memory or SSD.
 	   It is intended for databases or other programs that need extremely
Signature · 1 line
2.9.0
#1 lore raw
Quoted 22 lines · Arnd Bergmann

The new dm-writecache driver inconditionally uses the dax subsystem, leading to link errors in some configurations:

drivers/md/dm-writecache.o: In function `writecache_ctr':
dm-writecache.c:(.text+0x1fdc): undefined reference to dax_read_lock' dm-writecache.c:(.text+0x2004): undefined reference to dax_direct_access' dm-writecache.c:(.text+0x21cc): undefined reference to `dax_read_unlock'

It seems wrong to require DAX in order to build the writecache driver, but that at least avoids randconfig build errors.

Fixes bb15b431d650 ("dm: add writecache target")
---
 drivers/md/Kconfig | 1 +
 1 file changed, 1 insertion(+)
drivers/md/Kconfig +0 -0
index 852c7ebe2902..f8ecf2da1edf 100644

drivers/md/Kconfig config DM_CACHE_SMQ · line 341

Quoted 4 lines
drivers/md/Kconfig +1 -0
@@ -338,6 +338,7 @@ config DM_CACHE_SMQ
 config DM_WRITECACHE
        tristate "Writecache target"
        depends on BLK_DEV_DM
+       depends on DAX

This should probably be depends on DAX && DAX_DRIVER as we at least need pmem or dcssblk enabled to provide a dax capable block device for DM to claim.

#2 lore raw
Quoted 18 lines · Dan Williams
Quoted 17 lines · Arnd Bergmann

The new dm-writecache driver inconditionally uses the dax subsystem, leading to link errors in some configurations:

drivers/md/dm-writecache.o: In function `writecache_ctr':
dm-writecache.c:(.text+0x1fdc): undefined reference to dax_read_lock' dm-writecache.c:(.text+0x2004): undefined reference to dax_direct_access' dm-writecache.c:(.text+0x21cc): undefined reference to `dax_read_unlock'

It seems wrong to require DAX in order to build the writecache driver, but that at least avoids randconfig build errors.

Fixes bb15b431d650 ("dm: add writecache target")
---
 drivers/md/Kconfig | 1 +
 1 file changed, 1 insertion(+)
Quoted 13 lines

drivers/md/Kconfig config DM_CACHE_SMQ · line 341

Quoted 9 lines
drivers/md/Kconfig +1 -0
index 852c7ebe2902..f8ecf2da1edf 100644
@@ -338,6 +338,7 @@ config DM_CACHE_SMQ
 config DM_WRITECACHE
        tristate "Writecache target"
        depends on BLK_DEV_DM
+       depends on DAX

This should probably be depends on DAX && DAX_DRIVER as we at least need pmem or dcssblk enabled to provide a dax capable block device for DM to claim.

But dm-writecache is meant to be used for normal SSD even if PMEM isn't available in the kernel.

#3 lore raw
In reply to Arnd Bergmann
Quoted 1 line · Arnd Bergmann

The new dm-writecache driver inconditionally uses the dax

unconditionally

Quoted 21 lines

subsystem, leading to link errors in some configurations:

drivers/md/dm-writecache.o: In function `writecache_ctr':
dm-writecache.c:(.text+0x1fdc): undefined reference to dax_read_lock' dm-writecache.c:(.text+0x2004): undefined reference to dax_direct_access' dm-writecache.c:(.text+0x21cc): undefined reference to `dax_read_unlock'

It seems wrong to require DAX in order to build the writecache driver, but that at least avoids randconfig build errors.

Fixes bb15b431d650 ("dm: add writecache target")
---
 drivers/md/Kconfig | 1 +
 1 file changed, 1 insertion(+)
drivers/md/Kconfig +0 -0
index 852c7ebe2902..f8ecf2da1edf 100644

drivers/md/Kconfig config DM_CACHE_SMQ · line 344

Quoted 7 lines
drivers/md/Kconfig +1 -0
@@ -338,6 +338,7 @@ config DM_CACHE_SMQ
 config DM_WRITECACHE
 	tristate "Writecache target"
 	depends on BLK_DEV_DM
+	depends on DAX
 	---help---
 	   The writecache target caches writes on persistent memory or SSD.
 	   It is intended for databases or other programs that need extremely

I think the right way to handle this is to instead wrap all the DAX code in dm-writecache in "#if IS_ENABLED(CONFIG_DAX_DRIVER)" blocks and provide stubs for the non-DAX case. This prevents you from having to pull in all the generic DAX code unnecessarily.

In looking at the file I think this is just the persistent_memory_claim() function.

I'll send out a patch once I've tested a bit.

- Ross

#4 lore raw

PATCH 1/1 dm-writecache: fix compilation issue with !DAX

In reply to Arnd Bergmann

As reported by Arnd (https://lkml.org/lkml/2018/5/28/1697), dm-writecache will fail with link errors in configs where DAX isn't present:

drivers/md/dm-writecache.o: In function `writecache_ctr':
dm-writecache.c:(.text+0x1fdc): undefined reference to dax_read_lock' dm-writecache.c:(.text+0x2004): undefined reference to dax_direct_access' dm-writecache.c:(.text+0x21cc): undefined reference to `dax_read_unlock'

Fix this by following the lead of the other DM modules and wrapping calls to the generic DAX code in #if IS_ENABLED(CONFIG_DAX_DRIVER) blocks.

We also expand the failure case for the 'p' (persistent memory) flag so that fails on both architectures that don't support persistent memory and on kernels that don't have DAX support configured. This prevents us from ever hitting the BUG() in the persistent_memory_claim() stub.

---
 drivers/md/dm-writecache.c | 16 ++++++++++++----
 1 file changed, 12 insertions(+), 4 deletions(-)
drivers/md/dm-writecache.c +12 -4
index 92af65fdf4af..1c2b53ae1a96 100644
@@ -253,6 +253,7 @@ static void wc_unlock(struct dm_writecache *wc)
 	mutex_unlock(&wc->lock);
 }
 
+#if IS_ENABLED(CONFIG_DAX_DRIVER)
 static int persistent_memory_claim(struct dm_writecache *wc)
 {
 	int r;
@@ -337,6 +338,12 @@ static int persistent_memory_claim(struct dm_writecache *wc)
 err1:
 	return r;
 }
+#else
+static int persistent_memory_claim(struct dm_writecache *wc)
+{
+	BUG();
+}
+#endif
 
 static void persistent_memory_release(struct dm_writecache *wc)
 {
@@ -1901,16 +1908,17 @@ static int writecache_ctr(struct dm_target *ti, unsigned argc, char **argv)
 	if (!strcasecmp(string, "s")) {
 		wc->pmem_mode = false;
 	} else if (!strcasecmp(string, "p")) {
-#ifdef CONFIG_ARCH_HAS_PMEM_API
+#if defined(CONFIG_ARCH_HAS_PMEM_API) && IS_ENABLED(CONFIG_DAX_DRIVER)
 		wc->pmem_mode = true;
 		wc->writeback_fua = true;
 #else
 		/*
-		 * If the architecture doesn't support persistent memory, this
-		 * driver can only be used in SSD-only mode.
+		 * If the architecture doesn't support persistent memory or
+		 * the kernel doesn't support any DAX drivers, this driver can
+		 * only be used in SSD-only mode.
 		 */
 		r = -EOPNOTSUPP;
-		ti->error = "Persistent memory not supported on this architecture";
+		ti->error = "Persistent memory or DAX not supported on this system";
 		goto bad;
 #endif
 	} else {
Signature · 1 line
2.14.3
#5 lore raw

Re: dm-writecache: fix compilation issue with !DAX

Quoted 11 lines · Ross Zwisler

As reported by Arnd (https://lkml.org/lkml/2018/5/28/1697), dm-writecache will fail with link errors in configs where DAX isn't present:

drivers/md/dm-writecache.o: In function `writecache_ctr':
dm-writecache.c:(.text+0x1fdc): undefined reference to dax_read_lock' dm-writecache.c:(.text+0x2004): undefined reference to dax_direct_access' dm-writecache.c:(.text+0x21cc): undefined reference to `dax_read_unlock'

Fix this by following the lead of the other DM modules and wrapping calls to the generic DAX code in #if IS_ENABLED(CONFIG_DAX_DRIVER) blocks.

Quoted 7 lines

We also expand the failure case for the 'p' (persistent memory) flag so that fails on both architectures that don't support persistent memory and on kernels that don't have DAX support configured. This prevents us from ever hitting the BUG() in the persistent_memory_claim() stub.

Thanks, I've picked this up.

Mike

#6 lore raw

Re: dm-writecache: fix compilation issue with !DAX

Quoted 19 lines · Mike Snitzer
Quoted 16 lines · Ross Zwisler

As reported by Arnd (https://lkml.org/lkml/2018/5/28/1697), dm-writecache will fail with link errors in configs where DAX isn't present:

drivers/md/dm-writecache.o: In function `writecache_ctr':
dm-writecache.c:(.text+0x1fdc): undefined reference to dax_read_lock' dm-writecache.c:(.text+0x2004): undefined reference to dax_direct_access' dm-writecache.c:(.text+0x21cc): undefined reference to `dax_read_unlock'

Fix this by following the lead of the other DM modules and wrapping calls to the generic DAX code in #if IS_ENABLED(CONFIG_DAX_DRIVER) blocks.

We also expand the failure case for the 'p' (persistent memory) flag so that fails on both architectures that don't support persistent memory and on kernels that don't have DAX support configured. This prevents us from ever hitting the BUG() in the persistent_memory_claim() stub.

Quoted 4 lines
Quoted 2 lines

Thanks, I've picked this up.

...I assume you're also going to let the 'pmem api' discussion resolve before this all goes upstream?

#7 lore raw

Re: dm-writecache: fix compilation issue with !DAX

Quoted 20 lines · Dan Williams
Quoted 19 lines · Mike Snitzer
Quoted 16 lines · Ross Zwisler

As reported by Arnd (https://lkml.org/lkml/2018/5/28/1697), dm-writecache will fail with link errors in configs where DAX isn't present:

drivers/md/dm-writecache.o: In function `writecache_ctr':
dm-writecache.c:(.text+0x1fdc): undefined reference to dax_read_lock' dm-writecache.c:(.text+0x2004): undefined reference to dax_direct_access' dm-writecache.c:(.text+0x21cc): undefined reference to `dax_read_unlock'

Fix this by following the lead of the other DM modules and wrapping calls to the generic DAX code in #if IS_ENABLED(CONFIG_DAX_DRIVER) blocks.

We also expand the failure case for the 'p' (persistent memory) flag so that fails on both architectures that don't support persistent memory and on kernels that don't have DAX support configured. This prevents us from ever hitting the BUG() in the persistent_memory_claim() stub.

Quoted 7 lines
Quoted 4 lines
Quoted 2 lines

Thanks, I've picked this up.

...I assume you're also going to let the 'pmem api' discussion resolve before this all goes upstream?

Yeah, I'm going to pivot back to that and put time to it shortly. If dm-writecache has to wait another cycle (so 4.19 inclusion), while unfortunate, it wouldn't be the end of the world.

I look forward to your continued help, thanks.
Mike

maintainer
#8 lore raw

Re: [PATCH] dm-writecache: fix compilation issue with !DAX

In reply to Ross Zwisler
Quoted 27 lines · Ross Zwisler

As reported by Arnd (https://lkml.org/lkml/2018/5/28/1697), dm-writecache will fail with link errors in configs where DAX isn't present:

drivers/md/dm-writecache.o: In function `writecache_ctr':
dm-writecache.c:(.text+0x1fdc): undefined reference to dax_read_lock' dm-writecache.c:(.text+0x2004): undefined reference to dax_direct_access' dm-writecache.c:(.text+0x21cc): undefined reference to `dax_read_unlock'

Fix this by following the lead of the other DM modules and wrapping calls to the generic DAX code in #if IS_ENABLED(CONFIG_DAX_DRIVER) blocks.

We also expand the failure case for the 'p' (persistent memory) flag so that fails on both architectures that don't support persistent memory and on kernels that don't have DAX support configured. This prevents us from ever hitting the BUG() in the persistent_memory_claim() stub.

---
 drivers/md/dm-writecache.c | 16 ++++++++++++----
 1 file changed, 12 insertions(+), 4 deletions(-)
drivers/md/dm-writecache.c +0 -0
index 92af65fdf4af..1c2b53ae1a96 100644

drivers/md/dm-writecache.c static void wc_unlock(struct dm_writecache *wc) · line 256

Quoted 4 lines
drivers/md/dm-writecache.c +1 -0
@@ -253,6 +253,7 @@ static void wc_unlock(struct dm_writecache *wc)
 	mutex_unlock(&wc->lock);
 }
 
+#if IS_ENABLED(CONFIG_DAX_DRIVER)

We already have #if(n)def DM_WRITECACHE_ONLY_SSD

There is no need to use another macro for the same purpose.

Mikulas

Quoted 41 lines
drivers/md/dm-writecache.c +11 -4
 static int persistent_memory_claim(struct dm_writecache *wc)
 {
 	int r;
@@ -337,6 +338,12 @@ static int persistent_memory_claim(struct dm_writecache *wc)
 err1:
 	return r;
 }
+#else
+static int persistent_memory_claim(struct dm_writecache *wc)
+{
+	BUG();
+}
+#endif
 
 static void persistent_memory_release(struct dm_writecache *wc)
 {
@@ -1901,16 +1908,17 @@ static int writecache_ctr(struct dm_target *ti, unsigned argc, char **argv)
 	if (!strcasecmp(string, "s")) {
 		wc->pmem_mode = false;
 	} else if (!strcasecmp(string, "p")) {
-#ifdef CONFIG_ARCH_HAS_PMEM_API
+#if defined(CONFIG_ARCH_HAS_PMEM_API) && IS_ENABLED(CONFIG_DAX_DRIVER)
 		wc->pmem_mode = true;
 		wc->writeback_fua = true;
 #else
 		/*
-		 * If the architecture doesn't support persistent memory, this
-		 * driver can only be used in SSD-only mode.
+		 * If the architecture doesn't support persistent memory or
+		 * the kernel doesn't support any DAX drivers, this driver can
+		 * only be used in SSD-only mode.
 		 */
 		r = -EOPNOTSUPP;
-		ti->error = "Persistent memory not supported on this architecture";
+		ti->error = "Persistent memory or DAX not supported on this system";
 		goto bad;
 #endif
 	} else {
Signature · 1 line
2.14.3
#9 lore raw

Re: dm-writecache: fix compilation issue with !DAX

Quoted 34 lines · Mikulas Patocka
Quoted 30 lines · Ross Zwisler

As reported by Arnd (https://lkml.org/lkml/2018/5/28/1697), dm-writecache will fail with link errors in configs where DAX isn't present:

drivers/md/dm-writecache.o: In function `writecache_ctr':
dm-writecache.c:(.text+0x1fdc): undefined reference to dax_read_lock' dm-writecache.c:(.text+0x2004): undefined reference to dax_direct_access' dm-writecache.c:(.text+0x21cc): undefined reference to `dax_read_unlock'

Fix this by following the lead of the other DM modules and wrapping calls to the generic DAX code in #if IS_ENABLED(CONFIG_DAX_DRIVER) blocks.

We also expand the failure case for the 'p' (persistent memory) flag so that fails on both architectures that don't support persistent memory and on kernels that don't have DAX support configured. This prevents us from ever hitting the BUG() in the persistent_memory_claim() stub.

---
 drivers/md/dm-writecache.c | 16 ++++++++++++----
 1 file changed, 12 insertions(+), 4 deletions(-)
drivers/md/dm-writecache.c +0 -0
index 92af65fdf4af..1c2b53ae1a96 100644
@@ -253,6 +253,7 @@ static void wc_unlock(struct dm_writecache *wc)
 	mutex_unlock(&wc->lock);
 }
 
Quoted 5 lines

drivers/md/dm-writecache.c static void wc_unlock(struct dm_writecache *wc) · line 256

Quoted 1 line
drivers/md/dm-writecache.c +1 -0
+#if IS_ENABLED(CONFIG_DAX_DRIVER)

We already have #if(n)def DM_WRITECACHE_ONLY_SSD

There is no need to use another macro for the same purpose.

I removed DM_WRITECACHE_ONLY_SSD because it wasn't needed, this is the split out commit that I have since folded in:
https://git.kernel.org/pub/scm/linux/kernel/git/snitzer/linux.git/commit/?h=dm-4.18-writecache-wip&id=e7fd3d1c05659f7e1295178290fbdaebf36becdc

Ross's patch effectively builds ontop of that.

Mike

maintainer
#10 lore raw
In reply to Arnd Bergmann
Quoted 31 lines · Arnd Bergmann

The new dm-writecache driver inconditionally uses the dax subsystem, leading to link errors in some configurations:

drivers/md/dm-writecache.o: In function `writecache_ctr':
dm-writecache.c:(.text+0x1fdc): undefined reference to dax_read_lock' dm-writecache.c:(.text+0x2004): undefined reference to dax_direct_access' dm-writecache.c:(.text+0x21cc): undefined reference to `dax_read_unlock'

It seems wrong to require DAX in order to build the writecache driver, but that at least avoids randconfig build errors.

Fixes bb15b431d650 ("dm: add writecache target")
---
 drivers/md/Kconfig | 1 +
 1 file changed, 1 insertion(+)
drivers/md/Kconfig +1 -0
index 852c7ebe2902..f8ecf2da1edf 100644
@@ -338,6 +338,7 @@ config DM_CACHE_SMQ
 config DM_WRITECACHE
 	tristate "Writecache target"
 	depends on BLK_DEV_DM
+	depends on DAX
 	---help---
 	   The writecache target caches writes on persistent memory or SSD.
 	   It is intended for databases or other programs that need extremely
Signature · 1 line
2.9.0

dm-writecache may be used without DAX in SSD-only mode.

So, I'd fix this by changing the code in dm-writecache.c to

#if !defined(CONFIG_ARCH_HAS_PMEM_API) || !defined(CONFIG_DAX) #define DM_WRITECACHE_ONLY_SSD
#endif

Mikulas