return isert_post_response(isert_conn, isert_cmd);
 }
 
+static void
+isert_aborted_task(struct iscsi_conn *conn, struct iscsi_cmd *cmd)
+{
+       struct isert_cmd *isert_cmd = iscsit_priv_cmd(cmd);
+       struct isert_conn *isert_conn = (struct isert_conn *)conn->context;
+       struct isert_device *device = isert_conn->conn_device;
+
+       spin_lock_bh(&conn->cmd_lock);
+       if (!list_empty(&cmd->i_conn_node))
+               list_del_init(&cmd->i_conn_node);
+       spin_unlock_bh(&conn->cmd_lock);
+
+       if (cmd->data_direction == DMA_TO_DEVICE)
+               iscsit_stop_dataout_timer(cmd);
+
+       device->unreg_rdma_mem(isert_cmd, isert_conn);
+}
+
 static int
 isert_put_nopin(struct iscsi_cmd *cmd, struct iscsi_conn *conn,
                bool nopout_response)
        .iscsit_get_dataout     = isert_get_dataout,
        .iscsit_queue_data_in   = isert_put_datain,
        .iscsit_queue_status    = isert_put_response,
+       .iscsit_aborted_task    = isert_aborted_task,
 };
 
 static int __init isert_init(void)
 
        srpt_queue_response(cmd);
 }
 
+static void srpt_aborted_task(struct se_cmd *cmd)
+{
+       struct srpt_send_ioctx *ioctx = container_of(cmd,
+                               struct srpt_send_ioctx, cmd);
+
+       srpt_unmap_sg_to_ib_sge(ioctx->ch, ioctx);
+}
+
 static int srpt_queue_status(struct se_cmd *cmd)
 {
        struct srpt_send_ioctx *ioctx;
        .queue_data_in                  = srpt_queue_data_in,
        .queue_status                   = srpt_queue_status,
        .queue_tm_rsp                   = srpt_queue_tm_rsp,
+       .aborted_task                   = srpt_aborted_task,
        /*
         * Setup function pointers for generic logic in
         * target_core_fabric_configfs.c
 
        qlt_xmit_tm_rsp(mcmd);
 }
 
+static void tcm_qla2xxx_aborted_task(struct se_cmd *se_cmd)
+{
+       struct qla_tgt_cmd *cmd = container_of(se_cmd,
+                               struct qla_tgt_cmd, se_cmd);
+       struct scsi_qla_host *vha = cmd->vha;
+       struct qla_hw_data *ha = vha->hw;
+
+       if (!cmd->sg_mapped)
+               return;
+
+       pci_unmap_sg(ha->pdev, cmd->sg, cmd->sg_cnt, cmd->dma_data_direction);
+       cmd->sg_mapped = 0;
+}
+
 /* Local pointer to allocated TCM configfs fabric module */
 struct target_fabric_configfs *tcm_qla2xxx_fabric_configfs;
 struct target_fabric_configfs *tcm_qla2xxx_npiv_fabric_configfs;
        .queue_data_in                  = tcm_qla2xxx_queue_data_in,
        .queue_status                   = tcm_qla2xxx_queue_status,
        .queue_tm_rsp                   = tcm_qla2xxx_queue_tm_rsp,
+       .aborted_task                   = tcm_qla2xxx_aborted_task,
        /*
         * Setup function pointers for generic logic in
         * target_core_fabric_configfs.c
        .queue_data_in                  = tcm_qla2xxx_queue_data_in,
        .queue_status                   = tcm_qla2xxx_queue_status,
        .queue_tm_rsp                   = tcm_qla2xxx_queue_tm_rsp,
+       .aborted_task                   = tcm_qla2xxx_aborted_task,
        /*
         * Setup function pointers for generic logic in
         * target_core_fabric_configfs.c
 
        return 0;
 }
 
+static void iscsit_aborted_task(struct iscsi_conn *conn, struct iscsi_cmd *cmd)
+{
+       bool scsi_cmd = (cmd->iscsi_opcode == ISCSI_OP_SCSI_CMD);
+
+       spin_lock_bh(&conn->cmd_lock);
+       if (!list_empty(&cmd->i_conn_node))
+               list_del_init(&cmd->i_conn_node);
+       spin_unlock_bh(&conn->cmd_lock);
+
+       __iscsit_free_cmd(cmd, scsi_cmd, true);
+}
+
 static struct iscsit_transport iscsi_target_transport = {
        .name                   = "iSCSI/TCP",
        .transport_type         = ISCSI_TCP,
        .iscsit_response_queue  = iscsit_response_queue,
        .iscsit_queue_data_in   = iscsit_queue_rsp,
        .iscsit_queue_status    = iscsit_queue_rsp,
+       .iscsit_aborted_task    = iscsit_aborted_task,
 };
 
 static int __init iscsi_target_init_module(void)
 
        iscsit_add_cmd_to_response_queue(cmd, cmd->conn, cmd->i_state);
 }
 
+static void lio_aborted_task(struct se_cmd *se_cmd)
+{
+       struct iscsi_cmd *cmd = container_of(se_cmd, struct iscsi_cmd, se_cmd);
+
+       cmd->conn->conn_transport->iscsit_aborted_task(cmd->conn, cmd);
+}
+
 static char *lio_tpg_get_endpoint_wwn(struct se_portal_group *se_tpg)
 {
        struct iscsi_portal_group *tpg = se_tpg->se_tpg_fabric_ptr;
        fabric->tf_ops.queue_data_in = &lio_queue_data_in;
        fabric->tf_ops.queue_status = &lio_queue_status;
        fabric->tf_ops.queue_tm_rsp = &lio_queue_tm_rsp;
+       fabric->tf_ops.aborted_task = &lio_aborted_task;
        /*
         * Setup function pointers for generic logic in target_core_fabric_configfs.c
         */
 
 }
 EXPORT_SYMBOL(iscsit_release_cmd);
 
-static void __iscsit_free_cmd(struct iscsi_cmd *cmd, bool scsi_cmd,
-                             bool check_queues)
+void __iscsit_free_cmd(struct iscsi_cmd *cmd, bool scsi_cmd,
+                      bool check_queues)
 {
        struct iscsi_conn *conn = cmd->conn;
 
 
 extern bool iscsit_conn_all_queues_empty(struct iscsi_conn *);
 extern void iscsit_free_queue_reqs_for_conn(struct iscsi_conn *);
 extern void iscsit_release_cmd(struct iscsi_cmd *);
+extern void __iscsit_free_cmd(struct iscsi_cmd *, bool, bool);
 extern void iscsit_free_cmd(struct iscsi_cmd *, bool);
 extern int iscsit_check_session_usage_count(struct iscsi_session *);
 extern void iscsit_dec_session_usage_count(struct iscsi_session *);
 
        wake_up(&tl_tmr->tl_tmr_wait);
 }
 
+static void tcm_loop_aborted_task(struct se_cmd *se_cmd)
+{
+       return;
+}
+
 static char *tcm_loop_dump_proto_id(struct tcm_loop_hba *tl_hba)
 {
        switch (tl_hba->tl_proto_id) {
        fabric->tf_ops.queue_data_in = &tcm_loop_queue_data_in;
        fabric->tf_ops.queue_status = &tcm_loop_queue_status;
        fabric->tf_ops.queue_tm_rsp = &tcm_loop_queue_tm_rsp;
+       fabric->tf_ops.aborted_task = &tcm_loop_aborted_task;
 
        /*
         * Setup function pointers for generic logic in target_core_fabric_configfs.c
 
 {
 }
 
+static void sbp_aborted_task(struct se_cmd *se_cmd)
+{
+       return;
+}
+
 static int sbp_check_stop_free(struct se_cmd *se_cmd)
 {
        struct sbp_target_request *req = container_of(se_cmd,
        .queue_data_in                  = sbp_queue_data_in,
        .queue_status                   = sbp_queue_status,
        .queue_tm_rsp                   = sbp_queue_tm_rsp,
+       .aborted_task                   = sbp_aborted_task,
        .check_stop_free                = sbp_check_stop_free,
 
        .fabric_make_wwn                = sbp_make_tport,
 
                pr_err("Missing tfo->queue_tm_rsp()\n");
                return -EINVAL;
        }
+       if (!tfo->aborted_task) {
+               pr_err("Missing tfo->aborted_task()\n");
+               return -EINVAL;
+       }
        /*
         * We at least require tfo->fabric_make_wwn(), tfo->fabric_drop_wwn()
         * tfo->fabric_make_tpg() and tfo->fabric_drop_tpg() in
 
 {
        if (cmd->se_cmd_flags & SCF_SE_LUN_CMD)
                transport_lun_remove_cmd(cmd);
+       /*
+        * Allow the fabric driver to unmap any resources before
+        * releasing the descriptor via TFO->release_cmd()
+        */
+       if (remove)
+               cmd->se_tfo->aborted_task(cmd);
 
        if (transport_cmd_check_stop_to_fabric(cmd))
                return;
 
 u32 ft_get_task_tag(struct se_cmd *);
 int ft_get_cmd_state(struct se_cmd *);
 void ft_queue_tm_resp(struct se_cmd *);
+void ft_aborted_task(struct se_cmd *);
 
 /*
  * other internal functions.
 
        ft_send_resp_code(cmd, code);
 }
 
+void ft_aborted_task(struct se_cmd *se_cmd)
+{
+       return;
+}
+
 static void ft_send_work(struct work_struct *work);
 
 /*
 
        .queue_data_in =                ft_queue_data_in,
        .queue_status =                 ft_queue_status,
        .queue_tm_rsp =                 ft_queue_tm_resp,
+       .aborted_task =                 ft_aborted_task,
        /*
         * Setup function pointers for generic logic in
         * target_core_fabric_configfs.c
 
 {
 }
 
+static void usbg_aborted_task(struct se_cmd *se_cmd)
+{
+       return;
+}
+
 static const char *usbg_check_wwn(const char *name)
 {
        const char *n;
        .queue_data_in                  = usbg_send_read_response,
        .queue_status                   = usbg_send_status_response,
        .queue_tm_rsp                   = usbg_queue_tm_rsp,
+       .aborted_task                   = usbg_aborted_task,
        .check_stop_free                = usbg_check_stop_free,
 
        .fabric_make_wwn                = usbg_make_tport,
 
        return;
 }
 
+static void tcm_vhost_aborted_task(struct se_cmd *se_cmd)
+{
+       return;
+}
+
 static void tcm_vhost_free_evt(struct vhost_scsi *vs, struct tcm_vhost_evt *evt)
 {
        vs->vs_events_nr--;
        .queue_data_in                  = tcm_vhost_queue_data_in,
        .queue_status                   = tcm_vhost_queue_status,
        .queue_tm_rsp                   = tcm_vhost_queue_tm_rsp,
+       .aborted_task                   = tcm_vhost_aborted_task,
        /*
         * Setup callers for generic logic in target_core_fabric_configfs.c
         */
 
        int (*iscsit_get_dataout)(struct iscsi_conn *, struct iscsi_cmd *, bool);
        int (*iscsit_queue_data_in)(struct iscsi_conn *, struct iscsi_cmd *);
        int (*iscsit_queue_status)(struct iscsi_conn *, struct iscsi_cmd *);
+       void (*iscsit_aborted_task)(struct iscsi_conn *, struct iscsi_cmd *);
 };
 
 static inline void *iscsit_priv_cmd(struct iscsi_cmd *cmd)
 
        int (*queue_data_in)(struct se_cmd *);
        int (*queue_status)(struct se_cmd *);
        void (*queue_tm_rsp)(struct se_cmd *);
+       void (*aborted_task)(struct se_cmd *);
        /*
         * fabric module calls for target_core_fabric_configfs.c
         */