Commit be6f48b0 authored by Stefan Richter's avatar Stefan Richter

firewire: fw-sbp2: don't retry login or reconnect after unplug

If a device is being unplugged while fw-sbp2 had a login or reconnect on
schedule, it would take about half a minute to shut the fw_unit down:

    Jan 27 18:34:54 stein firewire_sbp2: logged in to fw2.0 LUN 0000 (0 retries)
    <unplug>
    Jan 27 18:34:59 stein firewire_sbp2: sbp2_scsi_abort
    Jan 27 18:34:59 stein scsi 25:0:0:0: Device offlined - not ready after error recovery
    Jan 27 18:35:01 stein firewire_sbp2: orb reply timed out, rcode=0x11
    Jan 27 18:35:06 stein firewire_sbp2: orb reply timed out, rcode=0x11
    Jan 27 18:35:12 stein firewire_sbp2: orb reply timed out, rcode=0x11
    Jan 27 18:35:17 stein firewire_sbp2: orb reply timed out, rcode=0x11
    Jan 27 18:35:22 stein firewire_sbp2: orb reply timed out, rcode=0x11
    Jan 27 18:35:27 stein firewire_sbp2: orb reply timed out, rcode=0x11
    Jan 27 18:35:32 stein firewire_sbp2: orb reply timed out, rcode=0x11
    Jan 27 18:35:32 stein firewire_sbp2: failed to login to fw2.0 LUN 0000
    Jan 27 18:35:32 stein firewire_sbp2: released fw2.0

After this patch, typically only a few seconds spent in __scsi_add_device
remain:

    Jan 27 19:05:50 stein firewire_sbp2: logged in to fw2.0 LUN 0000 (0 retries)
    <unplug>
    Jan 27 19:05:56 stein firewire_sbp2: sbp2_scsi_abort
    Jan 27 19:05:56 stein scsi 33:0:0:0: Device offlined - not ready after error recovery
    Jan 27 19:05:56 stein firewire_sbp2: released fw2.0

The benefit of this is less noise in the syslog.  It furthermore avoids
a few wasted CPU cycles and needlessly prolonged lifetime of a few
driver objects.
Signed-off-by: default avatarStefan Richter <stefanr@s5r6.in-berlin.de>
Signed-off-by: default avatarJarod Wilson <jwilson@redhat.com>
parent 96b19062
...@@ -499,6 +499,9 @@ sbp2_send_management_orb(struct sbp2_logical_unit *lu, int node_id, ...@@ -499,6 +499,9 @@ sbp2_send_management_orb(struct sbp2_logical_unit *lu, int node_id,
unsigned int timeout; unsigned int timeout;
int retval = -ENOMEM; int retval = -ENOMEM;
if (function == SBP2_LOGOUT_REQUEST && fw_device_is_shutdown(device))
return 0;
orb = kzalloc(sizeof(*orb), GFP_ATOMIC); orb = kzalloc(sizeof(*orb), GFP_ATOMIC);
if (orb == NULL) if (orb == NULL)
return -ENOMEM; return -ENOMEM;
...@@ -619,16 +622,13 @@ static void sbp2_release_target(struct kref *kref) ...@@ -619,16 +622,13 @@ static void sbp2_release_target(struct kref *kref)
struct sbp2_logical_unit *lu, *next; struct sbp2_logical_unit *lu, *next;
struct Scsi_Host *shost = struct Scsi_Host *shost =
container_of((void *)tgt, struct Scsi_Host, hostdata[0]); container_of((void *)tgt, struct Scsi_Host, hostdata[0]);
struct fw_device *device = fw_device(tgt->unit->device.parent);
list_for_each_entry_safe(lu, next, &tgt->lu_list, link) { list_for_each_entry_safe(lu, next, &tgt->lu_list, link) {
if (lu->sdev) if (lu->sdev)
scsi_remove_device(lu->sdev); scsi_remove_device(lu->sdev);
if (!fw_device_is_shutdown(device)) sbp2_send_management_orb(lu, tgt->node_id, lu->generation,
sbp2_send_management_orb(lu, tgt->node_id, SBP2_LOGOUT_REQUEST, lu->login_id, NULL);
lu->generation, SBP2_LOGOUT_REQUEST,
lu->login_id, NULL);
fw_core_remove_address_handler(&lu->address_handler); fw_core_remove_address_handler(&lu->address_handler);
list_del(&lu->link); list_del(&lu->link);
...@@ -673,6 +673,9 @@ static void sbp2_login(struct work_struct *work) ...@@ -673,6 +673,9 @@ static void sbp2_login(struct work_struct *work)
struct sbp2_login_response response; struct sbp2_login_response response;
int generation, node_id, local_node_id; int generation, node_id, local_node_id;
if (fw_device_is_shutdown(device))
goto out;
generation = device->generation; generation = device->generation;
smp_rmb(); /* node_id must not be older than generation */ smp_rmb(); /* node_id must not be older than generation */
node_id = device->node_id; node_id = device->node_id;
...@@ -944,6 +947,9 @@ static void sbp2_reconnect(struct work_struct *work) ...@@ -944,6 +947,9 @@ static void sbp2_reconnect(struct work_struct *work)
struct fw_device *device = fw_device(unit->device.parent); struct fw_device *device = fw_device(unit->device.parent);
int generation, node_id, local_node_id; int generation, node_id, local_node_id;
if (fw_device_is_shutdown(device))
goto out;
generation = device->generation; generation = device->generation;
smp_rmb(); /* node_id must not be older than generation */ smp_rmb(); /* node_id must not be older than generation */
node_id = device->node_id; node_id = device->node_id;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment