[<prev] [next>] [<thread-prev] [day] [month] [year] [list]
Message-ID: <20250623100957.000032a2@huawei.com>
Date: Mon, 23 Jun 2025 10:09:57 +0100
From: Jonathan Cameron <Jonathan.Cameron@...wei.com>
To: Neeraj Kumar <s.neeraj@...sung.com>
CC: <dan.j.williams@...el.com>, <dave@...olabs.net>, <dave.jiang@...el.com>,
<alison.schofield@...el.com>, <vishal.l.verma@...el.com>,
<ira.weiny@...el.com>, <a.manzanares@...sung.com>, <nifan.cxl@...il.com>,
<anisa.su@...sung.com>, <vishak.g@...sung.com>, <krish.reddy@...sung.com>,
<arun.george@...sung.com>, <alok.rathore@...sung.com>,
<neeraj.kernel@...il.com>, <linux-kernel@...r.kernel.org>,
<linux-cxl@...r.kernel.org>, <nvdimm@...ts.linux.dev>,
<gost.dev@...sung.com>, <cpgs@...sung.com>
Subject: Re: [RFC PATCH 06/20] nvdimm/region_label: Add region label
deletion routine
On Tue, 17 Jun 2025 18:09:30 +0530
Neeraj Kumar <s.neeraj@...sung.com> wrote:
> Added cxl v2.1 format region label deletion routine. This function is
> used to delete region label from LSA
>
> Signed-off-by: Neeraj Kumar <s.neeraj@...sung.com>
> ---
> drivers/nvdimm/label.c | 75 ++++++++++++++++++++++++++++++---
> drivers/nvdimm/label.h | 6 +++
> drivers/nvdimm/namespace_devs.c | 12 ++++++
> drivers/nvdimm/nd.h | 9 ++++
> include/linux/libnvdimm.h | 1 +
> 5 files changed, 98 insertions(+), 5 deletions(-)
>
> diff --git a/drivers/nvdimm/label.c b/drivers/nvdimm/label.c
> index 7f33d14ce0ef..9381c50086fc 100644
> --- a/drivers/nvdimm/label.c
> +++ b/drivers/nvdimm/label.c
> @@ -1034,7 +1034,8 @@ static int init_labels(struct nd_mapping *nd_mapping, int num_labels)
> return max(num_labels, old_num_labels);
> }
>
> -static int del_labels(struct nd_mapping *nd_mapping, uuid_t *uuid)
> +static int del_labels(struct nd_mapping *nd_mapping, uuid_t *uuid,
> + enum label_type ltype)
> {
> struct nvdimm_drvdata *ndd = to_ndd(nd_mapping);
> struct nd_label_ent *label_ent, *e;
> @@ -1058,8 +1059,18 @@ static int del_labels(struct nd_mapping *nd_mapping, uuid_t *uuid)
> if (!nd_label)
> continue;
> active++;
> - if (!nsl_uuid_equal(ndd, &nd_label->ns_label, uuid))
> - continue;
> +
> + if (ltype == NS_LABEL_TYPE) {
Perhaps a switch is more appropriate here.
> + if (!nsl_uuid_equal(ndd, &nd_label->ns_label, uuid))
> + continue;
> + } else if (ltype == RG_LABEL_TYPE) {
> + if (!nsl_uuid_equal(ndd, &nd_label->ns_label, uuid))
> + continue;
> + } else {
> + dev_err(ndd->dev, "Invalid label type\n");
> + return 0;
> + }
> +
> active--;
> slot = to_slot(ndd, nd_label);
> nd_label_free_slot(ndd, slot);
> @@ -1259,6 +1271,59 @@ int nd_pmem_region_label_update(struct nd_region *nd_region)
> return 0;
> }
>
> +int nd_pmem_region_label_delete(struct nd_region *nd_region)
> +{
> + int i, rc;
> + struct nd_interleave_set *nd_set = nd_region->nd_set;
> + struct nd_label_ent *label_ent;
> + bool is_non_rgl = false;
> + int ns_region_cnt = 0;
> +
> + for (i = 0; i < nd_region->ndr_mappings; i++) {
> + struct nd_mapping *nd_mapping = &nd_region->mapping[i];
> + struct nvdimm_drvdata *ndd = to_ndd(nd_mapping);
> +
> + /* Find non cxl format supported ndr_mappings */
> + if (!ndd->cxl)
> + is_non_rgl = true;
> +
> + /* Find if any NS label using this region */
> + mutex_lock(&nd_mapping->lock);
> + list_for_each_entry(label_ent, &nd_mapping->labels, list) {
> + if (!label_ent->label)
> + continue;
> +
> + /* Check if any available NS labels has same
Looks like wrong style for multiline comments in this file.
/*
* Check ...
> + * region_uuid in LSA
> + */
> + if (nsl_region_uuid_equal(&label_ent->label->ns_label,
> + &nd_set->uuid))
> + ns_region_cnt++;
> + }
> + mutex_unlock(&nd_mapping->lock);
> + }
> +
> + if (is_non_rgl) {
> + dev_dbg(&nd_region->dev, "Region label deletion unsupported\n");
> + return -EINVAL;
Why not bail out where you originally detect that above?
> + }
> +
> + if (ns_region_cnt) {
> + dev_dbg(&nd_region->dev, "Region/Namespace label in use\n");
> + return -EBUSY;
> + }
> +
> + for (i = 0; i < nd_region->ndr_mappings; i++) {
> + struct nd_mapping *nd_mapping = &nd_region->mapping[i];
> +
> + rc = del_labels(nd_mapping, &nd_set->uuid, RG_LABEL_TYPE);
> + if (rc)
> + return rc;
> + }
> +
> + return 0;
> +}
Powered by blists - more mailing lists