[PATCH WIP/RFC v3 3/6] nvme_rdma: keep a ref on the ctrl during delete/flush

Sagi Grimberg sagi at grimberg.me
Wed Aug 31 23:40:08 PDT 2016


> Oh. :)
>
> Does this fully avoid the race?
>
> @@ -1671,7 +1671,8 @@ static int nvme_rdma_del_ctrl(struct nvme_ctrl *nctrl)
>          * Keep a reference until all work is flushed since
>          * __nvme_rdma_del_ctrl can free the ctrl mem
>          */
> -       kref_get(&ctrl->ctrl.kref);
> +       if (!kref_get_unless_zero(&ctrl->ctrl.kref))
> +               return -ENOMEM;

We shouldn't return -ENOMEM failure because we'll only get it if
someone else already deleted the controller, -EBUSY is more appropriate.



More information about the Linux-nvme mailing list