Skip to content

Commit

Permalink
dax: fix detection of dax support for non-persistent memory block dev…
Browse files Browse the repository at this point in the history
…ices

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 of operations 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.

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.

Fixes: c2affe9 ("dax: do not print error message for non-persistent memory block device")
Cc: Jan Kara <[email protected]>
Cc: Vishal Verma <[email protected]>
Reviewed-and-tested-by: Adrian Huang <[email protected]>
Reviewed-by: Ira Weiny <[email protected]>
Reviewed-by: Mike Snitzer <[email protected]>
Reviewed-by: Pankaj Gupta <[email protected]>
Signed-off-by: Coly Li <[email protected]>
Signed-off-by: Vishal Verma <[email protected]>
Link: https://lore.kernel.org/r/[email protected]
  • Loading branch information
Coly Li authored and stellarhopper committed Sep 3, 2020
1 parent c2affe9 commit 6180bb4
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion drivers/dax/super.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down

0 comments on commit 6180bb4

Please sign in to comment.