diff options
author | Nicholas Bellinger <nab@linux-iscsi.org> | 2013-11-12 20:54:56 -0500 |
---|---|---|
committer | Greg Kroah-Hartman <gregkh@linuxfoundation.org> | 2013-12-04 13:56:14 -0500 |
commit | cf516effc76c78f948e6eb7cc46d4515003b423d (patch) | |
tree | 24bfa271ec40ccf9bcc5938ba91786801a7830c3 /drivers/target/iscsi | |
parent | 61688ba3da37952114be1bef89e2f4a3b0217624 (diff) |
iscsi-target: Fix mutex_trylock usage in iscsit_increment_maxcmdsn
commit 5e8e6b4b3adebf01a9d97056cbbfd8c44330df99 upstream.
This patch fixes a >= v3.10 regression bug with mutex_trylock() usage
within iscsit_increment_maxcmdsn(), that was originally added to allow
for a special case where ->cmdsn_mutex was already held from the
iscsit_execute_cmd() exception path for ib_isert.
When !mutex_trylock() was occuring under contention during normal RX/TX
process context codepaths, the bug was manifesting itself as the following
protocol error:
Received CmdSN: 0x000fcbb7 is greater than MaxCmdSN: 0x000fcbb6, protocol error.
Received CmdSN: 0x000fcbb8 is greater than MaxCmdSN: 0x000fcbb6, protocol error.
This patch simply avoids the direct ib_isert callback in lio_queue_status()
for the special iscsi_execute_cmd() exception cases, that allows the problematic
mutex_trylock() usage in iscsit_increment_maxcmdsn() to go away.
Reported-by: Moussa Ba <moussaba@micron.com>
Tested-by: Moussa Ba <moussaba@micron.com>
Signed-off-by: Nicholas Bellinger <nab@linux-iscsi.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Diffstat (limited to 'drivers/target/iscsi')
-rw-r--r-- | drivers/target/iscsi/iscsi_target_configfs.c | 5 | ||||
-rw-r--r-- | drivers/target/iscsi/iscsi_target_device.c | 6 |
2 files changed, 6 insertions, 5 deletions
diff --git a/drivers/target/iscsi/iscsi_target_configfs.c b/drivers/target/iscsi/iscsi_target_configfs.c index 421344da8b51..c45b3365d63d 100644 --- a/drivers/target/iscsi/iscsi_target_configfs.c +++ b/drivers/target/iscsi/iscsi_target_configfs.c | |||
@@ -1650,6 +1650,11 @@ static int lio_queue_status(struct se_cmd *se_cmd) | |||
1650 | struct iscsi_cmd *cmd = container_of(se_cmd, struct iscsi_cmd, se_cmd); | 1650 | struct iscsi_cmd *cmd = container_of(se_cmd, struct iscsi_cmd, se_cmd); |
1651 | 1651 | ||
1652 | cmd->i_state = ISTATE_SEND_STATUS; | 1652 | cmd->i_state = ISTATE_SEND_STATUS; |
1653 | |||
1654 | if (cmd->se_cmd.scsi_status || cmd->sense_reason) { | ||
1655 | iscsit_add_cmd_to_response_queue(cmd, cmd->conn, cmd->i_state); | ||
1656 | return 0; | ||
1657 | } | ||
1653 | cmd->conn->conn_transport->iscsit_queue_status(cmd->conn, cmd); | 1658 | cmd->conn->conn_transport->iscsit_queue_status(cmd->conn, cmd); |
1654 | 1659 | ||
1655 | return 0; | 1660 | return 0; |
diff --git a/drivers/target/iscsi/iscsi_target_device.c b/drivers/target/iscsi/iscsi_target_device.c index 1b74033510a0..4edcc47c0634 100644 --- a/drivers/target/iscsi/iscsi_target_device.c +++ b/drivers/target/iscsi/iscsi_target_device.c | |||
@@ -60,11 +60,7 @@ void iscsit_increment_maxcmdsn(struct iscsi_cmd *cmd, struct iscsi_session *sess | |||
60 | 60 | ||
61 | cmd->maxcmdsn_inc = 1; | 61 | cmd->maxcmdsn_inc = 1; |
62 | 62 | ||
63 | if (!mutex_trylock(&sess->cmdsn_mutex)) { | 63 | mutex_lock(&sess->cmdsn_mutex); |
64 | sess->max_cmd_sn += 1; | ||
65 | pr_debug("Updated MaxCmdSN to 0x%08x\n", sess->max_cmd_sn); | ||
66 | return; | ||
67 | } | ||
68 | sess->max_cmd_sn += 1; | 64 | sess->max_cmd_sn += 1; |
69 | pr_debug("Updated MaxCmdSN to 0x%08x\n", sess->max_cmd_sn); | 65 | pr_debug("Updated MaxCmdSN to 0x%08x\n", sess->max_cmd_sn); |
70 | mutex_unlock(&sess->cmdsn_mutex); | 66 | mutex_unlock(&sess->cmdsn_mutex); |