]>
Commit | Line | Data |
---|---|---|
2cb7cef9 BS |
1 | From: Hannes Reinecke <hare@suse.de> |
2 | Subject: Skip deleted devices in __scsi_device_lookup_by_target() | |
3 | References: bnc#465346 | |
4 | ||
5 | __scsi_device_lookup_by_target() will always return | |
6 | the first sdev with a matching LUN, regardless of | |
7 | the state. However, when this sdev is in SDEV_DEL | |
8 | scsi_device_lookup_by_target() will ignore this | |
9 | device and so any valid device on the list after | |
10 | the deleted device will never be found. | |
11 | So we have to modify __scsi_device_lookup_by_target() | |
12 | to skip any device in SDEV_DEL. | |
13 | ||
14 | Signed-off-by: Hannes Reinecke <hare@suse.de> | |
15 | ||
16 | diff --git a/drivers/scsi/scsi.c b/drivers/scsi/scsi.c | |
17 | index f8b79d4..537bb92 100644 | |
18 | --- a/drivers/scsi/scsi.c | |
19 | +++ b/drivers/scsi/scsi.c | |
20 | @@ -1099,7 +1099,8 @@ EXPORT_SYMBOL(__starget_for_each_device); | |
21 | * Description: Looks up the scsi_device with the specified @lun for a given | |
22 | * @starget. The returned scsi_device does not have an additional | |
23 | * reference. You must hold the host's host_lock over this call and | |
24 | - * any access to the returned scsi_device. | |
25 | + * any access to the returned scsi_device. A scsi_device in state | |
26 | + * SDEV_DEL is skipped. | |
27 | * | |
28 | * Note: The only reason why drivers should use this is because | |
29 | * they need to access the device list in irq context. Otherwise you | |
30 | @@ -1111,6 +1112,8 @@ struct scsi_device *__scsi_device_lookup_by_target(struct scsi_target *starget, | |
31 | struct scsi_device *sdev; | |
32 | ||
33 | list_for_each_entry(sdev, &starget->devices, same_target_siblings) { | |
34 | + if (sdev->sdev_state == SDEV_DEL) | |
35 | + continue; | |
36 | if (sdev->lun ==lun) | |
37 | return sdev; | |
38 | } |