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
328328 }
329329
330330 dimm_flags = 0;
331− set_bit(NDD_ALIASING, &dimm_flags);
331+ set_bit(NDD_LABELING, &dimm_flags);
332332
333333 p->nvdimm = nvdimm_create(p->bus, p, NULL, dimm_flags,
334334 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
20262026 continue;
20272027 }
20282028
2029− if (nfit_mem->bdw && nfit_mem->memdev_pmem)
2029+ if (nfit_mem->bdw && nfit_mem->memdev_pmem) {
20302030 set_bit(NDD_ALIASING, &flags);
2031+ set_bit(NDD_LABELING, &flags);
2032+ }
20312033
20322034 /* collate flags across all memdevs for this dimm */
20332035 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
9999 if (ndd->ns_current >= 0) {
100100 rc = nd_label_reserve_dpa(ndd);
101101 if (rc == 0)
102− nvdimm_set_aliasing(dev);
102+ nvdimm_set_labeling(dev);
103103 }
104104 nvdimm_bus_unlock(dev);
105105
drivers/nvdimm/dimm_devs.c+5−4
@@ -32,7 +32,7 @@ int nvdimm_check_config_data(struct device *dev) · 31 unmodified lines
3232
3333 if (!nvdimm->cmd_mask ||
3434 !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))
3636 return -ENXIO;
3737 else
3838 return -ENOTTY;
@@ -173,11 +173,11 @@ int nvdimm_set_config_data(struct nvdimm_drvdata *ndd, size_t offset, · 134 unmodified lines
173173 return rc;
174174 }
175175
176−void nvdimm_set_aliasing(struct device *dev)
176+void nvdimm_set_labeling(struct device *dev)
177177 {
178178 struct nvdimm *nvdimm = to_nvdimm(dev);
179179
180− set_bit(NDD_ALIASING, &nvdimm->flags);
180+ set_bit(NDD_LABELING, &nvdimm->flags);
181181 }
182182
183183 void nvdimm_set_locked(struct device *dev)
@@ -312,8 +312,9 @@ static ssize_t flags_show(struct device *dev, · 128 unmodified lines
312312 {
313313 struct nvdimm *nvdimm = to_nvdimm(dev);
314314
315− return sprintf(buf, "%s%s\n",
315+ return sprintf(buf, "%s%s%s\n",
316316 test_bit(NDD_ALIASING, &nvdimm->flags) ? "alias " : "",
317+ test_bit(NDD_LABELING, &nvdimm->flags) ? "label " : "",
317318 test_bit(NDD_LOCKED, &nvdimm->flags) ? "lock " : "");
318319 }
319320 static 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
25382538 if (!ndd) {
25392539 if (test_bit(NDD_LOCKED, &nvdimm->flags))
25402540 /* fail, label data may be unreadable */;
2541− else if (test_bit(NDD_ALIASING, &nvdimm->flags))
2541+ else if (test_bit(NDD_LABELING, &nvdimm->flags))
25422542 /* fail, labels needed to disambiguate dpa */;
25432543 else
25442544 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
252252 void *buf, size_t len);
253253 long nvdimm_clear_poison(struct device *dev, phys_addr_t phys,
254254 unsigned int len);
255−void nvdimm_set_aliasing(struct device *dev);
255+void nvdimm_set_labeling(struct device *dev);
256256 void nvdimm_set_locked(struct device *dev);
257257 void nvdimm_clear_locked(struct device *dev);
258258 int 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
195195 int nd_region_to_nstype(struct nd_region *nd_region)
196196 {
197197 if (is_memory(&nd_region->dev)) {
198− u16 i, alias;
198+ u16 i, label;
199199
200− for (i = 0, alias = 0; i < nd_region->ndr_mappings; i++) {
200+ for (i = 0, label = 0; i < nd_region->ndr_mappings; i++) {
201201 struct nd_mapping *nd_mapping = &nd_region->mapping[i];
202202 struct nvdimm *nvdimm = nd_mapping->nvdimm;
203203
204− if (test_bit(NDD_ALIASING, &nvdimm->flags))
205− alias++;
204+ if (test_bit(NDD_LABELING, &nvdimm->flags))
205+ label++;
206206 }
207− if (alias)
207+ if (label)
208208 return ND_DEVICE_NAMESPACE_PMEM;
209209 else
210210 return ND_DEVICE_NAMESPACE_IO;
include/linux/libnvdimm.h+2−0
@@ -37,6 +37,8 @@ enum { · 36 unmodified lines
3737 NDD_WORK_PENDING = 4,
3838 /* ignore / filter NSLABEL_FLAG_LOCAL for this DIMM, i.e. no aliasing */
3939 NDD_NOBLK = 5,
40+ /* dimm supports namespace labels */
41+ NDD_LABELING = 6,
4042
4143 /* need to set a limit somewhere, but yes, this is likely overkill */
4244 ND_IOCTL_MAX_BUFLEN = SZ_4M,