nvdimm/pmem: propagate personality discovery errors
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.
--- drivers/nvdimm/pmem.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-)
drivers/nvdimm/pmem.c +4 -2
@@ -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
Alison Schofield
maintainerQuoted 19 lines · Avi Weiss
nd_pmem_probe()ignores errors fromnd_btt_probe()and only propagates-EOPNOTSUPPfromnd_pfn_probe()andnd_dax_probe(). An allocation failure such as-ENOMEMcan therefore be overwritten by subsequent personality probes, allowing the namespace to be attached as raw PMEM.Return discovery errors other than
-ENODEVand-ENXIO. Preserve the existing raw-PMEM fallback for those error codes.Fixes 8c2f7e8658df ("libnvdimm: infrastructure for btt devices")Signed-off-by Avi Weiss <[email protected]>--- drivers/nvdimm/pmem.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-)drivers/nvdimm/pmem.c +0
-0
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