When iscsi_eh_cmd_timed_out gets called, we can ask scsi-ml to give us
more time if the cmd is making progress (i.e. if there was some data
transfer since the last timeout).

The problem is that task->last_xfer & task->last_timeout are set to
the value of 'jiffies' when allocating the task. If the target machine
is already dead when we send the cmd, no progress will be made. Still,
when iscsi_eh_cmd_timed_out will be called, it will think that data
was sent since the last timeout and reset the timer (and waste time).
In order to solve that, iscsi_eh_cmd_timed_out should also check if
there was any data transfer after the task was allocated.

How about the following patch?

diff --git a/kernel/libiscsi.c b/kernel/libiscsi.c
index 90f3018..b727c10 100644
--- a/kernel/libiscsi.c
+++ b/kernel/libiscsi.c
@@ -1419,6 +1419,7 @@ static inline struct iscsi_task
*iscsi_alloc_task(struct iscsi_conn *conn,
        task->conn = conn;
        task->sc = sc;
        task->have_checked_conn = 0;
+       task->init_time = jiffies;
        task->last_timeout = jiffies;
        task->last_xfer = jiffies;
        INIT_LIST_HEAD(&task->running);
@@ -1817,7 +1818,8 @@ static enum blk_eh_timer_return
iscsi_eh_cmd_timed_out(struct scsi_cmnd *sc)
         * we can check if it is the task or connection when we send the
         * nop as a ping.
         */
-       if (time_after_eq(task->last_xfer, task->last_timeout)) {
+       if (time_after_eq(task->last_xfer, task->last_timeout) &&
+           time_after(task->last_xfer, task->init_time)) {
                ISCSI_DBG_EH(session, "Command making progress. Asking "
                             "scsi-ml for more time to complete. "
                             "Last data recv at %lu. Last timeout was at "
diff --git a/kernel/libiscsi.h b/kernel/libiscsi.h
index 1990243..4712ea9 100644
--- a/kernel/libiscsi.h
+++ b/kernel/libiscsi.h
@@ -126,6 +126,7 @@ struct iscsi_task {
        struct iscsi_conn       *conn;          /* used connection    */

        /* data processing tracking */
+       unsigned long           init_time;
        unsigned long           last_xfer;
        unsigned long           last_timeout;
        int                     have_checked_conn;

-- 
You received this message because you are subscribed to the Google Groups 
"open-iscsi" group.
To post to this group, send email to open-is...@googlegroups.com.
To unsubscribe from this group, send email to 
open-iscsi+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/open-iscsi?hl=en.

Reply via email to