Linux-NVME Archive on lore.kernel.org
 help / color / mirror / Atom feed
From: roman.penyaev@profitbricks.com (Roman Pen)
Subject: [PATCH v2 2/8] nvmet-rdma: wrap raw kref_get/put() with corresponding helpers
Date: Mon,  4 Jun 2018 14:29:57 +0200	[thread overview]
Message-ID: <20180604123003.24748-3-roman.penyaev@profitbricks.com> (raw)
In-Reply-To: <20180604123003.24748-1-roman.penyaev@profitbricks.com>

This is just a preparation patch: put kref_put() and kref_get_unless_zero()
inside helpers with more suitable names.

Signed-off-by: Roman Pen <roman.penyaev at profitbricks.de>
Cc: Christoph Hellwig <hch at lst.de>
Cc: Steve Wise <swise at opengridcomputing.com>
Cc: Bart Van Assche <bart.vanassche at sandisk.com>
Cc: Sagi Grimberg <sagi at grimberg.me>
Cc: Doug Ledford <dledford at redhat.com>
Cc: linux-nvme at lists.infradead.org
---
 drivers/nvme/target/rdma.c | 19 ++++++++++++++-----
 1 file changed, 14 insertions(+), 5 deletions(-)

diff --git a/drivers/nvme/target/rdma.c b/drivers/nvme/target/rdma.c
index 52e0c5d579a7..4304b8d8d027 100644
--- a/drivers/nvme/target/rdma.c
+++ b/drivers/nvme/target/rdma.c
@@ -775,7 +775,7 @@ static int nvmet_rdma_init_srq(struct nvmet_rdma_device *ndev)
 	return ret;
 }
 
-static void nvmet_rdma_free_dev(struct kref *ref)
+static void nvmet_rdma_free_device(struct kref *ref)
 {
 	struct nvmet_rdma_device *ndev =
 		container_of(ref, struct nvmet_rdma_device, ref);
@@ -790,6 +790,16 @@ static void nvmet_rdma_free_dev(struct kref *ref)
 	kfree(ndev);
 }
 
+static int nvmet_rdma_dev_put(struct nvmet_rdma_device *dev)
+{
+	return kref_put(&dev->ref, nvmet_rdma_free_device);
+}
+
+static int nvmet_rdma_dev_get(struct nvmet_rdma_device *dev)
+{
+	return kref_get_unless_zero(&dev->ref);
+}
+
 static struct nvmet_rdma_device *
 nvmet_rdma_find_get_device(struct rdma_cm_id *cm_id)
 {
@@ -799,7 +809,7 @@ nvmet_rdma_find_get_device(struct rdma_cm_id *cm_id)
 	mutex_lock(&device_list_mutex);
 	list_for_each_entry(ndev, &device_list, entry) {
 		if (ndev->device->node_guid == cm_id->device->node_guid &&
-		    kref_get_unless_zero(&ndev->ref))
+		    nvmet_rdma_dev_get(ndev))
 			goto out_unlock;
 	}
 
@@ -945,8 +955,7 @@ static void nvmet_rdma_release_queue_work(struct work_struct *w)
 	struct nvmet_rdma_device *dev = queue->dev;
 
 	nvmet_rdma_free_queue(queue);
-
-	kref_put(&dev->ref, nvmet_rdma_free_dev);
+	nvmet_rdma_dev_put(dev);
 }
 
 static int
@@ -1163,7 +1172,7 @@ static int nvmet_rdma_queue_connect(struct rdma_cm_id *cm_id,
 	return 0;
 
 put_device:
-	kref_put(&ndev->ref, nvmet_rdma_free_dev);
+	nvmet_rdma_dev_put(ndev);
 
 	return ret;
 }
-- 
2.13.1

  parent reply	other threads:[~2018-06-04 12:29 UTC|newest]

Thread overview: 12+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-06-04 12:29 [PATCH v2 0/8] use ib_client API to wrap ib_device Roman Pen
2018-06-04 12:29 ` [PATCH v2 1/8] nvme-rdma: " Roman Pen
2018-06-04 21:38   ` Jason Gunthorpe
2018-06-05  8:24     ` Max Gurtovoy
2018-06-05 10:18       ` Roman Penyaev
2018-06-05 10:18     ` Roman Penyaev
2018-06-04 12:29 ` Roman Pen [this message]
2018-06-04 21:49   ` [PATCH v2 2/8] nvmet-rdma: wrap raw kref_get/put() with corresponding helpers Jason Gunthorpe
2018-06-05  4:43     ` Christoph Hellwig
2018-06-05 10:19       ` Roman Penyaev
2018-06-05 10:19     ` Roman Penyaev
2018-06-04 12:29 ` [PATCH v2 3/8] nvmet-rdma: use ib_client API to wrap ib_device Roman Pen

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20180604123003.24748-3-roman.penyaev@profitbricks.com \
    --to=roman.penyaev@profitbricks.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox