summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--etc/iscsid.conf16
-rw-r--r--include/iscsi_if.h2
-rw-r--r--kernel/2.6.16-18_compat.patch14
-rw-r--r--kernel/2.6.19_compat.patch14
-rw-r--r--kernel/iscsi_tcp.c12
-rw-r--r--kernel/libiscsi.c510
-rw-r--r--kernel/libiscsi.h32
-rw-r--r--kernel/scsi_transport_iscsi.c4
-rw-r--r--usr/config.h1
-rw-r--r--usr/idbm.c2
-rw-r--r--usr/initiator.c8
-rw-r--r--usr/initiator.h1
12 files changed, 378 insertions, 238 deletions
diff --git a/etc/iscsid.conf b/etc/iscsid.conf
index 0840594..e950e3f 100644
--- a/etc/iscsid.conf
+++ b/etc/iscsid.conf
@@ -204,3 +204,19 @@ discovery.sendtargets.iscsi.MaxRecvDataSegmentLength = 32768
# The default is to never use DataDigests and to allow the target to control
# the setting of the HeaderDigest checking with the initiator requesting
# a preference of disabling the checking.
+
+#************
+# Workarounds
+#************
+
+# Some targets like IET prefer after an initiator has sent a task
+# management function like an ABORT TASK or LOGICAL UNIT RESET, that
+# it does not respond to PDUs like R2Ts. To enable this behavior uncomment
+# the following line (The default behavior is No):
+# node.session.iscsi.FastAbort = Yes
+
+# Some targets like Equalogic prefer that after an initiator has sent
+# a task management function like an ABORT TASK or LOGICAL UNIT RESET, that
+# it continue to respond to R2Ts. To enable this uncomment this line (This
+# is the default behavior):
+node.session.iscsi.FastAbort = No
diff --git a/include/iscsi_if.h b/include/iscsi_if.h
index 8458425..803e8d9 100644
--- a/include/iscsi_if.h
+++ b/include/iscsi_if.h
@@ -236,6 +236,7 @@ enum iscsi_param {
ISCSI_PARAM_PASSWORD,
ISCSI_PARAM_PASSWORD_IN,
+ ISCSI_PARAM_FAST_ABORT,
/* must always be last */
ISCSI_PARAM_MAX,
};
@@ -266,6 +267,7 @@ enum iscsi_param {
#define ISCSI_USERNAME_IN (1 << ISCSI_PARAM_USERNAME_IN)
#define ISCSI_PASSWORD (1 << ISCSI_PARAM_PASSWORD)
#define ISCSI_PASSWORD_IN (1 << ISCSI_PARAM_PASSWORD_IN)
+#define ISCSI_FAST_ABORT (1 << ISCSI_PARAM_FAST_ABORT)
/* iSCSI HBA params */
enum iscsi_host_param {
diff --git a/kernel/2.6.16-18_compat.patch b/kernel/2.6.16-18_compat.patch
index 9d36516..88a3157 100644
--- a/kernel/2.6.16-18_compat.patch
+++ b/kernel/2.6.16-18_compat.patch
@@ -89,10 +89,10 @@ index 4b86fe4..1b4336d 100644
struct socket;
diff --git a/libiscsi.c b/libiscsi.c
-index f2ef4c7..fd241ca 100644
+index c7994d9..feca101 100644
--- a/libiscsi.c
+++ b/libiscsi.c
-@@ -760,10 +760,9 @@ again:
+@@ -782,10 +782,9 @@ again:
return rc;
}
@@ -105,17 +105,17 @@ index f2ef4c7..fd241ca 100644
int rc;
/*
* serialize Xmit worker on a per-connection basis.
-@@ -1528,7 +1527,7 @@ iscsi_conn_setup(struct iscsi_cls_session *cls_session, uint32_t conn_idx)
- if (conn->mgmtqueue == ERR_PTR(-ENOMEM))
- goto mgmtqueue_alloc_fail;
-
+@@ -1634,7 +1633,7 @@ iscsi_conn_setup(struct iscsi_cls_session *cls_session, uint32_t conn_idx)
+ INIT_LIST_HEAD(&conn->mgmtqueue);
+ INIT_LIST_HEAD(&conn->xmitqueue);
+ INIT_LIST_HEAD(&conn->requeue);
- INIT_WORK(&conn->xmitwork, iscsi_xmitworker);
+ INIT_WORK(&conn->xmitwork, iscsi_xmitworker, conn);
/* allocate login_mtask used for the login/text sequences */
spin_lock_bh(&session->lock);
diff --git a/libiscsi.h b/libiscsi.h
-index 3ee0f4f..24fb7d5 100644
+index e3e7ba0..f8493b4 100644
--- a/libiscsi.h
+++ b/libiscsi.h
@@ -25,8 +25,6 @@
diff --git a/kernel/2.6.19_compat.patch b/kernel/2.6.19_compat.patch
index 14b9f8b..43836b9 100644
--- a/kernel/2.6.19_compat.patch
+++ b/kernel/2.6.19_compat.patch
@@ -23,10 +23,10 @@ index 4b86fe4..0e468c6 100644
struct socket;
diff --git a/libiscsi.c b/libiscsi.c
-index f2ef4c7..fd241ca 100644
+index c7994d9..feca101 100644
--- a/libiscsi.c
+++ b/libiscsi.c
-@@ -760,10 +760,9 @@ again:
+@@ -782,10 +782,9 @@ again:
return rc;
}
@@ -39,17 +39,17 @@ index f2ef4c7..fd241ca 100644
int rc;
/*
* serialize Xmit worker on a per-connection basis.
-@@ -1528,7 +1527,7 @@ iscsi_conn_setup(struct iscsi_cls_session *cls_session, uint32_t conn_idx)
- if (conn->mgmtqueue == ERR_PTR(-ENOMEM))
- goto mgmtqueue_alloc_fail;
-
+@@ -1634,7 +1633,7 @@ iscsi_conn_setup(struct iscsi_cls_session *cls_session, uint32_t conn_idx)
+ INIT_LIST_HEAD(&conn->mgmtqueue);
+ INIT_LIST_HEAD(&conn->xmitqueue);
+ INIT_LIST_HEAD(&conn->requeue);
- INIT_WORK(&conn->xmitwork, iscsi_xmitworker);
+ INIT_WORK(&conn->xmitwork, iscsi_xmitworker, conn);
/* allocate login_mtask used for the login/text sequences */
spin_lock_bh(&session->lock);
diff --git a/libiscsi.h b/libiscsi.h
-index 3ee0f4f..24fb7d5 100644
+index e3e7ba0..f8493b4 100644
--- a/libiscsi.h
+++ b/libiscsi.h
@@ -25,8 +25,6 @@
diff --git a/kernel/iscsi_tcp.c b/kernel/iscsi_tcp.c
index 5b095ae..7e6b949 100644
--- a/kernel/iscsi_tcp.c
+++ b/kernel/iscsi_tcp.c
@@ -379,8 +379,7 @@ iscsi_r2t_rsp(struct iscsi_conn *conn, struct iscsi_cmd_task *ctask)
spin_lock(&session->lock);
iscsi_update_cmdsn(session, (struct iscsi_nopin*)rhdr);
- if (!ctask->sc || ctask->mtask ||
- session->state != ISCSI_STATE_LOGGED_IN) {
+ if (!ctask->sc || session->state != ISCSI_STATE_LOGGED_IN) {
printk(KERN_INFO "iscsi_tcp: dropping R2T itt %d in "
"recovery...\n", ctask->itt);
spin_unlock(&session->lock);
@@ -420,10 +419,9 @@ iscsi_r2t_rsp(struct iscsi_conn *conn, struct iscsi_cmd_task *ctask)
tcp_ctask->exp_datasn = r2tsn + 1;
__kfifo_put(tcp_ctask->r2tqueue, (void*)&r2t, sizeof(void*));
tcp_ctask->xmstate |= XMSTATE_SOL_HDR_INIT;
- list_move_tail(&ctask->running, &conn->xmitqueue);
-
- scsi_queue_work(session->host, &conn->xmitwork);
conn->r2t_pdus_cnt++;
+
+ iscsi_requeue_ctask(ctask);
spin_unlock(&session->lock);
return 0;
@@ -2272,6 +2270,7 @@ static struct scsi_host_template iscsi_sht = {
.max_sectors = 0xFFFF,
.cmd_per_lun = ISCSI_DEF_CMD_PER_LUN,
.eh_abort_handler = iscsi_eh_abort,
+ .eh_device_reset_handler= iscsi_eh_device_reset,
.eh_host_reset_handler = iscsi_eh_host_reset,
.use_clustering = DISABLE_CLUSTERING,
.slave_configure = iscsi_tcp_slave_configure,
@@ -2303,7 +2302,8 @@ static struct iscsi_transport iscsi_tcp_transport = {
ISCSI_PERSISTENT_ADDRESS |
ISCSI_TARGET_NAME | ISCSI_TPGT |
ISCSI_USERNAME | ISCSI_PASSWORD |
- ISCSI_USERNAME_IN | ISCSI_PASSWORD_IN,
+ ISCSI_USERNAME_IN | ISCSI_PASSWORD_IN |
+ ISCSI_FAST_ABORT,
.host_param_mask = ISCSI_HOST_HWADDRESS | ISCSI_HOST_IPADDRESS |
ISCSI_HOST_INITIATOR_NAME |
ISCSI_HOST_NETDEV_NAME,
diff --git a/kernel/libiscsi.c b/kernel/libiscsi.c
index 337055a..4207668 100644
--- a/kernel/libiscsi.c
+++ b/kernel/libiscsi.c
@@ -86,7 +86,7 @@ iscsi_update_cmdsn(struct iscsi_session *session, struct iscsi_nopin *hdr)
* xmit thread
*/
if (!list_empty(&session->leadconn->xmitqueue) ||
- __kfifo_len(session->leadconn->mgmtqueue))
+ !list_empty(&session->leadconn->mgmtqueue))
scsi_queue_work(session->host,
&session->leadconn->xmitwork);
}
@@ -321,15 +321,15 @@ static void iscsi_tmf_rsp(struct iscsi_conn *conn, struct iscsi_hdr *hdr)
conn->exp_statsn = be32_to_cpu(hdr->statsn) + 1;
conn->tmfrsp_pdus_cnt++;
- if (conn->tmabort_state != TMABORT_INITIAL)
+ if (conn->tmf_state != TMF_QUEUED)
return;
if (tmf->response == ISCSI_TMF_RSP_COMPLETE)
- conn->tmabort_state = TMABORT_SUCCESS;
+ conn->tmf_state = TMF_SUCCESS;
else if (tmf->response == ISCSI_TMF_RSP_NO_TASK)
- conn->tmabort_state = TMABORT_NOT_FOUND;
+ conn->tmf_state = TMF_NOT_FOUND;
else
- conn->tmabort_state = TMABORT_FAILED;
+ conn->tmf_state = TMF_FAILED;
wake_up(&conn->ehwait);
}
@@ -432,7 +432,7 @@ int __iscsi_complete_pdu(struct iscsi_conn *conn, struct iscsi_hdr *hdr,
*/
if (iscsi_recv_pdu(conn->cls_conn, hdr, data, datalen))
rc = ISCSI_ERR_CONN_FAILED;
- list_del(&mtask->running);
+ list_del_init(&mtask->running);
if (conn->login_mtask != mtask)
__kfifo_put(session->mgmtpool.queue,
(void*)&mtask, sizeof(void*));
@@ -454,10 +454,9 @@ int __iscsi_complete_pdu(struct iscsi_conn *conn, struct iscsi_hdr *hdr,
if (iscsi_recv_pdu(conn->cls_conn, hdr, data, datalen))
rc = ISCSI_ERR_CONN_FAILED;
- list_del(&mtask->running);
- if (conn->login_mtask != mtask)
- __kfifo_put(session->mgmtpool.queue,
- (void*)&mtask, sizeof(void*));
+ list_del_init(&mtask->running);
+ __kfifo_put(session->mgmtpool.queue,
+ (void*)&mtask, sizeof(void*));
break;
default:
rc = ISCSI_ERR_BAD_OPCODE;
@@ -612,7 +611,8 @@ static void iscsi_prep_mtask(struct iscsi_conn *conn,
session->tt->init_mgmt_task(conn, mtask);
debug_scsi("mgmtpdu [op 0x%x hdr->itt 0x%x datalen %d]\n",
- hdr->opcode, hdr->itt, mtask->data_count);
+ hdr->opcode & ISCSI_OPCODE_MASK, hdr->itt,
+ mtask->data_count);
}
static int iscsi_xmit_mtask(struct iscsi_conn *conn)
@@ -661,21 +661,13 @@ static int iscsi_check_cmdsn_window_closed(struct iscsi_conn *conn)
static int iscsi_xmit_ctask(struct iscsi_conn *conn)
{
struct iscsi_cmd_task *ctask = conn->ctask;
- int rc = 0;
-
- /*
- * serialize with TMF AbortTask
- */
- if (ctask->state == ISCSI_TASK_ABORTING)
- goto done;
+ int rc;
__iscsi_get_ctask(ctask);
spin_unlock_bh(&conn->session->lock);
rc = conn->session->tt->xmit_cmd_task(conn, ctask);
spin_lock_bh(&conn->session->lock);
__iscsi_put_ctask(ctask);
-
-done:
if (!rc)
/* done with this ctask */
conn->ctask = NULL;
@@ -683,6 +675,22 @@ done:
}
/**
+ * iscsi_requeue_ctask - requeue ctask to run from session workqueue
+ * @ctask: ctask to requeue
+ *
+ * LLDs that need to run a ctask from the session workqueue should call
+ * this. The session lock must be held.
+ */
+void iscsi_requeue_ctask(struct iscsi_cmd_task *ctask)
+{
+ struct iscsi_conn *conn = ctask->conn;
+
+ list_move_tail(&ctask->running, &conn->requeue);
+ scsi_queue_work(conn->session->host, &conn->xmitwork);
+}
+EXPORT_SYMBOL_GPL(iscsi_requeue_ctask);
+
+/**
* iscsi_data_xmit - xmit any command into the scheduled connection
* @conn: iscsi connection
*
@@ -720,27 +728,25 @@ static int iscsi_data_xmit(struct iscsi_conn *conn)
* overflow us with nop-ins
*/
check_mgmt:
- while (__kfifo_get(conn->mgmtqueue, (void*)&conn->mtask,
- sizeof(void*))) {
+ while (!list_empty(&conn->mgmtqueue)) {
+ conn->mtask = list_entry(conn->mgmtqueue.next,
+ struct iscsi_mgmt_task, running);
iscsi_prep_mtask(conn, conn->mtask);
- list_add_tail(&conn->mtask->running, &conn->mgmt_run_list);
+ list_move_tail(conn->mgmtqueue.next, &conn->mgmt_run_list);
rc = iscsi_xmit_mtask(conn);
if (rc)
goto again;
}
- /* process command queue */
+ /* process pending command queue */
while (!list_empty(&conn->xmitqueue)) {
- /*
- * iscsi tcp may readd the task to the xmitqueue to send
- * write data
- */
+ if (conn->tmf_state == TMF_QUEUED)
+ break;
+
conn->ctask = list_entry(conn->xmitqueue.next,
struct iscsi_cmd_task, running);
- if (conn->ctask->state == ISCSI_TASK_PENDING) {
- iscsi_prep_scsi_cmd_pdu(conn->ctask);
- conn->session->tt->init_cmd_task(conn->ctask);
- }
+ iscsi_prep_scsi_cmd_pdu(conn->ctask);
+ conn->session->tt->init_cmd_task(conn->ctask);
conn->ctask->state = ISCSI_TASK_RUNNING;
list_move_tail(conn->xmitqueue.next, &conn->run_list);
rc = iscsi_xmit_ctask(conn);
@@ -751,7 +757,22 @@ check_mgmt:
* we need to check the mgmt queue for nops that need to
* be sent to aviod starvation
*/
- if (__kfifo_len(conn->mgmtqueue))
+ if (!list_empty(&conn->mgmtqueue))
+ goto check_mgmt;
+ }
+
+ while (!list_empty(&conn->requeue)) {
+ if (conn->session->fast_abort && conn->tmf_state != TMF_INITIAL)
+ break;
+
+ conn->ctask = list_entry(conn->requeue.next,
+ struct iscsi_cmd_task, running);
+ conn->ctask->state = ISCSI_TASK_RUNNING;
+ list_move_tail(conn->requeue.next, &conn->run_list);
+ rc = iscsi_xmit_ctask(conn);
+ if (rc)
+ goto again;
+ if (!list_empty(&conn->mgmtqueue))
goto check_mgmt;
}
spin_unlock_bh(&conn->session->lock);
@@ -855,7 +876,6 @@ int iscsi_queuecommand(struct scsi_cmnd *sc, void (*done)(struct scsi_cmnd *))
atomic_set(&ctask->refcount, 1);
ctask->state = ISCSI_TASK_PENDING;
- ctask->mtask = NULL;
ctask->conn = conn;
ctask->sc = sc;
INIT_LIST_HEAD(&ctask->running);
@@ -925,9 +945,9 @@ __iscsi_conn_send_pdu(struct iscsi_conn *conn, struct iscsi_hdr *hdr,
} else
mtask->data_count = 0;
- INIT_LIST_HEAD(&mtask->running);
memcpy(mtask->hdr, hdr, sizeof(struct iscsi_hdr));
- __kfifo_put(conn->mgmtqueue, (void*)&mtask, sizeof(void*));
+ INIT_LIST_HEAD(&mtask->running);
+ list_add_tail(&mtask->running, &conn->mgmtqueue);
return mtask;
}
@@ -967,7 +987,6 @@ int iscsi_eh_host_reset(struct scsi_cmnd *sc)
struct Scsi_Host *host = sc->device->host;
struct iscsi_session *session = iscsi_hostdata(host->hostdata);
struct iscsi_conn *conn = session->leadconn;
- int fail_session = 0;
spin_lock_bh(&session->lock);
if (session->state == ISCSI_STATE_TERMINATE) {
@@ -978,19 +997,13 @@ failed:
return FAILED;
}
- if (sc->SCp.phase == session->age) {
- debug_scsi("failing connection CID %d due to SCSI host reset\n",
- conn->id);
- fail_session = 1;
- }
spin_unlock_bh(&session->lock);
/*
* we drop the lock here but the leadconn cannot be destoyed while
* we are in the scsi eh
*/
- if (fail_session)
- iscsi_conn_failure(conn, ISCSI_ERR_CONN_FAILED);
+ iscsi_conn_failure(conn, ISCSI_ERR_CONN_FAILED);
debug_scsi("iscsi_eh_host_reset wait for relogin\n");
wait_event_interruptible(conn->ehwait,
@@ -1011,120 +1024,74 @@ failed:
}
EXPORT_SYMBOL_GPL(iscsi_eh_host_reset);
-static void iscsi_tmabort_timedout(unsigned long data)
+static void iscsi_tmf_timedout(unsigned long data)
{
- struct iscsi_cmd_task *ctask = (struct iscsi_cmd_task *)data;
- struct iscsi_conn *conn = ctask->conn;
+ struct iscsi_conn *conn = (struct iscsi_conn *)data;
struct iscsi_session *session = conn->session;
spin_lock(&session->lock);
- if (conn->tmabort_state == TMABORT_INITIAL) {
- conn->tmabort_state = TMABORT_TIMEDOUT;
- debug_scsi("tmabort timedout [sc %p itt 0x%x]\n",
- ctask->sc, ctask->itt);
+ if (conn->tmf_state == TMF_QUEUED) {
+ conn->tmf_state = TMF_TIMEDOUT;
+ debug_scsi("tmf timedout\n");
/* unblock eh_abort() */
wake_up(&conn->ehwait);
}
spin_unlock(&session->lock);
}
-static int iscsi_exec_abort_task(struct scsi_cmnd *sc,
- struct iscsi_cmd_task *ctask)
+static int iscsi_exec_task_mgmt_fn(struct iscsi_conn *conn,
+ struct iscsi_tm *hdr, int age)
{
- struct iscsi_conn *conn = ctask->conn;
struct iscsi_session *session = conn->session;
- struct iscsi_tm *hdr = &conn->tmhdr;
-
- /*
- * ctask timed out but session is OK requests must be serialized.
- */
- memset(hdr, 0, sizeof(struct iscsi_tm));
- hdr->opcode = ISCSI_OP_SCSI_TMFUNC | ISCSI_OP_IMMEDIATE;
- hdr->flags = ISCSI_TM_FUNC_ABORT_TASK;
- hdr->flags |= ISCSI_FLAG_CMD_FINAL;
- memcpy(hdr->lun, ctask->hdr->lun, sizeof(hdr->lun));
- hdr->rtt = ctask->hdr->itt;
- hdr->refcmdsn = ctask->hdr->cmdsn;
+ struct iscsi_mgmt_task *mtask;
- ctask->mtask = __iscsi_conn_send_pdu(conn, (struct iscsi_hdr *)hdr,
- NULL, 0);
- if (!ctask->mtask) {
+ mtask = __iscsi_conn_send_pdu(conn, (struct iscsi_hdr *)hdr,
+ NULL, 0);
+ if (!mtask) {
+ spin_unlock_bh(&session->lock);
iscsi_conn_failure(conn, ISCSI_ERR_CONN_FAILED);
- debug_scsi("abort sent failure [itt 0x%x]\n", ctask->itt);
+ spin_lock_bh(&session->lock);
+ debug_scsi("tmf exec failure\n");
return -EPERM;
}
- ctask->state = ISCSI_TASK_ABORTING;
-
- debug_scsi("abort sent [itt 0x%x]\n", ctask->itt);
+ conn->tmfcmd_pdus_cnt++;
+ conn->tmf_timer.expires = 30 * HZ + jiffies;
+ conn->tmf_timer.function = iscsi_tmf_timedout;
+ conn->tmf_timer.data = (unsigned long)conn;
+ add_timer(&conn->tmf_timer);
+ debug_scsi("tmf set timeout\n");
- if (conn->tmabort_state == TMABORT_INITIAL) {
- conn->tmfcmd_pdus_cnt++;
- conn->tmabort_timer.expires = 20*HZ + jiffies;
- conn->tmabort_timer.function = iscsi_tmabort_timedout;
- conn->tmabort_timer.data = (unsigned long)ctask;
- add_timer(&conn->tmabort_timer);
- debug_scsi("abort set timeout [itt 0x%x]\n", ctask->itt);
- }
spin_unlock_bh(&session->lock);
+ mutex_unlock(&session->eh_mutex);
scsi_queue_work(session->host, &conn->xmitwork);
/*
* block eh thread until:
*
- * 1) abort response
- * 2) abort timeout
+ * 1) tmf response
+ * 2) tmf timeout
* 3) session is terminated or restarted or userspace has
* given up on recovery
*/
- wait_event_interruptible(conn->ehwait,
- sc->SCp.phase != session->age ||
+ wait_event_interruptible(conn->ehwait, age != session->age ||
session->state != ISCSI_STATE_LOGGED_IN ||
- conn->tmabort_state != TMABORT_INITIAL);
+ conn->tmf_state != TMF_QUEUED);
if (signal_pending(current))
flush_signals(current);
- del_timer_sync(&conn->tmabort_timer);
- spin_lock_bh(&session->lock);
- return 0;
-}
-
-/*
- * session lock must be held
- */
-static struct iscsi_mgmt_task *
-iscsi_remove_mgmt_task(struct kfifo *fifo, uint32_t itt)
-{
- int i, nr_tasks = __kfifo_len(fifo) / sizeof(void*);
- struct iscsi_mgmt_task *task;
-
- debug_scsi("searching %d tasks\n", nr_tasks);
+ del_timer_sync(&conn->tmf_timer);
- for (i = 0; i < nr_tasks; i++) {
- __kfifo_get(fifo, (void*)&task, sizeof(void*));
- debug_scsi("check task %u\n", task->itt);
-
- if (task->itt == itt) {
- debug_scsi("matched task\n");
- return task;
- }
+ mutex_lock(&session->eh_mutex);
+ spin_lock_bh(&session->lock);
+ /* if the session drops it will clean up the mtask */
+ if (age != session->age ||
+ session->state != ISCSI_STATE_LOGGED_IN)
+ return -ENOTCONN;
- __kfifo_put(fifo, (void*)&task, sizeof(void*));
+ if (!list_empty(&mtask->running)) {
+ list_del_init(&mtask->running);
+ __kfifo_put(session->mgmtpool.queue, (void*)&mtask,
+ sizeof(void*));
}
- return NULL;
-}
-
-static int iscsi_ctask_mtask_cleanup(struct iscsi_cmd_task *ctask)
-{
- struct iscsi_conn *conn = ctask->conn;
- struct iscsi_session *session = conn->session;
-
- if (!ctask->mtask)
- return -EINVAL;
-
- if (!iscsi_remove_mgmt_task(conn->mgmtqueue, ctask->mtask->itt))
- list_del(&ctask->mtask->running);
- __kfifo_put(session->mgmtpool.queue, (void*)&ctask->mtask,
- sizeof(void*));
- ctask->mtask = NULL;
return 0;
}
@@ -1148,7 +1115,6 @@ static void fail_command(struct iscsi_conn *conn, struct iscsi_cmd_task *ctask,
conn->session->queued_cmdsn--;
else
conn->session->tt->cleanup_cmd_task(conn, ctask);
- iscsi_ctask_mtask_cleanup(ctask);
sc->result = err;
sc->resid = sc->request_bufflen;
@@ -1158,14 +1124,78 @@ static void fail_command(struct iscsi_conn *conn, struct iscsi_cmd_task *ctask,
__iscsi_put_ctask(ctask);
}
+/*
+ * Fail commands. session lock held and recv side suspended and xmit
+ * thread flushed
+ */
+static void fail_all_commands(struct iscsi_conn *conn, unsigned lun)
+{
+ struct iscsi_cmd_task *ctask, *tmp;
+
+ if (conn->ctask && (conn->ctask->sc->device->lun == lun || lun == -1))
+ conn->ctask = NULL;
+
+ /* flush pending */
+ list_for_each_entry_safe(ctask, tmp, &conn->xmitqueue, running) {
+ if (lun == ctask->sc->device->lun || lun == -1) {
+ debug_scsi("failing pending sc %p itt 0x%x\n",
+ ctask->sc, ctask->itt);
+ fail_command(conn, ctask, DID_BUS_BUSY << 16);
+ }
+ }
+
+ list_for_each_entry_safe(ctask, tmp, &conn->requeue, running) {
+ if (lun == ctask->sc->device->lun || lun == -1) {
+ debug_scsi("failing requeued sc %p itt 0x%x\n",
+ ctask->sc, ctask->itt);
+ fail_command(conn, ctask, DID_BUS_BUSY << 16);
+ }
+ }
+
+ /* fail all other running */
+ list_for_each_entry_safe(ctask, tmp, &conn->run_list, running) {
+ if (lun == ctask->sc->device->lun || lun == -1) {
+ debug_scsi("failing in progress sc %p itt 0x%x\n",
+ ctask->sc, ctask->itt);
+ fail_command(conn, ctask, DID_BUS_BUSY << 16);
+ }
+ }
+}
+
+static void iscsi_suspend_tx(struct iscsi_conn *conn)
+{
+ set_bit(ISCSI_SUSPEND_BIT, &conn->suspend_tx);
+ scsi_flush_work(conn->session->host);
+}
+
+static void iscsi_start_tx(struct iscsi_conn *conn)
+{
+ clear_bit(ISCSI_SUSPEND_BIT, &conn->suspend_tx);
+ scsi_queue_work(conn->session->host, &conn->xmitwork);
+}
+
+static void iscsi_prep_abort_task_pdu(struct iscsi_cmd_task *ctask,
+ struct iscsi_tm *hdr)
+{
+ memset(hdr, 0, sizeof(*hdr));
+ hdr->opcode = ISCSI_OP_SCSI_TMFUNC | ISCSI_OP_IMMEDIATE;
+ hdr->flags = ISCSI_TM_FUNC_ABORT_TASK & ISCSI_FLAG_TM_FUNC_MASK;
+ hdr->flags |= ISCSI_FLAG_CMD_FINAL;
+ memcpy(hdr->lun, ctask->hdr->lun, sizeof(hdr->lun));
+ hdr->rtt = ctask->hdr->itt;
+ hdr->refcmdsn = ctask->hdr->cmdsn;
+}
+
int iscsi_eh_abort(struct scsi_cmnd *sc)
{
struct Scsi_Host *host = sc->device->host;
struct iscsi_session *session = iscsi_hostdata(host->hostdata);
struct iscsi_conn *conn;
struct iscsi_cmd_task *ctask;
- int rc;
+ struct iscsi_tm *hdr;
+ int rc, age;
+ mutex_lock(&session->eh_mutex);
spin_lock_bh(&session->lock);
/*
* if session was ISCSI_STATE_IN_RECOVERY then we may not have
@@ -1174,21 +1204,26 @@ int iscsi_eh_abort(struct scsi_cmnd *sc)
if (!sc->SCp.ptr) {
debug_scsi("sc never reached iscsi layer or it completed.\n");
spin_unlock_bh(&session->lock);
+ mutex_unlock(&session->eh_mutex);
return SUCCESS;
}
- ctask = (struct iscsi_cmd_task *)sc->SCp.ptr;
- conn = session->leadconn;
- conn->eh_abort_cnt++;
- debug_scsi("aborting [sc %p itt 0x%x]\n", sc, ctask->itt);
-
/*
* If we are not logged in or we have started a new session
* then let the host reset code handle this
*/
- if (session->state != ISCSI_STATE_LOGGED_IN ||
- sc->SCp.phase != session->age)
- goto failed;
+ if (!session->leadconn || session->state != ISCSI_STATE_LOGGED_IN ||
+ sc->SCp.phase != session->age) {
+ spin_unlock_bh(&session->lock);
+ return FAILED;
+ }
+
+ conn = session->leadconn;
+ conn->eh_abort_cnt++;
+ age = session->age;
+
+ ctask = (struct iscsi_cmd_task *)sc->SCp.ptr;
+ debug_scsi("aborting [sc %p itt 0x%x]\n", sc, ctask->itt);
/* ctask completed before time out */
if (!ctask->sc) {
@@ -1196,70 +1231,153 @@ int iscsi_eh_abort(struct scsi_cmnd *sc)
goto success;
}
- /* what should we do here ? */
- if (conn->ctask == ctask) {
- printk(KERN_INFO "iscsi: sc %p itt 0x%x partially sent. "
- "Failing abort\n", sc, ctask->itt);
- goto failed;
- }
-
if (ctask->state == ISCSI_TASK_PENDING) {
fail_command(conn, ctask, DID_ABORT << 16);
goto success;
}
- conn->tmabort_state = TMABORT_INITIAL;
- rc = iscsi_exec_abort_task(sc, ctask);
- if (rc || sc->SCp.phase != session->age ||
- session->state != ISCSI_STATE_LOGGED_IN)
+ /* only have one tmf outstanding at a time */
+ if (conn->tmf_state != TMF_INITIAL)
goto failed;
- iscsi_ctask_mtask_cleanup(ctask);
+ conn->tmf_state = TMF_QUEUED;
- switch (conn->tmabort_state) {
- case TMABORT_SUCCESS:
+ hdr = &conn->tmhdr;
+ iscsi_prep_abort_task_pdu(ctask, hdr);
+
+ if (iscsi_exec_task_mgmt_fn(conn, hdr, age)) {
+ rc = FAILED;
+ goto failed;
+ }
+
+ switch (conn->tmf_state) {
+ case TMF_SUCCESS:
spin_unlock_bh(&session->lock);
+ iscsi_suspend_tx(conn);
/*
* clean up task if aborted. grab the recv lock as a writer
*/
write_lock_bh(conn->recv_lock);
spin_lock(&session->lock);
fail_command(conn, ctask, DID_ABORT << 16);
+ conn->tmf_state = TMF_INITIAL;
spin_unlock(&session->lock);
write_unlock_bh(conn->recv_lock);
- /*
- * make sure xmit thread is not still touching the
- * ctask/scsi_cmnd
- */
- scsi_flush_work(session->host);
+ iscsi_start_tx(conn);
goto success_unlocked;
- case TMABORT_NOT_FOUND:
- if (!ctask->sc) {
+ case TMF_TIMEDOUT:
+ spin_unlock_bh(&session->lock);
+ iscsi_conn_failure(conn, ISCSI_ERR_CONN_FAILED);
+ goto failed_unlocked;
+ case TMF_NOT_FOUND:
+ if (!sc->SCp.ptr) {
+ conn->tmf_state = TMF_INITIAL;
/* ctask completed before tmf abort response */
debug_scsi("sc completed while abort in progress\n");
goto success;
}
/* fall through */
default:
- /* timedout or failed */
- spin_unlock_bh(&session->lock);
- iscsi_conn_failure(conn, ISCSI_ERR_CONN_FAILED);
- goto failed_unlocked;
+ conn->tmf_state = TMF_INITIAL;
+ goto failed;
}
success:
spin_unlock_bh(&session->lock);
success_unlocked:
debug_scsi("abort success [sc %lx itt 0x%x]\n", (long)sc, ctask->itt);
+ mutex_unlock(&session->eh_mutex);
return SUCCESS;
failed:
spin_unlock_bh(&session->lock);
failed_unlocked:
- debug_scsi("abort failed [sc %lx itt 0x%x]\n", (long)sc, ctask->itt);
+ debug_scsi("abort failed [sc %p itt 0x%x]\n", sc,
+ ctask ? ctask->itt : 0);
+ mutex_unlock(&session->eh_mutex);
return FAILED;
}
EXPORT_SYMBOL_GPL(iscsi_eh_abort);
+static void iscsi_prep_lun_reset_pdu(struct scsi_cmnd *sc, struct iscsi_tm *hdr)
+{
+ memset(hdr, 0, sizeof(*hdr));
+ hdr->opcode = ISCSI_OP_SCSI_TMFUNC | ISCSI_OP_IMMEDIATE;
+ hdr->flags = ISCSI_TM_FUNC_LOGICAL_UNIT_RESET & ISCSI_FLAG_TM_FUNC_MASK;
+ hdr->flags |= ISCSI_FLAG_CMD_FINAL;
+ int_to_scsilun(sc->device->lun, (struct scsi_lun *)hdr->lun);
+ hdr->rtt = ISCSI_RESERVED_TAG;
+}
+
+int iscsi_eh_device_reset(struct scsi_cmnd *sc)
+{
+ struct Scsi_Host *host = sc->device->host;
+ struct iscsi_session *session = iscsi_hostdata(host->hostdata);
+ struct iscsi_conn *conn;
+ struct iscsi_tm *hdr;
+ int rc = FAILED;
+
+ debug_scsi("LU Reset [sc %p lun %u]\n", sc, sc->device->lun);
+
+ mutex_lock(&session->eh_mutex);
+ spin_lock_bh(&session->lock);
+ /*
+ * Just check if we are not logged in. We cannot check for
+ * the phase because the reset could come from a ioctl.
+ */
+ if (!session->leadconn || session->state != ISCSI_STATE_LOGGED_IN)
+ goto unlock;
+ conn = session->leadconn;
+
+ /* only have one tmf outstanding at a time */
+ if (conn->tmf_state != TMF_INITIAL)
+ goto unlock;
+ conn->tmf_state = TMF_QUEUED;
+
+ hdr = &conn->tmhdr;
+ iscsi_prep_lun_reset_pdu(sc, hdr);
+
+ if (iscsi_exec_task_mgmt_fn(conn, hdr, session->age)) {
+ rc = FAILED;
+ goto unlock;
+ }
+
+ switch (conn->tmf_state) {
+ case TMF_SUCCESS:
+ break;
+ case TMF_TIMEDOUT:
+ spin_unlock_bh(&session->lock);
+ iscsi_conn_failure(conn, ISCSI_ERR_CONN_FAILED);
+ goto done;
+ default:
+ conn->tmf_state = TMF_INITIAL;
+ goto unlock;
+ }
+
+ rc = SUCCESS;
+ spin_unlock_bh(&session->lock);
+
+ iscsi_suspend_tx(conn);
+ /* need to grab the recv lock then session lock */
+ write_lock_bh(conn->recv_lock);
+ spin_lock(&session->lock);
+ fail_all_commands(conn, sc->device->lun);
+ conn->tmf_state = TMF_INITIAL;
+ spin_unlock(&session->lock);
+ write_unlock_bh(conn->recv_lock);
+
+ iscsi_start_tx(conn);
+ goto done;
+
+unlock:
+ spin_unlock_bh(&session->lock);
+done:
+ debug_scsi("iscsi_eh_device_reset %s\n",
+ rc == SUCCESS ? "SUCCESS" : "FAILED");
+ mutex_unlock(&session->eh_mutex);
+ return rc;
+}
+EXPORT_SYMBOL_GPL(iscsi_eh_device_reset);
+
int
iscsi_pool_init(struct iscsi_queue *q, int max, void ***items, int item_size)
{
@@ -1402,6 +1520,7 @@ iscsi_session_setup(struct iscsi_transport *iscsit,
session->max_cmdsn = initial_cmdsn + 1;
session->max_r2t = 1;
session->tt = iscsit;
+ mutex_init(&session->eh_mutex);
/* initialize SCSI PDU commands pool */
if (iscsi_pool_init(&session->cmdpool, session->cmds_max,
@@ -1523,17 +1642,12 @@ iscsi_conn_setup(struct iscsi_cls_session *cls_session, uint32_t conn_idx)
conn->c_stage = ISCSI_CONN_INITIAL_STAGE;
conn->id = conn_idx;
conn->exp_statsn = 0;
- conn->tmabort_state = TMABORT_INITIAL;
+ conn->tmf_state = TMF_INITIAL;
INIT_LIST_HEAD(&conn->run_list);
INIT_LIST_HEAD(&conn->mgmt_run_list);
+ INIT_LIST_HEAD(&conn->mgmtqueue);
INIT_LIST_HEAD(&conn->xmitqueue);
-
- /* initialize general immediate & non-immediate PDU commands queue */
- conn->mgmtqueue = kfifo_alloc(session->mgmtpool_max * sizeof(void*),
- GFP_KERNEL, NULL);
- if (conn->mgmtqueue == ERR_PTR(-ENOMEM))
- goto mgmtqueue_alloc_fail;
-
+ INIT_LIST_HEAD(&conn->requeue);
INIT_WORK(&conn->xmitwork, iscsi_xmitworker);
/* allocate login_mtask used for the login/text sequences */
@@ -1551,7 +1665,7 @@ iscsi_conn_setup(struct iscsi_cls_session *cls_session, uint32_t conn_idx)
goto login_mtask_data_alloc_fail;
conn->login_mtask->data = conn->data = data;
- init_timer(&conn->tmabort_timer);
+ init_timer(&conn->tmf_timer);
init_waitqueue_head(&conn->ehwait);
return cls_conn;
@@ -1560,8 +1674,6 @@ login_mtask_data_alloc_fail:
__kfifo_put(session->mgmtpool.queue, (void*)&conn->login_mtask,
sizeof(void*));
login_mtask_alloc_fail:
- kfifo_free(conn->mgmtqueue);
-mgmtqueue_alloc_fail:
iscsi_destroy_conn(cls_conn);
return NULL;
}
@@ -1581,7 +1693,6 @@ void iscsi_conn_teardown(struct iscsi_cls_conn *cls_conn)
unsigned long flags;
spin_lock_bh(&session->lock);
- set_bit(ISCSI_SUSPEND_BIT, &conn->suspend_tx);
conn->c_stage = ISCSI_CONN_CLEANUP_WAIT;
if (session->leadconn == conn) {
/*
@@ -1614,7 +1725,7 @@ void iscsi_conn_teardown(struct iscsi_cls_conn *cls_conn)
}
/* flush queued up work because we free the connection below */
- scsi_flush_work(session->host);
+ iscsi_suspend_tx(conn);
spin_lock_bh(&session->lock);
kfree(conn->data);
@@ -1625,8 +1736,6 @@ void iscsi_conn_teardown(struct iscsi_cls_conn *cls_conn)
session->leadconn = NULL;
spin_unlock_bh(&session->lock);
- kfifo_free(conn->mgmtqueue);
-
iscsi_destroy_conn(cls_conn);
}
EXPORT_SYMBOL_GPL(iscsi_conn_teardown);
@@ -1661,7 +1770,7 @@ int iscsi_conn_start(struct iscsi_cls_conn *cls_conn)
* commands after successful recovery
*/
conn->stop_stage = 0;
- conn->tmabort_state = TMABORT_INITIAL;
+ conn->tmf_state = TMF_INITIAL;
session->age++;
spin_unlock_bh(&session->lock);
@@ -1686,10 +1795,11 @@ flush_control_queues(struct iscsi_session *session, struct iscsi_conn *conn)
struct iscsi_mgmt_task *mtask, *tmp;
/* handle pending */
- while (__kfifo_get(conn->mgmtqueue, (void*)&mtask, sizeof(void*))) {
+ list_for_each_entry_safe(mtask, tmp, &conn->mgmtqueue, running) {
+ debug_scsi("flushing pending mgmt task itt 0x%x\n", mtask->itt);
+ list_del_init(&mtask->running);
if (mtask == conn->login_mtask)
continue;
- debug_scsi("flushing pending mgmt task itt 0x%x\n", mtask->itt);
__kfifo_put(session->mgmtpool.queue, (void*)&mtask,
sizeof(void*));
}
@@ -1697,7 +1807,7 @@ flush_control_queues(struct iscsi_session *session, struct iscsi_conn *conn)
/* handle running */
list_for_each_entry_safe(mtask, tmp, &conn->mgmt_run_list, running) {
debug_scsi("flushing running mgmt task itt 0x%x\n", mtask->itt);
- list_del(&mtask->running);
+ list_del_init(&mtask->running);
if (mtask == conn->login_mtask)
continue;
@@ -1708,36 +1818,16 @@ flush_control_queues(struct iscsi_session *session, struct iscsi_conn *conn)
conn->mtask = NULL;
}
-/* Fail commands. Mutex and session lock held and recv side suspended */
-static void fail_all_commands(struct iscsi_conn *conn)
-{
- struct iscsi_cmd_task *ctask, *tmp;
-
- /* flush pending */
- list_for_each_entry_safe(ctask, tmp, &conn->xmitqueue, running) {
- debug_scsi("failing pending sc %p itt 0x%x\n", ctask->sc,
- ctask->itt);
- fail_command(conn, ctask, DID_BUS_BUSY << 16);
- }
-
- /* fail all other running */
- list_for_each_entry_safe(ctask, tmp, &conn->run_list, running) {
- debug_scsi("failing in progress sc %p itt 0x%x\n",
- ctask->sc, ctask->itt);
- fail_command(conn, ctask, DID_BUS_BUSY << 16);
- }
-
- conn->ctask = NULL;
-}
-
static void iscsi_start_session_recovery(struct iscsi_session *session,
struct iscsi_conn *conn, int flag)
{
int old_stop_stage;
+ mutex_lock(&session->eh_mutex);
spin_lock_bh(&session->lock);
if (conn->stop_stage == STOP_CONN_TERM) {
spin_unlock_bh(&session->lock);
+ mutex_unlock(&session->eh_mutex);
return;
}
@@ -1748,6 +1838,7 @@ static void iscsi_start_session_recovery(struct iscsi_session *session,
*/
if (!conn->recv_lock) {
spin_unlock_bh(&session->lock);
+ mutex_unlock(&session->eh_mutex);
return;
}
@@ -1764,9 +1855,9 @@ static void iscsi_start_session_recovery(struct iscsi_session *session,
old_stop_stage = conn->stop_stage;
conn->stop_stage = flag;
conn->c_stage = ISCSI_CONN_STOPPED;
- set_bit(ISCSI_SUSPEND_BIT, &conn->suspend_tx);
spin_unlock_bh(&session->lock);
- scsi_flush_work(session->host);
+
+ iscsi_suspend_tx(conn);
write_lock_bh(conn->recv_lock);
set_bit(ISCSI_SUSPEND_BIT, &conn->suspend_rx);
@@ -1792,9 +1883,10 @@ static void iscsi_start_session_recovery(struct iscsi_session *session,
* flush queues.
*/
spin_lock_bh(&session->lock);
- fail_all_commands(conn);
+ fail_all_commands(conn, -1);
flush_control_queues(session, conn);
spin_unlock_bh(&session->lock);
+ mutex_unlock(&session->eh_mutex);
}
void iscsi_conn_stop(struct iscsi_cls_conn *cls_conn, int flag)
@@ -1842,6 +1934,9 @@ int iscsi_set_param(struct iscsi_cls_conn *cls_conn,
uint32_t value;
switch(param) {
+ case ISCSI_PARAM_FAST_ABORT:
+ sscanf(buf, "%d", &session->fast_abort);
+ break;
case ISCSI_PARAM_MAX_RECV_DLENGTH:
sscanf(buf, "%d", &conn->max_recv_dlength);
break;
@@ -1956,6 +2051,9 @@ int iscsi_session_get_param(struct iscsi_cls_session *cls_session,
int len;
switch(param) {
+ case ISCSI_PARAM_FAST_ABORT:
+ len = sprintf(buf, "%d\n", session->fast_abort);
+ break;
case ISCSI_PARAM_INITIAL_R2T_EN:
len = sprintf(buf, "%d\n", session->initial_r2t_en);
break;
diff --git a/kernel/libiscsi.h b/kernel/libiscsi.h
index bba8f93..dbea6b4 100644
--- a/kernel/libiscsi.h
+++ b/kernel/libiscsi.h
@@ -57,11 +57,14 @@ struct iscsi_nopin;
#define ISCSI_MAX_CMD_PER_LUN 128
/* Task Mgmt states */
-#define TMABORT_INITIAL 0x0
-#define TMABORT_SUCCESS 0x1
-#define TMABORT_FAILED 0x2
-#define TMABORT_TIMEDOUT 0x3
-#define TMABORT_NOT_FOUND 0x4
+enum {
+ TMF_INITIAL,
+ TMF_QUEUED,
+ TMF_SUCCESS,
+ TMF_FAILED,
+ TMF_TIMEDOUT,
+ TMF_NOT_FOUND,
+};
/* Connection suspend "bit" */
#define ISCSI_SUSPEND_BIT 1
@@ -91,7 +94,6 @@ enum {
ISCSI_TASK_COMPLETED,
ISCSI_TASK_PENDING,
ISCSI_TASK_RUNNING,
- ISCSI_TASK_ABORTING,
};
struct iscsi_cmd_task {
@@ -110,7 +112,6 @@ struct iscsi_cmd_task {
unsigned data_count; /* remaining Data-Out */
struct scsi_cmnd *sc; /* associated SCSI cmd*/
struct iscsi_conn *conn; /* used connection */
- struct iscsi_mgmt_task *mtask; /* tmf mtask in progr */
/* state set/tested under session->lock */
int state;
@@ -152,10 +153,11 @@ struct iscsi_conn {
struct iscsi_cmd_task *ctask; /* xmit ctask in progress */
/* xmit */
- struct kfifo *mgmtqueue; /* mgmt (control) xmit queue */
+ struct list_head mgmtqueue; /* mgmt (control) xmit queue */
struct list_head mgmt_run_list; /* list of control tasks */
struct list_head xmitqueue; /* data-path cmd queue */
struct list_head run_list; /* list of cmds in progress */
+ struct list_head requeue; /* tasks needing another run */
struct work_struct xmitwork; /* per-conn. xmit workqueue */
unsigned long suspend_tx; /* suspend Tx */
unsigned long suspend_rx; /* suspend Rx */
@@ -163,8 +165,8 @@ struct iscsi_conn {
/* abort */
wait_queue_head_t ehwait; /* used in eh_abort() */
struct iscsi_tm tmhdr;
- struct timer_list tmabort_timer;
- int tmabort_state; /* see TMABORT_INITIAL, etc.*/
+ struct timer_list tmf_timer;
+ int tmf_state; /* see TMF_INITIAL, etc.*/
/* negotiated params */
unsigned max_recv_dlength; /* initiator_max_recv_dsl*/
@@ -205,6 +207,13 @@ struct iscsi_queue {
};
struct iscsi_session {
+ /*
+ * Syncs up the scsi eh thread with the iscsi eh thread when sending
+ * task management functions. This must be taken before the session
+ * and recv lock.
+ */
+ struct mutex eh_mutex;
+
/* iSCSI session-wide sequencing */
uint32_t cmdsn;
uint32_t exp_cmdsn;
@@ -224,6 +233,7 @@ struct iscsi_session {
int pdu_inorder_en;
int dataseq_inorder_en;
int erl;
+ int fast_abort;
int tpgt;
char *username;
char *username_in;
@@ -261,6 +271,7 @@ struct iscsi_session {
extern int iscsi_change_queue_depth(struct scsi_device *sdev, int depth);
extern int iscsi_eh_abort(struct scsi_cmnd *sc);
extern int iscsi_eh_host_reset(struct scsi_cmnd *sc);
+extern int iscsi_eh_device_reset(struct scsi_cmnd *sc);
extern int iscsi_queuecommand(struct scsi_cmnd *sc,
void (*done)(struct scsi_cmnd *));
@@ -319,6 +330,7 @@ extern int __iscsi_complete_pdu(struct iscsi_conn *, struct iscsi_hdr *,
char *, int);
extern int iscsi_verify_itt(struct iscsi_conn *, struct iscsi_hdr *,
uint32_t *);
+extern void iscsi_requeue_ctask(struct iscsi_cmd_task *ctask);
/*
* generic helpers
diff --git a/kernel/scsi_transport_iscsi.c b/kernel/scsi_transport_iscsi.c
index 5bca8a9..96d44c3 100644
--- a/kernel/scsi_transport_iscsi.c
+++ b/kernel/scsi_transport_iscsi.c
@@ -30,7 +30,7 @@
#include "scsi_transport_iscsi.h"
#include "iscsi_if.h"
-#define ISCSI_SESSION_ATTRS 15
+#define ISCSI_SESSION_ATTRS 16
#define ISCSI_CONN_ATTRS 11
#define ISCSI_HOST_ATTRS 4
#define ISCSI_TRANSPORT_VERSION "2.0-865"
@@ -1229,6 +1229,7 @@ iscsi_session_attr(username, ISCSI_PARAM_USERNAME, 1);
iscsi_session_attr(username_in, ISCSI_PARAM_USERNAME_IN, 1);
iscsi_session_attr(password, ISCSI_PARAM_PASSWORD, 1);
iscsi_session_attr(password_in, ISCSI_PARAM_PASSWORD_IN, 1);
+iscsi_session_attr(fast_abort, ISCSI_PARAM_FAST_ABORT, 1);
#define iscsi_priv_session_attr_show(field, format) \
static ssize_t \
@@ -1450,6 +1451,7 @@ iscsi_register_transport(struct iscsi_transport *tt)
SETUP_SESSION_RD_ATTR(password_in, ISCSI_USERNAME_IN);
SETUP_SESSION_RD_ATTR(username, ISCSI_PASSWORD);
SETUP_SESSION_RD_ATTR(username_in, ISCSI_PASSWORD_IN);
+ SETUP_SESSION_RD_ATTR(fast_abort, ISCSI_FAST_ABORT);
SETUP_PRIV_SESSION_RD_ATTR(recovery_tmo);
BUG_ON(count > ISCSI_SESSION_ATTRS);
diff --git a/usr/config.h b/usr/config.h
index d468c0a..864aee7 100644
--- a/usr/config.h
+++ b/usr/config.h
@@ -124,6 +124,7 @@ struct iscsi_session_operational_config {
int MaxConnections;
int MaxOutstandingR2T;
int ERL;
+ int FastAbort;
};
#define CONFIG_DIGEST_NEVER 0
diff --git a/usr/idbm.c b/usr/idbm.c
index 1df125d..ed9dc1e 100644
--- a/usr/idbm.c
+++ b/usr/idbm.c
@@ -301,6 +301,8 @@ idbm_recinfo_node(node_rec_t *r, recinfo_t *ri)
__recinfo_int("node.session.err_timeo.reset_timeout", ri, r,
session.err_timeo.reset_timeout,
IDBM_SHOW, num);
+ __recinfo_int_o2("node.session.iscsi.FastAbort", ri, r,
+ session.iscsi.FastAbort, IDBM_SHOW, "No", "Yes", num);
__recinfo_int_o2("node.session.iscsi.InitialR2T", ri, r,
session.iscsi.InitialR2T, IDBM_SHOW,
"No", "Yes", num);
diff --git a/usr/initiator.c b/usr/initiator.c
index a7e88dd..d98f81b 100644
--- a/usr/initiator.c
+++ b/usr/initiator.c
@@ -529,6 +529,7 @@ __session_create(node_rec_t *rec, struct iscsi_transport *t)
"120 seconds\n");
session->replacement_timeout = DEF_REPLACEMENT_TIMEO;
}
+ session->fast_abort = rec->session.iscsi.FastAbort;
/* OUI and uniqifying number */
session->isid[0] = DRIVER_ISID_0;
@@ -1073,7 +1074,7 @@ mgmt_ipc_err_e iscsi_host_set_param(int host_no, int param, char *value)
return MGMT_IPC_OK;
}
-#define MAX_SESSION_PARAMS 24
+#define MAX_SESSION_PARAMS 25
#define MAX_HOST_PARAMS 3
static void
@@ -1229,6 +1230,11 @@ setup_full_feature_phase(iscsi_conn_t *conn)
.value = session->password_in,
.type = ISCSI_STRING,
.conn_only = 0,
+ }, {
+ .param = ISCSI_PARAM_FAST_ABORT,
+ .value = &session->fast_abort,
+ .type = ISCSI_INT,
+ .conn_only = 0,
},
/*
* FIXME: set these timeouts via set_param() API
diff --git a/usr/initiator.h b/usr/initiator.h
index 5a8d388..7008845 100644
--- a/usr/initiator.h
+++ b/usr/initiator.h
@@ -192,6 +192,7 @@ typedef struct iscsi_session {
int erl;
uint32_t imm_data_en;
uint32_t initial_r2t_en;
+ uint32_t fast_abort;
uint32_t first_burst;
uint32_t max_burst;
uint32_t pdu_inorder_en;