]> git.ipfire.org Git - thirdparty/kernel/stable-queue.git/commitdiff
3.14-stable patches
authorGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Sat, 28 Jun 2014 00:10:23 +0000 (17:10 -0700)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Sat, 28 Jun 2014 00:10:23 +0000 (17:10 -0700)
added patches:
iscsi-target-fix-abort_task-connection-reset-iscsi_queue_req-memory-leak.patch
target-iscsi-fix-sendtargets-response-pdu-for-iser-transport.patch
target-iser-improve-cm-events-handling.patch
target-iser-wait-for-proper-cleanup-before-unloading.patch
target-report-correct-response-length-for-some-commands.patch
target-set-cmd_t_active-bit-for-task-management-requests.patch
target-use-complete_all-for-se_cmd-t_transport_stop_comp.patch

queue-3.14/iscsi-target-fix-abort_task-connection-reset-iscsi_queue_req-memory-leak.patch [new file with mode: 0644]
queue-3.14/series
queue-3.14/target-iscsi-fix-sendtargets-response-pdu-for-iser-transport.patch [new file with mode: 0644]
queue-3.14/target-iser-improve-cm-events-handling.patch [new file with mode: 0644]
queue-3.14/target-iser-wait-for-proper-cleanup-before-unloading.patch [new file with mode: 0644]
queue-3.14/target-report-correct-response-length-for-some-commands.patch [new file with mode: 0644]
queue-3.14/target-set-cmd_t_active-bit-for-task-management-requests.patch [new file with mode: 0644]
queue-3.14/target-use-complete_all-for-se_cmd-t_transport_stop_comp.patch [new file with mode: 0644]

