[PATCH V3 10/10] nvmet: use xarray for ctrl ns storing
Christoph Hellwig
hch at lst.de
Wed Jul 15 03:10:27 EDT 2020
> index 9cdc39c8b729..2908acc7b1e2 100644
> --- a/drivers/nvme/target/core.c
> +++ b/drivers/nvme/target/core.c
> @@ -115,13 +115,14 @@ u16 nvmet_zero_sgl(struct nvmet_req *req, off_t off, size_t len)
>
> static unsigned int nvmet_max_nsid(struct nvmet_subsys *subsys)
> {
> - struct nvmet_ns *ns;
> + unsigned long nsid = 0;
> + struct nvmet_ns *cur;
> + unsigned long idx;
>
> - if (list_empty(&subsys->namespaces))
> - return 0;
> + xa_for_each(&subsys->namespaces, idx, cur)
> + nsid = cur->nsid;
>
> - ns = list_last_entry(&subsys->namespaces, struct nvmet_ns, dev_link);
> - return ns->nsid;
> + return nsid;
> }
If Matthew wants to add a helper to return the highest id for an xarray
this would be the place to use it.
> + ret = xa_insert(&subsys->namespaces, ns->nsid, ns, GFP_KERNEL);
> + if (ret)
> + goto out_dev_put;
I don't think out_dev_put is enough here as that fails to tear down
ns->ref.
More information about the Linux-nvme
mailing list