Commit 2d67017c authored by Bart Van Assche's avatar Bart Van Assche Committed by Doug Ledford

IB/srpt: Micro-optimize I/O context state manipulation

Since all I/O context state changes are already serialized, it is
not necessary to protect I/O context state changes with the I/O
context spinlock. Hence remove that spinlock.
Signed-off-by: default avatarBart Van Assche <bart.vanassche@wdc.com>
Signed-off-by: default avatarDoug Ledford <dledford@redhat.com>
parent dd3bec86
...@@ -764,15 +764,10 @@ static enum srpt_command_state srpt_set_cmd_state(struct srpt_send_ioctx *ioctx, ...@@ -764,15 +764,10 @@ static enum srpt_command_state srpt_set_cmd_state(struct srpt_send_ioctx *ioctx,
enum srpt_command_state new) enum srpt_command_state new)
{ {
enum srpt_command_state previous; enum srpt_command_state previous;
unsigned long flags;
BUG_ON(!ioctx);
spin_lock_irqsave(&ioctx->spinlock, flags);
previous = ioctx->state; previous = ioctx->state;
if (previous != SRPT_STATE_DONE) if (previous != SRPT_STATE_DONE)
ioctx->state = new; ioctx->state = new;
spin_unlock_irqrestore(&ioctx->spinlock, flags);
return previous; return previous;
} }
...@@ -790,17 +785,15 @@ static bool srpt_test_and_set_cmd_state(struct srpt_send_ioctx *ioctx, ...@@ -790,17 +785,15 @@ static bool srpt_test_and_set_cmd_state(struct srpt_send_ioctx *ioctx,
enum srpt_command_state new) enum srpt_command_state new)
{ {
enum srpt_command_state previous; enum srpt_command_state previous;
unsigned long flags;
WARN_ON(!ioctx); WARN_ON(!ioctx);
WARN_ON(old == SRPT_STATE_DONE); WARN_ON(old == SRPT_STATE_DONE);
WARN_ON(new == SRPT_STATE_NEW); WARN_ON(new == SRPT_STATE_NEW);
spin_lock_irqsave(&ioctx->spinlock, flags);
previous = ioctx->state; previous = ioctx->state;
if (previous == old) if (previous == old)
ioctx->state = new; ioctx->state = new;
spin_unlock_irqrestore(&ioctx->spinlock, flags);
return previous == old; return previous == old;
} }
...@@ -1170,7 +1163,6 @@ static struct srpt_send_ioctx *srpt_get_send_ioctx(struct srpt_rdma_ch *ch) ...@@ -1170,7 +1163,6 @@ static struct srpt_send_ioctx *srpt_get_send_ioctx(struct srpt_rdma_ch *ch)
return ioctx; return ioctx;
BUG_ON(ioctx->ch != ch); BUG_ON(ioctx->ch != ch);
spin_lock_init(&ioctx->spinlock);
ioctx->state = SRPT_STATE_NEW; ioctx->state = SRPT_STATE_NEW;
ioctx->n_rdma = 0; ioctx->n_rdma = 0;
ioctx->n_rw_ctx = 0; ioctx->n_rw_ctx = 0;
...@@ -1192,7 +1184,6 @@ static struct srpt_send_ioctx *srpt_get_send_ioctx(struct srpt_rdma_ch *ch) ...@@ -1192,7 +1184,6 @@ static struct srpt_send_ioctx *srpt_get_send_ioctx(struct srpt_rdma_ch *ch)
static int srpt_abort_cmd(struct srpt_send_ioctx *ioctx) static int srpt_abort_cmd(struct srpt_send_ioctx *ioctx)
{ {
enum srpt_command_state state; enum srpt_command_state state;
unsigned long flags;
BUG_ON(!ioctx); BUG_ON(!ioctx);
...@@ -1201,7 +1192,6 @@ static int srpt_abort_cmd(struct srpt_send_ioctx *ioctx) ...@@ -1201,7 +1192,6 @@ static int srpt_abort_cmd(struct srpt_send_ioctx *ioctx)
* the ib_srpt driver, change the state to the next state. * the ib_srpt driver, change the state to the next state.
*/ */
spin_lock_irqsave(&ioctx->spinlock, flags);
state = ioctx->state; state = ioctx->state;
switch (state) { switch (state) {
case SRPT_STATE_NEED_DATA: case SRPT_STATE_NEED_DATA:
...@@ -1216,7 +1206,6 @@ static int srpt_abort_cmd(struct srpt_send_ioctx *ioctx) ...@@ -1216,7 +1206,6 @@ static int srpt_abort_cmd(struct srpt_send_ioctx *ioctx)
__func__, state); __func__, state);
break; break;
} }
spin_unlock_irqrestore(&ioctx->spinlock, flags);
pr_debug("Aborting cmd with state %d -> %d and tag %lld\n", state, pr_debug("Aborting cmd with state %d -> %d and tag %lld\n", state,
ioctx->state, ioctx->cmd.tag); ioctx->state, ioctx->cmd.tag);
...@@ -2431,13 +2420,11 @@ static void srpt_queue_response(struct se_cmd *cmd) ...@@ -2431,13 +2420,11 @@ static void srpt_queue_response(struct se_cmd *cmd)
struct ib_send_wr send_wr, *first_wr = &send_wr, *bad_wr; struct ib_send_wr send_wr, *first_wr = &send_wr, *bad_wr;
struct ib_sge sge; struct ib_sge sge;
enum srpt_command_state state; enum srpt_command_state state;
unsigned long flags;
int resp_len, ret, i; int resp_len, ret, i;
u8 srp_tm_status; u8 srp_tm_status;
BUG_ON(!ch); BUG_ON(!ch);
spin_lock_irqsave(&ioctx->spinlock, flags);
state = ioctx->state; state = ioctx->state;
switch (state) { switch (state) {
case SRPT_STATE_NEW: case SRPT_STATE_NEW:
...@@ -2452,7 +2439,6 @@ static void srpt_queue_response(struct se_cmd *cmd) ...@@ -2452,7 +2439,6 @@ static void srpt_queue_response(struct se_cmd *cmd)
ch, ioctx->ioctx.index, ioctx->state); ch, ioctx->ioctx.index, ioctx->state);
break; break;
} }
spin_unlock_irqrestore(&ioctx->spinlock, flags);
if (unlikely(WARN_ON_ONCE(state == SRPT_STATE_CMD_RSP_SENT))) if (unlikely(WARN_ON_ONCE(state == SRPT_STATE_CMD_RSP_SENT)))
return; return;
......
...@@ -195,7 +195,6 @@ struct srpt_rw_ctx { ...@@ -195,7 +195,6 @@ struct srpt_rw_ctx {
* @rw_ctxs: RDMA read/write contexts. * @rw_ctxs: RDMA read/write contexts.
* @rdma_cqe: RDMA completion queue element. * @rdma_cqe: RDMA completion queue element.
* @free_list: Node in srpt_rdma_ch.free_list. * @free_list: Node in srpt_rdma_ch.free_list.
* @spinlock: Protects 'state'.
* @state: I/O context state. * @state: I/O context state.
* @cmd: Target core command data structure. * @cmd: Target core command data structure.
* @sense_data: SCSI sense data. * @sense_data: SCSI sense data.
...@@ -213,7 +212,6 @@ struct srpt_send_ioctx { ...@@ -213,7 +212,6 @@ struct srpt_send_ioctx {
struct ib_cqe rdma_cqe; struct ib_cqe rdma_cqe;
struct list_head free_list; struct list_head free_list;
spinlock_t spinlock;
enum srpt_command_state state; enum srpt_command_state state;
struct se_cmd cmd; struct se_cmd cmd;
u8 n_rdma; u8 n_rdma;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment