diff options
author | James.Smart@Emulex.Com <James.Smart@Emulex.Com> | 2005-06-10 22:24:30 -0400 |
---|---|---|
committer | James Bottomley <jejb@mulgrave.(none)> | 2005-08-08 18:14:55 -0400 |
commit | 5c44cd2afad3f7b015542187e147a820600172f1 (patch) | |
tree | ef4b63ee55d0481569b1bd680e376b0d94b2b6f0 /drivers/scsi/scsi_transport_fc.c | |
parent | 9c472dd9197429a37691e91c938660a062bf20b0 (diff) |
[SCSI] fix target scanning oops with fc transport class
We have some nasty issues with 2.6.12-rc6. Any request to scan on
the lpfc or qla2xxx FC adapters will oops. What is happening is the
system is defaulting to non-transport registered targets, which
inherit the parent of the scan. On this second scan, performed by
the attribute, the parent becomes the shost instead of the rport.
The slave functions in the 2 FC adapters use starget_to_rport()
routines, which incorrectly map the shost as an rport pointer.
Additionally, this pointed out other weaknesses:
- If the target structure is torn down outside of the transport,
we have no method for it to be regenerated at the proper parent.
- We have race conditions on the target being allocated by both
the midlayer scan (parent=shost) and by the fc transport
(parent=rport).
Signed-off-by: James Bottomley <James.Bottomley@SteelEye.com>
Diffstat (limited to 'drivers/scsi/scsi_transport_fc.c')
-rw-r--r-- | drivers/scsi/scsi_transport_fc.c | 19 |
1 files changed, 19 insertions, 0 deletions
diff --git a/drivers/scsi/scsi_transport_fc.c b/drivers/scsi/scsi_transport_fc.c index 35d1c1e8e345..e6412fce423c 100644 --- a/drivers/scsi/scsi_transport_fc.c +++ b/drivers/scsi/scsi_transport_fc.c | |||
@@ -1022,6 +1022,23 @@ static int fc_rport_match(struct attribute_container *cont, | |||
1022 | return &i->rport_attr_cont.ac == cont; | 1022 | return &i->rport_attr_cont.ac == cont; |
1023 | } | 1023 | } |
1024 | 1024 | ||
1025 | |||
1026 | /* | ||
1027 | * Must be called with shost->host_lock held | ||
1028 | */ | ||
1029 | static struct device *fc_target_parent(struct Scsi_Host *shost, | ||
1030 | int channel, uint id) | ||
1031 | { | ||
1032 | struct fc_rport *rport; | ||
1033 | |||
1034 | list_for_each_entry(rport, &fc_host_rports(shost), peers) | ||
1035 | if ((rport->channel == channel) && | ||
1036 | (rport->scsi_target_id == id)) | ||
1037 | return &rport->dev; | ||
1038 | |||
1039 | return NULL; | ||
1040 | } | ||
1041 | |||
1025 | struct scsi_transport_template * | 1042 | struct scsi_transport_template * |
1026 | fc_attach_transport(struct fc_function_template *ft) | 1043 | fc_attach_transport(struct fc_function_template *ft) |
1027 | { | 1044 | { |
@@ -1057,6 +1074,8 @@ fc_attach_transport(struct fc_function_template *ft) | |||
1057 | 1074 | ||
1058 | /* Transport uses the shost workq for scsi scanning */ | 1075 | /* Transport uses the shost workq for scsi scanning */ |
1059 | i->t.create_work_queue = 1; | 1076 | i->t.create_work_queue = 1; |
1077 | |||
1078 | i->t.target_parent = fc_target_parent; | ||
1060 | 1079 | ||
1061 | /* | 1080 | /* |
1062 | * Setup SCSI Target Attributes. | 1081 | * Setup SCSI Target Attributes. |