diff options
author | Aneesh Kumar K.V <aneesh.kumar@linux.ibm.com> | 2019-09-05 11:45:58 -0400 |
---|---|---|
committer | Dan Williams <dan.j.williams@intel.com> | 2019-09-05 19:11:14 -0400 |
commit | 1c97afa714098aab2ca588cc654f8ff67dd46dcb (patch) | |
tree | f02ffe73409579b6d215b9b913576698c86f8d30 | |
parent | a2d1c7a61db9b1e261410c7d9e2be2243040749b (diff) |
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 <aneesh.kumar@linux.ibm.com>
Link: https://lore.kernel.org/r/20190905154603.10349-3-aneesh.kumar@linux.ibm.com
Signed-off-by: Dan Williams <dan.j.williams@intel.com>
-rw-r--r-- | drivers/nvdimm/bus.c | 3 | ||||
-rw-r--r-- | drivers/nvdimm/pmem.c | 29 |
2 files changed, 27 insertions, 5 deletions
diff --git a/drivers/nvdimm/bus.c b/drivers/nvdimm/bus.c index ee6de34ae525..75a58a6e9615 100644 --- a/drivers/nvdimm/bus.c +++ b/drivers/nvdimm/bus.c | |||
@@ -95,7 +95,8 @@ static int nvdimm_bus_probe(struct device *dev) | |||
95 | rc = nd_drv->probe(dev); | 95 | rc = nd_drv->probe(dev); |
96 | debug_nvdimm_unlock(dev); | 96 | debug_nvdimm_unlock(dev); |
97 | 97 | ||
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)) | ||
99 | nd_region_advance_seeds(to_nd_region(dev->parent), dev); | 100 | nd_region_advance_seeds(to_nd_region(dev->parent), dev); |
100 | nvdimm_bus_probe_end(nvdimm_bus); | 101 | nvdimm_bus_probe_end(nvdimm_bus); |
101 | 102 | ||
diff --git a/drivers/nvdimm/pmem.c b/drivers/nvdimm/pmem.c index 4c121dd03dd9..f9f76f6ba07b 100644 --- a/drivers/nvdimm/pmem.c +++ b/drivers/nvdimm/pmem.c | |||
@@ -490,6 +490,7 @@ static int pmem_attach_disk(struct device *dev, | |||
490 | 490 | ||
491 | static int nd_pmem_probe(struct device *dev) | 491 | static int nd_pmem_probe(struct device *dev) |
492 | { | 492 | { |
493 | int ret; | ||
493 | struct nd_namespace_common *ndns; | 494 | struct nd_namespace_common *ndns; |
494 | 495 | ||
495 | ndns = nvdimm_namespace_common_probe(dev); | 496 | ndns = nvdimm_namespace_common_probe(dev); |
@@ -505,12 +506,32 @@ static int nd_pmem_probe(struct device *dev) | |||
505 | if (is_nd_pfn(dev)) | 506 | if (is_nd_pfn(dev)) |
506 | return pmem_attach_disk(dev, ndns); | 507 | return pmem_attach_disk(dev, ndns); |
507 | 508 | ||
508 | /* if we find a valid info-block we'll come back as that personality */ | 509 | ret = nd_btt_probe(dev, ndns); |
509 | if (nd_btt_probe(dev, ndns) == 0 || nd_pfn_probe(dev, ndns) == 0 | 510 | if (ret == 0) |
510 | || nd_dax_probe(dev, ndns) == 0) | ||
511 | return -ENXIO; | 511 | return -ENXIO; |
512 | 512 | ||
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; | ||
514 | return pmem_attach_disk(dev, ndns); | 535 | return pmem_attach_disk(dev, ndns); |
515 | } | 536 | } |
516 | 537 | ||