Skip to contentSkip to conversation

dax: fix for do not print error message for non-persistent memory block device

PATCH Superseded Coly Li 4 participants 6 messages Sep 3, 2020 – Sep 11, 2020

Subsystems (3)

v1 of 4 Superseded Latest is v4 →

lore
Share & tools
lore

Coly Li

author
#0 lore raw

PATCH 1/1 dax: fix for do not print error message for non-persistent memory block device

When calling __generic_fsdax_supported(), a dax-unsupported device may not have dax_dev as NULL, e.g. the dax related code block is not enabled by Kconfig.

Therefore in __generic_fsdax_supported(), to check whether a device supports DAX or not, the following order should be performed,
- If dax_dev pointer is NULL, it means the device driver explicitly announce it doesn't support DAX. Then it is OK to directly return false from __generic_fsdax_supported().
- If dax_dev pointer is NOT NULL, it might be because the driver doesn't support DAX and not explicitly initialize related data structure. Then bdev_dax_supported() should be called for further check.

IMHO if device driver desn't explicitly set its dax_dev pointer to NULL, this is not a bug. Calling bdev_dax_supported() makes sure they can be recognized as dax-unsupported eventually.

This patch does the following change for the above purpose,
- if (!dax_dev && !bdev_dax_supported(bdev, blocksize)) {
+ if (!dax_dev || !bdev_dax_supported(bdev, blocksize)) {

Fixes c2affe920b0e ("dax: do not print error message for non-persistent memory block device")
Cc Adrian Huang <[email protected]>
Cc Ira Weiny <[email protected]>
Cc Jan Kara <[email protected]>
Cc Mike Snitzer <[email protected]>
Cc Pankaj Gupta <[email protected]>
Cc Vishal Verma <[email protected]>
---
 drivers/dax/super.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/dax/super.c +1 -1
index 32642634c1bb..e5767c83ea23 100644
@@ -100,7 +100,7 @@ bool __generic_fsdax_supported(struct dax_device *dax_dev,
 		return false;
 	}
 
-	if (!dax_dev && !bdev_dax_supported(bdev, blocksize)) {
+	if (!dax_dev || !bdev_dax_supported(bdev, blocksize)) {
 		pr_debug("%s: error: dax unsupported by block device\n",
 				bdevname(bdev, buf));
 		return false;
Signature · 1 line
2.26.2
#1 lore raw
Quoted 27 lines

-----Original Message-----
From: Coly Li <[email protected]>
Sent: Thursday, September 3, 2020 7:56 PM
To: [email protected]
Cc: [email protected]; Coly Li <[email protected]>; Adrian Huang12 <[email protected]>; Ira Weiny <[email protected]>; Jan Kara <[email protected]>; Mike Snitzer <[email protected]>; Pankaj Gupta <[email protected]>; Vishal Verma <[email protected]>
Subject: [External] [PATCH] dax: fix for do not print error message for non- persistent memory block device

When calling __generic_fsdax_supported(), a dax-unsupported device may not have dax_dev as NULL, e.g. the dax related code block is not enabled by Kconfig.

Therefore in __generic_fsdax_supported(), to check whether a device supports DAX or not, the following order should be performed,
- If dax_dev pointer is NULL, it means the device driver explicitly announce it doesn't support DAX. Then it is OK to directly return false from __generic_fsdax_supported().
- If dax_dev pointer is NOT NULL, it might be because the driver doesn't support DAX and not explicitly initialize related data structure. Then bdev_dax_supported() should be called for further check.

IMHO if device driver desn't explicitly set its dax_dev pointer to NULL, this is not a bug. Calling bdev_dax_supported() makes sure they can be recognized as dax- unsupported eventually.

Quoted 8 lines

This patch does the following change for the above purpose,
- if (!dax_dev && !bdev_dax_supported(bdev, blocksize)) {
+ if (!dax_dev || !bdev_dax_supported(bdev, blocksize)) {

Fixes c2affe920b0e ("dax: do not print error message for non-persistent

memory block device")

The dax error messages ("dm-X: error: dax access failed (-95)") are gone away when executing the command 'lvm2-testsuite --only activate-minor'.

Reviewed-and-Tested-by Adrian Huang <[email protected]>
Quoted 26 lines
Cc Adrian Huang <[email protected]>
Cc Ira Weiny <[email protected]>
Cc Jan Kara <[email protected]>
Cc Mike Snitzer <[email protected]>
Cc Pankaj Gupta <[email protected]>
Cc Vishal Verma <[email protected]>
---
 drivers/dax/super.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/dax/super.c index renamed from drivers/dax/super.c +0 -0

32642634c1bb..e5767c83ea23 100644

drivers/dax/super.c +1 -1
@@ -100,7 +100,7 @@ bool __generic_fsdax_supported(struct dax_device
 *dax_dev,
 		return false;
 	}
 
-	if (!dax_dev && !bdev_dax_supported(bdev, blocksize)) {
+	if (!dax_dev || !bdev_dax_supported(bdev, blocksize)) {
 		pr_debug("%s: error: dax unsupported by block device\n",
 				bdevname(bdev, buf));

return false;
--
2.26.2

Reviewed-by on v1 1/1
#2 lore raw
In reply to Coly Li
Quoted 17 lines · Coly Li

When calling __generic_fsdax_supported(), a dax-unsupported device may not have dax_dev as NULL, e.g. the dax related code block is not enabled by Kconfig.

Therefore in __generic_fsdax_supported(), to check whether a device supports DAX or not, the following order should be performed,
- If dax_dev pointer is NULL, it means the device driver explicitly announce it doesn't support DAX. Then it is OK to directly return false from __generic_fsdax_supported().
- If dax_dev pointer is NOT NULL, it might be because the driver doesn't support DAX and not explicitly initialize related data structure. Then bdev_dax_supported() should be called for further check.

IMHO if device driver desn't explicitly set its dax_dev pointer to NULL, this is not a bug. Calling bdev_dax_supported() makes sure they can be recognized as dax-unsupported eventually.

Quoted 7 lines

This patch does the following change for the above purpose,
- if (!dax_dev && !bdev_dax_supported(bdev, blocksize)) {
+ if (!dax_dev || !bdev_dax_supported(bdev, blocksize)) {

Fixes c2affe920b0e ("dax: do not print error message for non-persistent memory block device")

I hate to do this because I realize this is a bug which people really need fixed.

However, shouldn't we also check (!dax_dev || !bdev_dax_supported()) as the _first_ check in __generic_fsdax_supported()?

It seems like the other pr_info's could also be called when DAX is not supported and we probably don't want them to be?

Perhaps that should be a follow on patch though. So...

As a direct fix to c2affe920b0e

Quoted 26 lines
Cc Adrian Huang <[email protected]>
Cc Ira Weiny <[email protected]>
Cc Jan Kara <[email protected]>
Cc Mike Snitzer <[email protected]>
Cc Pankaj Gupta <[email protected]>
Cc Vishal Verma <[email protected]>
---
 drivers/dax/super.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/dax/super.c +1 -1
index 32642634c1bb..e5767c83ea23 100644
@@ -100,7 +100,7 @@ bool __generic_fsdax_supported(struct dax_device *dax_dev,
 		return false;
 	}
 
-	if (!dax_dev && !bdev_dax_supported(bdev, blocksize)) {
+	if (!dax_dev || !bdev_dax_supported(bdev, blocksize)) {
 		pr_debug("%s: error: dax unsupported by block device\n",
 				bdevname(bdev, buf));
 		return false;
Signature · 1 line
2.26.2
author
#3 lore raw
Quoted 29 lines · Ira Weiny
Quoted 17 lines · Coly Li

When calling __generic_fsdax_supported(), a dax-unsupported device may not have dax_dev as NULL, e.g. the dax related code block is not enabled by Kconfig.

Therefore in __generic_fsdax_supported(), to check whether a device supports DAX or not, the following order should be performed,
- If dax_dev pointer is NULL, it means the device driver explicitly announce it doesn't support DAX. Then it is OK to directly return false from __generic_fsdax_supported().
- If dax_dev pointer is NOT NULL, it might be because the driver doesn't support DAX and not explicitly initialize related data structure. Then bdev_dax_supported() should be called for further check.

IMHO if device driver desn't explicitly set its dax_dev pointer to NULL, this is not a bug. Calling bdev_dax_supported() makes sure they can be recognized as dax-unsupported eventually.

Quoted 7 lines

This patch does the following change for the above purpose,
- if (!dax_dev && !bdev_dax_supported(bdev, blocksize)) {
+ if (!dax_dev || !bdev_dax_supported(bdev, blocksize)) {

Fixes c2affe920b0e ("dax: do not print error message for non-persistent memory block device")

I hate to do this because I realize this is a bug which people really need fixed.

Quoted 7 lines

However, shouldn't we also check (!dax_dev || !bdev_dax_supported()) as the _first_ check in __generic_fsdax_supported()?

It seems like the other pr_info's could also be called when DAX is not supported and we probably don't want them to be?

Perhaps that should be a follow on patch though. So...

I am not author of c2affe920b0e, but I guess it was because bdev_dax_supported() needed blocksize, so blocksize should pass previous checks firstly to make sure bdev_dax_supported() has a correct blocksize to check.

Quoted 4 lines

As a direct fix to c2affe920b0e

Thanks.

Coly Li

Quoted 27 lines
Quoted 27 lines
Cc Adrian Huang <[email protected]>
Cc Ira Weiny <[email protected]>
Cc Jan Kara <[email protected]>
Cc Mike Snitzer <[email protected]>
Cc Pankaj Gupta <[email protected]>
Cc Vishal Verma <[email protected]>
---
 drivers/dax/super.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/dax/super.c +1 -1
index 32642634c1bb..e5767c83ea23 100644
@@ -100,7 +100,7 @@ bool __generic_fsdax_supported(struct dax_device *dax_dev,
 		return false;
 	}
 
-	if (!dax_dev && !bdev_dax_supported(bdev, blocksize)) {
+	if (!dax_dev || !bdev_dax_supported(bdev, blocksize)) {
 		pr_debug("%s: error: dax unsupported by block device\n",
 				bdevname(bdev, buf));
 		return false;
Signature · 1 line
2.26.2
Reviewed-by
#4 lore raw

But it should be moved prior to the two bdev_dax_pgoff() checks right?
Else a misaligned partition on a dax unsupported block device can
print the below messages.

kernel: sda1: error: unaligned partition for dax
kernel: sda2: error: unaligned partition for dax
kernel: sda3: error: unaligned partition for dax

Quoted 85 lines · Coly Li
Quoted 29 lines · Ira Weiny
Quoted 17 lines · Coly Li

When calling __generic_fsdax_supported(), a dax-unsupported device may not have dax_dev as NULL, e.g. the dax related code block is not enabled by Kconfig.

Therefore in __generic_fsdax_supported(), to check whether a device supports DAX or not, the following order should be performed,
- If dax_dev pointer is NULL, it means the device driver explicitly announce it doesn't support DAX. Then it is OK to directly return false from __generic_fsdax_supported().
- If dax_dev pointer is NOT NULL, it might be because the driver doesn't support DAX and not explicitly initialize related data structure. Then bdev_dax_supported() should be called for further check.

IMHO if device driver desn't explicitly set its dax_dev pointer to NULL, this is not a bug. Calling bdev_dax_supported() makes sure they can be recognized as dax-unsupported eventually.

Quoted 7 lines

This patch does the following change for the above purpose,
- if (!dax_dev && !bdev_dax_supported(bdev, blocksize)) {
+ if (!dax_dev || !bdev_dax_supported(bdev, blocksize)) {

Fixes c2affe920b0e ("dax: do not print error message for non-persistent memory block device")

I hate to do this because I realize this is a bug which people really need fixed.

Quoted 7 lines

However, shouldn't we also check (!dax_dev || !bdev_dax_supported()) as the _first_ check in __generic_fsdax_supported()?

It seems like the other pr_info's could also be called when DAX is not supported and we probably don't want them to be?

Perhaps that should be a follow on patch though. So...

I am not author of c2affe920b0e, but I guess it was because bdev_dax_supported() needed blocksize, so blocksize should pass previous checks firstly to make sure bdev_dax_supported() has a correct blocksize to check.

Quoted 4 lines

As a direct fix to c2affe920b0e

Thanks.

Coly Li

Quoted 19 lines
Quoted 19 lines
Cc Adrian Huang <[email protected]>
Cc Ira Weiny <[email protected]>
Cc Jan Kara <[email protected]>
Cc Mike Snitzer <[email protected]>
Cc Pankaj Gupta <[email protected]>
Cc Vishal Verma <[email protected]>
---
 drivers/dax/super.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/dax/super.c +0 -0
index 32642634c1bb..e5767c83ea23 100644
@@ -100,7 +100,7 @@ bool __generic_fsdax_supported(struct dax_device *dax_dev,
             return false;
     }
 
Quoted 8 lines
Quoted 8 lines
drivers/dax/super.c +1 -2
-    if (!dax_dev && !bdev_dax_supported(bdev, blocksize)) {
+    if (!dax_dev || !bdev_dax_supported(bdev, blocksize)) {
             pr_debug("%s: error: dax unsupported by block device\n",
                             bdevname(bdev, buf));
             return false;
--

2.26.2

_______________________________________________
Linux-nvdimm mailing list -- [email protected] To unsubscribe send an email to [email protected]

author
#5 lore raw
Quoted 8 lines · John Pittman

But it should be moved prior to the two bdev_dax_pgoff() checks right?
Else a misaligned partition on a dax unsupported block device can
print the below messages.

kernel: sda1: error: unaligned partition for dax
kernel: sda2: error: unaligned partition for dax
kernel: sda3: error: unaligned partition for dax

Aha, yes you are right, I agree with you.

Coly Li

Quoted 56 lines
Quoted 53 lines · Coly Li
Quoted 29 lines · Ira Weiny
Quoted 17 lines · Coly Li

When calling __generic_fsdax_supported(), a dax-unsupported device may not have dax_dev as NULL, e.g. the dax related code block is not enabled by Kconfig.

Therefore in __generic_fsdax_supported(), to check whether a device supports DAX or not, the following order should be performed,
- If dax_dev pointer is NULL, it means the device driver explicitly announce it doesn't support DAX. Then it is OK to directly return false from __generic_fsdax_supported().
- If dax_dev pointer is NOT NULL, it might be because the driver doesn't support DAX and not explicitly initialize related data structure. Then bdev_dax_supported() should be called for further check.

IMHO if device driver desn't explicitly set its dax_dev pointer to NULL, this is not a bug. Calling bdev_dax_supported() makes sure they can be recognized as dax-unsupported eventually.

Quoted 7 lines

This patch does the following change for the above purpose,
- if (!dax_dev && !bdev_dax_supported(bdev, blocksize)) {
+ if (!dax_dev || !bdev_dax_supported(bdev, blocksize)) {

Fixes c2affe920b0e ("dax: do not print error message for non-persistent memory block device")

I hate to do this because I realize this is a bug which people really need fixed.

Quoted 7 lines

However, shouldn't we also check (!dax_dev || !bdev_dax_supported()) as the _first_ check in __generic_fsdax_supported()?

It seems like the other pr_info's could also be called when DAX is not supported and we probably don't want them to be?

Perhaps that should be a follow on patch though. So...

I am not author of c2affe920b0e, but I guess it was because bdev_dax_supported() needed blocksize, so blocksize should pass previous checks firstly to make sure bdev_dax_supported() has a correct blocksize to check.

Quoted 4 lines

As a direct fix to c2affe920b0e

Thanks.

Coly Li

[snipped]