IB/srp: Maintain a single connection per I_T nexus

The sysfs attribute 'add_target' may be used to relogin to a
target. An SRP target that receives a second login request from
an initiator will disconnect the previous connection. So before
trying to reconnect, check whether another connection to the
same SRP target identifier already exists. If so, remove the
target port.  Add a target to the target list before connecting
instead of after such that this algorithm has a chance to work.

Signed-off-by: Bart Van Assche <bvanassche@acm.org>
srp_transport: Add transport layer error handling

Add the necessary functions in the SRP transport module to allow
an SRP initiator driver to implement transport error handling.
This includes:
- Support for implementing fast_io_fail_tmo, the time that should
  elapse after having detected a transport layer problem and
  before failing I/O.
- Support for implementing dev_loss_tmo, the time that should
  elapse after having detected a transport layer problem and
  before removing a remote port.

Signed-off-by: Bart Van Assche <bvanassche@acm.org>
IB/srp: Add dev_loss_tmo support

Remove an SRP host if either dev_loss_tmo expired or the target
closed the IB connection.

Signed-off-by: Bart Van Assche <bvanassche@acm.org>
IB/srp: Backport to older kernels

This patch has been tested on RHEL 6.0, RHEL 6.1, RHEL 6.2, RHEL 6.3
and Ubuntu 10.04.

Signed-off-by: Bart Van Assche <bvanassche@acm.org>
Add README
README: Add a test

Signed-off-by: Bart Van Assche <bvanassche@acm.org>
scsi_transport_srp: Fail I/O faster

Let the dev_loss_tmo and fast_io_fail_tmo timers start when a failure
occurs instead of when it is reported. Also, if a SCSI timeout occurs
during port removal, stop the SCSI EH.

Signed-off-by: Bart Van Assche <bvanassche@acm.org>
ib_srp: Remove SCSI devices upon port down event

This patch is a modified version of a patch from Karandeep Chahal
<kchahal@ddn.com> that was posted on May 29, 2012 on the linux-rdma
mailing list (http://www.mail-archive.com/linux-rdma@vger.kernel.org/msg11796.html).

Signed-off-by: Bart Van Assche <bvanassche@acm.org>
scsi_transport_srp: Eliminate srp_stop_rport()

Signed-off-by: Bart Van Assche <bvanassche@acm.org>
ib_srp: Log reconnection success

Signed-off-by: Bart Van Assche <bvanassche@acm.org>
ib_srp: Avoid that cable pull during connect triggers a deadlock

Avoid that srp_connect_target() and srp_disconnect_target() can be
invoked concurrently since that might trigger a deadlock - both
functions use the target->done completion.

Stack trace for the deadlock:
 [<ffffffff8155e67d>] schedule_timeout+0x22d/0x300
 [<ffffffff8155d7f6>] wait_for_common+0xd6/0x180
 [<ffffffff8155d95d>] wait_for_completion+0x1d/0x20
 [<ffffffffa0383b13>] srp_disconnect_target+0xa3/0x350 [ib_srp]
 [<ffffffffa0387df5>] srp_reconnect_target+0x115/0x370 [ib_srp]
 [<ffffffffa038809f>] srp_reset_host+0x4f/0x60 [ib_srp]
 [<ffffffff8138b7d2>] scsi_try_host_reset+0x42/0x110
 [<ffffffff8138d012>] scsi_eh_host_reset+0x42/0x180
 [<ffffffff8138d1e1>] scsi_eh_ready_devs+0x91/0x150
 [<ffffffff8138d5cd>] scsi_unjam_host+0xed/0x210
 [<ffffffff8138d808>] scsi_error_handler+0x118/0x170
 [<ffffffff81085dc6>] kthread+0x96/0xa0

Signed-off-by: Bart Van Assche <bvanassche@acm.org>
Rework workqueue backport

Makes the system much more responsive during error recovery on
kernel 2.6.35 and before.

Signed-off-by: Bart Van Assche <bvanassche@acm.org>