diff options
author | James Bottomley <James.Bottomley@HansenPartnership.com> | 2008-08-22 17:43:59 -0400 |
---|---|---|
committer | James Bottomley <James.Bottomley@HansenPartnership.com> | 2008-10-03 12:46:13 -0400 |
commit | 0f1d87a2acb8fd1f2ef8af109a785123ddc1a6cb (patch) | |
tree | c59113a5f6ba81983e1bc4abad235436b1842f28 | |
parent | 22447be7d15aefcfab84e9bec4859a28198b0c62 (diff) |
[SCSI] add inline functions for recognising created and blocked states
The created and blocked states are very shortly going to correspond to
mixed sdev_state states.
Signed-off-by: James Bottomley <James.Bottomley@HansenPartnership.com>
-rw-r--r-- | drivers/scsi/scsi.c | 13 | ||||
-rw-r--r-- | drivers/scsi/scsi_scan.c | 4 | ||||
-rw-r--r-- | include/scsi/scsi_device.h | 11 |
3 files changed, 20 insertions, 8 deletions
diff --git a/drivers/scsi/scsi.c b/drivers/scsi/scsi.c index ee6be596503d..762a8797e0be 100644 --- a/drivers/scsi/scsi.c +++ b/drivers/scsi/scsi.c | |||
@@ -664,13 +664,14 @@ int scsi_dispatch_cmd(struct scsi_cmnd *cmd) | |||
664 | goto out; | 664 | goto out; |
665 | } | 665 | } |
666 | 666 | ||
667 | /* Check to see if the scsi lld put this device into state SDEV_BLOCK. */ | 667 | /* Check to see if the scsi lld made this device blocked. */ |
668 | if (unlikely(cmd->device->sdev_state == SDEV_BLOCK)) { | 668 | if (unlikely(scsi_device_blocked(cmd->device))) { |
669 | /* | 669 | /* |
670 | * in SDEV_BLOCK, the command is just put back on the device | 670 | * in blocked state, the command is just put back on |
671 | * queue. The suspend state has already blocked the queue so | 671 | * the device queue. The suspend state has already |
672 | * future requests should not occur until the device | 672 | * blocked the queue so future requests should not |
673 | * transitions out of the suspend state. | 673 | * occur until the device transitions out of the |
674 | * suspend state. | ||
674 | */ | 675 | */ |
675 | scsi_queue_insert(cmd, SCSI_MLQUEUE_DEVICE_BUSY); | 676 | scsi_queue_insert(cmd, SCSI_MLQUEUE_DEVICE_BUSY); |
676 | 677 | ||
diff --git a/drivers/scsi/scsi_scan.c b/drivers/scsi/scsi_scan.c index 34d0de6cd511..2926baaac31e 100644 --- a/drivers/scsi/scsi_scan.c +++ b/drivers/scsi/scsi_scan.c | |||
@@ -994,7 +994,7 @@ static int scsi_probe_and_add_lun(struct scsi_target *starget, | |||
994 | */ | 994 | */ |
995 | sdev = scsi_device_lookup_by_target(starget, lun); | 995 | sdev = scsi_device_lookup_by_target(starget, lun); |
996 | if (sdev) { | 996 | if (sdev) { |
997 | if (rescan || sdev->sdev_state != SDEV_CREATED) { | 997 | if (rescan || !scsi_device_created(sdev)) { |
998 | SCSI_LOG_SCAN_BUS(3, printk(KERN_INFO | 998 | SCSI_LOG_SCAN_BUS(3, printk(KERN_INFO |
999 | "scsi scan: device exists on %s\n", | 999 | "scsi scan: device exists on %s\n", |
1000 | sdev->sdev_gendev.bus_id)); | 1000 | sdev->sdev_gendev.bus_id)); |
@@ -1467,7 +1467,7 @@ static int scsi_report_lun_scan(struct scsi_target *starget, int bflags, | |||
1467 | kfree(lun_data); | 1467 | kfree(lun_data); |
1468 | out: | 1468 | out: |
1469 | scsi_device_put(sdev); | 1469 | scsi_device_put(sdev); |
1470 | if (sdev->sdev_state == SDEV_CREATED) | 1470 | if (scsi_device_created(sdev)) |
1471 | /* | 1471 | /* |
1472 | * the sdev we used didn't appear in the report luns scan | 1472 | * the sdev we used didn't appear in the report luns scan |
1473 | */ | 1473 | */ |
diff --git a/include/scsi/scsi_device.h b/include/scsi/scsi_device.h index 80b2e93c2936..cc46652e4658 100644 --- a/include/scsi/scsi_device.h +++ b/include/scsi/scsi_device.h | |||
@@ -384,10 +384,21 @@ static inline unsigned int sdev_id(struct scsi_device *sdev) | |||
384 | #define scmd_id(scmd) sdev_id((scmd)->device) | 384 | #define scmd_id(scmd) sdev_id((scmd)->device) |
385 | #define scmd_channel(scmd) sdev_channel((scmd)->device) | 385 | #define scmd_channel(scmd) sdev_channel((scmd)->device) |
386 | 386 | ||
387 | /* | ||
388 | * checks for positions of the SCSI state machine | ||
389 | */ | ||
387 | static inline int scsi_device_online(struct scsi_device *sdev) | 390 | static inline int scsi_device_online(struct scsi_device *sdev) |
388 | { | 391 | { |
389 | return sdev->sdev_state != SDEV_OFFLINE; | 392 | return sdev->sdev_state != SDEV_OFFLINE; |
390 | } | 393 | } |
394 | static inline int scsi_device_blocked(struct scsi_device *sdev) | ||
395 | { | ||
396 | return sdev->sdev_state == SDEV_BLOCK; | ||
397 | } | ||
398 | static inline int scsi_device_created(struct scsi_device *sdev) | ||
399 | { | ||
400 | return sdev->sdev_state == SDEV_CREATED; | ||
401 | } | ||
391 | 402 | ||
392 | /* accessor functions for the SCSI parameters */ | 403 | /* accessor functions for the SCSI parameters */ |
393 | static inline int scsi_device_sync(struct scsi_device *sdev) | 404 | static inline int scsi_device_sync(struct scsi_device *sdev) |