summaryrefslogtreecommitdiffstats
path: root/drivers/nvme
diff options
context:
space:
mode:
authorSteve Wise <swise@opengridcomputing.com>2016-09-01 18:12:25 +0200
committerSagi Grimberg <sagi@grimberg.me>2016-09-04 09:00:53 +0200
commitcdbecc8d24b642b67ae79a0acc2ff18d3d0e677e (patch)
tree00ff4a84a7f5dd39dee42fc589aefbee12abb77d /drivers/nvme
parentiw_cxgb4: block module unload until all ep resources are released (diff)
downloadlinux-cdbecc8d24b642b67ae79a0acc2ff18d3d0e677e.tar.xz
linux-cdbecc8d24b642b67ae79a0acc2ff18d3d0e677e.zip
nvme_rdma: keep a ref on the ctrl during delete/flush
Reviewed-by: Christoph Hellwig <hch@lst.de> Reviewed-by: Sagi Grimberg <sagi@grimbrg.me> Signed-off-by: Steve Wise <swise@opengridcomputing.com> Signed-off-by: Sagi Grimberg <sagi@grimberg.me>
Diffstat (limited to 'drivers/nvme')
-rw-r--r--drivers/nvme/host/rdma.c26
1 files changed, 18 insertions, 8 deletions
diff --git a/drivers/nvme/host/rdma.c b/drivers/nvme/host/rdma.c
index ab545fb347a0..15b0c1d025f5 100644
--- a/drivers/nvme/host/rdma.c
+++ b/drivers/nvme/host/rdma.c
@@ -1351,9 +1351,15 @@ static int nvme_rdma_device_unplug(struct nvme_rdma_queue *queue)
ret = 1;
}
- /* Queue controller deletion */
+ /*
+ * Queue controller deletion. Keep a reference until all
+ * work is flushed since delete_work will free the ctrl mem
+ */
+ kref_get(&ctrl->ctrl.kref);
queue_work(nvme_rdma_wq, &ctrl->delete_work);
flush_work(&ctrl->delete_work);
+ nvme_put_ctrl(&ctrl->ctrl);
+
return ret;
}
@@ -1700,15 +1706,19 @@ static int __nvme_rdma_del_ctrl(struct nvme_rdma_ctrl *ctrl)
static int nvme_rdma_del_ctrl(struct nvme_ctrl *nctrl)
{
struct nvme_rdma_ctrl *ctrl = to_rdma_ctrl(nctrl);
- int ret;
+ int ret = 0;
+ /*
+ * Keep a reference until all work is flushed since
+ * __nvme_rdma_del_ctrl can free the ctrl mem
+ */
+ if (!kref_get_unless_zero(&ctrl->ctrl.kref))
+ return -EBUSY;
ret = __nvme_rdma_del_ctrl(ctrl);
- if (ret)
- return ret;
-
- flush_work(&ctrl->delete_work);
-
- return 0;
+ if (!ret)
+ flush_work(&ctrl->delete_work);
+ nvme_put_ctrl(&ctrl->ctrl);
+ return ret;
}
static void nvme_rdma_remove_ctrl_work(struct work_struct *work)