aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/nvdimm/namespace_devs.c
diff options
context:
space:
mode:
authorKeith Busch <keith.busch@intel.com>2018-07-24 17:07:57 -0400
committerDave Jiang <dave.jiang@intel.com>2018-07-25 17:11:09 -0400
commit12e3129e29b406c41bc89231092a20d79dbf802c (patch)
treed774b3a77f6b9f457ae974847d55831172b1fb0f /drivers/nvdimm/namespace_devs.c
parent06cb081a92e4b66c1ad3bf8d7b5830378e857eda (diff)
libnvdimm: Use max contiguous area for namespace size
This patch will find the max contiguous area to determine the largest pmem namespace size that can be created. If the requested size exceeds the largest available, ENOSPC error will be returned. This fixes the allocation underrun error and wrong error return code that have otherwise been observed as the following kernel warning: WARNING: CPU: <CPU> PID: <PID> at drivers/nvdimm/namespace_devs.c:913 size_store Fixes: a1f3e4d6a0c3 ("libnvdimm, region: update nd_region_available_dpa() for multi-pmem support") Cc: <stable@vger.kernel.org> Signed-off-by: Keith Busch <keith.busch@intel.com> Reviewed-by: Vishal Verma <vishal.l.verma@intel.com> Signed-off-by: Dave Jiang <dave.jiang@intel.com>
Diffstat (limited to 'drivers/nvdimm/namespace_devs.c')
-rw-r--r--drivers/nvdimm/namespace_devs.c6
1 files changed, 3 insertions, 3 deletions
diff --git a/drivers/nvdimm/namespace_devs.c b/drivers/nvdimm/namespace_devs.c
index cb322f2bc605..4a4266250c28 100644
--- a/drivers/nvdimm/namespace_devs.c
+++ b/drivers/nvdimm/namespace_devs.c
@@ -799,7 +799,7 @@ static int merge_dpa(struct nd_region *nd_region,
799 return 0; 799 return 0;
800} 800}
801 801
802static int __reserve_free_pmem(struct device *dev, void *data) 802int __reserve_free_pmem(struct device *dev, void *data)
803{ 803{
804 struct nvdimm *nvdimm = data; 804 struct nvdimm *nvdimm = data;
805 struct nd_region *nd_region; 805 struct nd_region *nd_region;
@@ -836,7 +836,7 @@ static int __reserve_free_pmem(struct device *dev, void *data)
836 return 0; 836 return 0;
837} 837}
838 838
839static void release_free_pmem(struct nvdimm_bus *nvdimm_bus, 839void release_free_pmem(struct nvdimm_bus *nvdimm_bus,
840 struct nd_mapping *nd_mapping) 840 struct nd_mapping *nd_mapping)
841{ 841{
842 struct nvdimm_drvdata *ndd = to_ndd(nd_mapping); 842 struct nvdimm_drvdata *ndd = to_ndd(nd_mapping);
@@ -1032,7 +1032,7 @@ static ssize_t __size_store(struct device *dev, unsigned long long val)
1032 1032
1033 allocated += nvdimm_allocated_dpa(ndd, &label_id); 1033 allocated += nvdimm_allocated_dpa(ndd, &label_id);
1034 } 1034 }
1035 available = nd_region_available_dpa(nd_region); 1035 available = nd_region_allocatable_dpa(nd_region);
1036 1036
1037 if (val > available + allocated) 1037 if (val > available + allocated)
1038 return -ENOSPC; 1038 return -ENOSPC;