public inbox for linux-scsi@vger.kernel.org
 help / color / mirror / Atom feed
* [PATCH] hpsa: fix physical device lun and target numbering problem
@ 2011-08-09 13:18 Stephen M. Cameron
  2011-08-09 13:33 ` Stephen Cameron
  2011-08-09 16:13 ` Greg KH
  0 siblings, 2 replies; 7+ messages in thread
From: Stephen M. Cameron @ 2011-08-09 13:18 UTC (permalink / raw)
  To: james.bottomley
  Cc: linux-scsi, linux-kernel, mikem, stephenmcameron, thenzl, akpm,
	stable

From: Stephen M. Cameron <scameron@beardog.cce.hp.com>

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>
---
 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 1f32f06..b200b73 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,
 	BUG_ON(entry < 0 || entry >= HPSA_MAX_SCSI_DEVS_PER_HBA);
 	removed[*nremoved] = h->dev[entry];
 	(*nremoved)++;
+
+	/*
+	 * New physical devices won't have target/lun assigned yet
+	 * so we need to preserve the values in the slot we are replacing.
+	 */
+	if (new_entry->target == -1) {
+		new_entry->target = h->dev[entry]->target;
+		new_entry->lun = h->dev[entry]->lun;
+	}
+
 	h->dev[entry] = new_entry;
 	added[*nadded] = new_entry;
 	(*nadded)++;

^ permalink raw reply related	[flat|nested] 7+ messages in thread

end of thread, other threads:[~2011-08-09 20:20 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2011-08-09 13:18 [PATCH] hpsa: fix physical device lun and target numbering problem Stephen M. Cameron
2011-08-09 13:33 ` Stephen Cameron
2011-08-09 19:58   ` Stephen Cameron
2011-08-09 20:06     ` James Bottomley
2011-08-09 20:09       ` scameron
2011-08-09 20:20         ` James Bottomley
2011-08-09 16:13 ` Greg KH

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox