* [PATCH v2] nvdimm/pmem: propagate personality discovery errors
@ 2026-11-08 8:21 Avi Weiss
0 siblings, 0 replies; only message in thread
From: Avi Weiss @ 2026-11-08 8:21 UTC (permalink / raw)
To: djbw, vishal.l.verma, dave.jiang, alison.schofield
Cc: iweiny, nvdimm, linux-kernel, Avi Weiss
nd_pmem_probe() ignores errors from BTT discovery and only propagates
-EOPNOTSUPP from PFN and DAX discovery. Allocation failures can therefore
be mistaken for an absent personality, allowing a namespace to fall back
to raw PMEM.
Report -ENOMEM when allocating the BTT, PFN, or DAX info-block buffer
fails, retaining the existing device cleanup paths. Propagate discovery
errors other than -ENODEV and -ENXIO, and keep raw-PMEM fallback for
those two error codes.
Fixes: 8c2f7e8658df ("libnvdimm: infrastructure for btt devices")
Signed-off-by: Avi Weiss <thnkslprpt@gmail.com>
---
v2:
- return -ENOMEM for BTT, PFN, and DAX superblock buffer
allocation failures, retaining the existing cleanup paths
- correct/clarify the comment describing raw-PMEM fallback and
namespace-seed advancement
- rebase to v7.4-rc1
drivers/nvdimm/btt_devs.c | 4 +++-
drivers/nvdimm/dax_devs.c | 4 +++-
drivers/nvdimm/pfn_devs.c | 4 +++-
drivers/nvdimm/pmem.c | 19 ++++++++-----------
4 files changed, 17 insertions(+), 14 deletions(-)
diff --git a/drivers/nvdimm/btt_devs.c b/drivers/nvdimm/btt_devs.c
index d6b2f157368f6..c3c5cb686743b 100644
--- a/drivers/nvdimm/btt_devs.c
+++ b/drivers/nvdimm/btt_devs.c
@@ -349,7 +349,9 @@ int nd_btt_probe(struct device *dev, struct nd_namespace_common *ndns)
if (!btt_dev)
return -ENOMEM;
btt_sb = devm_kzalloc(dev, sizeof(*btt_sb), GFP_KERNEL);
- rc = __nd_btt_probe(to_nd_btt(btt_dev), ndns, btt_sb);
+ rc = -ENOMEM;
+ if (btt_sb)
+ rc = __nd_btt_probe(to_nd_btt(btt_dev), ndns, btt_sb);
dev_dbg(dev, "btt: %s\n", rc == 0 ? dev_name(btt_dev) : "<none>");
if (rc < 0) {
struct nd_btt *nd_btt = to_nd_btt(btt_dev);
diff --git a/drivers/nvdimm/dax_devs.c b/drivers/nvdimm/dax_devs.c
index decc70f2fe3ff..4d4048578efac 100644
--- a/drivers/nvdimm/dax_devs.c
+++ b/drivers/nvdimm/dax_devs.c
@@ -113,7 +113,9 @@ int nd_dax_probe(struct device *dev, struct nd_namespace_common *ndns)
pfn_sb = devm_kmalloc(dev, sizeof(*pfn_sb), GFP_KERNEL);
nd_pfn = &nd_dax->nd_pfn;
nd_pfn->pfn_sb = pfn_sb;
- rc = nd_pfn_validate(nd_pfn, DAX_SIG);
+ rc = -ENOMEM;
+ if (pfn_sb)
+ rc = nd_pfn_validate(nd_pfn, DAX_SIG);
dev_dbg(dev, "dax: %s\n", rc == 0 ? dev_name(dax_dev) : "<none>");
if (rc < 0) {
nd_detach_ndns(dax_dev, &nd_pfn->ndns);
diff --git a/drivers/nvdimm/pfn_devs.c b/drivers/nvdimm/pfn_devs.c
index 8fa9c16aba7ea..39b8d5eed7ef5 100644
--- a/drivers/nvdimm/pfn_devs.c
+++ b/drivers/nvdimm/pfn_devs.c
@@ -637,7 +637,9 @@ int nd_pfn_probe(struct device *dev, struct nd_namespace_common *ndns)
pfn_sb = devm_kmalloc(dev, sizeof(*pfn_sb), GFP_KERNEL);
nd_pfn = to_nd_pfn(pfn_dev);
nd_pfn->pfn_sb = pfn_sb;
- rc = nd_pfn_validate(nd_pfn, PFN_SIG);
+ rc = -ENOMEM;
+ if (pfn_sb)
+ rc = nd_pfn_validate(nd_pfn, PFN_SIG);
dev_dbg(dev, "pfn: %s\n", rc == 0 ? dev_name(pfn_dev) : "<none>");
if (rc < 0) {
nd_detach_ndns(pfn_dev, &nd_pfn->ndns);
diff --git a/drivers/nvdimm/pmem.c b/drivers/nvdimm/pmem.c
index 0766a6949b285..efdb804ad5d78 100644
--- a/drivers/nvdimm/pmem.c
+++ b/drivers/nvdimm/pmem.c
@@ -632,28 +632,25 @@ static int nd_pmem_probe(struct device *dev)
ret = nd_btt_probe(dev, ndns);
if (ret == 0)
return -ENXIO;
+ else if (ret != -ENODEV && ret != -ENXIO)
+ return ret;
/*
- * We have two failure conditions here, there is no
- * info reserver block or we found a valid info reserve block
- * but failed to initialize the pfn superblock.
- *
- * For the first case consider namespace as a raw pmem namespace
- * and attach a disk.
- *
- * For the latter, consider this a success and advance the namespace
- * seed.
+ * An absent or unreadable PFN/DAX info block allows probing the
+ * next personality or falling back to raw PMEM. Other errors
+ * are propagated, including -EOPNOTSUPP, which causes
+ * nvdimm_bus_probe() to advance the namespace seed.
*/
ret = nd_pfn_probe(dev, ndns);
if (ret == 0)
return -ENXIO;
- else if (ret == -EOPNOTSUPP)
+ else if (ret != -ENODEV && ret != -ENXIO)
return ret;
ret = nd_dax_probe(dev, ndns);
if (ret == 0)
return -ENXIO;
- else if (ret == -EOPNOTSUPP)
+ else if (ret != -ENODEV && ret != -ENXIO)
return ret;
/* probe complete, attach handles namespace enabling */
base-commit: 6628e7d4c6b25c8d18f1345e3a20d21829aae7e4
--
2.43.0
^ permalink raw reply [flat|nested] only message in thread
only message in thread, other threads:[~2026-11-08 8:21 UTC | newest]
Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2026-11-08 8:21 [PATCH v2] nvdimm/pmem: propagate personality discovery errors Avi Weiss
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®