diff --git a/queue-3.14/iscsi-target-fix-abort_task-connection-reset-iscsi_queue_req-memory-leak.patch b/queue-3.14/iscsi-target-fix-abort_task-connection-reset-iscsi_queue_req-memory-leak.patch
new file mode 100644 (file)
index 0000000..a3decf9
--- /dev/null
@@ -0,0 +1,48 @@
+From bbc050488525e1ab1194c27355f63c66814385b8 Mon Sep 17 00:00:00 2001
+From: Nicholas Bellinger <nab@linux-iscsi.org>
+Date: Tue, 10 Jun 2014 04:03:54 +0000
+Subject: iscsi-target: Fix ABORT_TASK + connection reset iscsi_queue_req memory leak
+
+From: Nicholas Bellinger <nab@linux-iscsi.org>
+
+commit bbc050488525e1ab1194c27355f63c66814385b8 upstream.
+
+This patch fixes a iscsi_queue_req memory leak when ABORT_TASK response
+has been queued by TFO->queue_tm_rsp() -> lio_queue_tm_rsp() after a
+long standing I/O completes, but the connection has already reset and
+waiting for cleanup to complete in iscsit_release_commands_from_conn()
+-> transport_generic_free_cmd() -> transport_wait_for_tasks() code.
+
+It moves iscsit_free_queue_reqs_for_conn() after the per-connection command
+list has been released, so that the associated se_cmd tag can be completed +
+released by target-core before freeing any remaining iscsi_queue_req memory
+for the connection generated by lio_queue_tm_rsp().
+
+Cc: Thomas Glanzmann <thomas@glanzmann.de>
+Cc: Charalampos Pournaris <charpour@gmail.com>
+Signed-off-by: Nicholas Bellinger <nab@linux-iscsi.org>
+Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
+
+---
+ drivers/target/iscsi/iscsi_target.c |    3 +--
+ 1 file changed, 1 insertion(+), 2 deletions(-)
+
+--- a/drivers/target/iscsi/iscsi_target.c
++++ b/drivers/target/iscsi/iscsi_target.c
+@@ -4205,8 +4205,6 @@ int iscsit_close_connection(
+       if (conn->conn_transport->iscsit_wait_conn)
+               conn->conn_transport->iscsit_wait_conn(conn);
+-      iscsit_free_queue_reqs_for_conn(conn);
+-
+       /*
+        * During Connection recovery drop unacknowledged out of order
+        * commands for this connection, and prepare the other commands
+@@ -4223,6 +4221,7 @@ int iscsit_close_connection(
+               iscsit_clear_ooo_cmdsns_for_conn(conn);
+               iscsit_release_commands_from_conn(conn);
+       }
++      iscsit_free_queue_reqs_for_conn(conn);
+       /*
+        * Handle decrementing session or connection usage count if
index 7008ce277da173b8e4d51c82b7bf3871314782f4..f2da84c5619c29eb9e09cda35fc82c59117df125 100644 (file)
@@ -71,3 +71,10 @@ bluetooth-6lowpan-fix-mac-address-universal-local-bit-handling.patch
 bluetooth-fix-l2cap-deadlock.patch
 target-iser-bail-from-accept_np-if-np_thread-is-trying-to-close.patch
 target-iser-fix-hangs-in-connection-teardown.patch
+target-iser-improve-cm-events-handling.patch
+target-iser-wait-for-proper-cleanup-before-unloading.patch
+target-set-cmd_t_active-bit-for-task-management-requests.patch
+target-use-complete_all-for-se_cmd-t_transport_stop_comp.patch
+iscsi-target-fix-abort_task-connection-reset-iscsi_queue_req-memory-leak.patch
+target-iscsi-fix-sendtargets-response-pdu-for-iser-transport.patch
+target-report-correct-response-length-for-some-commands.patch
diff --git a/queue-3.14/target-iscsi-fix-sendtargets-response-pdu-for-iser-transport.patch b/queue-3.14/target-iscsi-fix-sendtargets-response-pdu-for-iser-transport.patch
new file mode 100644 (file)
index 0000000..cda3b86
--- /dev/null
@@ -0,0 +1,98 @@
+From 22c7aaa57e80853b4904a46c18f97db0036a3b97 Mon Sep 17 00:00:00 2001
+From: Sagi Grimberg <sagig@mellanox.com>
+Date: Tue, 10 Jun 2014 18:27:59 +0300
+Subject: Target/iscsi: Fix sendtargets response pdu for iser transport
+
+From: Sagi Grimberg <sagig@mellanox.com>
+
+commit 22c7aaa57e80853b4904a46c18f97db0036a3b97 upstream.
+
+In case the transport is iser we should not include the
+iscsi target info in the sendtargets text response pdu.
+This causes sendtargets response to include the target
+info twice.
+
+Modify iscsit_build_sendtargets_response to filter
+transport types that don't match.
+
+Signed-off-by: Sagi Grimberg <sagig@mellanox.com>
+Reported-by: Slava Shwartsman <valyushash@gmail.com>
+Signed-off-by: Nicholas Bellinger <nab@linux-iscsi.org>
+Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
+
+---
+ drivers/infiniband/ulp/isert/ib_isert.c |    2 +-
+ drivers/target/iscsi/iscsi_target.c     |   14 ++++++++++----
+ include/target/iscsi/iscsi_transport.h  |    3 ++-
+ 3 files changed, 13 insertions(+), 6 deletions(-)
+
+--- a/drivers/infiniband/ulp/isert/ib_isert.c
++++ b/drivers/infiniband/ulp/isert/ib_isert.c
+@@ -2044,7 +2044,7 @@ isert_put_text_rsp(struct iscsi_cmd *cmd
+       int rc;
+       isert_create_send_desc(isert_conn, isert_cmd, &isert_cmd->tx_desc);
+-      rc = iscsit_build_text_rsp(cmd, conn, hdr);
++      rc = iscsit_build_text_rsp(cmd, conn, hdr, ISCSI_INFINIBAND);
+       if (rc < 0)
+               return rc;
+--- a/drivers/target/iscsi/iscsi_target.c
++++ b/drivers/target/iscsi/iscsi_target.c
+@@ -3361,7 +3361,9 @@ static bool iscsit_check_inaddr_any(stru
+ #define SENDTARGETS_BUF_LIMIT 32768U
+-static int iscsit_build_sendtargets_response(struct iscsi_cmd *cmd)
++static int
++iscsit_build_sendtargets_response(struct iscsi_cmd *cmd,
++                                enum iscsit_transport_type network_transport)
+ {
+       char *payload = NULL;
+       struct iscsi_conn *conn = cmd->conn;
+@@ -3438,6 +3440,9 @@ static int iscsit_build_sendtargets_resp
+                               struct iscsi_np *np = tpg_np->tpg_np;
+                               bool inaddr_any = iscsit_check_inaddr_any(np);
++                              if (np->np_network_transport != network_transport)
++                                      continue;
++
+                               if (!target_name_printed) {
+                                       len = sprintf(buf, "TargetName=%s",
+                                                     tiqn->tiqn);
+@@ -3491,11 +3496,12 @@ eob:
+ int
+ iscsit_build_text_rsp(struct iscsi_cmd *cmd, struct iscsi_conn *conn,
+-                    struct iscsi_text_rsp *hdr)
++                    struct iscsi_text_rsp *hdr,
++                    enum iscsit_transport_type network_transport)
+ {
+       int text_length, padding;
+-      text_length = iscsit_build_sendtargets_response(cmd);
++      text_length = iscsit_build_sendtargets_response(cmd, network_transport);
+       if (text_length < 0)
+               return text_length;
+@@ -3533,7 +3539,7 @@ static int iscsit_send_text_rsp(
+       u32 tx_size = 0;
+       int text_length, iov_count = 0, rc;
+-      rc = iscsit_build_text_rsp(cmd, conn, hdr);
++      rc = iscsit_build_text_rsp(cmd, conn, hdr, ISCSI_TCP);
+       if (rc < 0)
+               return rc;
+--- a/include/target/iscsi/iscsi_transport.h
++++ b/include/target/iscsi/iscsi_transport.h
+@@ -68,7 +68,8 @@ extern void iscsit_build_nopin_rsp(struc
+ extern void iscsit_build_task_mgt_rsp(struct iscsi_cmd *, struct iscsi_conn *,
+                               struct iscsi_tm_rsp *);
+ extern int iscsit_build_text_rsp(struct iscsi_cmd *, struct iscsi_conn *,
+-                              struct iscsi_text_rsp *);
++                              struct iscsi_text_rsp *,
++                              enum iscsit_transport_type);
+ extern void iscsit_build_reject(struct iscsi_cmd *, struct iscsi_conn *,
+                               struct iscsi_reject *);
+ extern int iscsit_build_logout_rsp(struct iscsi_cmd *, struct iscsi_conn *,
diff --git a/queue-3.14/target-iser-improve-cm-events-handling.patch b/queue-3.14/target-iser-improve-cm-events-handling.patch
new file mode 100644 (file)
index 0000000..74f7b02
--- /dev/null
@@ -0,0 +1,113 @@
+From 88c4015fda6d014392f76d3b1688347950d7a12d Mon Sep 17 00:00:00 2001
+From: Sagi Grimberg <sagig@mellanox.com>
+Date: Mon, 19 May 2014 17:44:24 +0300
+Subject: Target/iser: Improve cm events handling
+
+From: Sagi Grimberg <sagig@mellanox.com>
+
+commit 88c4015fda6d014392f76d3b1688347950d7a12d upstream.
+
+There are 4 RDMA_CM events that all basically mean that
+the user should teardown the IB connection:
+- DISCONNECTED
+- ADDR_CHANGE
+- DEVICE_REMOVAL
+- TIMEWAIT_EXIT
+
+Only in DISCONNECTED/ADDR_CHANGE it makes sense to
+call rdma_disconnect (send DREQ/DREP to our initiator).
+So we keep the same teardown handler for all of them
+but only indicate calling rdma_disconnect for the relevant
+events.
+
+This patch also removes redundant debug prints for each single
+event.
+
+v2 changes:
+ - Call isert_disconnected_handler() for DEVICE_REMOVAL (Or + Sag)
+
+Signed-off-by: Sagi Grimberg <sagig@mellanox.com>
+Signed-off-by: Nicholas Bellinger <nab@linux-iscsi.org>
+Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
+
+---
+ drivers/infiniband/ulp/isert/ib_isert.c |   26 ++++++++++++++------------
+ drivers/infiniband/ulp/isert/ib_isert.h |    1 +
+ 2 files changed, 15 insertions(+), 12 deletions(-)
+
+--- a/drivers/infiniband/ulp/isert/ib_isert.c
++++ b/drivers/infiniband/ulp/isert/ib_isert.c
+@@ -706,8 +706,10 @@ isert_disconnect_work(struct work_struct
+               return;
+       }
+-      /* Send DREQ/DREP towards our initiator */
+-      rdma_disconnect(isert_conn->conn_cm_id);
++      if (isert_conn->disconnect) {
++              /* Send DREQ/DREP towards our initiator */
++              rdma_disconnect(isert_conn->conn_cm_id);
++      }
+       mutex_unlock(&isert_conn->conn_mutex);
+@@ -717,10 +719,11 @@ wake_up:
+ }
+ static void
+-isert_disconnected_handler(struct rdma_cm_id *cma_id)
++isert_disconnected_handler(struct rdma_cm_id *cma_id, bool disconnect)
+ {
+       struct isert_conn *isert_conn = (struct isert_conn *)cma_id->context;
++      isert_conn->disconnect = disconnect;
+       INIT_WORK(&isert_conn->conn_logout_work, isert_disconnect_work);
+       schedule_work(&isert_conn->conn_logout_work);
+ }
+@@ -729,29 +732,28 @@ static int
+ isert_cma_handler(struct rdma_cm_id *cma_id, struct rdma_cm_event *event)
+ {
+       int ret = 0;
++      bool disconnect = false;
+       pr_debug("isert_cma_handler: event %d status %d conn %p id %p\n",
+                event->event, event->status, cma_id->context, cma_id);
+       switch (event->event) {
+       case RDMA_CM_EVENT_CONNECT_REQUEST:
+-              pr_debug("RDMA_CM_EVENT_CONNECT_REQUEST: >>>>>>>>>>>>>>>\n");
+               ret = isert_connect_request(cma_id, event);
+               break;
+       case RDMA_CM_EVENT_ESTABLISHED:
+-              pr_debug("RDMA_CM_EVENT_ESTABLISHED >>>>>>>>>>>>>>\n");
+               isert_connected_handler(cma_id);
+               break;
+-      case RDMA_CM_EVENT_DISCONNECTED:
+-              pr_debug("RDMA_CM_EVENT_DISCONNECTED: >>>>>>>>>>>>>>\n");
+-              isert_disconnected_handler(cma_id);
+-              break;
+-      case RDMA_CM_EVENT_DEVICE_REMOVAL:
+-      case RDMA_CM_EVENT_ADDR_CHANGE:
++      case RDMA_CM_EVENT_ADDR_CHANGE:    /* FALLTHRU */
++      case RDMA_CM_EVENT_DISCONNECTED:   /* FALLTHRU */
++      case RDMA_CM_EVENT_DEVICE_REMOVAL: /* FALLTHRU */
++              disconnect = true;
++      case RDMA_CM_EVENT_TIMEWAIT_EXIT:  /* FALLTHRU */
++              isert_disconnected_handler(cma_id, disconnect);
+               break;
+       case RDMA_CM_EVENT_CONNECT_ERROR:
+       default:
+-              pr_err("Unknown RDMA CMA event: %d\n", event->event);
++              pr_err("Unhandled RDMA CMA event: %d\n", event->event);
+               break;
+       }
+--- a/drivers/infiniband/ulp/isert/ib_isert.h
++++ b/drivers/infiniband/ulp/isert/ib_isert.h
+@@ -127,6 +127,7 @@ struct isert_conn {
+ #define ISERT_COMP_BATCH_COUNT        8
+       int                     conn_comp_batch;
+       struct llist_head       conn_comp_llist;
++      bool                    disconnect;
+ };
+ #define ISERT_MAX_CQ 64
diff --git a/queue-3.14/target-iser-wait-for-proper-cleanup-before-unloading.patch b/queue-3.14/target-iser-wait-for-proper-cleanup-before-unloading.patch
new file mode 100644 (file)
index 0000000..f38efb7
--- /dev/null
@@ -0,0 +1,31 @@
+From f5ebec9629cf78eeeea4b8258882a9f439ab2404 Mon Sep 17 00:00:00 2001
+From: Sagi Grimberg <sagig@mellanox.com>
+Date: Mon, 19 May 2014 17:44:25 +0300
+Subject: Target/iser: Wait for proper cleanup before unloading
+
+From: Sagi Grimberg <sagig@mellanox.com>
+
+commit f5ebec9629cf78eeeea4b8258882a9f439ab2404 upstream.
+
+disconnected_handler works are scheduled on system_wq.
+When attempting to unload, first make sure all works
+have cleaned up.
+
+Signed-off-by: Sagi Grimberg <sagig@mellanox.com>
+Signed-off-by: Nicholas Bellinger <nab@linux-iscsi.org>
+Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
+
+---
+ drivers/infiniband/ulp/isert/ib_isert.c |    1 +
+ 1 file changed, 1 insertion(+)
+
+--- a/drivers/infiniband/ulp/isert/ib_isert.c
++++ b/drivers/infiniband/ulp/isert/ib_isert.c
+@@ -2856,6 +2856,7 @@ destroy_rx_wq:
+ static void __exit isert_exit(void)
+ {
++      flush_scheduled_work();
+       destroy_workqueue(isert_comp_wq);
+       destroy_workqueue(isert_rx_wq);
+       iscsit_unregister_transport(&iser_target_transport);
diff --git a/queue-3.14/target-report-correct-response-length-for-some-commands.patch b/queue-3.14/target-report-correct-response-length-for-some-commands.patch
new file mode 100644 (file)
index 0000000..b370e03
--- /dev/null
@@ -0,0 +1,145 @@
+From 2426bd456a61407388b6e61fc5f98dbcbebc50e2 Mon Sep 17 00:00:00 2001
+From: Roland Dreier <roland@purestorage.com>
+Date: Tue, 10 Jun 2014 11:07:47 -0700
+Subject: target: Report correct response length for some commands
+
+From: Roland Dreier <roland@purestorage.com>
+
+commit 2426bd456a61407388b6e61fc5f98dbcbebc50e2 upstream.
+
+When an initiator sends an allocation length bigger than what its
+command consumes, the target should only return the actual response data
+and set the residual length to the unused part of the allocation length.
+
+Add a helper function that command handlers (INQUIRY, READ CAPACITY,
+etc) can use to do this correctly, and use this code to get the correct
+residual for commands that don't use the full initiator allocation in the
+handlers for READ CAPACITY, READ CAPACITY(16), INQUIRY, MODE SENSE and
+REPORT LUNS.
+
+This addresses a handful of failures as reported by Christophe with
+the Windows Certification Kit:
+
+  http://permalink.gmane.org/gmane.linux.scsi.target.devel/6515
+
+Signed-off-by: Roland Dreier <roland@purestorage.com>
+Tested-by: Christophe Vu-Brugier <cvubrugier@yahoo.fr>
+Signed-off-by: Nicholas Bellinger <nab@linux-iscsi.org>
+Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
+
+---
+ drivers/target/target_core_sbc.c       |    4 ++--
+ drivers/target/target_core_spc.c       |    9 ++++++---
+ drivers/target/target_core_transport.c |   17 +++++++++++++++++
+ include/target/target_core_backend.h   |    1 +
+ 4 files changed, 26 insertions(+), 5 deletions(-)
+
+--- a/drivers/target/target_core_sbc.c
++++ b/drivers/target/target_core_sbc.c
+@@ -81,7 +81,7 @@ sbc_emulate_readcapacity(struct se_cmd *
+               transport_kunmap_data_sg(cmd);
+       }
+-      target_complete_cmd(cmd, GOOD);
++      target_complete_cmd_with_length(cmd, GOOD, 8);
+       return 0;
+ }
+@@ -134,7 +134,7 @@ sbc_emulate_readcapacity_16(struct se_cm
+               transport_kunmap_data_sg(cmd);
+       }
+-      target_complete_cmd(cmd, GOOD);
++      target_complete_cmd_with_length(cmd, GOOD, 32);
+       return 0;
+ }
+--- a/drivers/target/target_core_spc.c
++++ b/drivers/target/target_core_spc.c
+@@ -714,6 +714,7 @@ spc_emulate_inquiry(struct se_cmd *cmd)
+       unsigned char *buf;
+       sense_reason_t ret;
+       int p;
++      int len = 0;
+       buf = kzalloc(SE_INQUIRY_BUF, GFP_KERNEL);
+       if (!buf) {
+@@ -735,6 +736,7 @@ spc_emulate_inquiry(struct se_cmd *cmd)
+               }
+               ret = spc_emulate_inquiry_std(cmd, buf);
++              len = buf[4] + 5;
+               goto out;
+       }
+@@ -742,6 +744,7 @@ spc_emulate_inquiry(struct se_cmd *cmd)
+               if (cdb[2] == evpd_handlers[p].page) {
+                       buf[1] = cdb[2];
+                       ret = evpd_handlers[p].emulate(cmd, buf);
++                      len = get_unaligned_be16(&buf[2]) + 4;
+                       goto out;
+               }
+       }
+@@ -758,7 +761,7 @@ out:
+       kfree(buf);
+       if (!ret)
+-              target_complete_cmd(cmd, GOOD);
++              target_complete_cmd_with_length(cmd, GOOD, len);
+       return ret;
+ }
+@@ -1089,7 +1092,7 @@ set_length:
+               transport_kunmap_data_sg(cmd);
+       }
+-      target_complete_cmd(cmd, GOOD);
++      target_complete_cmd_with_length(cmd, GOOD, length);
+       return 0;
+ }
+@@ -1266,7 +1269,7 @@ done:
+       buf[3] = (lun_count & 0xff);
+       transport_kunmap_data_sg(cmd);
+-      target_complete_cmd(cmd, GOOD);
++      target_complete_cmd_with_length(cmd, GOOD, 8 + lun_count * 8);
+       return 0;
+ }
+ EXPORT_SYMBOL(spc_emulate_report_luns);
+--- a/drivers/target/target_core_transport.c
++++ b/drivers/target/target_core_transport.c
+@@ -692,6 +692,23 @@ void target_complete_cmd(struct se_cmd *
+ }
+ EXPORT_SYMBOL(target_complete_cmd);
++void target_complete_cmd_with_length(struct se_cmd *cmd, u8 scsi_status, int length)
++{
++      if (scsi_status == SAM_STAT_GOOD && length < cmd->data_length) {
++              if (cmd->se_cmd_flags & SCF_UNDERFLOW_BIT) {
++                      cmd->residual_count += cmd->data_length - length;
++              } else {
++                      cmd->se_cmd_flags |= SCF_UNDERFLOW_BIT;
++                      cmd->residual_count = cmd->data_length - length;
++              }
++
++              cmd->data_length = length;
++      }
++
++      target_complete_cmd(cmd, scsi_status);
++}
++EXPORT_SYMBOL(target_complete_cmd_with_length);
++
+ static void target_add_to_state_list(struct se_cmd *cmd)
+ {
+       struct se_device *dev = cmd->se_dev;
+--- a/include/target/target_core_backend.h
++++ b/include/target/target_core_backend.h
+@@ -59,6 +59,7 @@ int  transport_subsystem_register(struct
+ void  transport_subsystem_release(struct se_subsystem_api *);
+ void  target_complete_cmd(struct se_cmd *, u8);
++void  target_complete_cmd_with_length(struct se_cmd *, u8, int);
+ sense_reason_t        spc_parse_cdb(struct se_cmd *cmd, unsigned int *size);
+ sense_reason_t        spc_emulate_report_luns(struct se_cmd *cmd);
diff --git a/queue-3.14/target-set-cmd_t_active-bit-for-task-management-requests.patch b/queue-3.14/target-set-cmd_t_active-bit-for-task-management-requests.patch
new file mode 100644 (file)
index 0000000..7391f2d
--- /dev/null
@@ -0,0 +1,42 @@
+From f15e9cd910c4d9da7de43f2181f362082fc45f0f Mon Sep 17 00:00:00 2001
+From: Nicholas Bellinger <nab@linux-iscsi.org>
+Date: Mon, 9 Jun 2014 23:13:20 +0000
+Subject: target: Set CMD_T_ACTIVE bit for Task Management Requests
+
+From: Nicholas Bellinger <nab@linux-iscsi.org>
+
+commit f15e9cd910c4d9da7de43f2181f362082fc45f0f upstream.
+
+This patch fixes a bug where se_cmd descriptors associated with a
+Task Management Request (TMR) where not setting CMD_T_ACTIVE before
+being dispatched into target_tmr_work() process context.
+
+This is required in order for transport_generic_free_cmd() ->
+transport_wait_for_tasks() to wait on se_cmd->t_transport_stop_comp
+if a session reset event occurs while an ABORT_TASK is outstanding
+waiting for another I/O to complete.
+
+Cc: Thomas Glanzmann <thomas@glanzmann.de>
+Cc: Charalampos Pournaris <charpour@gmail.com>
+Signed-off-by: Nicholas Bellinger <nab@linux-iscsi.org>
+Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
+
+---
+ drivers/target/target_core_transport.c |    6 ++++++
+ 1 file changed, 6 insertions(+)
+
+--- a/drivers/target/target_core_transport.c
++++ b/drivers/target/target_core_transport.c
+@@ -2868,6 +2868,12 @@ static void target_tmr_work(struct work_
+ int transport_generic_handle_tmr(
+       struct se_cmd *cmd)
+ {
++      unsigned long flags;
++
++      spin_lock_irqsave(&cmd->t_state_lock, flags);
++      cmd->transport_state |= CMD_T_ACTIVE;
++      spin_unlock_irqrestore(&cmd->t_state_lock, flags);
++
+       INIT_WORK(&cmd->work, target_tmr_work);
+       queue_work(cmd->se_dev->tmr_wq, &cmd->work);
+       return 0;
diff --git a/queue-3.14/target-use-complete_all-for-se_cmd-t_transport_stop_comp.patch b/queue-3.14/target-use-complete_all-for-se_cmd-t_transport_stop_comp.patch
new file mode 100644 (file)
index 0000000..3881215
--- /dev/null
@@ -0,0 +1,56 @@
+From a95d6511303b848da45ee27b35018bb58087bdc6 Mon Sep 17 00:00:00 2001
+From: Nicholas Bellinger <nab@linux-iscsi.org>
+Date: Mon, 9 Jun 2014 23:36:51 +0000
+Subject: target: Use complete_all for se_cmd->t_transport_stop_comp
+
+From: Nicholas Bellinger <nab@linux-iscsi.org>
+
+commit a95d6511303b848da45ee27b35018bb58087bdc6 upstream.
+
+This patch fixes a bug where multiple waiters on ->t_transport_stop_comp
+occurs due to a concurrent ABORT_TASK and session reset both invoking
+transport_wait_for_tasks(), while waiting for the associated se_cmd
+descriptor backend processing to complete.
+
+For this case, complete_all() should be invoked in order to wake up
+both waiters in core_tmr_abort_task() + transport_generic_free_cmd()
+process contexts.
+
+Cc: Thomas Glanzmann <thomas@glanzmann.de>
+Cc: Charalampos Pournaris <charpour@gmail.com>
+Signed-off-by: Nicholas Bellinger <nab@linux-iscsi.org>
+Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
+
+---
+ drivers/target/target_core_transport.c |    6 +++---
+ 1 file changed, 3 insertions(+), 3 deletions(-)
+
+--- a/drivers/target/target_core_transport.c
++++ b/drivers/target/target_core_transport.c
+@@ -560,7 +560,7 @@ static int transport_cmd_check_stop(stru
+               spin_unlock_irqrestore(&cmd->t_state_lock, flags);
+-              complete(&cmd->t_transport_stop_comp);
++              complete_all(&cmd->t_transport_stop_comp);
+               return 1;
+       }
+@@ -676,7 +676,7 @@ void target_complete_cmd(struct se_cmd *
+       if (cmd->transport_state & CMD_T_ABORTED &&
+           cmd->transport_state & CMD_T_STOP) {
+               spin_unlock_irqrestore(&cmd->t_state_lock, flags);
+-              complete(&cmd->t_transport_stop_comp);
++              complete_all(&cmd->t_transport_stop_comp);
+               return;
+       } else if (!success) {
+               INIT_WORK(&cmd->work, target_complete_failure_work);
+@@ -1748,7 +1748,7 @@ void target_execute_cmd(struct se_cmd *c
+                       cmd->se_tfo->get_task_tag(cmd));
+               spin_unlock_irq(&cmd->t_state_lock);
+-              complete(&cmd->t_transport_stop_comp);
++              complete_all(&cmd->t_transport_stop_comp);
+               return;
+       }