On 23/06/25 10:17AM, Jonathan Cameron wrote:
On Tue, 17 Jun 2025 18:09:36 +0530
Neeraj Kumar <s.nee...@samsung.com> wrote:
During namespace creation skip presence of region label if present.
Also preserve region label into labels list if present.
Signed-off-by: Neeraj Kumar <s.nee...@samsung.com>
---
drivers/nvdimm/namespace_devs.c | 48 +++++++++++++++++++++++++++++----
1 file changed, 43 insertions(+), 5 deletions(-)
diff --git a/drivers/nvdimm/namespace_devs.c b/drivers/nvdimm/namespace_devs.c
index b081661b7aaa..ca8f8546170c 100644
--- a/drivers/nvdimm/namespace_devs.c
+++ b/drivers/nvdimm/namespace_devs.c
@@ -1976,6 +1976,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, nd_label))
+ continue;
+
/* skip labels that describe extents outside of the region */
if (nsl_get_dpa(ndd, &nd_label->ns_label) < nd_mapping->start ||
nsl_get_dpa(ndd, &nd_label->ns_label) > map_end)
@@ -2014,9 +2018,29 @@ 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++) {
+ 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) {
+ struct nd_lsa_label *nd_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
Comment syntax as before looks to be inconsistent with file.
Thanks, Will update it everywhere its inconsistent.
+ * 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;
@@ -2028,7 +2052,7 @@ 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;
+ struct nd_label_ent *le, *e;
LIST_HEAD(list);
int j;
@@ -2039,10 +2063,24 @@ 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) {
+ struct nd_lsa_label *nd_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
Comment syntax.
Sure, Will fix it up
+ * 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);