diff options
author | Stephen M. Cameron <scameron@beardog.cce.hp.com> | 2011-08-09 09:18:01 -0400 |
---|---|---|
committer | James Bottomley <JBottomley@Parallels.com> | 2011-08-26 15:52:39 -0400 |
commit | 01350d05539d1c95ef3568d062d864ab76ae7670 (patch) | |
tree | 0c1f3cc68e87cecb1393f4ed09fb78edc593995f | |
parent | 0b0e1d6cbcc8627970e0399df8f06edd690ec7d9 (diff) |
[SCSI] hpsa: fix physical device lun and target numbering problem
If a physical device exposed to the OS by hpsa
is replaced (e.g. one hot plug tape drive is replaced
by another, or a tape drive is placed into "OBDR" mode
in which it acts like a CD-ROM device) and a rescan is
initiated, the replaced device will be added to the
SCSI midlayer with target and lun numbers set to -1.
After that, a panic is likely to ensue. When a physical
device is replaced, the lun and target number should be
preserved.
Signed-off-by: Stephen M. Cameron <scameron@beardog.cce.hp.com>
Cc: stable@kernel.org
Signed-off-by: James Bottomley <JBottomley@Parallels.com>
-rw-r--r-- | drivers/scsi/hpsa.c | 10 |
1 files changed, 10 insertions, 0 deletions
diff --git a/drivers/scsi/hpsa.c b/drivers/scsi/hpsa.c index 1f32f0610bc0..b200b736b000 100644 --- a/drivers/scsi/hpsa.c +++ b/drivers/scsi/hpsa.c | |||
@@ -676,6 +676,16 @@ static void hpsa_scsi_replace_entry(struct ctlr_info *h, int hostno, | |||
676 | BUG_ON(entry < 0 || entry >= HPSA_MAX_SCSI_DEVS_PER_HBA); | 676 | BUG_ON(entry < 0 || entry >= HPSA_MAX_SCSI_DEVS_PER_HBA); |
677 | removed[*nremoved] = h->dev[entry]; | 677 | removed[*nremoved] = h->dev[entry]; |
678 | (*nremoved)++; | 678 | (*nremoved)++; |
679 | |||
680 | /* | ||
681 | * New physical devices won't have target/lun assigned yet | ||
682 | * so we need to preserve the values in the slot we are replacing. | ||
683 | */ | ||
684 | if (new_entry->target == -1) { | ||
685 | new_entry->target = h->dev[entry]->target; | ||
686 | new_entry->lun = h->dev[entry]->lun; | ||
687 | } | ||
688 | |||
679 | h->dev[entry] = new_entry; | 689 | h->dev[entry] = new_entry; |
680 | added[*nadded] = new_entry; | 690 | added[*nadded] = new_entry; |
681 | (*nadded)++; | 691 | (*nadded)++; |