[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-Id: <20250917132940.1566437-11-s.neeraj@samsung.com>
Date: Wed, 17 Sep 2025 18:59:30 +0530
From: Neeraj Kumar <s.neeraj@...sung.com>
To: linux-cxl@...r.kernel.org, nvdimm@...ts.linux.dev,
linux-kernel@...r.kernel.org, gost.dev@...sung.com
Cc: a.manzanares@...sung.com, vishak.g@...sung.com, neeraj.kernel@...il.com,
Neeraj Kumar <s.neeraj@...sung.com>
Subject: [PATCH V3 10/20] nvdimm/namespace_label: Skip region label during
namespace creation
During namespace creation, skip any region labels found. And Preserve
region label into labels list if present.
Signed-off-by: Neeraj Kumar <s.neeraj@...sung.com>
---
drivers/nvdimm/namespace_devs.c | 52 +++++++++++++++++++++++++++++----
1 file changed, 47 insertions(+), 5 deletions(-)
diff --git a/drivers/nvdimm/namespace_devs.c b/drivers/nvdimm/namespace_devs.c
index 564a73b1da41..735310e6fc11 100644
--- a/drivers/nvdimm/namespace_devs.c
+++ b/drivers/nvdimm/namespace_devs.c
@@ -1979,6 +1979,10 @@ static struct device **scan_labels(struct nd_region *nd_region)
if (!nd_label)
continue;
+ /* Skip region labels if present */
+ if (is_region_label(ndd, (union nd_lsa_label *) nd_label))
+ continue;
+
/* skip labels that describe extents outside of the region */
if (nsl_get_dpa(ndd, nd_label) < nd_mapping->start ||
nsl_get_dpa(ndd, nd_label) > map_end)
@@ -2017,9 +2021,31 @@ static struct device **scan_labels(struct nd_region *nd_region)
if (count == 0) {
struct nd_namespace_pmem *nspm;
+ for (i = 0; i < nd_region->ndr_mappings; i++) {
+ union nd_lsa_label *nd_label;
+ struct nd_label_ent *le, *e;
+ LIST_HEAD(list);
- /* Publish a zero-sized namespace for userspace to configure. */
- nd_mapping_free_labels(nd_mapping);
+ nd_mapping = &nd_region->mapping[i];
+ if (list_empty(&nd_mapping->labels))
+ continue;
+
+ list_for_each_entry_safe(le, e, &nd_mapping->labels,
+ list) {
+ nd_label = (union nd_lsa_label *) le->label;
+
+ /* Preserve region labels if present */
+ if (is_region_label(ndd, nd_label))
+ list_move_tail(&le->list, &list);
+ }
+
+ /*
+ * Publish a zero-sized namespace for userspace
+ * to configure.
+ */
+ nd_mapping_free_labels(nd_mapping);
+ list_splice_init(&list, &nd_mapping->labels);
+ }
nspm = kzalloc(sizeof(*nspm), GFP_KERNEL);
if (!nspm)
goto err;
@@ -2031,7 +2057,8 @@ static struct device **scan_labels(struct nd_region *nd_region)
} else if (is_memory(&nd_region->dev)) {
/* clean unselected labels */
for (i = 0; i < nd_region->ndr_mappings; i++) {
- struct list_head *l, *e;
+ union nd_lsa_label *nd_label;
+ struct nd_label_ent *le, *e;
LIST_HEAD(list);
int j;
@@ -2042,10 +2069,25 @@ static struct device **scan_labels(struct nd_region *nd_region)
}
j = count;
- list_for_each_safe(l, e, &nd_mapping->labels) {
+ list_for_each_entry_safe(le, e, &nd_mapping->labels,
+ list) {
+ nd_label = (union nd_lsa_label *) le->label;
+
+ /* Preserve region labels */
+ if (is_region_label(ndd, nd_label)) {
+ list_move_tail(&le->list, &list);
+ continue;
+ }
+
+ /*
+ * Once preserving selected ns label done
+ * break out of loop
+ */
if (!j--)
break;
- list_move_tail(l, &list);
+
+ /* Preserve selected ns label */
+ list_move_tail(&le->list, &list);
}
nd_mapping_free_labels(nd_mapping);
list_splice_init(&list, &nd_mapping->labels);
--
2.34.1
Powered by blists - more mailing lists