diff options
author | Stephen M. Cameron <scameron@beardog.cce.hp.com> | 2010-02-04 09:43:41 -0500 |
---|---|---|
committer | James Bottomley <James.Bottomley@suse.de> | 2010-02-17 14:23:18 -0500 |
commit | 2a8ccf3187aff6defed72f7d8fa562ff2f69ef2a (patch) | |
tree | b55656a02ecd844d9a12aec8ec22d23aebc50767 /drivers/scsi/hpsa.c | |
parent | 23231048309ea8eed0189f1eb8f870f08703cac0 (diff) |
[SCSI] hpsa: fix bug in adjust_hpsa_scsi_table
fix bug in adjust_hpsa_scsi_table which caused devices which have
changed size, etc. to do the wrong thing.
The problem was as follows:
The driver maintains its current idea of what devices are present
in the h->dev[] array. When it updates this array, it scans the
hardware, and produces a new list of devices, call it sd[], for
scsi devices.
Then, it compares each item in h->dev[] vs. sd[], and any items which
are not present sd it removes from h->dev[], and any items present
in sd[], but different, it modifies in h->dev[].
Then, it looks for items in sd[] which are not present in h->dev[],
and adds those items into h->dev[]. All the while, it keeps track
of what items were added and removed to/from h->dev[].
Finally, it updates the SCSI mid-layer by removing and adding
the same devices it removed and added to/from h->dev[]. (modified
devices count as a remove then add.)
originally, when a "changed" device was discovered, it was
removed then added to h->dev[]. The item was added to the *end*
of h->dev[]. And, the item was removed from sd[] as well
(nulled out). As it processed h->dev[], these newly added items
at the end of the list were encountered, and sd[] was searched,
but those items were nulled out. So they ended up getting removed
immediately after they were added.
The solution is to have a way to replace items in the h->dev[]
array instead of doing a remove + add. Then the "changed" items.
are not encountered a second time, and removed.
Signed-off-by: Stephen M. Cameron <scameron@beardog.cce.hp.com>
Signed-off-by: James Bottomley <James.Bottomley@suse.de>
Diffstat (limited to 'drivers/scsi/hpsa.c')
-rw-r--r-- | drivers/scsi/hpsa.c | 26 |
1 files changed, 20 insertions, 6 deletions
diff --git a/drivers/scsi/hpsa.c b/drivers/scsi/hpsa.c index 2764cb605693..6b40221a7220 100644 --- a/drivers/scsi/hpsa.c +++ b/drivers/scsi/hpsa.c | |||
@@ -675,6 +675,24 @@ lun_assigned: | |||
675 | return 0; | 675 | return 0; |
676 | } | 676 | } |
677 | 677 | ||
678 | /* Replace an entry from h->dev[] array. */ | ||
679 | static void hpsa_scsi_replace_entry(struct ctlr_info *h, int hostno, | ||
680 | int entry, struct hpsa_scsi_dev_t *new_entry, | ||
681 | struct hpsa_scsi_dev_t *added[], int *nadded, | ||
682 | struct hpsa_scsi_dev_t *removed[], int *nremoved) | ||
683 | { | ||
684 | /* assumes h->devlock is held */ | ||
685 | BUG_ON(entry < 0 || entry >= HPSA_MAX_SCSI_DEVS_PER_HBA); | ||
686 | removed[*nremoved] = h->dev[entry]; | ||
687 | (*nremoved)++; | ||
688 | h->dev[entry] = new_entry; | ||
689 | added[*nadded] = new_entry; | ||
690 | (*nadded)++; | ||
691 | dev_info(&h->pdev->dev, "%s device c%db%dt%dl%d changed.\n", | ||
692 | scsi_device_type(new_entry->devtype), hostno, new_entry->bus, | ||
693 | new_entry->target, new_entry->lun); | ||
694 | } | ||
695 | |||
678 | /* Remove an entry from h->dev[] array. */ | 696 | /* Remove an entry from h->dev[] array. */ |
679 | static void hpsa_scsi_remove_entry(struct ctlr_info *h, int hostno, int entry, | 697 | static void hpsa_scsi_remove_entry(struct ctlr_info *h, int hostno, int entry, |
680 | struct hpsa_scsi_dev_t *removed[], int *nremoved) | 698 | struct hpsa_scsi_dev_t *removed[], int *nremoved) |
@@ -835,12 +853,8 @@ static void adjust_hpsa_scsi_table(struct ctlr_info *h, int hostno, | |||
835 | continue; /* remove ^^^, hence i not incremented */ | 853 | continue; /* remove ^^^, hence i not incremented */ |
836 | } else if (device_change == DEVICE_CHANGED) { | 854 | } else if (device_change == DEVICE_CHANGED) { |
837 | changes++; | 855 | changes++; |
838 | hpsa_scsi_remove_entry(h, hostno, i, | 856 | hpsa_scsi_replace_entry(h, hostno, i, sd[entry], |
839 | removed, &nremoved); | 857 | added, &nadded, removed, &nremoved); |
840 | (void) hpsa_scsi_add_entry(h, hostno, sd[entry], | ||
841 | added, &nadded); | ||
842 | /* add can't fail, we just removed one. */ | ||
843 | |||
844 | /* Set it to NULL to prevent it from being freed | 858 | /* Set it to NULL to prevent it from being freed |
845 | * at the bottom of hpsa_update_scsi_devices() | 859 | * at the bottom of hpsa_update_scsi_devices() |
846 | */ | 860 | */ |