aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorDan Williams <dan.j.williams@intel.com>2017-01-09 20:30:49 -0500
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>2017-01-26 02:24:37 -0500
commit3c4d83a1a41efdf2c191d0072e6545e6bf8ecc94 (patch)
treed5493965e47a900af1307a9be50fc9bf76c6849d
parentf29f3616b9328e17f902f1839634b2440ca07982 (diff)
libnvdimm, namespace: fix pmem namespace leak, delete when size set to zero
commit 1f19b983a8877f81763fab3e693c6befe212736d upstream. Commit 98a29c39dc68 ("libnvdimm, namespace: allow creation of multiple pmem-namespaces per region") added support for establishing additional pmem namespace beyond the seed device, similar to blk namespaces. However, it neglected to delete the namespace when the size is set to zero. Fixes: 98a29c39dc68 ("libnvdimm, namespace: allow creation of multiple pmem-namespaces per region") 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.c23
1 files changed, 10 insertions, 13 deletions
diff --git a/drivers/nvdimm/namespace_devs.c b/drivers/nvdimm/namespace_devs.c
index abe5c6bc756c..1480734c2d6e 100644
--- a/drivers/nvdimm/namespace_devs.c
+++ b/drivers/nvdimm/namespace_devs.c
@@ -957,6 +957,7 @@ static ssize_t __size_store(struct device *dev, unsigned long long val)
957{ 957{
958 resource_size_t allocated = 0, available = 0; 958 resource_size_t allocated = 0, available = 0;
959 struct nd_region *nd_region = to_nd_region(dev->parent); 959 struct nd_region *nd_region = to_nd_region(dev->parent);
960 struct nd_namespace_common *ndns = to_ndns(dev);
960 struct nd_mapping *nd_mapping; 961 struct nd_mapping *nd_mapping;
961 struct nvdimm_drvdata *ndd; 962 struct nvdimm_drvdata *ndd;
962 struct nd_label_id label_id; 963 struct nd_label_id label_id;
@@ -964,7 +965,7 @@ static ssize_t __size_store(struct device *dev, unsigned long long val)
964 u8 *uuid = NULL; 965 u8 *uuid = NULL;
965 int rc, i; 966 int rc, i;
966 967
967 if (dev->driver || to_ndns(dev)->claim) 968 if (dev->driver || ndns->claim)
968 return -EBUSY; 969 return -EBUSY;
969 970
970 if (is_namespace_pmem(dev)) { 971 if (is_namespace_pmem(dev)) {
@@ -1034,20 +1035,16 @@ static ssize_t __size_store(struct device *dev, unsigned long long val)
1034 1035
1035 nd_namespace_pmem_set_resource(nd_region, nspm, 1036 nd_namespace_pmem_set_resource(nd_region, nspm,
1036 val * nd_region->ndr_mappings); 1037 val * nd_region->ndr_mappings);
1037 } else if (is_namespace_blk(dev)) {
1038 struct nd_namespace_blk *nsblk = to_nd_namespace_blk(dev);
1039
1040 /*
1041 * Try to delete the namespace if we deleted all of its
1042 * allocation, this is not the seed device for the
1043 * region, and it is not actively claimed by a btt
1044 * instance.
1045 */
1046 if (val == 0 && nd_region->ns_seed != dev
1047 && !nsblk->common.claim)
1048 nd_device_unregister(dev, ND_ASYNC);
1049 } 1038 }
1050 1039
1040 /*
1041 * Try to delete the namespace if we deleted all of its
1042 * allocation, this is not the seed device for the region, and
1043 * it is not actively claimed by a btt instance.
1044 */
1045 if (val == 0 && nd_region->ns_seed != dev && !ndns->claim)
1046 nd_device_unregister(dev, ND_ASYNC);
1047
1051 return rc; 1048 return rc;
1052} 1049}
1053 1050