History

libnvdimm/region: Introduce NDD_LABELING

The NDD_ALIASING flag is used to indicate where pmem capacity might alias with blk capacity and require labeling. It is also used to indicate whether the DIMM supports labeling. Separate this latter capability into its own flag so that the NDD_ALIASING flag is scoped to true aliased configurations. To my knowledge aliased configurations only exist in the ACPI spec, there are no known platforms that ship this support in production. This clarity allows namespace-capacity alignment constraints around interleave-ways to be relaxed.

Dan Williams committed 6 years ago

Commit a0e37451 parent 6acd7d58 files · +19 −14Browse files

Unified · Split

8 files
  1. arch/powerpc/platforms/pseries/papr_scm.c +1 −1
  2. drivers/acpi/nfit/core.c +3 −1
  3. drivers/nvdimm/dimm.c +1 −1
  4. drivers/nvdimm/dimm_devs.c +5 −4
  5. drivers/nvdimm/namespace_devs.c +1 −1
  6. drivers/nvdimm/nd.h +1 −1
  7. drivers/nvdimm/region_devs.c +5 −5
  8. include/linux/libnvdimm.h +2 −0
arch/powerpc/platforms/pseries/papr_scm.c+1−1
@@ -328,7 +328,7 @@ static int papr_scm_nvdimm_init(struct papr_scm_priv *p) · 327 unmodified lines
328 }328 }
329 329
330 dimm_flags = 0;330 dimm_flags = 0;
331 set_bit(NDD_ALIASING, &dimm_flags);331 set_bit(NDD_LABELING, &dimm_flags);
332 332
333 p->nvdimm = nvdimm_create(p->bus, p, NULL, dimm_flags,333 p->nvdimm = nvdimm_create(p->bus, p, NULL, dimm_flags,
334 PAPR_SCM_DIMM_CMD_MASK, 0, NULL);334 PAPR_SCM_DIMM_CMD_MASK, 0, NULL);
drivers/acpi/nfit/core.c+3−1
@@ -2026,8 +2026,10 @@ static int acpi_nfit_register_dimms(struct acpi_nfit_desc *acpi_desc) · 2025 unmodified lines
2026 continue;2026 continue;
2027 }2027 }
2028 2028
2029 if (nfit_mem->bdw && nfit_mem->memdev_pmem)2029 if (nfit_mem->bdw && nfit_mem->memdev_pmem) {
2030 set_bit(NDD_ALIASING, &flags);2030 set_bit(NDD_ALIASING, &flags);
2031 set_bit(NDD_LABELING, &flags);
2032 }
2031 2033
2032 /* collate flags across all memdevs for this dimm */2034 /* collate flags across all memdevs for this dimm */
2033 list_for_each_entry(nfit_memdev, &acpi_desc->memdevs, list) {2035 list_for_each_entry(nfit_memdev, &acpi_desc->memdevs, list) {
drivers/nvdimm/dimm.c+1−1
@@ -99,7 +99,7 @@ static int nvdimm_probe(struct device *dev) · 98 unmodified lines
99 if (ndd->ns_current >= 0) {99 if (ndd->ns_current >= 0) {
100 rc = nd_label_reserve_dpa(ndd);100 rc = nd_label_reserve_dpa(ndd);
101 if (rc == 0)101 if (rc == 0)
102 nvdimm_set_aliasing(dev);102 nvdimm_set_labeling(dev);
103 }103 }
104 nvdimm_bus_unlock(dev);104 nvdimm_bus_unlock(dev);
105 105
drivers/nvdimm/dimm_devs.c+5−4
@@ -32,7 +32,7 @@ int nvdimm_check_config_data(struct device *dev) · 31 unmodified lines
32 32
33 if (!nvdimm->cmd_mask ||33 if (!nvdimm->cmd_mask ||
34 !test_bit(ND_CMD_GET_CONFIG_DATA, &nvdimm->cmd_mask)) {34 !test_bit(ND_CMD_GET_CONFIG_DATA, &nvdimm->cmd_mask)) {
35 if (test_bit(NDD_ALIASING, &nvdimm->flags))35 if (test_bit(NDD_LABELING, &nvdimm->flags))
36 return -ENXIO;36 return -ENXIO;
37 else37 else
38 return -ENOTTY;38 return -ENOTTY;
@@ -173,11 +173,11 @@ int nvdimm_set_config_data(struct nvdimm_drvdata *ndd, size_t offset, · 134 unmodified lines
173 return rc;173 return rc;
174}174}
175 175
176void nvdimm_set_aliasing(struct device *dev)176void nvdimm_set_labeling(struct device *dev)
177{177{
178 struct nvdimm *nvdimm = to_nvdimm(dev);178 struct nvdimm *nvdimm = to_nvdimm(dev);
179 179
180 set_bit(NDD_ALIASING, &nvdimm->flags);180 set_bit(NDD_LABELING, &nvdimm->flags);
181}181}
182 182
183void nvdimm_set_locked(struct device *dev)183void nvdimm_set_locked(struct device *dev)
@@ -312,8 +312,9 @@ static ssize_t flags_show(struct device *dev, · 128 unmodified lines
312{312{
313 struct nvdimm *nvdimm = to_nvdimm(dev);313 struct nvdimm *nvdimm = to_nvdimm(dev);
314 314
315 return sprintf(buf, "%s%s\n",315 return sprintf(buf, "%s%s%s\n",
316 test_bit(NDD_ALIASING, &nvdimm->flags) ? "alias " : "",316 test_bit(NDD_ALIASING, &nvdimm->flags) ? "alias " : "",
317 test_bit(NDD_LABELING, &nvdimm->flags) ? "label " : "",
317 test_bit(NDD_LOCKED, &nvdimm->flags) ? "lock " : "");318 test_bit(NDD_LOCKED, &nvdimm->flags) ? "lock " : "");
318}319}
319static DEVICE_ATTR_RO(flags);320static DEVICE_ATTR_RO(flags);
drivers/nvdimm/namespace_devs.c+1−1
@@ -2538,7 +2538,7 @@ static int init_active_labels(struct nd_region *nd_region) · 2537 unmodified lines
2538 if (!ndd) {2538 if (!ndd) {
2539 if (test_bit(NDD_LOCKED, &nvdimm->flags))2539 if (test_bit(NDD_LOCKED, &nvdimm->flags))
2540 /* fail, label data may be unreadable */;2540 /* fail, label data may be unreadable */;
2541 else if (test_bit(NDD_ALIASING, &nvdimm->flags))2541 else if (test_bit(NDD_LABELING, &nvdimm->flags))
2542 /* fail, labels needed to disambiguate dpa */;2542 /* fail, labels needed to disambiguate dpa */;
2543 else2543 else
2544 return 0;2544 return 0;
drivers/nvdimm/nd.h+1−1
@@ -252,7 +252,7 @@ int nvdimm_set_config_data(struct nvdimm_drvdata *ndd, size_t offset, · 251 unmodified lines
252 void *buf, size_t len);252 void *buf, size_t len);
253long nvdimm_clear_poison(struct device *dev, phys_addr_t phys,253long nvdimm_clear_poison(struct device *dev, phys_addr_t phys,
254 unsigned int len);254 unsigned int len);
255void nvdimm_set_aliasing(struct device *dev);255void nvdimm_set_labeling(struct device *dev);
256void nvdimm_set_locked(struct device *dev);256void nvdimm_set_locked(struct device *dev);
257void nvdimm_clear_locked(struct device *dev);257void nvdimm_clear_locked(struct device *dev);
258int nvdimm_security_setup_events(struct device *dev);258int nvdimm_security_setup_events(struct device *dev);
drivers/nvdimm/region_devs.c+5−5
@@ -195,16 +195,16 @@ EXPORT_SYMBOL_GPL(nd_blk_region_set_provider_data); · 194 unmodified lines
195int nd_region_to_nstype(struct nd_region *nd_region)195int nd_region_to_nstype(struct nd_region *nd_region)
196{196{
197 if (is_memory(&nd_region->dev)) {197 if (is_memory(&nd_region->dev)) {
198 u16 i, alias;198 u16 i, label;
199 199
200 for (i = 0, alias = 0; i < nd_region->ndr_mappings; i++) {200 for (i = 0, label = 0; i < nd_region->ndr_mappings; i++) {
201 struct nd_mapping *nd_mapping = &nd_region->mapping[i];201 struct nd_mapping *nd_mapping = &nd_region->mapping[i];
202 struct nvdimm *nvdimm = nd_mapping->nvdimm;202 struct nvdimm *nvdimm = nd_mapping->nvdimm;
203 203
204 if (test_bit(NDD_ALIASING, &nvdimm->flags))204 if (test_bit(NDD_LABELING, &nvdimm->flags))
205 alias++;205 label++;
206 }206 }
207 if (alias)207 if (label)
208 return ND_DEVICE_NAMESPACE_PMEM;208 return ND_DEVICE_NAMESPACE_PMEM;
209 else209 else
210 return ND_DEVICE_NAMESPACE_IO;210 return ND_DEVICE_NAMESPACE_IO;
include/linux/libnvdimm.h+2−0
@@ -37,6 +37,8 @@ enum { · 36 unmodified lines
37 NDD_WORK_PENDING = 4,37 NDD_WORK_PENDING = 4,
38 /* ignore / filter NSLABEL_FLAG_LOCAL for this DIMM, i.e. no aliasing */38 /* ignore / filter NSLABEL_FLAG_LOCAL for this DIMM, i.e. no aliasing */
39 NDD_NOBLK = 5,39 NDD_NOBLK = 5,
40 /* dimm supports namespace labels */
41 NDD_LABELING = 6,
40 42
41 /* need to set a limit somewhere, but yes, this is likely overkill */43 /* need to set a limit somewhere, but yes, this is likely overkill */
42 ND_IOCTL_MAX_BUFLEN = SZ_4M,44 ND_IOCTL_MAX_BUFLEN = SZ_4M,