aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorDan Williams <dan.j.williams@intel.com>2017-01-24 14:24:07 -0500
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>2017-02-14 18:25:32 -0500
commitebffa7bc77c88218a484a47ab61822943539b252 (patch)
tree8dab3e81ab47b3d4d8ff8182e869091cbc00914b
parent46cf1520ed9167f83196022d651f0625152ea79b (diff)
libnvdimm, namespace: do not delete namespace-id 0
commit 9d032f4201d39e5cf43a8709a047e481f5723fdc upstream. 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. Fixes: 98a29c39dc68 ("libnvdimm, namespace: allow creation of multiple pmem-namespaces per region") Reviewed-by: Johannes Thumshirn <jthumshirn@suse.de> Signed-off-by: Dan Williams <dan.j.williams@intel.com> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
-rw-r--r--drivers/nvdimm/namespace_devs.c11
1 files changed, 7 insertions, 4 deletions
diff --git a/drivers/nvdimm/namespace_devs.c b/drivers/nvdimm/namespace_devs.c
index 1480734c2d6e..aefca644219b 100644
--- a/drivers/nvdimm/namespace_devs.c
+++ b/drivers/nvdimm/namespace_devs.c
@@ -962,8 +962,8 @@ static ssize_t __size_store(struct device *dev, unsigned long long val)
962 struct nvdimm_drvdata *ndd; 962 struct nvdimm_drvdata *ndd;
963 struct nd_label_id label_id; 963 struct nd_label_id label_id;
964 u32 flags = 0, remainder; 964 u32 flags = 0, remainder;
965 int rc, i, id = -1;
965 u8 *uuid = NULL; 966 u8 *uuid = NULL;
966 int rc, i;
967 967
968 if (dev->driver || ndns->claim) 968 if (dev->driver || ndns->claim)
969 return -EBUSY; 969 return -EBUSY;
@@ -972,11 +972,13 @@ static ssize_t __size_store(struct device *dev, unsigned long long val)
972 struct nd_namespace_pmem *nspm = to_nd_namespace_pmem(dev); 972 struct nd_namespace_pmem *nspm = to_nd_namespace_pmem(dev);
973 973
974 uuid = nspm->uuid; 974 uuid = nspm->uuid;
975 id = nspm->id;
975 } else if (is_namespace_blk(dev)) { 976 } else if (is_namespace_blk(dev)) {
976 struct nd_namespace_blk *nsblk = to_nd_namespace_blk(dev); 977 struct nd_namespace_blk *nsblk = to_nd_namespace_blk(dev);
977 978
978 uuid = nsblk->uuid; 979 uuid = nsblk->uuid;
979 flags = NSLABEL_FLAG_LOCAL; 980 flags = NSLABEL_FLAG_LOCAL;
981 id = nsblk->id;
980 } 982 }
981 983
982 /* 984 /*
@@ -1039,10 +1041,11 @@ static ssize_t __size_store(struct device *dev, unsigned long long val)
1039 1041
1040 /* 1042 /*
1041 * Try to delete the namespace if we deleted all of its 1043 * Try to delete the namespace if we deleted all of its
1042 * allocation, this is not the seed device for the region, and 1044 * allocation, this is not the seed or 0th device for the
1043 * it is not actively claimed by a btt instance. 1045 * region, and it is not actively claimed by a btt, pfn, or dax
1046 * instance.
1044 */ 1047 */
1045 if (val == 0 && nd_region->ns_seed != dev && !ndns->claim) 1048 if (val == 0 && id != 0 && nd_region->ns_seed != dev && !ndns->claim)
1046 nd_device_unregister(dev, ND_ASYNC); 1049 nd_device_unregister(dev, ND_ASYNC);
1047 1050
1048 return rc; 1051 return rc;