Commit 9d032f42 authored by Dan Williams's avatar Dan Williams

libnvdimm, namespace: do not delete namespace-id 0

Given that the naming of pmem devices changes from the pmemX form to the
pmemX.Y form when namespace id is greater than 0, arrange for namespaces
with id-0 to be exempt from deletion. Otherwise a simple reconfiguration
of an existing namespace to a new mode results in a name change of the
resulting block device:

    # ndctl list --namespace=namespace1.0
    {
      "dev":"namespace1.0",
      "mode":"raw",
      "size":2147483648,
      "uuid":"3dadf3dc-89b9-4b24-b20e-abc8a4707ce3",
      "blockdev":"pmem1"
    }

    # ndctl create-namespace --reconfig=namespace1.0 --mode=memory --force
    {
      "dev":"namespace1.1",
      "mode":"memory",
      "size":2111832064,
      "uuid":"7b4a6341-7318-4219-a02c-fb57c0bbf613",
      "blockdev":"pmem1.1"
    }

This change does require tooling changes to explicitly look for
namespaceX.0 if the seed has already advanced to another namespace.

Cc: <stable@vger.kernel.org>
Fixes: 98a29c39 ("libnvdimm, namespace: allow creation of multiple pmem-namespaces per region")
Reviewed-by: default avatarJohannes Thumshirn <jthumshirn@suse.de>
Signed-off-by: default avatarDan Williams <dan.j.williams@intel.com>
parent 970d14e3
...@@ -962,8 +962,8 @@ static ssize_t __size_store(struct device *dev, unsigned long long val) ...@@ -962,8 +962,8 @@ static ssize_t __size_store(struct device *dev, unsigned long long val)
struct nvdimm_drvdata *ndd; struct nvdimm_drvdata *ndd;
struct nd_label_id label_id; struct nd_label_id label_id;
u32 flags = 0, remainder; u32 flags = 0, remainder;
int rc, i, id = -1;
u8 *uuid = NULL; u8 *uuid = NULL;
int rc, i;
if (dev->driver || ndns->claim) if (dev->driver || ndns->claim)
return -EBUSY; return -EBUSY;
...@@ -972,11 +972,13 @@ static ssize_t __size_store(struct device *dev, unsigned long long val) ...@@ -972,11 +972,13 @@ static ssize_t __size_store(struct device *dev, unsigned long long val)
struct nd_namespace_pmem *nspm = to_nd_namespace_pmem(dev); struct nd_namespace_pmem *nspm = to_nd_namespace_pmem(dev);
uuid = nspm->uuid; uuid = nspm->uuid;
id = nspm->id;
} else if (is_namespace_blk(dev)) { } else if (is_namespace_blk(dev)) {
struct nd_namespace_blk *nsblk = to_nd_namespace_blk(dev); struct nd_namespace_blk *nsblk = to_nd_namespace_blk(dev);
uuid = nsblk->uuid; uuid = nsblk->uuid;
flags = NSLABEL_FLAG_LOCAL; flags = NSLABEL_FLAG_LOCAL;
id = nsblk->id;
} }
/* /*
...@@ -1039,10 +1041,11 @@ static ssize_t __size_store(struct device *dev, unsigned long long val) ...@@ -1039,10 +1041,11 @@ static ssize_t __size_store(struct device *dev, unsigned long long val)
/* /*
* Try to delete the namespace if we deleted all of its * Try to delete the namespace if we deleted all of its
* allocation, this is not the seed device for the region, and * allocation, this is not the seed or 0th device for the
* it is not actively claimed by a btt instance. * region, and it is not actively claimed by a btt, pfn, or dax
* instance.
*/ */
if (val == 0 && nd_region->ns_seed != dev && !ndns->claim) if (val == 0 && id != 0 && nd_region->ns_seed != dev && !ndns->claim)
nd_device_unregister(dev, ND_ASYNC); nd_device_unregister(dev, ND_ASYNC);
return rc; return rc;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment