@@ -1680,6 +1680,18 @@ void transport_generic_request_failure(struct se_cmd *cmd,
{
int ret = 0, post_ret = 0;
+ /*
+ * For SAM Task Attribute emulation for failed struct se_cmd
+ */
+ transport_complete_task_attr(cmd);
+ /*
+ * Handle special case for COMPARE_AND_WRITE failure, where the
+ * callback is expected to drop the per device ->caw_sem.
+ */
+ if ((cmd->se_cmd_flags & SCF_COMPARE_AND_WRITE) &&
+ cmd->transport_complete_callback)
+ cmd->transport_complete_callback(cmd, false, &post_ret);
+
if (transport_check_aborted_status(cmd, 1))
return;
@@ -1693,18 +1705,6 @@ void transport_generic_request_failure(struct se_cmd *cmd,
(cmd->transport_state & CMD_T_STOP) != 0,
(cmd->transport_state & CMD_T_SENT) != 0);
- /*
- * For SAM Task Attribute emulation for failed struct se_cmd
- */
- transport_complete_task_attr(cmd);
- /*
- * Handle special case for COMPARE_AND_WRITE failure, where the
- * callback is expected to drop the per device ->caw_sem.
- */
- if ((cmd->se_cmd_flags & SCF_COMPARE_AND_WRITE) &&
- cmd->transport_complete_callback)
- cmd->transport_complete_callback(cmd, false, &post_ret);
-
switch (sense_reason) {
case TCM_NON_EXISTENT_LUN:
case TCM_UNSUPPORTED_SCSI_OPCODE:
If CMD_T_ABORTED is set __transport_check_aborted_status will return 1 and transport_generic_request_failure will return immediately. If that happens and the command was a CAW then transport_complete_callback will not be called and the caw_sem will be left held. There is a similar problem for the SCF_TASK_ATTR_SET path where transport_complete_task_attr may not be called in that failure path. This patch just moves the transport_complete_task_attr and transport_complete_callback to before transport_check_aborted_status. Signed-off-by: Mike Christie <mchristi@redhat.com> --- drivers/target/target_core_transport.c | 24 ++++++++++++------------ 1 file changed, 12 insertions(+), 12 deletions(-)