Skip to contentSkip to conversation

nvdimm/pmem: propagate personality discovery errors

PATCH Superseded Avi Weiss 2 participants 2 messages Oct 30 – Nov 5

Subsystems (2)

v1 of 2 Superseded Latest is v2 →

lore
Share & tools
lore

Avi Weiss

author
#0 lore raw

PATCH 1/1 nvdimm/pmem: propagate personality discovery errors

nd_pmem_probe() ignores errors from nd_btt_probe() and only propagates -EOPNOTSUPP from nd_pfn_probe() and nd_dax_probe(). An allocation failure such as -ENOMEM can therefore be overwritten by subsequent personality probes, allowing the namespace to be attached as raw PMEM.

Return discovery errors other than -ENODEV and -ENXIO. Preserve the existing raw-PMEM fallback for those error codes.

Fixes 8c2f7e8658df ("libnvdimm: infrastructure for btt devices")
---
 drivers/nvdimm/pmem.c | 6 ++++--
 1 file changed, 4 insertions(+), 2 deletions(-)
drivers/nvdimm/pmem.c +4 -2
index 0766a6949b28..78acc9b0b1a0 100644
@@ -632,6 +632,8 @@ 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
@@ -647,13 +649,13 @@ static int nd_pmem_probe(struct device *dev)
 	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: d89e1d186ec9271bf78e62771779e9fc03bf0fc3

Signature · 1 line
2.43.0
maintainer
#1 lore raw
Quoted 19 lines · Avi Weiss

nd_pmem_probe() ignores errors from nd_btt_probe() and only propagates -EOPNOTSUPP from nd_pfn_probe() and nd_dax_probe(). An allocation failure such as -ENOMEM can therefore be overwritten by subsequent personality probes, allowing the namespace to be attached as raw PMEM.

Return discovery errors other than -ENODEV and -ENXIO. Preserve the existing raw-PMEM fallback for those error codes.

Fixes 8c2f7e8658df ("libnvdimm: infrastructure for btt devices")
---
 drivers/nvdimm/pmem.c | 6 ++++--
 1 file changed, 4 insertions(+), 2 deletions(-)
drivers/nvdimm/pmem.c +0 -0
index 0766a6949b28..78acc9b0b1a0 100644

drivers/nvdimm/pmem.c static int nd_pmem_probe(struct device *dev) · line 636

Quoted 5 lines
drivers/nvdimm/pmem.c +2 -0
@@ -632,6 +632,8 @@ 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;

Hi Avi,

Thanks for the patch! I think it could be made more complete.

Does this also need changes in the discovery helpers? If the btt_sb allocation fails, __nd_btt_probe() returns -ENODEV, so this still allows fallback to raw PMEM.

The pfn_sb allocations in nd_pfn_probe() and nd_dax_probe() appear to have the same issue: nd_pfn_validate() returns -ENODEV for a NULL buffer. Should those allocation failures return -ENOMEM too?

Quoted 7 lines
drivers/nvdimm/pmem.c +0 -0
 	/*
 	 * We have two failure conditions here, there is no
@@ -647,13 +649,13 @@ static int nd_pmem_probe(struct device *dev)
 	ret = nd_pfn_probe(dev, ndns);
 	if (ret == 0)
 		return -ENXIO;

drivers/nvdimm/pmem.c static int nd_pmem_probe(struct device *dev) · line 659

Quoted 10 lines
drivers/nvdimm/pmem.c +2 -2
-	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;

Suggest updating the comment above nd_pfn_probe()? It says failure to initialize the pfn superblock advances the namespace seed, but nvdimm_bus_probe() only does that for success or -EOPNOTSUPP. With other errors now propagated, that wording seems too broad.

Quoted 4 lines
drivers/nvdimm/pmem.c +0 -0
 	/* probe complete, attach handles namespace enabling */
 

base-commit: d89e1d186ec9271bf78e62771779e9fc03bf0fc3

Please base your v2 on a linus mainline tag, like v7.4-rc1.

-- Alison

Quoted 3 lines
Signature · 1 line
2.43.0