]>
Commit | Line | Data |
---|---|---|
2cb7cef9 BS |
1 | From: James Bottomley <James.Bottomley@HansenPartnership.com> |
2 | Subject: Fix block timeout residue problems | |
3 | Date: Fri Dec 5 08:47:58 2008 +0100 | |
4 | References: bnc#447249,bnc#441335 | |
5 | ||
6 | It looks like there was only a partial conversion of the SCSI layer to | |
7 | the block timeout. The missing piece was killing timeout in struct | |
8 | scsi_device and leaving it with a zero value. This has already | |
9 | resulted in a regression: | |
10 | ||
11 | http://bugzilla.kernel.org/show_bug.cgi?id=12120 | |
12 | ||
13 | But on closer inspection, there were lots of other dangling driver | |
14 | uses of the timeout value which would likewise have introduced hard to | |
15 | trace regressions. | |
16 | ||
17 | This patch series eliminates the timeout variable from struct | |
18 | scsi_device and makes everything uniformly use the block timeout. Any | |
19 | wrong use of the scsi device timeout will now result in a compile | |
20 | failure. | |
21 | ||
22 | Signed-off-by: James Bottomley <james.bottomley@hansenpartnership.com> | |
23 | Signed-off-by: Hannes Reinecke <hare@suse.de> | |
24 | ||
25 | --- | |
26 | drivers/scsi/aacraid/linit.c | 4 +- | |
27 | drivers/scsi/ibmvscsi/ibmvscsi.c | 2 - | |
28 | drivers/scsi/megaraid/megaraid_sas.c | 3 +- | |
29 | drivers/scsi/scsi_error.c | 2 - | |
30 | drivers/scsi/st.c | 47 ++++++++++++++++++++--------------- | |
31 | drivers/scsi/stex.c | 2 - | |
32 | include/scsi/scsi_device.h | 2 - | |
33 | 7 files changed, 35 insertions(+), 27 deletions(-) | |
34 | ||
35 | --- a/drivers/scsi/aacraid/linit.c | |
36 | +++ b/drivers/scsi/aacraid/linit.c | |
37 | @@ -427,8 +427,8 @@ static int aac_slave_configure(struct sc | |
38 | * Firmware has an individual device recovery time typically | |
39 | * of 35 seconds, give us a margin. | |
40 | */ | |
41 | - if (sdev->timeout < (45 * HZ)) | |
42 | - sdev->timeout = 45 * HZ; | |
43 | + if (sdev->request_queue->rq_timeout < (45 * HZ)) | |
44 | + blk_queue_rq_timeout(sdev->request_queue, 45*HZ); | |
45 | for (cid = 0; cid < aac->maximum_num_containers; ++cid) | |
46 | if (aac->fsa_dev[cid].valid) | |
47 | ++num_lsu; | |
48 | --- a/drivers/scsi/ibmvscsi/ibmvscsi.c | |
49 | +++ b/drivers/scsi/ibmvscsi/ibmvscsi.c | |
50 | @@ -1442,7 +1442,7 @@ static int ibmvscsi_slave_configure(stru | |
51 | spin_lock_irqsave(shost->host_lock, lock_flags); | |
52 | if (sdev->type == TYPE_DISK) { | |
53 | sdev->allow_restart = 1; | |
54 | - sdev->timeout = 60 * HZ; | |
55 | + blk_queue_rq_timeout(sdev->request_queue, 60 * HZ); | |
56 | } | |
57 | scsi_adjust_queue_depth(sdev, 0, shost->cmd_per_lun); | |
58 | spin_unlock_irqrestore(shost->host_lock, lock_flags); | |
59 | --- a/drivers/scsi/megaraid/megaraid_sas.c | |
60 | +++ b/drivers/scsi/megaraid/megaraid_sas.c | |
61 | @@ -1016,7 +1016,8 @@ static int megasas_slave_configure(struc | |
62 | * The RAID firmware may require extended timeouts. | |
63 | */ | |
64 | if (sdev->channel >= MEGASAS_MAX_PD_CHANNELS) | |
65 | - sdev->timeout = MEGASAS_DEFAULT_CMD_TIMEOUT * HZ; | |
66 | + blk_queue_rq_timeout(sdev->request_queue, | |
67 | + MEGASAS_DEFAULT_CMD_TIMEOUT * HZ); | |
68 | return 0; | |
69 | } | |
70 | ||
71 | --- a/drivers/scsi/scsi_error.c | |
72 | +++ b/drivers/scsi/scsi_error.c | |
73 | @@ -1013,7 +1013,7 @@ static int scsi_eh_try_stu(struct scsi_c | |
74 | ||
75 | for (i = 0; rtn == NEEDS_RETRY && i < 2; i++) | |
76 | rtn = scsi_send_eh_cmnd(scmd, stu_command, 6, | |
77 | - scmd->device->timeout, 0); | |
78 | + scmd->device->request_queue->rq_timeout, 0); | |
79 | ||
80 | if (rtn == SUCCESS) | |
81 | return 0; | |
82 | --- a/drivers/scsi/st.c | |
83 | +++ b/drivers/scsi/st.c | |
84 | @@ -613,7 +613,8 @@ static int cross_eof(struct scsi_tape * | |
85 | tape_name(STp), forward ? "forward" : "backward")); | |
86 | ||
87 | SRpnt = st_do_scsi(NULL, STp, cmd, 0, DMA_NONE, | |
88 | - STp->device->timeout, MAX_RETRIES, 1); | |
89 | + STp->device->request_queue->rq_timeout, | |
90 | + MAX_RETRIES, 1); | |
91 | if (!SRpnt) | |
92 | return (STp->buffer)->syscall_result; | |
93 | ||
94 | @@ -657,7 +658,8 @@ static int st_flush_write_buffer(struct | |
95 | cmd[4] = blks; | |
96 | ||
97 | SRpnt = st_do_scsi(NULL, STp, cmd, transfer, DMA_TO_DEVICE, | |
98 | - STp->device->timeout, MAX_WRITE_RETRIES, 1); | |
99 | + STp->device->request_queue->rq_timeout, | |
100 | + MAX_WRITE_RETRIES, 1); | |
101 | if (!SRpnt) | |
102 | return (STp->buffer)->syscall_result; | |
103 | ||
104 | @@ -987,7 +989,8 @@ static int check_tape(struct scsi_tape * | |
105 | cmd[0] = READ_BLOCK_LIMITS; | |
106 | ||
107 | SRpnt = st_do_scsi(SRpnt, STp, cmd, 6, DMA_FROM_DEVICE, | |
108 | - STp->device->timeout, MAX_READY_RETRIES, 1); | |
109 | + STp->device->request_queue->rq_timeout, | |
110 | + MAX_READY_RETRIES, 1); | |
111 | if (!SRpnt) { | |
112 | retval = (STp->buffer)->syscall_result; | |
113 | goto err_out; | |
114 | @@ -1014,7 +1017,8 @@ static int check_tape(struct scsi_tape * | |
115 | cmd[4] = 12; | |
116 | ||
117 | SRpnt = st_do_scsi(SRpnt, STp, cmd, 12, DMA_FROM_DEVICE, | |
118 | - STp->device->timeout, MAX_READY_RETRIES, 1); | |
119 | + STp->device->request_queue->rq_timeout, | |
120 | + MAX_READY_RETRIES, 1); | |
121 | if (!SRpnt) { | |
122 | retval = (STp->buffer)->syscall_result; | |
123 | goto err_out; | |
124 | @@ -1247,7 +1251,8 @@ static int st_flush(struct file *filp, f | |
125 | cmd[4] = 1 + STp->two_fm; | |
126 | ||
127 | SRpnt = st_do_scsi(NULL, STp, cmd, 0, DMA_NONE, | |
128 | - STp->device->timeout, MAX_WRITE_RETRIES, 1); | |
129 | + STp->device->request_queue->rq_timeout, | |
130 | + MAX_WRITE_RETRIES, 1); | |
131 | if (!SRpnt) { | |
132 | result = (STp->buffer)->syscall_result; | |
133 | goto out; | |
134 | @@ -1634,7 +1639,8 @@ st_write(struct file *filp, const char _ | |
135 | cmd[4] = blks; | |
136 | ||
137 | SRpnt = st_do_scsi(SRpnt, STp, cmd, transfer, DMA_TO_DEVICE, | |
138 | - STp->device->timeout, MAX_WRITE_RETRIES, !async_write); | |
139 | + STp->device->request_queue->rq_timeout, | |
140 | + MAX_WRITE_RETRIES, !async_write); | |
141 | if (!SRpnt) { | |
142 | retval = STbp->syscall_result; | |
143 | goto out; | |
144 | @@ -1804,7 +1810,8 @@ static long read_tape(struct scsi_tape * | |
145 | ||
146 | SRpnt = *aSRpnt; | |
147 | SRpnt = st_do_scsi(SRpnt, STp, cmd, bytes, DMA_FROM_DEVICE, | |
148 | - STp->device->timeout, MAX_RETRIES, 1); | |
149 | + STp->device->request_queue->rq_timeout, | |
150 | + MAX_RETRIES, 1); | |
151 | release_buffering(STp, 1); | |
152 | *aSRpnt = SRpnt; | |
153 | if (!SRpnt) | |
154 | @@ -2213,7 +2220,8 @@ static int st_set_options(struct scsi_ta | |
155 | DEBC( printk(KERN_INFO "%s: Long timeout set to %d seconds.\n", name, | |
156 | (value & ~MT_ST_SET_LONG_TIMEOUT))); | |
157 | } else { | |
158 | - STp->device->timeout = value * HZ; | |
159 | + blk_queue_rq_timeout(STp->device->request_queue, | |
160 | + value * HZ); | |
161 | DEBC( printk(KERN_INFO "%s: Normal timeout set to %d seconds.\n", | |
162 | name, value) ); | |
163 | } | |
164 | @@ -2321,7 +2329,7 @@ static int read_mode_page(struct scsi_ta | |
165 | cmd[4] = 255; | |
166 | ||
167 | SRpnt = st_do_scsi(SRpnt, STp, cmd, cmd[4], DMA_FROM_DEVICE, | |
168 | - STp->device->timeout, 0, 1); | |
169 | + STp->device->request_queue->rq_timeout, 0, 1); | |
170 | if (SRpnt == NULL) | |
171 | return (STp->buffer)->syscall_result; | |
172 | ||
173 | @@ -2352,7 +2360,7 @@ static int write_mode_page(struct scsi_t | |
174 | (STp->buffer)->b_data[pgo + MP_OFF_PAGE_NBR] &= MP_MSK_PAGE_NBR; | |
175 | ||
176 | SRpnt = st_do_scsi(SRpnt, STp, cmd, cmd[4], DMA_TO_DEVICE, | |
177 | - (slow ? STp->long_timeout : STp->device->timeout), 0, 1); | |
178 | + (slow ? STp->long_timeout : STp->device->request_queue->rq_timeout), 0, 1); | |
179 | if (SRpnt == NULL) | |
180 | return (STp->buffer)->syscall_result; | |
181 | ||
182 | @@ -2464,7 +2472,7 @@ static int do_load_unload(struct scsi_ta | |
183 | } | |
184 | if (STp->immediate) { | |
185 | cmd[1] = 1; /* Don't wait for completion */ | |
186 | - timeout = STp->device->timeout; | |
187 | + timeout = STp->device->request_queue->rq_timeout; | |
188 | } | |
189 | else | |
190 | timeout = STp->long_timeout; | |
191 | @@ -2638,7 +2646,7 @@ static int st_int_ioctl(struct scsi_tape | |
192 | cmd[2] = (arg >> 16); | |
193 | cmd[3] = (arg >> 8); | |
194 | cmd[4] = arg; | |
195 | - timeout = STp->device->timeout; | |
196 | + timeout = STp->device->request_queue->rq_timeout; | |
197 | DEBC( | |
198 | if (cmd_in == MTWEOF) | |
199 | printk(ST_DEB_MSG "%s: Writing %d filemarks.\n", name, | |
200 | @@ -2656,7 +2664,7 @@ static int st_int_ioctl(struct scsi_tape | |
201 | cmd[0] = REZERO_UNIT; | |
202 | if (STp->immediate) { | |
203 | cmd[1] = 1; /* Don't wait for completion */ | |
204 | - timeout = STp->device->timeout; | |
205 | + timeout = STp->device->request_queue->rq_timeout; | |
206 | } | |
207 | DEBC(printk(ST_DEB_MSG "%s: Rewinding tape.\n", name)); | |
208 | fileno = blkno = at_sm = 0; | |
209 | @@ -2669,7 +2677,7 @@ static int st_int_ioctl(struct scsi_tape | |
210 | cmd[0] = START_STOP; | |
211 | if (STp->immediate) { | |
212 | cmd[1] = 1; /* Don't wait for completion */ | |
213 | - timeout = STp->device->timeout; | |
214 | + timeout = STp->device->request_queue->rq_timeout; | |
215 | } | |
216 | cmd[4] = 3; | |
217 | DEBC(printk(ST_DEB_MSG "%s: Retensioning tape.\n", name)); | |
218 | @@ -2702,7 +2710,7 @@ static int st_int_ioctl(struct scsi_tape | |
219 | cmd[1] = (arg ? 1 : 0); /* Long erase with non-zero argument */ | |
220 | if (STp->immediate) { | |
221 | cmd[1] |= 2; /* Don't wait for completion */ | |
222 | - timeout = STp->device->timeout; | |
223 | + timeout = STp->device->request_queue->rq_timeout; | |
224 | } | |
225 | else | |
226 | timeout = STp->long_timeout * 8; | |
227 | @@ -2754,7 +2762,7 @@ static int st_int_ioctl(struct scsi_tape | |
228 | (STp->buffer)->b_data[9] = (ltmp >> 16); | |
229 | (STp->buffer)->b_data[10] = (ltmp >> 8); | |
230 | (STp->buffer)->b_data[11] = ltmp; | |
231 | - timeout = STp->device->timeout; | |
232 | + timeout = STp->device->request_queue->rq_timeout; | |
233 | DEBC( | |
234 | if (cmd_in == MTSETBLK || cmd_in == SET_DENS_AND_BLK) | |
235 | printk(ST_DEB_MSG | |
236 | @@ -2944,7 +2952,8 @@ static int get_location(struct scsi_tape | |
237 | scmd[1] = 1; | |
238 | } | |
239 | SRpnt = st_do_scsi(NULL, STp, scmd, 20, DMA_FROM_DEVICE, | |
240 | - STp->device->timeout, MAX_READY_RETRIES, 1); | |
241 | + STp->device->request_queue->rq_timeout, | |
242 | + MAX_READY_RETRIES, 1); | |
243 | if (!SRpnt) | |
244 | return (STp->buffer)->syscall_result; | |
245 | ||
246 | @@ -3045,7 +3054,7 @@ static int set_location(struct scsi_tape | |
247 | } | |
248 | if (STp->immediate) { | |
249 | scmd[1] |= 1; /* Don't wait for completion */ | |
250 | - timeout = STp->device->timeout; | |
251 | + timeout = STp->device->request_queue->rq_timeout; | |
252 | } | |
253 | ||
254 | SRpnt = st_do_scsi(NULL, STp, scmd, 0, DMA_NONE, | |
255 | @@ -4028,7 +4037,7 @@ static int st_probe(struct device *dev) | |
256 | tpnt->partition = 0; | |
257 | tpnt->new_partition = 0; | |
258 | tpnt->nbr_partitions = 0; | |
259 | - tpnt->device->timeout = ST_TIMEOUT; | |
260 | + blk_queue_rq_timeout(tpnt->device->request_queue, ST_TIMEOUT); | |
261 | tpnt->long_timeout = ST_LONG_TIMEOUT; | |
262 | tpnt->try_dio = try_direct_io && !SDp->host->unchecked_isa_dma; | |
263 | ||
264 | --- a/drivers/scsi/stex.c | |
265 | +++ b/drivers/scsi/stex.c | |
266 | @@ -477,7 +477,7 @@ stex_slave_config(struct scsi_device *sd | |
267 | { | |
268 | sdev->use_10_for_rw = 1; | |
269 | sdev->use_10_for_ms = 1; | |
270 | - sdev->timeout = 60 * HZ; | |
271 | + blk_queue_rq_timeout(sdev->request_queue, 60 * HZ); | |
272 | sdev->tagged_supported = 1; | |
273 | ||
274 | return 0; | |
275 | --- a/include/scsi/scsi_device.h | |
276 | +++ b/include/scsi/scsi_device.h | |
277 | @@ -160,8 +160,6 @@ struct scsi_device { | |
278 | atomic_t iodone_cnt; | |
279 | atomic_t ioerr_cnt; | |
280 | ||
281 | - int timeout; | |
282 | - | |
283 | struct device sdev_gendev, | |
284 | sdev_dev; | |
285 |