From f213e944cf50663861876c1cf99d1f7655c91a14 Mon Sep 17 00:00:00 2001 From: Bart Van Assche Date: Thu, 20 Mar 2014 15:14:45 +0000 Subject: [PATCH] ib_srpt: Micro-optimize I/O context state manipulation All ioctx->state manipulations are serialized per command so it is not necessary to use locking to protect these manipulations. git-svn-id: http://svn.code.sf.net/p/scst/svn/trunk@5345 d57e44dd-8a1f-0410-8b47-8ef2f437770f --- srpt/src/ib_srpt.c | 17 ++++------------- 1 file changed, 4 insertions(+), 13 deletions(-) diff --git a/srpt/src/ib_srpt.c b/srpt/src/ib_srpt.c index 8e826759e..0b81a7267 100644 --- a/srpt/src/ib_srpt.c +++ b/srpt/src/ib_srpt.c @@ -926,13 +926,11 @@ static enum srpt_command_state srpt_set_cmd_state(struct srpt_send_ioctx *ioctx, { enum srpt_command_state previous; - BUG_ON(!ioctx); + EXTRACHECKS_BUG_ON(!ioctx); - spin_lock(&ioctx->spinlock); previous = ioctx->state; if (previous != SRPT_STATE_DONE) ioctx->state = new; - spin_unlock(&ioctx->spinlock); return previous; } @@ -948,15 +946,13 @@ static bool srpt_test_and_set_cmd_state(struct srpt_send_ioctx *ioctx, { enum srpt_command_state previous; - WARN_ON(!ioctx); - WARN_ON(old == SRPT_STATE_DONE); - WARN_ON(new == SRPT_STATE_NEW); + EXTRACHECKS_BUG_ON(!ioctx); + EXTRACHECKS_BUG_ON(old == SRPT_STATE_DONE); + EXTRACHECKS_BUG_ON(new == SRPT_STATE_NEW); - spin_lock(&ioctx->spinlock); previous = ioctx->state; if (previous == old) ioctx->state = new; - spin_unlock(&ioctx->spinlock); return previous == old; } @@ -1371,7 +1367,6 @@ static void srpt_abort_cmd(struct srpt_send_ioctx *ioctx, * SRPT_STATE_DATA_IN ensures that srpt_xmit_response() will call this * function a second time. */ - spin_lock(&ioctx->spinlock); state = ioctx->state; switch (state) { case SRPT_STATE_NEED_DATA: @@ -1385,8 +1380,6 @@ static void srpt_abort_cmd(struct srpt_send_ioctx *ioctx, default: break; } - spin_unlock(&ioctx->spinlock); - if (state == SRPT_STATE_DONE) goto out; @@ -3328,7 +3321,6 @@ static int srpt_xmit_response(struct scst_cmd *scmnd) ch = scst_sess_get_tgt_priv(scst_cmd_get_session(scmnd)); BUG_ON(!ch); - spin_lock(&ioctx->spinlock); state = ioctx->state; switch (state) { case SRPT_STATE_NEW: @@ -3339,7 +3331,6 @@ static int srpt_xmit_response(struct scst_cmd *scmnd) WARN(true, "Unexpected command state %d", state); break; } - spin_unlock(&ioctx->spinlock); if (unlikely(scst_cmd_aborted_on_xmit(scmnd))) { srpt_adjust_req_lim(ch, 0, 1);