Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 0ee1d714 authored by Brian King's avatar Brian King Committed by James Bottomley
Browse files

[SCSI] ipr: Fix target id allocation re-use problem



For the latest ipr SAS adapters, target id's are a completely
logical construct that are managed in the ipr driver. This fixes
an issue that can arise if a device is deleted via sysfs. If
a new device is then physically added, it will use the previous
device's target id. If the host is then rescanned, the device
that had been deleted, since it is using the same target id as
the new device is using, will never be found, resulting in
a missing device. Fix this by only freeing the target id
only if the resource is actually gone.

Signed-off-by: default avatarBrian King <brking@linux.vnet.ibm.com>
Signed-off-by: default avatarJames Bottomley <JBottomley@Parallels.com>
parent 7d7311c4
Loading
Loading
Loading
Loading
+9 −8
Original line number Diff line number Diff line
@@ -4339,8 +4339,7 @@ static struct ipr_resource_entry *ipr_find_starget(struct scsi_target *starget)

	list_for_each_entry(res, &ioa_cfg->used_res_q, queue) {
		if ((res->bus == starget->channel) &&
		    (res->target == starget->id) &&
		    (res->lun == 0)) {
		    (res->target == starget->id)) {
			return res;
		}
	}
@@ -4414,6 +4413,7 @@ static void ipr_target_destroy(struct scsi_target *starget)
	struct ipr_ioa_cfg *ioa_cfg = (struct ipr_ioa_cfg *) shost->hostdata;

	if (ioa_cfg->sis64) {
		if (!ipr_find_starget(starget)) {
			if (starget->channel == IPR_ARRAY_VIRTUAL_BUS)
				clear_bit(starget->id, ioa_cfg->array_ids);
			else if (starget->channel == IPR_VSET_VIRTUAL_BUS)
@@ -4421,6 +4421,7 @@ static void ipr_target_destroy(struct scsi_target *starget)
			else if (starget->channel == 0)
				clear_bit(starget->id, ioa_cfg->target_ids);
		}
	}

	if (sata_port) {
		starget->hostdata = NULL;