mirror of
https://mirrors.bfsu.edu.cn/git/linux.git
synced 2024-11-15 16:24:13 +08:00
[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>
This commit is contained in:
parent
2323104830
commit
2a8ccf3187
@ -675,6 +675,24 @@ lun_assigned:
|
|||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* Replace an entry from h->dev[] array. */
|
||||||
|
static void hpsa_scsi_replace_entry(struct ctlr_info *h, int hostno,
|
||||||
|
int entry, struct hpsa_scsi_dev_t *new_entry,
|
||||||
|
struct hpsa_scsi_dev_t *added[], int *nadded,
|
||||||
|
struct hpsa_scsi_dev_t *removed[], int *nremoved)
|
||||||
|
{
|
||||||
|
/* assumes h->devlock is held */
|
||||||
|
BUG_ON(entry < 0 || entry >= HPSA_MAX_SCSI_DEVS_PER_HBA);
|
||||||
|
removed[*nremoved] = h->dev[entry];
|
||||||
|
(*nremoved)++;
|
||||||
|
h->dev[entry] = new_entry;
|
||||||
|
added[*nadded] = new_entry;
|
||||||
|
(*nadded)++;
|
||||||
|
dev_info(&h->pdev->dev, "%s device c%db%dt%dl%d changed.\n",
|
||||||
|
scsi_device_type(new_entry->devtype), hostno, new_entry->bus,
|
||||||
|
new_entry->target, new_entry->lun);
|
||||||
|
}
|
||||||
|
|
||||||
/* Remove an entry from h->dev[] array. */
|
/* Remove an entry from h->dev[] array. */
|
||||||
static void hpsa_scsi_remove_entry(struct ctlr_info *h, int hostno, int entry,
|
static void hpsa_scsi_remove_entry(struct ctlr_info *h, int hostno, int entry,
|
||||||
struct hpsa_scsi_dev_t *removed[], int *nremoved)
|
struct hpsa_scsi_dev_t *removed[], int *nremoved)
|
||||||
@ -835,12 +853,8 @@ static void adjust_hpsa_scsi_table(struct ctlr_info *h, int hostno,
|
|||||||
continue; /* remove ^^^, hence i not incremented */
|
continue; /* remove ^^^, hence i not incremented */
|
||||||
} else if (device_change == DEVICE_CHANGED) {
|
} else if (device_change == DEVICE_CHANGED) {
|
||||||
changes++;
|
changes++;
|
||||||
hpsa_scsi_remove_entry(h, hostno, i,
|
hpsa_scsi_replace_entry(h, hostno, i, sd[entry],
|
||||||
removed, &nremoved);
|
added, &nadded, removed, &nremoved);
|
||||||
(void) hpsa_scsi_add_entry(h, hostno, sd[entry],
|
|
||||||
added, &nadded);
|
|
||||||
/* add can't fail, we just removed one. */
|
|
||||||
|
|
||||||
/* Set it to NULL to prevent it from being freed
|
/* Set it to NULL to prevent it from being freed
|
||||||
* at the bottom of hpsa_update_scsi_devices()
|
* at the bottom of hpsa_update_scsi_devices()
|
||||||
*/
|
*/
|
||||||
|
Loading…
Reference in New Issue
Block a user