Re: [RFC 2/5] nvmet-rdma: use ib_client API to wrap ib_device

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 





On 05/15/2018 06:15 PM, Roman Pen wrote:
ib_client API provides a way to wrap an ib_device with a specific ULP
structure.  Using that API local lists and mutexes can be completely
avoided and allocation/removal paths become a bit cleaner.

Signed-off-by: Roman Pen <roman.penyaev@xxxxxxxxxxxxxxx>
Cc: Christoph Hellwig <hch@xxxxxx>
Cc: Steve Wise <swise@xxxxxxxxxxxxxxxxxxxxx>
Cc: Bart Van Assche <bart.vanassche@xxxxxxxxxxx>
Cc: Sagi Grimberg <sagi@xxxxxxxxxxx>
Cc: Doug Ledford <dledford@xxxxxxxxxx>
---
  drivers/nvme/target/rdma.c | 85 ++++++++++++++++++++++++----------------------
  1 file changed, 45 insertions(+), 40 deletions(-)

diff --git a/drivers/nvme/target/rdma.c b/drivers/nvme/target/rdma.c
index 52e0c5d579a7..59f937aa4728 100644
--- a/drivers/nvme/target/rdma.c
+++ b/drivers/nvme/target/rdma.c
@@ -125,9 +125,7 @@ MODULE_PARM_DESC(use_srq, "Use shared receive queue.");
  static DEFINE_IDA(nvmet_rdma_queue_ida);
  static LIST_HEAD(nvmet_rdma_queue_list);
  static DEFINE_MUTEX(nvmet_rdma_queue_mutex);
-
-static LIST_HEAD(device_list);
-static DEFINE_MUTEX(device_list_mutex);
+static struct ib_client nvmet_rdma_ib_client;
static bool nvmet_rdma_execute_command(struct nvmet_rdma_rsp *rsp);
  static void nvmet_rdma_send_done(struct ib_cq *cq, struct ib_wc *wc);
@@ -780,38 +778,49 @@ static void nvmet_rdma_free_dev(struct kref *ref)
  	struct nvmet_rdma_device *ndev =
  		container_of(ref, struct nvmet_rdma_device, ref);
- mutex_lock(&device_list_mutex);
-	list_del(&ndev->entry);
-	mutex_unlock(&device_list_mutex);
-
+	ib_set_client_data(ndev->device, &nvmet_rdma_ib_client, NULL);
  	nvmet_rdma_destroy_srq(ndev);
  	ib_dealloc_pd(ndev->pd);
-
  	kfree(ndev);
  }
+static int nvmet_rdma_dev_put(struct nvmet_rdma_device *dev)
+{
+	return kref_put(&dev->ref, nvmet_rdma_free_dev);
+}
+
+static int nvmet_rdma_dev_get(struct nvmet_rdma_device *dev)
+{
+	return kref_get_unless_zero(&dev->ref);
+}
+

This can be split to a prep patch.

Other than that looks good IMO
--
To unsubscribe from this list: send the line "unsubscribe linux-rdma" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html



[Index of Archives]     [Linux USB Devel]     [Video for Linux]     [Linux Audio Users]     [Photo]     [Yosemite News]     [Yosemite Photos]     [Linux Kernel]     [Linux SCSI]     [XFree86]

  Powered by Linux