diff options
author | Dan Williams <dan.j.williams@intel.com> | 2018-06-13 18:08:36 +0200 |
---|---|---|
committer | Dan Williams <dan.j.williams@intel.com> | 2018-07-14 19:27:00 +0200 |
commit | 08e6b3c6e3a054f566367740c94b8c1d18e52056 (patch) | |
tree | 2b32de4d367f7fe923c2826b6b0be3269f91a82f /drivers/nvdimm/namespace_devs.c | |
parent | tools/testing/nvdimm: advertise a write cache for nfit_test (diff) | |
download | linux-08e6b3c6e3a054f566367740c94b8c1d18e52056.tar.xz linux-08e6b3c6e3a054f566367740c94b8c1d18e52056.zip |
libnvdimm: Introduce locked DIMM capacity support
When a DIMM is locked its namespace label area may not be. Introduce the
distinction of locked namespaces to allow namespace enumeration while
the capacity is locked.
Signed-off-by: Dan Williams <dan.j.williams@intel.com>
Diffstat (limited to 'drivers/nvdimm/namespace_devs.c')
-rw-r--r-- | drivers/nvdimm/namespace_devs.c | 23 |
1 files changed, 23 insertions, 0 deletions
diff --git a/drivers/nvdimm/namespace_devs.c b/drivers/nvdimm/namespace_devs.c index 28afdd668905..cb322f2bc605 100644 --- a/drivers/nvdimm/namespace_devs.c +++ b/drivers/nvdimm/namespace_devs.c @@ -1144,6 +1144,26 @@ resource_size_t nvdimm_namespace_capacity(struct nd_namespace_common *ndns) } EXPORT_SYMBOL(nvdimm_namespace_capacity); +bool nvdimm_namespace_locked(struct nd_namespace_common *ndns) +{ + int i; + bool locked = false; + struct device *dev = &ndns->dev; + struct nd_region *nd_region = to_nd_region(dev->parent); + + for (i = 0; i < nd_region->ndr_mappings; i++) { + struct nd_mapping *nd_mapping = &nd_region->mapping[i]; + struct nvdimm *nvdimm = nd_mapping->nvdimm; + + if (test_bit(NDD_LOCKED, &nvdimm->flags)) { + dev_dbg(dev, "%s locked\n", nvdimm_name(nvdimm)); + locked = true; + } + } + return locked; +} +EXPORT_SYMBOL(nvdimm_namespace_locked); + static ssize_t size_show(struct device *dev, struct device_attribute *attr, char *buf) { @@ -1695,6 +1715,9 @@ struct nd_namespace_common *nvdimm_namespace_common_probe(struct device *dev) } } + if (nvdimm_namespace_locked(ndns)) + return ERR_PTR(-EACCES); + size = nvdimm_namespace_capacity(ndns); if (size < ND_MIN_NAMESPACE_SIZE) { dev_dbg(&ndns->dev, "%pa, too small must be at least %#x\n", |