diff options
author | James.Smart@Emulex.Com <James.Smart@Emulex.Com> | 2005-10-18 12:03:35 -0400 |
---|---|---|
committer | James Bottomley <jejb@mulgrave.(none)> | 2005-10-28 21:20:07 -0500 |
commit | 19a7b4aebf9ad435c69a7e39930338499af4d152 (patch) | |
tree | 6d1c4cbc822009c8facb219dcd955d52070655d1 /drivers/scsi/qla2xxx | |
parent | 422c0d61d591cbfb70f029e13505fb437e169d68 (diff) |
[SCSI] update fc_transport for removal of block/unblock functions
We recently went back to implement a board reset. When we perform the
reset, we wanted to tear down the internal data structures and rebuild
them. Unfortunately, when it came to the rport structure, things were
odd. If we deleted them, the scsi targets and sdevs would be
torn down. Not a good thing for a temporary reset. We could block the
rports, but we either maintain the internal structures to keep the
rport reference (perhaps even replicating what's in the transport),
or we have to fatten the fc transport with new search routines to find
the rport (and deal with a case of a dangling rport that the driver
forgets).
It dawned on me that we had actually reached this state incorrectly.
When the fc transport first started, we did the block/unblock first, then
added the rport interface. The purpose of block/unblock is to hide the
temporary disappearance of the rport (e.g. being deleted, then readded).
Why are we making the driver do the block/unblock ? We should be making
the transport have only an rport add/delete, and the let the transport
handle the block/unblock.
So... This patch removes the existing fc_remote_port_block/unblock
functions. It moves the block/unblock functionality into the
fc_remote_port_add/delete functions. Updates for the lpfc driver are
included. Qlogic driver updates are also enclosed, thanks to the
contributions of Andrew Vasquez. [Note: the qla2xxx changes are
relative to the scsi-misc-2.6 tree as of this morning - which does
not include the recent patches sent by Andrew]. The zfcp driver does
not use the block/unblock functions.
One last comment: The resulting behavior feels very clean. The LLDD is
concerned only with add/delete, which corresponds to the physical
disappearance. However, the fact that the scsi target and sdevs are
not immediately torn down after the LLDD calls delete causes an
interesting scenario... the midlayer can call the xxx_slave_alloc and
xxx_queuecommand functions with a sdev that is at the location the
rport used to be. The driver must validate the device exists when it
first enters these functions. In thinking about it, this has always
been the case for the LLDD and these routines. The existing drivers
already check for existence. However, this highlights that simple
validation via data structure dereferencing needs to be watched.
To deal with this, a new transport function, fc_remote_port_chkready()
was created that LLDDs should call when they first enter these two
routines. It validates the rport state, and returns a scsi result
which could be returned. In addition to solving the above, it also
creates consistent behavior from the LLDD's when the block and deletes
are occuring.
Rejections fixed up and
Signed-off-by: James Bottomley <James.Bottomley@SteelEye.com>
Diffstat (limited to 'drivers/scsi/qla2xxx')
-rw-r--r-- | drivers/scsi/qla2xxx/qla_def.h | 3 | ||||
-rw-r--r-- | drivers/scsi/qla2xxx/qla_init.c | 26 | ||||
-rw-r--r-- | drivers/scsi/qla2xxx/qla_os.c | 21 | ||||
-rw-r--r-- | drivers/scsi/qla2xxx/qla_rscn.c | 3 |
4 files changed, 40 insertions, 13 deletions
diff --git a/drivers/scsi/qla2xxx/qla_def.h b/drivers/scsi/qla2xxx/qla_def.h index fc3234c3625..7096945ea23 100644 --- a/drivers/scsi/qla2xxx/qla_def.h +++ b/drivers/scsi/qla2xxx/qla_def.h @@ -21,6 +21,7 @@ #include <linux/spinlock.h> #include <linux/completion.h> #include <linux/interrupt.h> +#include <linux/workqueue.h> #include <asm/semaphore.h> #include <scsi/scsi.h> @@ -1665,6 +1666,8 @@ typedef struct fc_port { struct fc_rport *rport; u32 supported_classes; + struct work_struct rport_add_work; + struct work_struct rport_del_work; } fc_port_t; /* diff --git a/drivers/scsi/qla2xxx/qla_init.c b/drivers/scsi/qla2xxx/qla_init.c index ce7e712ebe8..290a6b92616 100644 --- a/drivers/scsi/qla2xxx/qla_init.c +++ b/drivers/scsi/qla2xxx/qla_init.c @@ -1668,6 +1668,24 @@ qla2x00_nvram_config(scsi_qla_host_t *ha) return (rval); } +static void +qla2x00_rport_add(void *data) +{ + fc_port_t *fcport = data; + + qla2x00_reg_remote_port(fcport->ha, fcport); +} + +static void +qla2x00_rport_del(void *data) +{ + fc_port_t *fcport = data; + + if (fcport->rport) + fc_remote_port_delete(fcport->rport); + fcport->rport = NULL; +} + /** * qla2x00_alloc_fcport() - Allocate a generic fcport. * @ha: HA context @@ -1693,6 +1711,8 @@ qla2x00_alloc_fcport(scsi_qla_host_t *ha, gfp_t flags) atomic_set(&fcport->state, FCS_UNCONFIGURED); fcport->flags = FCF_RLC_SUPPORT; fcport->supported_classes = FC_COS_UNSPECIFIED; + INIT_WORK(&fcport->rport_add_work, qla2x00_rport_add, fcport); + INIT_WORK(&fcport->rport_del_work, qla2x00_rport_del, fcport); return (fcport); } @@ -2056,8 +2076,8 @@ qla2x00_reg_remote_port(scsi_qla_host_t *ha, fc_port_t *fcport) struct fc_rport *rport; if (fcport->rport) { - fc_remote_port_unblock(fcport->rport); - return; + fc_remote_port_delete(fcport->rport); + fcport->rport = NULL; } rport_ids.node_name = wwn_to_u64(fcport->node_name); @@ -2071,7 +2091,7 @@ qla2x00_reg_remote_port(scsi_qla_host_t *ha, fc_port_t *fcport) "Unable to allocate fc remote port!\n"); return; } - rport->dd_data = fcport; + *((fc_port_t **)rport->dd_data) = fcport; rport->supported_classes = fcport->supported_classes; rport_ids.roles = FC_RPORT_ROLE_UNKNOWN; diff --git a/drivers/scsi/qla2xxx/qla_os.c b/drivers/scsi/qla2xxx/qla_os.c index b899282a856..c58c9d97b04 100644 --- a/drivers/scsi/qla2xxx/qla_os.c +++ b/drivers/scsi/qla2xxx/qla_os.c @@ -348,11 +348,13 @@ qla2x00_queuecommand(struct scsi_cmnd *cmd, void (*done)(struct scsi_cmnd *)) { scsi_qla_host_t *ha = to_qla_host(cmd->device->host); fc_port_t *fcport = (struct fc_port *) cmd->device->hostdata; + struct fc_rport *rport = starget_to_rport(scsi_target(cmd->device)); srb_t *sp; int rval; - if (!fcport) { - cmd->result = DID_NO_CONNECT << 16; + rval = fc_remote_port_chkready(rport); + if (rval) { + cmd->result = rval; goto qc_fail_command; } @@ -401,11 +403,13 @@ qla24xx_queuecommand(struct scsi_cmnd *cmd, void (*done)(struct scsi_cmnd *)) { scsi_qla_host_t *ha = to_qla_host(cmd->device->host); fc_port_t *fcport = (struct fc_port *) cmd->device->hostdata; + struct fc_rport *rport = starget_to_rport(scsi_target(cmd->device)); srb_t *sp; int rval; - if (!fcport) { - cmd->result = DID_NO_CONNECT << 16; + rval = fc_remote_port_chkready(rport); + if (rval) { + cmd->result = rval; goto qc24_fail_command; } @@ -1041,10 +1045,10 @@ qla2xxx_slave_alloc(struct scsi_device *sdev) { struct fc_rport *rport = starget_to_rport(scsi_target(sdev)); - if (!rport) + if (!rport || fc_remote_port_chkready(rport)) return -ENXIO; - sdev->hostdata = rport->dd_data; + sdev->hostdata = *(fc_port_t **)rport->dd_data; return 0; } @@ -1636,7 +1640,8 @@ void qla2x00_mark_device_lost(scsi_qla_host_t *ha, fc_port_t *fcport, int do_login) { if (atomic_read(&fcport->state) == FCS_ONLINE && fcport->rport) - fc_remote_port_block(fcport->rport); + schedule_work(&fcport->rport_del_work); + /* * We may need to retry the login, so don't change the state of the * port but do the retries. @@ -1697,7 +1702,7 @@ qla2x00_mark_all_devices_lost(scsi_qla_host_t *ha) if (atomic_read(&fcport->state) == FCS_DEVICE_DEAD) continue; if (atomic_read(&fcport->state) == FCS_ONLINE && fcport->rport) - fc_remote_port_block(fcport->rport); + schedule_work(&fcport->rport_del_work); atomic_set(&fcport->state, FCS_DEVICE_LOST); } } diff --git a/drivers/scsi/qla2xxx/qla_rscn.c b/drivers/scsi/qla2xxx/qla_rscn.c index 3e53f62d640..2c3342108dd 100644 --- a/drivers/scsi/qla2xxx/qla_rscn.c +++ b/drivers/scsi/qla2xxx/qla_rscn.c @@ -320,8 +320,7 @@ qla2x00_update_login_fcport(scsi_qla_host_t *ha, struct mbx_entry *mbxstat, fcport->flags &= ~FCF_FAILOVER_NEEDED; fcport->iodesc_idx_sent = IODESC_INVALID_INDEX; atomic_set(&fcport->state, FCS_ONLINE); - if (fcport->rport) - fc_remote_port_unblock(fcport->rport); + schedule_work(&fcport->rport_add_work); } |