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_scan.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_scan.c')
-rw-r--r-- | drivers/scsi/scsi_scan.c | 16 |
1 files changed, 15 insertions, 1 deletions
diff --git a/drivers/scsi/scsi_scan.c b/drivers/scsi/scsi_scan.c index 2d3c4ac475f2..48edd67982a5 100644 --- a/drivers/scsi/scsi_scan.c +++ b/drivers/scsi/scsi_scan.c | |||
@@ -336,9 +336,23 @@ static struct scsi_target *scsi_alloc_target(struct device *parent, | |||
336 | unsigned long flags; | 336 | unsigned long flags; |
337 | const int size = sizeof(struct scsi_target) | 337 | const int size = sizeof(struct scsi_target) |
338 | + shost->transportt->target_size; | 338 | + shost->transportt->target_size; |
339 | struct scsi_target *starget = kmalloc(size, GFP_ATOMIC); | 339 | struct scsi_target *starget; |
340 | struct scsi_target *found_target; | 340 | struct scsi_target *found_target; |
341 | 341 | ||
342 | /* | ||
343 | * Obtain the real parent from the transport. The transport | ||
344 | * is allowed to fail (no error) if there is nothing at that | ||
345 | * target id. | ||
346 | */ | ||
347 | if (shost->transportt->target_parent) { | ||
348 | spin_lock_irqsave(shost->host_lock, flags); | ||
349 | parent = shost->transportt->target_parent(shost, channel, id); | ||
350 | spin_unlock_irqrestore(shost->host_lock, flags); | ||
351 | if (!parent) | ||
352 | return NULL; | ||
353 | } | ||
354 | |||
355 | starget = kmalloc(size, GFP_KERNEL); | ||
342 | if (!starget) { | 356 | if (!starget) { |
343 | printk(KERN_ERR "%s: allocation failure\n", __FUNCTION__); | 357 | printk(KERN_ERR "%s: allocation failure\n", __FUNCTION__); |
344 | return NULL; | 358 | return NULL; |