]> git.ipfire.org Git - ipfire-2.x.git/blame - src/patches/suse-2.6.27.39/patches.fixes/scsi-refactor-busy-processing
Imported linux-2.6.27.39 suse/xen patches.
[ipfire-2.x.git] / src / patches / suse-2.6.27.39 / patches.fixes / scsi-refactor-busy-processing
CommitLineData
2cb7cef9
BS
1Subject: [SCSI] refactor sdev/starget/shost busy checking
2From: Kiyoshi Ueda <k-ueda@ct.jp.nec.com>
3Date: Thu Oct 23 11:42:16 2008 -0500:
4Git: 9d11251709f31d49c8167a619d4475fdf6cd7f73
5
6This patch refactors the busy checking codes of scsi_device,
7Scsi_Host and scsi_target. There should be no functional change.
8
9This is a preparation for another patch which exports scsi's busy
10state to the block layer for request stacking drivers.
11
12Signed-off-by: Kiyoshi Ueda <k-ueda@ct.jp.nec.com>
13Signed-off-by: Jun'ichi Nomura <j-nomura@ce.jp.nec.com>
14Signed-off-by: James Bottomley <James.Bottomley@HansenPartnership.com>
15Signed-off-by: Hannes Reinecke <hare@suse.de>
16
17---
18 drivers/scsi/scsi_lib.c | 30 ++++++++++++++++++++----------
19 1 file changed, 20 insertions(+), 10 deletions(-)
20
21--- a/drivers/scsi/scsi_lib.c
22+++ b/drivers/scsi/scsi_lib.c
23@@ -529,6 +529,14 @@ static void scsi_single_lun_run(struct s
24 spin_unlock_irqrestore(shost->host_lock, flags);
25 }
26
27+static inline int scsi_device_is_busy(struct scsi_device *sdev)
28+{
29+ if (sdev->device_busy >= sdev->queue_depth || sdev->device_blocked)
30+ return 1;
31+
32+ return 0;
33+}
34+
35 static inline int scsi_target_is_busy(struct scsi_target *starget)
36 {
37 return ((starget->can_queue > 0 &&
38@@ -536,6 +544,15 @@ static inline int scsi_target_is_busy(st
39 starget->target_blocked);
40 }
41
42+static inline int scsi_host_is_busy(struct Scsi_Host *shost)
43+{
44+ if ((shost->can_queue > 0 && shost->host_busy >= shost->can_queue) ||
45+ shost->host_blocked || shost->host_self_blocked)
46+ return 1;
47+
48+ return 0;
49+}
50+
51 /*
52 * Function: scsi_run_queue()
53 *
54@@ -558,11 +575,7 @@ static void scsi_run_queue(struct reques
55 scsi_single_lun_run(sdev);
56
57 spin_lock_irqsave(shost->host_lock, flags);
58- while (!list_empty(&shost->starved_list) &&
59- !shost->host_blocked && !shost->host_self_blocked &&
60- !((shost->can_queue > 0) &&
61- (shost->host_busy >= shost->can_queue))) {
62-
63+ while (!list_empty(&shost->starved_list) && !scsi_host_is_busy(shost)) {
64 int flagset;
65
66 /*
67@@ -1349,8 +1362,6 @@ EXPORT_SYMBOL(scsi_prep_fn);
68 static inline int scsi_dev_queue_ready(struct request_queue *q,
69 struct scsi_device *sdev)
70 {
71- if (sdev->device_busy >= sdev->queue_depth)
72- return 0;
73 if (sdev->device_busy == 0 && sdev->device_blocked) {
74 /*
75 * unblock after device_blocked iterates to zero
76@@ -1364,7 +1375,7 @@ static inline int scsi_dev_queue_ready(s
77 return 0;
78 }
79 }
80- if (sdev->device_blocked)
81+ if (scsi_device_is_busy(sdev))
82 return 0;
83
84 return 1;
85@@ -1441,8 +1452,7 @@ static inline int scsi_host_queue_ready(
86 return 0;
87 }
88 }
89- if ((shost->can_queue > 0 && shost->host_busy >= shost->can_queue) ||
90- shost->host_blocked || shost->host_self_blocked) {
91+ if (scsi_host_is_busy(shost)) {
92 if (list_empty(&sdev->starved_entry))
93 list_add_tail(&sdev->starved_entry, &shost->starved_list);
94 return 0;