+++ /dev/null
-From 12e3129e29b406c41bc89231092a20d79dbf802c Mon Sep 17 00:00:00 2001
-From: Keith Busch <keith.busch@intel.com>
-Date: Tue, 24 Jul 2018 15:07:57 -0600
-Subject: libnvdimm: Use max contiguous area for namespace size
-
-From: Keith Busch <keith.busch@intel.com>
-
-commit 12e3129e29b406c41bc89231092a20d79dbf802c upstream.
-
-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>
-Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
-
----
- drivers/nvdimm/dimm_devs.c | 31 +++++++++++++++++++++++++++++++
- drivers/nvdimm/namespace_devs.c | 6 +++---
- drivers/nvdimm/nd-core.h | 8 ++++++++
- drivers/nvdimm/region_devs.c | 24 ++++++++++++++++++++++++
- 4 files changed, 66 insertions(+), 3 deletions(-)
-
---- a/drivers/nvdimm/dimm_devs.c
-+++ b/drivers/nvdimm/dimm_devs.c
-@@ -524,6 +524,37 @@ resource_size_t nd_blk_available_dpa(str
- }
-
- /**
-+ * nd_pmem_max_contiguous_dpa - For the given dimm+region, return the max
-+ * contiguous unallocated dpa range.
-+ * @nd_region: constrain available space check to this reference region
-+ * @nd_mapping: container of dpa-resource-root + labels
-+ */
-+resource_size_t nd_pmem_max_contiguous_dpa(struct nd_region *nd_region,
-+ struct nd_mapping *nd_mapping)
-+{
-+ struct nvdimm_drvdata *ndd = to_ndd(nd_mapping);
-+ struct nvdimm_bus *nvdimm_bus;
-+ resource_size_t max = 0;
-+ struct resource *res;
-+
-+ /* if a dimm is disabled the available capacity is zero */
-+ if (!ndd)
-+ return 0;
-+
-+ nvdimm_bus = walk_to_nvdimm_bus(ndd->dev);
-+ if (__reserve_free_pmem(&nd_region->dev, nd_mapping->nvdimm))
-+ return 0;
-+ for_each_dpa_resource(ndd, res) {
-+ if (strcmp(res->name, "pmem-reserve") != 0)
-+ continue;
-+ if (resource_size(res) > max)
-+ max = resource_size(res);
-+ }
-+ release_free_pmem(nvdimm_bus, nd_mapping);
-+ return max;
-+}
-+
-+/**
- * nd_pmem_available_dpa - for the given dimm+region account unallocated dpa
- * @nd_mapping: container of dpa-resource-root + labels
- * @nd_region: constrain available space check to this reference region
---- a/drivers/nvdimm/namespace_devs.c
-+++ b/drivers/nvdimm/namespace_devs.c
-@@ -799,7 +799,7 @@ static int merge_dpa(struct nd_region *n
- return 0;
- }
-
--static int __reserve_free_pmem(struct device *dev, void *data)
-+int __reserve_free_pmem(struct device *dev, void *data)
- {
- struct nvdimm *nvdimm = data;
- struct nd_region *nd_region;
-@@ -836,7 +836,7 @@ static int __reserve_free_pmem(struct de
- return 0;
- }
-
--static void release_free_pmem(struct nvdimm_bus *nvdimm_bus,
-+void release_free_pmem(struct nvdimm_bus *nvdimm_bus,
- struct nd_mapping *nd_mapping)
- {
- struct nvdimm_drvdata *ndd = to_ndd(nd_mapping);
-@@ -1032,7 +1032,7 @@ static ssize_t __size_store(struct devic
-
- allocated += nvdimm_allocated_dpa(ndd, &label_id);
- }
-- available = nd_region_available_dpa(nd_region);
-+ available = nd_region_allocatable_dpa(nd_region);
-
- if (val > available + allocated)
- return -ENOSPC;
---- a/drivers/nvdimm/nd-core.h
-+++ b/drivers/nvdimm/nd-core.h
-@@ -101,6 +101,14 @@ struct nd_region;
- struct nvdimm_drvdata;
- struct nd_mapping;
- void nd_mapping_free_labels(struct nd_mapping *nd_mapping);
-+
-+int __reserve_free_pmem(struct device *dev, void *data);
-+void release_free_pmem(struct nvdimm_bus *nvdimm_bus,
-+ struct nd_mapping *nd_mapping);
-+
-+resource_size_t nd_pmem_max_contiguous_dpa(struct nd_region *nd_region,
-+ struct nd_mapping *nd_mapping);
-+resource_size_t nd_region_allocatable_dpa(struct nd_region *nd_region);
- resource_size_t nd_pmem_available_dpa(struct nd_region *nd_region,
- struct nd_mapping *nd_mapping, resource_size_t *overlap);
- resource_size_t nd_blk_available_dpa(struct nd_region *nd_region);
---- a/drivers/nvdimm/region_devs.c
-+++ b/drivers/nvdimm/region_devs.c
-@@ -381,6 +381,30 @@ resource_size_t nd_region_available_dpa(
- return available;
- }
-
-+resource_size_t nd_region_allocatable_dpa(struct nd_region *nd_region)
-+{
-+ resource_size_t available = 0;
-+ int i;
-+
-+ if (is_memory(&nd_region->dev))
-+ available = PHYS_ADDR_MAX;
-+
-+ WARN_ON(!is_nvdimm_bus_locked(&nd_region->dev));
-+ for (i = 0; i < nd_region->ndr_mappings; i++) {
-+ struct nd_mapping *nd_mapping = &nd_region->mapping[i];
-+
-+ if (is_memory(&nd_region->dev))
-+ available = min(available,
-+ nd_pmem_max_contiguous_dpa(nd_region,
-+ nd_mapping));
-+ else if (is_nd_blk(&nd_region->dev))
-+ available += nd_blk_available_dpa(nd_region);
-+ }
-+ if (is_memory(&nd_region->dev))
-+ return available * nd_region->ndr_mappings;
-+ return available;
-+}
-+
- static ssize_t available_size_show(struct device *dev,
- struct device_attribute *attr, char *buf)
- {
fb-fix-lost-console-when-the-user-unplugs-a-usb-adapter.patch
udlfb-set-optimal-write-delay.patch
getxattr-use-correct-xattr-length.patch
-libnvdimm-use-max-contiguous-area-for-namespace-size.patch
libnvdimm-fix-ars_status-output-length-calculation.patch
bcache-release-dc-writeback_lock-properly-in-bch_writeback_thread.patch
cap_inode_getsecurity-use-d_find_any_alias-instead-of-d_find_alias.patch
+++ /dev/null
-From 12e3129e29b406c41bc89231092a20d79dbf802c Mon Sep 17 00:00:00 2001
-From: Keith Busch <keith.busch@intel.com>
-Date: Tue, 24 Jul 2018 15:07:57 -0600
-Subject: libnvdimm: Use max contiguous area for namespace size
-
-From: Keith Busch <keith.busch@intel.com>
-
-commit 12e3129e29b406c41bc89231092a20d79dbf802c upstream.
-
-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>
-Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
-
----
- drivers/nvdimm/dimm_devs.c | 31 +++++++++++++++++++++++++++++++
- drivers/nvdimm/namespace_devs.c | 6 +++---
- drivers/nvdimm/nd-core.h | 8 ++++++++
- drivers/nvdimm/region_devs.c | 24 ++++++++++++++++++++++++
- 4 files changed, 66 insertions(+), 3 deletions(-)
-
---- a/drivers/nvdimm/dimm_devs.c
-+++ b/drivers/nvdimm/dimm_devs.c
-@@ -494,6 +494,37 @@ resource_size_t nd_blk_available_dpa(str
- }
-
- /**
-+ * nd_pmem_max_contiguous_dpa - For the given dimm+region, return the max
-+ * contiguous unallocated dpa range.
-+ * @nd_region: constrain available space check to this reference region
-+ * @nd_mapping: container of dpa-resource-root + labels
-+ */
-+resource_size_t nd_pmem_max_contiguous_dpa(struct nd_region *nd_region,
-+ struct nd_mapping *nd_mapping)
-+{
-+ struct nvdimm_drvdata *ndd = to_ndd(nd_mapping);
-+ struct nvdimm_bus *nvdimm_bus;
-+ resource_size_t max = 0;
-+ struct resource *res;
-+
-+ /* if a dimm is disabled the available capacity is zero */
-+ if (!ndd)
-+ return 0;
-+
-+ nvdimm_bus = walk_to_nvdimm_bus(ndd->dev);
-+ if (__reserve_free_pmem(&nd_region->dev, nd_mapping->nvdimm))
-+ return 0;
-+ for_each_dpa_resource(ndd, res) {
-+ if (strcmp(res->name, "pmem-reserve") != 0)
-+ continue;
-+ if (resource_size(res) > max)
-+ max = resource_size(res);
-+ }
-+ release_free_pmem(nvdimm_bus, nd_mapping);
-+ return max;
-+}
-+
-+/**
- * nd_pmem_available_dpa - for the given dimm+region account unallocated dpa
- * @nd_mapping: container of dpa-resource-root + labels
- * @nd_region: constrain available space check to this reference region
---- a/drivers/nvdimm/namespace_devs.c
-+++ b/drivers/nvdimm/namespace_devs.c
-@@ -780,7 +780,7 @@ static int merge_dpa(struct nd_region *n
- return 0;
- }
-
--static int __reserve_free_pmem(struct device *dev, void *data)
-+int __reserve_free_pmem(struct device *dev, void *data)
- {
- struct nvdimm *nvdimm = data;
- struct nd_region *nd_region;
-@@ -817,7 +817,7 @@ static int __reserve_free_pmem(struct de
- return 0;
- }
-
--static void release_free_pmem(struct nvdimm_bus *nvdimm_bus,
-+void release_free_pmem(struct nvdimm_bus *nvdimm_bus,
- struct nd_mapping *nd_mapping)
- {
- struct nvdimm_drvdata *ndd = to_ndd(nd_mapping);
-@@ -1013,7 +1013,7 @@ static ssize_t __size_store(struct devic
-
- allocated += nvdimm_allocated_dpa(ndd, &label_id);
- }
-- available = nd_region_available_dpa(nd_region);
-+ available = nd_region_allocatable_dpa(nd_region);
-
- if (val > available + allocated)
- return -ENOSPC;
---- a/drivers/nvdimm/nd-core.h
-+++ b/drivers/nvdimm/nd-core.h
-@@ -91,6 +91,14 @@ struct nd_region;
- struct nvdimm_drvdata;
- struct nd_mapping;
- void nd_mapping_free_labels(struct nd_mapping *nd_mapping);
-+
-+int __reserve_free_pmem(struct device *dev, void *data);
-+void release_free_pmem(struct nvdimm_bus *nvdimm_bus,
-+ struct nd_mapping *nd_mapping);
-+
-+resource_size_t nd_pmem_max_contiguous_dpa(struct nd_region *nd_region,
-+ struct nd_mapping *nd_mapping);
-+resource_size_t nd_region_allocatable_dpa(struct nd_region *nd_region);
- resource_size_t nd_pmem_available_dpa(struct nd_region *nd_region,
- struct nd_mapping *nd_mapping, resource_size_t *overlap);
- resource_size_t nd_blk_available_dpa(struct nd_region *nd_region);
---- a/drivers/nvdimm/region_devs.c
-+++ b/drivers/nvdimm/region_devs.c
-@@ -320,6 +320,30 @@ resource_size_t nd_region_available_dpa(
- return available;
- }
-
-+resource_size_t nd_region_allocatable_dpa(struct nd_region *nd_region)
-+{
-+ resource_size_t available = 0;
-+ int i;
-+
-+ if (is_memory(&nd_region->dev))
-+ available = PHYS_ADDR_MAX;
-+
-+ WARN_ON(!is_nvdimm_bus_locked(&nd_region->dev));
-+ for (i = 0; i < nd_region->ndr_mappings; i++) {
-+ struct nd_mapping *nd_mapping = &nd_region->mapping[i];
-+
-+ if (is_memory(&nd_region->dev))
-+ available = min(available,
-+ nd_pmem_max_contiguous_dpa(nd_region,
-+ nd_mapping));
-+ else if (is_nd_blk(&nd_region->dev))
-+ available += nd_blk_available_dpa(nd_region);
-+ }
-+ if (is_memory(&nd_region->dev))
-+ return available * nd_region->ndr_mappings;
-+ return available;
-+}
-+
- static ssize_t available_size_show(struct device *dev,
- struct device_attribute *attr, char *buf)
- {
fb-fix-lost-console-when-the-user-unplugs-a-usb-adapter.patch
udlfb-set-optimal-write-delay.patch
getxattr-use-correct-xattr-length.patch
-libnvdimm-use-max-contiguous-area-for-namespace-size.patch
libnvdimm-fix-ars_status-output-length-calculation.patch
bcache-release-dc-writeback_lock-properly-in-bch_writeback_thread.patch
perf-auxtrace-fix-queue-resize.patch