[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-Id: <1479708496-9828-6-git-send-email-binoy.jayan@linaro.org>
Date: Mon, 21 Nov 2016 11:38:12 +0530
From: Binoy Jayan <binoy.jayan@...aro.org>
To: Doug Ledford <dledford@...hat.com>,
Sean Hefty <sean.hefty@...el.com>,
Sagi Grimberg <sagi@...mberg.me>,
Hal Rosenstock <hal.rosenstock@...il.com>,
Leon Romanovsky <leonro@...lanox.com>,
Sagi Grimberg <sagig@...lanox.com>,
Bart Van Assche <bart.vanassche@...disk.com>,
Nicholas Bellinger <nab@...ux-iscsi.org>,
Jenny Derzhavetz <jennyf@...lanox.com>,
Ira Weiny <ira.weiny@...el.com>,
Steve Wise <swise@...ngridcomputing.com>,
Mark Bloch <markb@...lanox.com>,
Tatyana E Nikolova <tatyana.e.nikolova@...el.com>,
Matan Barak <matanb@...lanox.com>,
Lijun Ou <oulijun@...wei.com>,
"Wei Hu(Xavier)" <xavier.huwei@...wei.com>
Cc: Faisal Latif <faisal.latif@...el.com>,
Mustafa Ismail <mustafa.ismail@...el.com>,
Mark Brown <broonie@...nel.org>, Arnd Bergmann <arnd@...db.de>,
linux-rdma@...r.kernel.org, linux-kernel@...r.kernel.org,
target-devel@...r.kernel.org, Binoy Jayan <binoy.jayan@...aro.org>
Subject: [PATCH v5 5/9] IB/isert: Replace semaphore sem with completion
The semaphore 'sem' in isert_device is used as completion, but in a
counting fashion as isert_connected_handler could be called multiple times
during which it allows for that number of waiters (isert_accept_np) to
continue without blocking, each consuming one node out from the list
isert_np-pending in the same order in which they were enqueued (FIFO). So,
convert it to struct completion. Semaphores are going away in the future.
Signed-off-by: Binoy Jayan <binoy.jayan@...aro.org>
---
drivers/infiniband/ulp/isert/ib_isert.c | 6 +++---
drivers/infiniband/ulp/isert/ib_isert.h | 3 ++-
2 files changed, 5 insertions(+), 4 deletions(-)
diff --git a/drivers/infiniband/ulp/isert/ib_isert.c b/drivers/infiniband/ulp/isert/ib_isert.c
index 6dd43f6..de80f56 100644
--- a/drivers/infiniband/ulp/isert/ib_isert.c
+++ b/drivers/infiniband/ulp/isert/ib_isert.c
@@ -619,7 +619,7 @@
mutex_unlock(&isert_np->mutex);
isert_info("np %p: Allow accept_np to continue\n", isert_np);
- up(&isert_np->sem);
+ complete(&isert_np->comp);
}
static void
@@ -2311,7 +2311,7 @@ struct rdma_cm_id *
isert_err("Unable to allocate struct isert_np\n");
return -ENOMEM;
}
- sema_init(&isert_np->sem, 0);
+ init_completion(&isert_np->comp);
mutex_init(&isert_np->mutex);
INIT_LIST_HEAD(&isert_np->accepted);
INIT_LIST_HEAD(&isert_np->pending);
@@ -2427,7 +2427,7 @@ struct rdma_cm_id *
int ret;
accept_wait:
- ret = down_interruptible(&isert_np->sem);
+ ret = wait_for_completion_interruptible(&isert_np->comp);
if (ret)
return -ENODEV;
diff --git a/drivers/infiniband/ulp/isert/ib_isert.h b/drivers/infiniband/ulp/isert/ib_isert.h
index c02ada5..a1277c0 100644
--- a/drivers/infiniband/ulp/isert/ib_isert.h
+++ b/drivers/infiniband/ulp/isert/ib_isert.h
@@ -3,6 +3,7 @@
#include <linux/in6.h>
#include <rdma/ib_verbs.h>
#include <rdma/rdma_cm.h>
+#include <linux/completion.h>
#include <rdma/rw.h>
#include <scsi/iser.h>
@@ -190,7 +191,7 @@ struct isert_device {
struct isert_np {
struct iscsi_np *np;
- struct semaphore sem;
+ struct completion comp;
struct rdma_cm_id *cm_id;
struct mutex mutex;
struct list_head accepted;
--
The Qualcomm Innovation Center, Inc. is a member of the Code Aurora Forum,
a Linux Foundation Collaborative Project
Powered by blists - more mailing lists