Skip to content

Commit 1c97afa

Browse files
kvaneeshdjbw
authored andcommitted
libnvdimm/pmem: Advance namespace seed for specific probe errors
In order to support marking namespaces with unsupported feature/versions disabled, nvdimm core should advance the namespace seed on these probe failures. Otherwise, these failed namespaces will be considered a seed namespace and will be wrongly used while creating new namespaces. Add -EOPNOTSUPP as return from pmem probe callback to indicate a namespace initialization failures due to pfn superblock feature/version mismatch. Signed-off-by: Aneesh Kumar K.V <[email protected]> Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Dan Williams <[email protected]>
1 parent a2d1c7a commit 1c97afa

File tree

2 files changed

+27
-5
lines changed

2 files changed

+27
-5
lines changed

drivers/nvdimm/bus.c

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -95,7 +95,8 @@ static int nvdimm_bus_probe(struct device *dev)
9595
rc = nd_drv->probe(dev);
9696
debug_nvdimm_unlock(dev);
9797

98-
if (rc == 0 && dev->parent && is_nd_region(dev->parent))
98+
if ((rc == 0 || rc == -EOPNOTSUPP) &&
99+
dev->parent && is_nd_region(dev->parent))
99100
nd_region_advance_seeds(to_nd_region(dev->parent), dev);
100101
nvdimm_bus_probe_end(nvdimm_bus);
101102

drivers/nvdimm/pmem.c

Lines changed: 25 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -490,6 +490,7 @@ static int pmem_attach_disk(struct device *dev,
490490

491491
static int nd_pmem_probe(struct device *dev)
492492
{
493+
int ret;
493494
struct nd_namespace_common *ndns;
494495

495496
ndns = nvdimm_namespace_common_probe(dev);
@@ -505,12 +506,32 @@ static int nd_pmem_probe(struct device *dev)
505506
if (is_nd_pfn(dev))
506507
return pmem_attach_disk(dev, ndns);
507508

508-
/* if we find a valid info-block we'll come back as that personality */
509-
if (nd_btt_probe(dev, ndns) == 0 || nd_pfn_probe(dev, ndns) == 0
510-
|| nd_dax_probe(dev, ndns) == 0)
509+
ret = nd_btt_probe(dev, ndns);
510+
if (ret == 0)
511511
return -ENXIO;
512512

513-
/* ...otherwise we're just a raw pmem device */
513+
/*
514+
* We have two failure conditions here, there is no
515+
* info reserver block or we found a valid info reserve block
516+
* but failed to initialize the pfn superblock.
517+
*
518+
* For the first case consider namespace as a raw pmem namespace
519+
* and attach a disk.
520+
*
521+
* For the latter, consider this a success and advance the namespace
522+
* seed.
523+
*/
524+
ret = nd_pfn_probe(dev, ndns);
525+
if (ret == 0)
526+
return -ENXIO;
527+
else if (ret == -EOPNOTSUPP)
528+
return ret;
529+
530+
ret = nd_dax_probe(dev, ndns);
531+
if (ret == 0)
532+
return -ENXIO;
533+
else if (ret == -EOPNOTSUPP)
534+
return ret;
514535
return pmem_attach_disk(dev, ndns);
515536
}
516537

0 commit comments

Comments
 (0)