[PATCH 8/8] nvmet: make configfs setup namespace aware

Hannes Reinecke hare at suse.de
Tue Jun 16 02:33:32 PDT 2026


On 6/16/26 11:11, Maurizio Lombardi wrote:
> On Sat Jun 13, 2026 at 1:14 PM CEST, Hannes Reinecke wrote:
>> Implement 'fill_subsystem' and 'clear_subsystem' callbacks to make
>> nvmet configfs namespace aware.
>>
>> +static int nvmet_add_port_list(u64 ns_id, struct nvmet_port *p)
>> +{
>> +	struct list_head *port_list;
>> +
>> +	mutex_lock(&nvmet_ports_mutex);
>> +	port_list = idr_find(&nvmet_ports_idr, ns_id);
>> +	if (!port_list) {
>> +		int err;
>> +
>> +		port_list = kzalloc_obj(*port_list);
>> +		if (!port_list)
>> +			return -ENOMEM;
>> +		INIT_LIST_HEAD(port_list);
>> +		err = idr_alloc(&nvmet_ports_idr, port_list,
>> +				ns_id, ns_id + 1, GFP_KERNEL);
>> +		if (err < 0) {
>> +			kfree(port_list);
>> +			return err;
>> +		}
>> +		WARN_ON(err != ns_id);
>> +	}
>> +	list_add(&p->global_entry, port_list);
>> +	mutex_unlock(&nvmet_ports_mutex);
>> +	return 0;
>> +}
> 
> Just a minor thing that I noticed: the error paths leave the mutex
> locked.
> 
Oh. And so they do. Thanks for pointing it out.
(Sashiko already told me, but nevertheless :-)

Cheers,

Hannes
-- 
Dr. Hannes Reinecke                  Kernel Storage Architect
hare at suse.de                                +49 911 74053 688
SUSE Software Solutions GmbH, Frankenstr. 146, 90461 Nürnberg
HRB 36809 (AG Nürnberg), GF: I. Totev, A. McDonald, W. Knoblich



More information about the Linux-nvme mailing list