Re: [PATCH V3 07/20] nvdimm/region_label: Add region label delete support

Neeraj Kumar
2025-10-06T04:53:09Z

[-- Attachment #1: Type: text/plain, Size: 1776 bytes --]

On 22/09/25 02:37PM, Dave Jiang wrote:
>
>> +int nd_pmem_region_label_delete(struct nd_region *nd_region)
>> +{
>> + struct nd_interleave_set *nd_set = nd_region->nd_set;
>> + struct nd_label_ent *label_ent;
>> + int ns_region_cnt = 0;
>> + int i, rc;
>> +
>> + 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) {
>> + dev_info(&nd_region->dev, "Unsupported region label\n");
>> + return -EINVAL;
>> + }
>> +
>> + /* Find if any NS label using this region */
>> + guard(mutex)(&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
>> + * region_uuid in LSA
>> + */
>> + if (nsl_region_uuid_equal(label_ent->label,
>> + &nd_set->uuid))
>> + ns_region_cnt++;
>
>Why not just return -EBUSY here immediately? It seems the code returns -EBUSY as long as there's 1 or more below.
>
>> + }
>> + }
>> +
>> + 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;
>> + }
>
>Can this be folded into the for loop above or does it a full pass to check before starting the label deletion process?
>
>DJ

Yes, if we use "return -EBUSY" in first loop itself then we can call del_labels()
I will fix this in next patch-set

Regards,
Neeraj

[-- Attachment #2: Type: text/plain, Size: 0 bytes --]