Skip to contentSkip to conversation

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

PATCH Superseded Coly Li 3 participants 4 messages Sep 3, 2020

Subsystems (3)

v2 of 4 Superseded Latest is v4 →

lore
Share & tools
lore

Coly Li

author
#0 lore raw

PATCH v2 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")
Reviewed-and-Tested-by 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]>

---
Changelog:
v2: add Reviewed-and-Tested-by from Adrian Huang.
v1: initial version.

 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 on v2 1/1
#1 lore raw
Quoted 43 lines

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")
Reviewed-and-Tested-by 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]>

---
Changelog:
v2: add Reviewed-and-Tested-by from Adrian Huang.
v1: initial version.

 drivers/dax/super.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/dax/super.c +0 -0
index 32642634c1bb..e5767c83ea23 100644

drivers/dax/super.c bool __generic_fsdax_supported(struct dax_device *dax_dev,

Quoted 9 lines
drivers/dax/super.c +1 -2
@@ -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;
--

Looks good.

Reviewed-by on v2 1/1
#2 lore raw
In reply to Coly Li
Quoted 13 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.

Quoted 7 lines

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)) {

Don't think I've ever seen a one-liner fix document the diff in its patch header. Really no need for that.

Quoted 8 lines
Fixes c2affe920b0e ("dax: do not print error message for non-persistent memory block device")
Reviewed-and-Tested-by 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]>

Thanks for fixing this,

Quoted 24 lines

---
Changelog:
v2: add Reviewed-and-Tested-by from Adrian Huang.
v1: initial version.

 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 20 lines · Mike Snitzer
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
Quoted 3 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)) {

Don't think I've ever seen a one-liner fix document the diff in its patch header. Really no need for that.

Oops, I just see this comment when I maximum my email client window now. OK, I will post a v4 version to remove the above diff-like style comment.

Coly Li