On 11/19/25 12:52 AM, Neeraj Kumar wrote:
> During namespace creation we scan labels present in LSA using
> scan_labels(). Currently scan_labels() is only preserving
> namespace labels into label_ent list.
> 
> In this patch we also preserve region label into label_ent list
> 
> Signed-off-by: Neeraj Kumar <[email protected]>

Reviewed-by: Dave Jiang <[email protected]>

> ---
>  drivers/nvdimm/namespace_devs.c | 47 +++++++++++++++++++++++++++++----
>  1 file changed, 42 insertions(+), 5 deletions(-)
> 
> diff --git a/drivers/nvdimm/namespace_devs.c b/drivers/nvdimm/namespace_devs.c
> index b1abbe602a5e..9450200b4470 100644
> --- a/drivers/nvdimm/namespace_devs.c
> +++ b/drivers/nvdimm/namespace_devs.c
> @@ -1999,9 +1999,32 @@ 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 cxl_region_label *region_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) {
> +                             region_label = le->region_label;
> +                             if (!region_label)
> +                                     continue;
> +
> +                             /* Preserve region labels if present */
> +                             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;
> @@ -2013,7 +2036,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;
>  
> @@ -2024,10 +2047,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) {
> +                             /* Preserve region labels */
> +                             if (uuid_equal(&le->label_uuid,
> +                                            &cxl_region_uuid)) {
> +                                     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);


Reply via email to