[SCSI] Skip deleted devices in __scsi_device_lookup_by_target()

Previous message: [thread] [date] [author]
Next message: [thread] [date] [author]
From: Linux Kernel Mailing List
Date: Friday, January 16, 2009 - 9:59 am

Gitweb:     http://git.kernel.org/git/?p=linux/kernel/git/torvalds/linux-2.6.git;a=commit;h=32aeef...
Commit:     32aeef605aa01e1fee45e052eceffb00e72ba2b0
Parent:     debf47779efd6eace440c884c8cca2665d966eb4
Author:     Hannes Reinecke <hare@suse.de>
AuthorDate: Tue Jan 13 16:50:37 2009 +0100
Committer:  James Bottomley <James.Bottomley@HansenPartnership.com>
CommitDate: Tue Jan 13 10:48:11 2009 -0600

    [SCSI] Skip deleted devices in __scsi_device_lookup_by_target()
    
    __scsi_device_lookup_by_target() will always return
    the first sdev with a matching LUN, regardless of
    the state. However, when this sdev is in SDEV_DEL
    scsi_device_lookup_by_target() will ignore this
    device and so any valid device on the list after
    the deleted device will never be found.
    So we have to modify __scsi_device_lookup_by_target()
    to skip any device in SDEV_DEL.
    
    Signed-off-by: Hannes Reinecke <hare@suse.de>
    Signed-off-by: James Bottomley <James.Bottomley@HansenPartnership.com>
---
 drivers/scsi/scsi.c |    5 ++++-
 1 files changed, 4 insertions(+), 1 deletions(-)

diff --git a/drivers/scsi/scsi.c b/drivers/scsi/scsi.c
index 42e72a2..cbcd3f6 100644
--- a/drivers/scsi/scsi.c
+++ b/drivers/scsi/scsi.c
@@ -1095,7 +1095,8 @@ EXPORT_SYMBOL(__starget_for_each_device);
  * Description: Looks up the scsi_device with the specified @lun for a given
  * @starget.  The returned scsi_device does not have an additional
  * reference.  You must hold the host's host_lock over this call and
- * any access to the returned scsi_device.
+ * any access to the returned scsi_device. A scsi_device in state
+ * SDEV_DEL is skipped.
  *
  * Note:  The only reason why drivers should use this is because
  * they need to access the device list in irq context.  Otherwise you
@@ -1107,6 +1108,8 @@ struct scsi_device *__scsi_device_lookup_by_target(struct scsi_target *starget,
 	struct scsi_device *sdev;
 
 	list_for_each_entry(sdev, &starget->devices, same_target_siblings) {
+		if (sdev->sdev_state == SDEV_DEL)
+			continue;
 		if (sdev->lun ==lun)
 			return sdev;
 	}
--
To unsubscribe from this list: send the line "unsubscribe git-commits-head" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Previous message: [thread] [date] [author]
Next message: [thread] [date] [author]

Messages in current thread:
[SCSI] Skip deleted devices in __scsi_device_lookup_by_tar ..., Linux Kernel Mailing ..., (Fri Jan 16, 9:59 am)