+++ /dev/null
-Subject: [SCSI] refactor sdev/starget/shost busy checking
-From: Kiyoshi Ueda <k-ueda@ct.jp.nec.com>
-Date: Thu Oct 23 11:42:16 2008 -0500:
-Git: 9d11251709f31d49c8167a619d4475fdf6cd7f73
-
-This patch refactors the busy checking codes of scsi_device,
-Scsi_Host and scsi_target. There should be no functional change.
-
-This is a preparation for another patch which exports scsi's busy
-state to the block layer for request stacking drivers.
-
-Signed-off-by: Kiyoshi Ueda <k-ueda@ct.jp.nec.com>
-Signed-off-by: Jun'ichi Nomura <j-nomura@ce.jp.nec.com>
-Signed-off-by: James Bottomley <James.Bottomley@HansenPartnership.com>
-Signed-off-by: Hannes Reinecke <hare@suse.de>
-
----
- drivers/scsi/scsi_lib.c | 30 ++++++++++++++++++++----------
- 1 file changed, 20 insertions(+), 10 deletions(-)
-
---- a/drivers/scsi/scsi_lib.c
-+++ b/drivers/scsi/scsi_lib.c
-@@ -529,6 +529,14 @@ static void scsi_single_lun_run(struct s
- spin_unlock_irqrestore(shost->host_lock, flags);
- }
-
-+static inline int scsi_device_is_busy(struct scsi_device *sdev)
-+{
-+ if (sdev->device_busy >= sdev->queue_depth || sdev->device_blocked)
-+ return 1;
-+
-+ return 0;
-+}
-+
- static inline int scsi_target_is_busy(struct scsi_target *starget)
- {
- return ((starget->can_queue > 0 &&
-@@ -536,6 +544,15 @@ static inline int scsi_target_is_busy(st
- starget->target_blocked);
- }
-
-+static inline int scsi_host_is_busy(struct Scsi_Host *shost)
-+{
-+ if ((shost->can_queue > 0 && shost->host_busy >= shost->can_queue) ||
-+ shost->host_blocked || shost->host_self_blocked)
-+ return 1;
-+
-+ return 0;
-+}
-+
- /*
- * Function: scsi_run_queue()
- *
-@@ -558,11 +575,7 @@ static void scsi_run_queue(struct reques
- scsi_single_lun_run(sdev);
-
- spin_lock_irqsave(shost->host_lock, flags);
-- while (!list_empty(&shost->starved_list) &&
-- !shost->host_blocked && !shost->host_self_blocked &&
-- !((shost->can_queue > 0) &&
-- (shost->host_busy >= shost->can_queue))) {
--
-+ while (!list_empty(&shost->starved_list) && !scsi_host_is_busy(shost)) {
- int flagset;
-
- /*
-@@ -1349,8 +1362,6 @@ EXPORT_SYMBOL(scsi_prep_fn);
- static inline int scsi_dev_queue_ready(struct request_queue *q,
- struct scsi_device *sdev)
- {
-- if (sdev->device_busy >= sdev->queue_depth)
-- return 0;
- if (sdev->device_busy == 0 && sdev->device_blocked) {
- /*
- * unblock after device_blocked iterates to zero
-@@ -1364,7 +1375,7 @@ static inline int scsi_dev_queue_ready(s
- return 0;
- }
- }
-- if (sdev->device_blocked)
-+ if (scsi_device_is_busy(sdev))
- return 0;
-
- return 1;
-@@ -1441,8 +1452,7 @@ static inline int scsi_host_queue_ready(
- return 0;
- }
- }
-- if ((shost->can_queue > 0 && shost->host_busy >= shost->can_queue) ||
-- shost->host_blocked || shost->host_self_blocked) {
-+ if (scsi_host_is_busy(shost)) {
- if (list_empty(&sdev->starved_entry))
- list_add_tail(&sdev->starved_entry, &shost->starved_list);
- return 0;