summaryrefslogtreecommitdiffstats
path: root/drivers/nvdimm/namespace_devs.c
diff options
context:
space:
mode:
Diffstat (limited to 'drivers/nvdimm/namespace_devs.c')
-rw-r--r--drivers/nvdimm/namespace_devs.c506
1 files changed, 34 insertions, 472 deletions
diff --git a/drivers/nvdimm/namespace_devs.c b/drivers/nvdimm/namespace_devs.c
index b57a2d36c517..62b83b2e26e3 100644
--- a/drivers/nvdimm/namespace_devs.c
+++ b/drivers/nvdimm/namespace_devs.c
@@ -32,21 +32,7 @@ static void namespace_pmem_release(struct device *dev)
kfree(nspm);
}
-static void namespace_blk_release(struct device *dev)
-{
- struct nd_namespace_blk *nsblk = to_nd_namespace_blk(dev);
- struct nd_region *nd_region = to_nd_region(dev->parent);
-
- if (nsblk->id >= 0)
- ida_simple_remove(&nd_region->ns_ida, nsblk->id);
- kfree(nsblk->alt_name);
- kfree(nsblk->uuid);
- kfree(nsblk->res);
- kfree(nsblk);
-}
-
static bool is_namespace_pmem(const struct device *dev);
-static bool is_namespace_blk(const struct device *dev);
static bool is_namespace_io(const struct device *dev);
static int is_uuid_busy(struct device *dev, void *data)
@@ -57,10 +43,6 @@ static int is_uuid_busy(struct device *dev, void *data)
struct nd_namespace_pmem *nspm = to_nd_namespace_pmem(dev);
uuid2 = nspm->uuid;
- } else if (is_namespace_blk(dev)) {
- struct nd_namespace_blk *nsblk = to_nd_namespace_blk(dev);
-
- uuid2 = nsblk->uuid;
} else if (is_nd_btt(dev)) {
struct nd_btt *nd_btt = to_nd_btt(dev);
@@ -178,12 +160,6 @@ const char *nvdimm_namespace_disk_name(struct nd_namespace_common *ndns,
else
sprintf(name, "pmem%d%s", nd_region->id,
suffix ? suffix : "");
- } else if (is_namespace_blk(&ndns->dev)) {
- struct nd_namespace_blk *nsblk;
-
- nsblk = to_nd_namespace_blk(&ndns->dev);
- sprintf(name, "ndblk%d.%d%s", nd_region->id, nsblk->id,
- suffix ? suffix : "");
} else {
return NULL;
}
@@ -201,10 +177,6 @@ const uuid_t *nd_dev_to_uuid(struct device *dev)
struct nd_namespace_pmem *nspm = to_nd_namespace_pmem(dev);
return nspm->uuid;
- } else if (is_namespace_blk(dev)) {
- struct nd_namespace_blk *nsblk = to_nd_namespace_blk(dev);
-
- return nsblk->uuid;
} else
return &uuid_null;
}
@@ -229,10 +201,6 @@ static ssize_t __alt_name_store(struct device *dev, const char *buf,
struct nd_namespace_pmem *nspm = to_nd_namespace_pmem(dev);
ns_altname = &nspm->alt_name;
- } else if (is_namespace_blk(dev)) {
- struct nd_namespace_blk *nsblk = to_nd_namespace_blk(dev);
-
- ns_altname = &nsblk->alt_name;
} else
return -ENXIO;
@@ -264,83 +232,6 @@ out:
return rc;
}
-static resource_size_t nd_namespace_blk_size(struct nd_namespace_blk *nsblk)
-{
- struct nd_region *nd_region = to_nd_region(nsblk->common.dev.parent);
- struct nd_mapping *nd_mapping = &nd_region->mapping[0];
- struct nvdimm_drvdata *ndd = to_ndd(nd_mapping);
- struct nd_label_id label_id;
- resource_size_t size = 0;
- struct resource *res;
-
- if (!nsblk->uuid)
- return 0;
- nd_label_gen_id(&label_id, nsblk->uuid, NSLABEL_FLAG_LOCAL);
- for_each_dpa_resource(ndd, res)
- if (strcmp(res->name, label_id.id) == 0)
- size += resource_size(res);
- return size;
-}
-
-static bool __nd_namespace_blk_validate(struct nd_namespace_blk *nsblk)
-{
- struct nd_region *nd_region = to_nd_region(nsblk->common.dev.parent);
- struct nd_mapping *nd_mapping = &nd_region->mapping[0];
- struct nvdimm_drvdata *ndd = to_ndd(nd_mapping);
- struct nd_label_id label_id;
- struct resource *res;
- int count, i;
-
- if (!nsblk->uuid || !nsblk->lbasize || !ndd)
- return false;
-
- count = 0;
- nd_label_gen_id(&label_id, nsblk->uuid, NSLABEL_FLAG_LOCAL);
- for_each_dpa_resource(ndd, res) {
- if (strcmp(res->name, label_id.id) != 0)
- continue;
- /*
- * Resources with unacknowledged adjustments indicate a
- * failure to update labels
- */
- if (res->flags & DPA_RESOURCE_ADJUSTED)
- return false;
- count++;
- }
-
- /* These values match after a successful label update */
- if (count != nsblk->num_resources)
- return false;
-
- for (i = 0; i < nsblk->num_resources; i++) {
- struct resource *found = NULL;
-
- for_each_dpa_resource(ndd, res)
- if (res == nsblk->res[i]) {
- found = res;
- break;
- }
- /* stale resource */
- if (!found)
- return false;
- }
-
- return true;
-}
-
-resource_size_t nd_namespace_blk_validate(struct nd_namespace_blk *nsblk)
-{
- resource_size_t size;
-
- nvdimm_bus_lock(&nsblk->common.dev);
- size = __nd_namespace_blk_validate(nsblk);
- nvdimm_bus_unlock(&nsblk->common.dev);
-
- return size;
-}
-EXPORT_SYMBOL(nd_namespace_blk_validate);
-
-
static int nd_namespace_label_update(struct nd_region *nd_region,
struct device *dev)
{
@@ -363,16 +254,6 @@ static int nd_namespace_label_update(struct nd_region *nd_region,
return 0;
return nd_pmem_namespace_label_update(nd_region, nspm, size);
- } else if (is_namespace_blk(dev)) {
- struct nd_namespace_blk *nsblk = to_nd_namespace_blk(dev);
- resource_size_t size = nd_namespace_blk_size(nsblk);
-
- if (size == 0 && nsblk->uuid)
- /* delete allocation */;
- else if (!nsblk->uuid || !nsblk->lbasize)
- return 0;
-
- return nd_blk_namespace_label_update(nd_region, nsblk, size);
} else
return -ENXIO;
}
@@ -405,10 +286,6 @@ static ssize_t alt_name_show(struct device *dev,
struct nd_namespace_pmem *nspm = to_nd_namespace_pmem(dev);
ns_altname = nspm->alt_name;
- } else if (is_namespace_blk(dev)) {
- struct nd_namespace_blk *nsblk = to_nd_namespace_blk(dev);
-
- ns_altname = nsblk->alt_name;
} else
return -ENXIO;
@@ -420,13 +297,11 @@ static int scan_free(struct nd_region *nd_region,
struct nd_mapping *nd_mapping, struct nd_label_id *label_id,
resource_size_t n)
{
- bool is_blk = strncmp(label_id->id, "blk", 3) == 0;
struct nvdimm_drvdata *ndd = to_ndd(nd_mapping);
int rc = 0;
while (n) {
struct resource *res, *last;
- resource_size_t new_start;
last = NULL;
for_each_dpa_resource(ndd, res)
@@ -444,16 +319,7 @@ static int scan_free(struct nd_region *nd_region,
continue;
}
- /*
- * Keep BLK allocations relegated to high DPA as much as
- * possible
- */
- if (is_blk)
- new_start = res->start + n;
- else
- new_start = res->start;
-
- rc = adjust_resource(res, new_start, resource_size(res) - n);
+ rc = adjust_resource(res, res->start, resource_size(res) - n);
if (rc == 0)
res->flags |= DPA_RESOURCE_ADJUSTED;
nd_dbg_dpa(nd_region, ndd, res, "shrink %d\n", rc);
@@ -495,20 +361,12 @@ static resource_size_t init_dpa_allocation(struct nd_label_id *label_id,
struct nd_region *nd_region, struct nd_mapping *nd_mapping,
resource_size_t n)
{
- bool is_blk = strncmp(label_id->id, "blk", 3) == 0;
struct nvdimm_drvdata *ndd = to_ndd(nd_mapping);
- resource_size_t first_dpa;
struct resource *res;
int rc = 0;
- /* allocate blk from highest dpa first */
- if (is_blk)
- first_dpa = nd_mapping->start + nd_mapping->size - n;
- else
- first_dpa = nd_mapping->start;
-
/* first resource allocation for this label-id or dimm */
- res = nvdimm_allocate_dpa(ndd, label_id, first_dpa, n);
+ res = nvdimm_allocate_dpa(ndd, label_id, nd_mapping->start, n);
if (!res)
rc = -EBUSY;
@@ -539,7 +397,6 @@ static void space_valid(struct nd_region *nd_region, struct nvdimm_drvdata *ndd,
resource_size_t n, struct resource *valid)
{
bool is_reserve = strcmp(label_id->id, "pmem-reserve") == 0;
- bool is_pmem = strncmp(label_id->id, "pmem", 4) == 0;
unsigned long align;
align = nd_region->align / nd_region->ndr_mappings;
@@ -552,21 +409,6 @@ static void space_valid(struct nd_region *nd_region, struct nvdimm_drvdata *ndd,
if (is_reserve)
return;
- if (!is_pmem) {
- struct nd_mapping *nd_mapping = &nd_region->mapping[0];
- struct nvdimm_bus *nvdimm_bus;
- struct blk_alloc_info info = {
- .nd_mapping = nd_mapping,
- .available = nd_mapping->size,
- .res = valid,
- };
-
- WARN_ON(!is_nd_blk(&nd_region->dev));
- nvdimm_bus = walk_to_nvdimm_bus(&nd_region->dev);
- device_for_each_child(&nvdimm_bus->dev, &info, alias_dpa_busy);
- return;
- }
-
/* allocation needs to be contiguous, so this is all or nothing */
if (resource_size(valid) < n)
goto invalid;
@@ -594,7 +436,6 @@ static resource_size_t scan_allocate(struct nd_region *nd_region,
resource_size_t n)
{
resource_size_t mapping_end = nd_mapping->start + nd_mapping->size - 1;
- bool is_pmem = strncmp(label_id->id, "pmem", 4) == 0;
struct nvdimm_drvdata *ndd = to_ndd(nd_mapping);
struct resource *res, *exist = NULL, valid;
const resource_size_t to_allocate = n;
@@ -692,10 +533,6 @@ static resource_size_t scan_allocate(struct nd_region *nd_region,
}
if (strcmp(action, "allocate") == 0) {
- /* BLK allocate bottom up */
- if (!is_pmem)
- valid.start += available - allocate;
-
new_res = nvdimm_allocate_dpa(ndd, label_id,
valid.start, allocate);
if (!new_res)
@@ -731,12 +568,7 @@ static resource_size_t scan_allocate(struct nd_region *nd_region,
return 0;
}
- /*
- * If we allocated nothing in the BLK case it may be because we are in
- * an initial "pmem-reserve pass". Only do an initial BLK allocation
- * when none of the DPA space is reserved.
- */
- if ((is_pmem || !ndd->dpa.child) && n == to_allocate)
+ if (n == to_allocate)
return init_dpa_allocation(label_id, nd_region, nd_mapping, n);
return n;
}
@@ -795,7 +627,7 @@ int __reserve_free_pmem(struct device *dev, void *data)
if (nd_mapping->nvdimm != nvdimm)
continue;
- n = nd_pmem_available_dpa(nd_region, nd_mapping, &rem);
+ n = nd_pmem_available_dpa(nd_region, nd_mapping);
if (n == 0)
return 0;
rem = scan_allocate(nd_region, nd_mapping, &label_id, n);
@@ -820,19 +652,6 @@ void release_free_pmem(struct nvdimm_bus *nvdimm_bus,
nvdimm_free_dpa(ndd, res);
}
-static int reserve_free_pmem(struct nvdimm_bus *nvdimm_bus,
- struct nd_mapping *nd_mapping)
-{
- struct nvdimm *nvdimm = nd_mapping->nvdimm;
- int rc;
-
- rc = device_for_each_child(&nvdimm_bus->dev, nvdimm,
- __reserve_free_pmem);
- if (rc)
- release_free_pmem(nvdimm_bus, nd_mapping);
- return rc;
-}
-
/**
* grow_dpa_allocation - for each dimm allocate n bytes for @label_id
* @nd_region: the set of dimms to allocate @n more bytes from
@@ -849,37 +668,14 @@ static int reserve_free_pmem(struct nvdimm_bus *nvdimm_bus,
static int grow_dpa_allocation(struct nd_region *nd_region,
struct nd_label_id *label_id, resource_size_t n)
{
- struct nvdimm_bus *nvdimm_bus = walk_to_nvdimm_bus(&nd_region->dev);
- bool is_pmem = strncmp(label_id->id, "pmem", 4) == 0;
int i;
for (i = 0; i < nd_region->ndr_mappings; i++) {
struct nd_mapping *nd_mapping = &nd_region->mapping[i];
resource_size_t rem = n;
- int rc, j;
-
- /*
- * In the BLK case try once with all unallocated PMEM
- * reserved, and once without
- */
- for (j = is_pmem; j < 2; j++) {
- bool blk_only = j == 0;
-
- if (blk_only) {
- rc = reserve_free_pmem(nvdimm_bus, nd_mapping);
- if (rc)
- return rc;
- }
- rem = scan_allocate(nd_region, nd_mapping,
- label_id, rem);
- if (blk_only)
- release_free_pmem(nvdimm_bus, nd_mapping);
-
- /* try again and allow encroachments into PMEM */
- if (rem == 0)
- break;
- }
+ int rc;
+ rem = scan_allocate(nd_region, nd_mapping, label_id, rem);
dev_WARN_ONCE(&nd_region->dev, rem,
"allocation underrun: %#llx of %#llx bytes\n",
(unsigned long long) n - rem,
@@ -966,12 +762,6 @@ static ssize_t __size_store(struct device *dev, unsigned long long val)
uuid = nspm->uuid;
id = nspm->id;
- } else if (is_namespace_blk(dev)) {
- struct nd_namespace_blk *nsblk = to_nd_namespace_blk(dev);
-
- uuid = nsblk->uuid;
- flags = NSLABEL_FLAG_LOCAL;
- id = nsblk->id;
}
/*
@@ -998,8 +788,8 @@ static ssize_t __size_store(struct device *dev, unsigned long long val)
ndd = to_ndd(nd_mapping);
/*
- * All dimms in an interleave set, or the base dimm for a blk
- * region, need to be enabled for the size to be changed.
+ * All dimms in an interleave set, need to be enabled
+ * for the size to be changed.
*/
if (!ndd)
return -ENXIO;
@@ -1067,10 +857,6 @@ static ssize_t size_store(struct device *dev,
struct nd_namespace_pmem *nspm = to_nd_namespace_pmem(dev);
uuid = &nspm->uuid;
- } else if (is_namespace_blk(dev)) {
- struct nd_namespace_blk *nsblk = to_nd_namespace_blk(dev);
-
- uuid = &nsblk->uuid;
}
if (rc == 0 && val == 0 && uuid) {
@@ -1095,8 +881,6 @@ resource_size_t __nvdimm_namespace_capacity(struct nd_namespace_common *ndns)
struct nd_namespace_pmem *nspm = to_nd_namespace_pmem(dev);
return resource_size(&nspm->nsio.res);
- } else if (is_namespace_blk(dev)) {
- return nd_namespace_blk_size(to_nd_namespace_blk(dev));
} else if (is_namespace_io(dev)) {
struct nd_namespace_io *nsio = to_nd_namespace_io(dev);
@@ -1152,12 +936,8 @@ static uuid_t *namespace_to_uuid(struct device *dev)
struct nd_namespace_pmem *nspm = to_nd_namespace_pmem(dev);
return nspm->uuid;
- } else if (is_namespace_blk(dev)) {
- struct nd_namespace_blk *nsblk = to_nd_namespace_blk(dev);
-
- return nsblk->uuid;
- } else
- return ERR_PTR(-ENXIO);
+ }
+ return ERR_PTR(-ENXIO);
}
static ssize_t uuid_show(struct device *dev, struct device_attribute *attr,
@@ -1183,7 +963,6 @@ static int namespace_update_uuid(struct nd_region *nd_region,
struct device *dev, uuid_t *new_uuid,
uuid_t **old_uuid)
{
- u32 flags = is_namespace_blk(dev) ? NSLABEL_FLAG_LOCAL : 0;
struct nd_label_id old_label_id;
struct nd_label_id new_label_id;
int i;
@@ -1214,8 +993,8 @@ static int namespace_update_uuid(struct nd_region *nd_region,
return -EBUSY;
}
- nd_label_gen_id(&old_label_id, *old_uuid, flags);
- nd_label_gen_id(&new_label_id, new_uuid, flags);
+ nd_label_gen_id(&old_label_id, *old_uuid, 0);
+ nd_label_gen_id(&new_label_id, new_uuid, 0);
for (i = 0; i < nd_region->ndr_mappings; i++) {
struct nd_mapping *nd_mapping = &nd_region->mapping[i];
struct nvdimm_drvdata *ndd = to_ndd(nd_mapping);
@@ -1261,10 +1040,6 @@ static ssize_t uuid_store(struct device *dev,
struct nd_namespace_pmem *nspm = to_nd_namespace_pmem(dev);
ns_uuid = &nspm->uuid;
- } else if (is_namespace_blk(dev)) {
- struct nd_namespace_blk *nsblk = to_nd_namespace_blk(dev);
-
- ns_uuid = &nsblk->uuid;
} else
return -ENXIO;
@@ -1313,21 +1088,11 @@ static ssize_t resource_show(struct device *dev,
}
static DEVICE_ATTR_ADMIN_RO(resource);
-static const unsigned long blk_lbasize_supported[] = { 512, 520, 528,
- 4096, 4104, 4160, 4224, 0 };
-
static const unsigned long pmem_lbasize_supported[] = { 512, 4096, 0 };
static ssize_t sector_size_show(struct device *dev,
struct device_attribute *attr, char *buf)
{
- if (is_namespace_blk(dev)) {
- struct nd_namespace_blk *nsblk = to_nd_namespace_blk(dev);
-
- return nd_size_select_show(nsblk->lbasize,
- blk_lbasize_supported, buf);
- }
-
if (is_namespace_pmem(dev)) {
struct nd_namespace_pmem *nspm = to_nd_namespace_pmem(dev);
@@ -1345,12 +1110,7 @@ static ssize_t sector_size_store(struct device *dev,
unsigned long *lbasize;
ssize_t rc = 0;
- if (is_namespace_blk(dev)) {
- struct nd_namespace_blk *nsblk = to_nd_namespace_blk(dev);
-
- lbasize = &nsblk->lbasize;
- supported = blk_lbasize_supported;
- } else if (is_namespace_pmem(dev)) {
+ if (is_namespace_pmem(dev)) {
struct nd_namespace_pmem *nspm = to_nd_namespace_pmem(dev);
lbasize = &nspm->lbasize;
@@ -1390,11 +1150,6 @@ static ssize_t dpa_extents_show(struct device *dev,
uuid = nspm->uuid;
flags = 0;
- } else if (is_namespace_blk(dev)) {
- struct nd_namespace_blk *nsblk = to_nd_namespace_blk(dev);
-
- uuid = nsblk->uuid;
- flags = NSLABEL_FLAG_LOCAL;
}
if (!uuid)
@@ -1627,10 +1382,7 @@ static umode_t namespace_visible(struct kobject *kobj,
{
struct device *dev = container_of(kobj, struct device, kobj);
- if (a == &dev_attr_resource.attr && is_namespace_blk(dev))
- return 0;
-
- if (is_namespace_pmem(dev) || is_namespace_blk(dev)) {
+ if (is_namespace_pmem(dev)) {
if (a == &dev_attr_size.attr)
return 0644;
@@ -1671,22 +1423,11 @@ static const struct device_type namespace_pmem_device_type = {
.groups = nd_namespace_attribute_groups,
};
-static const struct device_type namespace_blk_device_type = {
- .name = "nd_namespace_blk",
- .release = namespace_blk_release,
- .groups = nd_namespace_attribute_groups,
-};
-
static bool is_namespace_pmem(const struct device *dev)
{
return dev ? dev->type == &namespace_pmem_device_type : false;
}
-static bool is_namespace_blk(const struct device *dev)
-{
- return dev ? dev->type == &namespace_blk_device_type : false;
-}
-
static bool is_namespace_io(const struct device *dev)
{
return dev ? dev->type == &namespace_io_device_type : false;
@@ -1769,18 +1510,6 @@ struct nd_namespace_common *nvdimm_namespace_common_probe(struct device *dev)
nspm = to_nd_namespace_pmem(&ndns->dev);
if (uuid_not_set(nspm->uuid, &ndns->dev, __func__))
return ERR_PTR(-ENODEV);
- } else if (is_namespace_blk(&ndns->dev)) {
- struct nd_namespace_blk *nsblk;
-
- nsblk = to_nd_namespace_blk(&ndns->dev);
- if (uuid_not_set(nsblk->uuid, &ndns->dev, __func__))
- return ERR_PTR(-ENODEV);
- if (!nsblk->lbasize) {
- dev_dbg(&ndns->dev, "sector size not set\n");
- return ERR_PTR(-ENODEV);
- }
- if (!nd_namespace_blk_validate(nsblk))
- return ERR_PTR(-ENODEV);
}
return ndns;
@@ -1790,16 +1519,12 @@ EXPORT_SYMBOL(nvdimm_namespace_common_probe);
int devm_namespace_enable(struct device *dev, struct nd_namespace_common *ndns,
resource_size_t size)
{
- if (is_namespace_blk(&ndns->dev))
- return 0;
return devm_nsio_enable(dev, to_nd_namespace_io(&ndns->dev), size);
}
EXPORT_SYMBOL_GPL(devm_namespace_enable);
void devm_namespace_disable(struct device *dev, struct nd_namespace_common *ndns)
{
- if (is_namespace_blk(&ndns->dev))
- return;
devm_nsio_disable(dev, to_nd_namespace_io(&ndns->dev));
}
EXPORT_SYMBOL_GPL(devm_namespace_disable);
@@ -2014,10 +1739,7 @@ static struct device *create_namespace_pmem(struct nd_region *nd_region,
/*
* Fix up each mapping's 'labels' to have the validated pmem label for
* that position at labels[0], and NULL at labels[1]. In the process,
- * check that the namespace aligns with interleave-set. We know
- * that it does not overlap with any blk namespaces by virtue of
- * the dimm being enabled (i.e. nd_label_reserve_dpa()
- * succeeded).
+ * check that the namespace aligns with interleave-set.
*/
nsl_get_uuid(ndd, nd_label, &uuid);
rc = select_pmem_id(nd_region, &uuid);
@@ -2077,54 +1799,6 @@ static struct device *create_namespace_pmem(struct nd_region *nd_region,
return ERR_PTR(rc);
}
-struct resource *nsblk_add_resource(struct nd_region *nd_region,
- struct nvdimm_drvdata *ndd, struct nd_namespace_blk *nsblk,
- resource_size_t start)
-{
- struct nd_label_id label_id;
- struct resource *res;
-
- nd_label_gen_id(&label_id, nsblk->uuid, NSLABEL_FLAG_LOCAL);
- res = krealloc(nsblk->res,
- sizeof(void *) * (nsblk->num_resources + 1),
- GFP_KERNEL);
- if (!res)
- return NULL;
- nsblk->res = (struct resource **) res;
- for_each_dpa_resource(ndd, res)
- if (strcmp(res->name, label_id.id) == 0
- && res->start == start) {
- nsblk->res[nsblk->num_resources++] = res;
- return res;
- }
- return NULL;
-}
-
-static struct device *nd_namespace_blk_create(struct nd_region *nd_region)
-{
- struct nd_namespace_blk *nsblk;
- struct device *dev;
-
- if (!is_nd_blk(&nd_region->dev))
- return NULL;
-
- nsblk = kzalloc(sizeof(*nsblk), GFP_KERNEL);
- if (!nsblk)
- return NULL;
-
- dev = &nsblk->common.dev;
- dev->type = &namespace_blk_device_type;
- nsblk->id = ida_simple_get(&nd_region->ns_ida, 0, 0, GFP_KERNEL);
- if (nsblk->id < 0) {
- kfree(nsblk);
- return NULL;
- }
- dev_set_name(dev, "namespace%d.%d", nd_region->id, nsblk->id);
- dev->parent = &nd_region->dev;
-
- return &nsblk->common.dev;
-}
-
static struct device *nd_namespace_pmem_create(struct nd_region *nd_region)
{
struct nd_namespace_pmem *nspm;
@@ -2163,18 +1837,14 @@ void nd_region_create_ns_seed(struct nd_region *nd_region)
if (nd_region_to_nstype(nd_region) == ND_DEVICE_NAMESPACE_IO)
return;
- if (is_nd_blk(&nd_region->dev))
- nd_region->ns_seed = nd_namespace_blk_create(nd_region);
- else
- nd_region->ns_seed = nd_namespace_pmem_create(nd_region);
+ nd_region->ns_seed = nd_namespace_pmem_create(nd_region);
/*
* Seed creation failures are not fatal, provisioning is simply
* disabled until memory becomes available
*/
if (!nd_region->ns_seed)
- dev_err(&nd_region->dev, "failed to create %s namespace\n",
- is_nd_blk(&nd_region->dev) ? "blk" : "pmem");
+ dev_err(&nd_region->dev, "failed to create namespace\n");
else
nd_device_register(nd_region->ns_seed);
}
@@ -2225,7 +1895,6 @@ static int add_namespace_resource(struct nd_region *nd_region,
for (i = 0; i < count; i++) {
uuid_t *uuid = namespace_to_uuid(devs[i]);
- struct resource *res;
if (IS_ERR(uuid)) {
WARN_ON(1);
@@ -2234,91 +1903,23 @@ static int add_namespace_resource(struct nd_region *nd_region,
if (!nsl_uuid_equal(ndd, nd_label, uuid))
continue;
- if (is_namespace_blk(devs[i])) {
- res = nsblk_add_resource(nd_region, ndd,
- to_nd_namespace_blk(devs[i]),
- nsl_get_dpa(ndd, nd_label));
- if (!res)
- return -ENXIO;
- nd_dbg_dpa(nd_region, ndd, res, "%d assign\n", count);
- } else {
- dev_err(&nd_region->dev,
- "error: conflicting extents for uuid: %pUb\n",
- uuid);
- return -ENXIO;
- }
- break;
+ dev_err(&nd_region->dev,
+ "error: conflicting extents for uuid: %pUb\n", uuid);
+ return -ENXIO;
}
return i;
}
-static struct device *create_namespace_blk(struct nd_region *nd_region,
- struct nd_namespace_label *nd_label, int count)
-{
-
- struct nd_mapping *nd_mapping = &nd_region->mapping[0];
- struct nd_interleave_set *nd_set = nd_region->nd_set;
- struct nvdimm_drvdata *ndd = to_ndd(nd_mapping);
- struct nd_namespace_blk *nsblk;
- char name[NSLABEL_NAME_LEN];
- struct device *dev = NULL;
- struct resource *res;
- uuid_t uuid;
-
- if (!nsl_validate_type_guid(ndd, nd_label, &nd_set->type_guid))
- return ERR_PTR(-EAGAIN);
- if (!nsl_validate_blk_isetcookie(ndd, nd_label, nd_set->cookie2))
- return ERR_PTR(-EAGAIN);
-
- nsblk = kzalloc(sizeof(*nsblk), GFP_KERNEL);
- if (!nsblk)
- return ERR_PTR(-ENOMEM);
- dev = &nsblk->common.dev;
- dev->type = &namespace_blk_device_type;
- dev->parent = &nd_region->dev;
- nsblk->id = -1;
- nsblk->lbasize = nsl_get_lbasize(ndd, nd_label);
- nsl_get_uuid(ndd, nd_label, &uuid);
- nsblk->uuid = kmemdup(&uuid, sizeof(uuid_t), GFP_KERNEL);
- nsblk->common.claim_class = nsl_get_claim_class(ndd, nd_label);
- if (!nsblk->uuid)
- goto blk_err;
- nsl_get_name(ndd, nd_label, name);
- if (name[0]) {
- nsblk->alt_name = kmemdup(name, NSLABEL_NAME_LEN, GFP_KERNEL);
- if (!nsblk->alt_name)
- goto blk_err;
- }
- res = nsblk_add_resource(nd_region, ndd, nsblk,
- nsl_get_dpa(ndd, nd_label));
- if (!res)
- goto blk_err;
- nd_dbg_dpa(nd_region, ndd, res, "%d: assign\n", count);
- return dev;
- blk_err:
- namespace_blk_release(dev);
- return ERR_PTR(-ENXIO);
-}
-
static int cmp_dpa(const void *a, const void *b)
{
const struct device *dev_a = *(const struct device **) a;
const struct device *dev_b = *(const struct device **) b;
- struct nd_namespace_blk *nsblk_a, *nsblk_b;
struct nd_namespace_pmem *nspm_a, *nspm_b;
if (is_namespace_io(dev_a))
return 0;
- if (is_namespace_blk(dev_a)) {
- nsblk_a = to_nd_namespace_blk(dev_a);
- nsblk_b = to_nd_namespace_blk(dev_b);
-
- return memcmp(&nsblk_a->res[0]->start, &nsblk_b->res[0]->start,
- sizeof(resource_size_t));
- }
-
nspm_a = to_nd_namespace_pmem(dev_a);
nspm_b = to_nd_namespace_pmem(dev_b);
@@ -2339,16 +1940,9 @@ static struct device **scan_labels(struct nd_region *nd_region)
list_for_each_entry_safe(label_ent, e, &nd_mapping->labels, list) {
struct nd_namespace_label *nd_label = label_ent->label;
struct device **__devs;
- u32 flags;
if (!nd_label)
continue;
- flags = nsl_get_flags(ndd, nd_label);
- if (is_nd_blk(&nd_region->dev)
- == !!(flags & NSLABEL_FLAG_LOCAL))
- /* pass, region matches label type */;
- else
- continue;
/* skip labels that describe extents outside of the region */
if (nsl_get_dpa(ndd, nd_label) < nd_mapping->start ||
@@ -2367,12 +1961,7 @@ static struct device **scan_labels(struct nd_region *nd_region)
kfree(devs);
devs = __devs;
- if (is_nd_blk(&nd_region->dev))
- dev = create_namespace_blk(nd_region, nd_label, count);
- else
- dev = create_namespace_pmem(nd_region, nd_mapping,
- nd_label);
-
+ dev = create_namespace_pmem(nd_region, nd_mapping, nd_label);
if (IS_ERR(dev)) {
switch (PTR_ERR(dev)) {
case -EAGAIN:
@@ -2389,35 +1978,25 @@ static struct device **scan_labels(struct nd_region *nd_region)
}
- dev_dbg(&nd_region->dev, "discovered %d %s namespace%s\n",
- count, is_nd_blk(&nd_region->dev)
- ? "blk" : "pmem", count == 1 ? "" : "s");
+ dev_dbg(&nd_region->dev, "discovered %d namespace%s\n", count,
+ count == 1 ? "" : "s");
if (count == 0) {
+ struct nd_namespace_pmem *nspm;
+
/* Publish a zero-sized namespace for userspace to configure. */
nd_mapping_free_labels(nd_mapping);
devs = kcalloc(2, sizeof(dev), GFP_KERNEL);
if (!devs)
goto err;
- if (is_nd_blk(&nd_region->dev)) {
- struct nd_namespace_blk *nsblk;
- nsblk = kzalloc(sizeof(*nsblk), GFP_KERNEL);
- if (!nsblk)
- goto err;
- dev = &nsblk->common.dev;
- dev->type = &namespace_blk_device_type;
- } else {
- struct nd_namespace_pmem *nspm;
-
- nspm = kzalloc(sizeof(*nspm), GFP_KERNEL);
- if (!nspm)
- goto err;
- dev = &nspm->nsio.common.dev;
- dev->type = &namespace_pmem_device_type;
- nd_namespace_pmem_set_resource(nd_region, nspm, 0);
- }
+ nspm = kzalloc(sizeof(*nspm), GFP_KERNEL);
+ if (!nspm)
+ goto err;
+ dev = &nspm->nsio.common.dev;
+ dev->type = &namespace_pmem_device_type;
+ nd_namespace_pmem_set_resource(nd_region, nspm, 0);
dev->parent = &nd_region->dev;
devs[count++] = dev;
} else if (is_memory(&nd_region->dev)) {
@@ -2452,10 +2031,7 @@ static struct device **scan_labels(struct nd_region *nd_region)
err:
if (devs) {
for (i = 0; devs[i]; i++)
- if (is_nd_blk(&nd_region->dev))
- namespace_blk_release(devs[i]);
- else
- namespace_pmem_release(devs[i]);
+ namespace_pmem_release(devs[i]);
kfree(devs);
}
return NULL;
@@ -2554,12 +2130,6 @@ static int init_active_labels(struct nd_region *nd_region)
if (!label_ent)
break;
label = nd_label_active(ndd, j);
- if (test_bit(NDD_NOBLK, &nvdimm->flags)) {
- u32 flags = nsl_get_flags(ndd, label);
-
- flags &= ~NSLABEL_FLAG_LOCAL;
- nsl_set_flags(ndd, label, flags);
- }
label_ent->label = label;
mutex_lock(&nd_mapping->lock);
@@ -2603,7 +2173,6 @@ int nd_region_register_namespaces(struct nd_region *nd_region, int *err)
devs = create_namespace_io(nd_region);
break;
case ND_DEVICE_NAMESPACE_PMEM:
- case ND_DEVICE_NAMESPACE_BLK:
devs = create_namespaces(nd_region);
break;
default:
@@ -2618,19 +2187,12 @@ int nd_region_register_namespaces(struct nd_region *nd_region, int *err)
struct device *dev = devs[i];
int id;
- if (type == ND_DEVICE_NAMESPACE_BLK) {
- struct nd_namespace_blk *nsblk;
-
- nsblk = to_nd_namespace_blk(dev);
- id = ida_simple_get(&nd_region->ns_ida, 0, 0,
- GFP_KERNEL);
- nsblk->id = id;
- } else if (type == ND_DEVICE_NAMESPACE_PMEM) {
+ if (type == ND_DEVICE_NAMESPACE_PMEM) {
struct nd_namespace_pmem *nspm;
nspm = to_nd_namespace_pmem(dev);
id = ida_simple_get(&nd_region->ns_ida, 0, 0,
- GFP_KERNEL);
+ GFP_KERNEL);
nspm->id = id;
} else
id = i;