[SCSI] scsi_transport_fc: Remove capping from dev_loss_tmo
authorHannes Reinecke <hare@suse.de>
Tue, 15 Dec 2009 08:26:06 +0000 (09:26 +0100)
committerJames Bottomley <James.Bottomley@suse.de>
Mon, 18 Jan 2010 16:48:09 +0000 (10:48 -0600)
Currently dev_loss_tmo is capped by SCSI_DEVICE_BLOCK_MAX_TIMEOUT.
This causes problem with multipathing when the 'no_path_retry' setting
exceeds the dev_loss_tmo setting, as then the system might run into
a deadlock when all paths have been removed temporarily for longer
than dev_loss_tmo.
The principal reasons for the capping has been that we should
not allow a remote port to remain in status 'blocked' indefinitely,
so the capping is there to ensure that the port status is being reset
eventually.
However, the fast_io_fail_tmo will also move the remote port out of
the 'blocked' state, so for any HBA driver implementing both the
capping should really be on the fast_io_fail_tmo, and not on the
dev_loss_tmo.
This patch implements just that, ie the fast_io_fail_tmo is capped
to SCSI_DEVICE_BLOCK_TIMEOUT and the capping is removed from
dev_loss_tmo when fast_io_fail_tmo is set.
This allows us to synchronize the dev_loss_tmo setting to the
'no_path_retry' setting from multipathing thus avoiding the deadlock.

Signed-off-by: Hannes Reinecke <hare@suse.de>
Acked-by: James Smart <james.smart@emulex.com>
Signed-off-by: James Bottomley <James.Bottomley@suse.de>
drivers/scsi/scsi_transport_fc.c

index 653f22a8deb9f7ee829667e72e45352f22ea00ea..79660ee3e2113affe5735c4c97786f5142b1f10c 100644 (file)
@@ -475,7 +475,8 @@ MODULE_PARM_DESC(dev_loss_tmo,
                 "Maximum number of seconds that the FC transport should"
                 " insulate the loss of a remote port. Once this value is"
                 " exceeded, the scsi target is removed. Value should be"
-                " between 1 and SCSI_DEVICE_BLOCK_MAX_TIMEOUT.");
+                " between 1 and SCSI_DEVICE_BLOCK_MAX_TIMEOUT if"
+                " fast_io_fail_tmo is not set.");
 
 /*
  * Netlink Infrastructure
@@ -842,9 +843,17 @@ store_fc_rport_dev_loss_tmo(struct device *dev, struct device_attribute *attr,
            (rport->port_state == FC_PORTSTATE_NOTPRESENT))
                return -EBUSY;
        val = simple_strtoul(buf, &cp, 0);
-       if ((*cp && (*cp != '\n')) ||
-           (val < 0) || (val > SCSI_DEVICE_BLOCK_MAX_TIMEOUT))
+       if ((*cp && (*cp != '\n')) || (val < 0))
                return -EINVAL;
+
+       /*
+        * If fast_io_fail is off we have to cap
+        * dev_loss_tmo at SCSI_DEVICE_BLOCK_MAX_TIMEOUT
+        */
+       if (rport->fast_io_fail_tmo == -1 &&
+           val > SCSI_DEVICE_BLOCK_MAX_TIMEOUT)
+               return -EINVAL;
+
        i->f->set_rport_dev_loss_tmo(rport, val);
        return count;
 }
@@ -925,9 +934,16 @@ store_fc_rport_fast_io_fail_tmo(struct device *dev,
                rport->fast_io_fail_tmo = -1;
        else {
                val = simple_strtoul(buf, &cp, 0);
-               if ((*cp && (*cp != '\n')) ||
-                   (val < 0) || (val >= rport->dev_loss_tmo))
+               if ((*cp && (*cp != '\n')) || (val < 0))
                        return -EINVAL;
+               /*
+                * Cap fast_io_fail by dev_loss_tmo or
+                * SCSI_DEVICE_BLOCK_MAX_TIMEOUT.
+                */
+               if ((val >= rport->dev_loss_tmo) ||
+                   (val > SCSI_DEVICE_BLOCK_MAX_TIMEOUT))
+                       return -EINVAL;
+
                rport->fast_io_fail_tmo = val;
        }
        return count;