[PATCH 8/8] nvmet: make configfs setup namespace aware
Maurizio Lombardi
mlombard at arkamax.eu
Tue Jun 16 02:11:09 PDT 2026
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.
Maurizio
More information about the Linux-nvme
mailing list