diff options
author | Willem Riede <osst@riede.org> | 2006-02-11 14:46:56 -0500 |
---|---|---|
committer | James Bottomley <jejb@mulgrave.il.steeleye.com> | 2006-03-07 10:16:01 -0500 |
commit | 5e6575c051f3313feb9fe1aad61263b3560df5cc (patch) | |
tree | e8bfe9b9670ff782f1d27707689edf69761785f3 /drivers | |
parent | 286fc8f8ea7ef58b54f150fc900ce019af483e89 (diff) |
[SCSI] osst: changes required to move forward to block request
On 02/07/2006 04:12:55 AM, Christoph Hellwig wrote:
> On Mon, Feb 06, 2006 at 08:02:21PM -0500, Willem Riede wrote:
>
> > But I will certainly help retire scsi_request. And anything else that is
> > needed to keep up with proper kernel style. Let me know what those are, if
> > you would? I'll start looking at how st has changed, and will be back with
> > any questions I may have.
>
> right now the above is the most urgent bit. What would be nice but not
> required is a conversion to the sense handling helpers, similar to what
> st got (aka using the *normalize_sense functions and then dealing with the
> parsed sense buffer instead of the raw sense data)
Ok, so here is my first take at satisfying this request.
Be warned, that beyond compiling, and checking that the new module
doesn't immediately blow up, there hasn't yet been a lot of testing.
But this should allow you to comment on the changes, and move forward
with dropping scsi_request from the kernel code.
Signed-off-by: Willem Riede <osst@riede.org>
Signed-off-by: James Bottomley <James.Bottomley@SteelEye.com>
Diffstat (limited to 'drivers')
-rw-r--r-- | drivers/scsi/osst.c | 503 | ||||
-rw-r--r-- | drivers/scsi/osst.h | 12 |
2 files changed, 290 insertions, 225 deletions
diff --git a/drivers/scsi/osst.c b/drivers/scsi/osst.c index b9f6084fdd9e..00f3edc2417f 100644 --- a/drivers/scsi/osst.c +++ b/drivers/scsi/osst.c | |||
@@ -13,7 +13,7 @@ | |||
13 | order) Klaus Ehrenfried, Wolfgang Denk, Steve Hirsch, Andreas Koppenh"ofer, | 13 | order) Klaus Ehrenfried, Wolfgang Denk, Steve Hirsch, Andreas Koppenh"ofer, |
14 | Michael Leodolter, Eyal Lebedinsky, J"org Weule, and Eric Youngdale. | 14 | Michael Leodolter, Eyal Lebedinsky, J"org Weule, and Eric Youngdale. |
15 | 15 | ||
16 | Copyright 1992 - 2002 Kai Makisara / 2000 - 2004 Willem Riede | 16 | Copyright 1992 - 2002 Kai Makisara / 2000 - 2006 Willem Riede |
17 | email osst@riede.org | 17 | email osst@riede.org |
18 | 18 | ||
19 | $Header: /cvsroot/osst/Driver/osst.c,v 1.73 2005/01/01 21:13:34 wriede Exp $ | 19 | $Header: /cvsroot/osst/Driver/osst.c,v 1.73 2005/01/01 21:13:34 wriede Exp $ |
@@ -24,7 +24,7 @@ | |||
24 | */ | 24 | */ |
25 | 25 | ||
26 | static const char * cvsid = "$Id: osst.c,v 1.73 2005/01/01 21:13:34 wriede Exp $"; | 26 | static const char * cvsid = "$Id: osst.c,v 1.73 2005/01/01 21:13:34 wriede Exp $"; |
27 | static const char * osst_version = "0.99.3"; | 27 | static const char * osst_version = "0.99.4"; |
28 | 28 | ||
29 | /* The "failure to reconnect" firmware bug */ | 29 | /* The "failure to reconnect" firmware bug */ |
30 | #define OSST_FW_NEED_POLL_MIN 10601 /*(107A)*/ | 30 | #define OSST_FW_NEED_POLL_MIN 10601 /*(107A)*/ |
@@ -69,7 +69,6 @@ static const char * osst_version = "0.99.3"; | |||
69 | #include <scsi/scsi_eh.h> | 69 | #include <scsi/scsi_eh.h> |
70 | #include <scsi/scsi_host.h> | 70 | #include <scsi/scsi_host.h> |
71 | #include <scsi/scsi_ioctl.h> | 71 | #include <scsi/scsi_ioctl.h> |
72 | #include <scsi/scsi_request.h> | ||
73 | 72 | ||
74 | #define ST_KILOBYTE 1024 | 73 | #define ST_KILOBYTE 1024 |
75 | 74 | ||
@@ -176,16 +175,16 @@ static struct scsi_driver osst_template = { | |||
176 | } | 175 | } |
177 | }; | 176 | }; |
178 | 177 | ||
179 | static int osst_int_ioctl(struct osst_tape *STp, struct scsi_request ** aSRpnt, | 178 | static int osst_int_ioctl(struct osst_tape *STp, struct osst_request ** aSRpnt, |
180 | unsigned int cmd_in, unsigned long arg); | 179 | unsigned int cmd_in, unsigned long arg); |
181 | 180 | ||
182 | static int osst_set_frame_position(struct osst_tape *STp, struct scsi_request ** aSRpnt, int frame, int skip); | 181 | static int osst_set_frame_position(struct osst_tape *STp, struct osst_request ** aSRpnt, int frame, int skip); |
183 | 182 | ||
184 | static int osst_get_frame_position(struct osst_tape *STp, struct scsi_request ** aSRpnt); | 183 | static int osst_get_frame_position(struct osst_tape *STp, struct osst_request ** aSRpnt); |
185 | 184 | ||
186 | static int osst_flush_write_buffer(struct osst_tape *STp, struct scsi_request ** aSRpnt); | 185 | static int osst_flush_write_buffer(struct osst_tape *STp, struct osst_request ** aSRpnt); |
187 | 186 | ||
188 | static int osst_write_error_recovery(struct osst_tape * STp, struct scsi_request ** aSRpnt, int pending); | 187 | static int osst_write_error_recovery(struct osst_tape * STp, struct osst_request ** aSRpnt, int pending); |
189 | 188 | ||
190 | static inline char *tape_name(struct osst_tape *tape) | 189 | static inline char *tape_name(struct osst_tape *tape) |
191 | { | 190 | { |
@@ -194,52 +193,84 @@ static inline char *tape_name(struct osst_tape *tape) | |||
194 | 193 | ||
195 | /* Routines that handle the interaction with mid-layer SCSI routines */ | 194 | /* Routines that handle the interaction with mid-layer SCSI routines */ |
196 | 195 | ||
196 | |||
197 | /* Normalize Sense */ | ||
198 | static void osst_analyze_sense(struct osst_request *SRpnt, struct st_cmdstatus *s) | ||
199 | { | ||
200 | const u8 *ucp; | ||
201 | const u8 *sense = SRpnt->sense; | ||
202 | |||
203 | s->have_sense = scsi_normalize_sense(SRpnt->sense, | ||
204 | SCSI_SENSE_BUFFERSIZE, &s->sense_hdr); | ||
205 | s->flags = 0; | ||
206 | |||
207 | if (s->have_sense) { | ||
208 | s->deferred = 0; | ||
209 | s->remainder_valid = | ||
210 | scsi_get_sense_info_fld(sense, SCSI_SENSE_BUFFERSIZE, &s->uremainder64); | ||
211 | switch (sense[0] & 0x7f) { | ||
212 | case 0x71: | ||
213 | s->deferred = 1; | ||
214 | case 0x70: | ||
215 | s->fixed_format = 1; | ||
216 | s->flags = sense[2] & 0xe0; | ||
217 | break; | ||
218 | case 0x73: | ||
219 | s->deferred = 1; | ||
220 | case 0x72: | ||
221 | s->fixed_format = 0; | ||
222 | ucp = scsi_sense_desc_find(sense, SCSI_SENSE_BUFFERSIZE, 4); | ||
223 | s->flags = ucp ? (ucp[3] & 0xe0) : 0; | ||
224 | break; | ||
225 | } | ||
226 | } | ||
227 | } | ||
228 | |||
197 | /* Convert the result to success code */ | 229 | /* Convert the result to success code */ |
198 | static int osst_chk_result(struct osst_tape * STp, struct scsi_request * SRpnt) | 230 | static int osst_chk_result(struct osst_tape * STp, struct osst_request * SRpnt) |
199 | { | 231 | { |
200 | char *name = tape_name(STp); | 232 | char *name = tape_name(STp); |
201 | int result = SRpnt->sr_result; | 233 | int result = SRpnt->result; |
202 | unsigned char * sense = SRpnt->sr_sense_buffer, scode; | 234 | u8 * sense = SRpnt->sense, scode; |
203 | #if DEBUG | 235 | #if DEBUG |
204 | const char *stp; | 236 | const char *stp; |
205 | #endif | 237 | #endif |
238 | struct st_cmdstatus *cmdstatp; | ||
206 | 239 | ||
207 | if (!result) { | 240 | if (!result) |
208 | sense[0] = 0; /* We don't have sense data if this byte is zero */ | ||
209 | return 0; | 241 | return 0; |
210 | } | 242 | |
211 | if ((driver_byte(result) & DRIVER_MASK) == DRIVER_SENSE) | 243 | cmdstatp = &STp->buffer->cmdstat; |
212 | scode = sense[2] & 0x0f; | 244 | osst_analyze_sense(SRpnt, cmdstatp); |
213 | else { | 245 | |
214 | sense[0] = 0; /* We don't have sense data if this byte is zero */ | 246 | if (cmdstatp->have_sense) |
247 | scode = STp->buffer->cmdstat.sense_hdr.sense_key; | ||
248 | else | ||
215 | scode = 0; | 249 | scode = 0; |
216 | } | ||
217 | #if DEBUG | 250 | #if DEBUG |
218 | if (debugging) { | 251 | if (debugging) { |
219 | printk(OSST_DEB_MSG "%s:D: Error: %x, cmd: %x %x %x %x %x %x Len: %d\n", | 252 | printk(OSST_DEB_MSG "%s:D: Error: %x, cmd: %x %x %x %x %x %x\n", |
220 | name, result, | 253 | name, result, |
221 | SRpnt->sr_cmnd[0], SRpnt->sr_cmnd[1], SRpnt->sr_cmnd[2], | 254 | SRpnt->cmd[0], SRpnt->cmd[1], SRpnt->cmd[2], |
222 | SRpnt->sr_cmnd[3], SRpnt->sr_cmnd[4], SRpnt->sr_cmnd[5], | 255 | SRpnt->cmd[3], SRpnt->cmd[4], SRpnt->cmd[5]); |
223 | SRpnt->sr_bufflen); | ||
224 | if (scode) printk(OSST_DEB_MSG "%s:D: Sense: %02x, ASC: %02x, ASCQ: %02x\n", | 256 | if (scode) printk(OSST_DEB_MSG "%s:D: Sense: %02x, ASC: %02x, ASCQ: %02x\n", |
225 | name, scode, sense[12], sense[13]); | 257 | name, scode, sense[12], sense[13]); |
226 | if (driver_byte(result) & DRIVER_SENSE) | 258 | if (cmdstatp->have_sense) |
227 | scsi_print_req_sense("osst ", SRpnt); | 259 | __scsi_print_sense("osst ", SRpnt->sense, SCSI_SENSE_BUFFERSIZE); |
228 | } | 260 | } |
229 | else | 261 | else |
230 | #endif | 262 | #endif |
231 | if (!(driver_byte(result) & DRIVER_SENSE) || | 263 | if (cmdstatp->have_sense && ( |
232 | ((sense[0] & 0x70) == 0x70 && | ||
233 | scode != NO_SENSE && | 264 | scode != NO_SENSE && |
234 | scode != RECOVERED_ERROR && | 265 | scode != RECOVERED_ERROR && |
235 | /* scode != UNIT_ATTENTION && */ | 266 | /* scode != UNIT_ATTENTION && */ |
236 | scode != BLANK_CHECK && | 267 | scode != BLANK_CHECK && |
237 | scode != VOLUME_OVERFLOW && | 268 | scode != VOLUME_OVERFLOW && |
238 | SRpnt->sr_cmnd[0] != MODE_SENSE && | 269 | SRpnt->cmd[0] != MODE_SENSE && |
239 | SRpnt->sr_cmnd[0] != TEST_UNIT_READY)) { /* Abnormal conditions for tape */ | 270 | SRpnt->cmd[0] != TEST_UNIT_READY)) { /* Abnormal conditions for tape */ |
240 | if (driver_byte(result) & DRIVER_SENSE) { | 271 | if (cmdstatp->have_sense) { |
241 | printk(KERN_WARNING "%s:W: Command with sense data:\n", name); | 272 | printk(KERN_WARNING "%s:W: Command with sense data:\n", name); |
242 | scsi_print_req_sense("osst:", SRpnt); | 273 | __scsi_print_sense("osst ", SRpnt->sense, SCSI_SENSE_BUFFERSIZE); |
243 | } | 274 | } |
244 | else { | 275 | else { |
245 | static int notyetprinted = 1; | 276 | static int notyetprinted = 1; |
@@ -259,15 +290,14 @@ static int osst_chk_result(struct osst_tape * STp, struct scsi_request * SRpnt) | |||
259 | } | 290 | } |
260 | STp->pos_unknown |= STp->device->was_reset; | 291 | STp->pos_unknown |= STp->device->was_reset; |
261 | 292 | ||
262 | if ((sense[0] & 0x70) == 0x70 && | 293 | if (cmdstatp->have_sense && scode == RECOVERED_ERROR) { |
263 | scode == RECOVERED_ERROR) { | ||
264 | STp->recover_count++; | 294 | STp->recover_count++; |
265 | STp->recover_erreg++; | 295 | STp->recover_erreg++; |
266 | #if DEBUG | 296 | #if DEBUG |
267 | if (debugging) { | 297 | if (debugging) { |
268 | if (SRpnt->sr_cmnd[0] == READ_6) | 298 | if (SRpnt->cmd[0] == READ_6) |
269 | stp = "read"; | 299 | stp = "read"; |
270 | else if (SRpnt->sr_cmnd[0] == WRITE_6) | 300 | else if (SRpnt->cmd[0] == WRITE_6) |
271 | stp = "write"; | 301 | stp = "write"; |
272 | else | 302 | else |
273 | stp = "ioctl"; | 303 | stp = "ioctl"; |
@@ -283,74 +313,99 @@ static int osst_chk_result(struct osst_tape * STp, struct scsi_request * SRpnt) | |||
283 | 313 | ||
284 | 314 | ||
285 | /* Wakeup from interrupt */ | 315 | /* Wakeup from interrupt */ |
286 | static void osst_sleep_done (struct scsi_cmnd * SCpnt) | 316 | static void osst_sleep_done(void *data, char *sense, int result, int resid) |
287 | { | 317 | { |
288 | struct osst_tape * STp = container_of(SCpnt->request->rq_disk->private_data, struct osst_tape, driver); | 318 | struct osst_request *SRpnt = data; |
289 | 319 | struct osst_tape *STp = SRpnt->stp; | |
290 | if ((STp->buffer)->writing && | ||
291 | (SCpnt->sense_buffer[0] & 0x70) == 0x70 && | ||
292 | (SCpnt->sense_buffer[2] & 0x40)) { | ||
293 | /* EOM at write-behind, has all been written? */ | ||
294 | if ((SCpnt->sense_buffer[2] & 0x0f) == VOLUME_OVERFLOW) | ||
295 | STp->buffer->midlevel_result = SCpnt->result; /* Error */ | ||
296 | else | ||
297 | STp->buffer->midlevel_result = INT_MAX; /* OK */ | ||
298 | } | ||
299 | else | ||
300 | STp->buffer->midlevel_result = SCpnt->result; | ||
301 | SCpnt->request->rq_status = RQ_SCSI_DONE; | ||
302 | STp->buffer->last_SRpnt = SCpnt->sc_request; | ||
303 | 320 | ||
321 | memcpy(SRpnt->sense, sense, SCSI_SENSE_BUFFERSIZE); | ||
322 | STp->buffer->cmdstat.midlevel_result = SRpnt->result = result; | ||
304 | #if DEBUG | 323 | #if DEBUG |
305 | STp->write_pending = 0; | 324 | STp->write_pending = 0; |
306 | #endif | 325 | #endif |
307 | complete(SCpnt->request->waiting); | 326 | if (SRpnt->waiting) |
327 | complete(SRpnt->waiting); | ||
328 | } | ||
329 | |||
330 | /* osst_request memory management */ | ||
331 | static struct osst_request *osst_allocate_request(void) | ||
332 | { | ||
333 | return kzalloc(sizeof(struct osst_request), GFP_KERNEL); | ||
308 | } | 334 | } |
309 | 335 | ||
336 | static void osst_release_request(struct osst_request *streq) | ||
337 | { | ||
338 | kfree(streq); | ||
339 | } | ||
310 | 340 | ||
311 | /* Do the scsi command. Waits until command performed if do_wait is true. | 341 | /* Do the scsi command. Waits until command performed if do_wait is true. |
312 | Otherwise osst_write_behind_check() is used to check that the command | 342 | Otherwise osst_write_behind_check() is used to check that the command |
313 | has finished. */ | 343 | has finished. */ |
314 | static struct scsi_request * osst_do_scsi(struct scsi_request *SRpnt, struct osst_tape *STp, | 344 | static struct osst_request * osst_do_scsi(struct osst_request *SRpnt, struct osst_tape *STp, |
315 | unsigned char *cmd, int bytes, int direction, int timeout, int retries, int do_wait) | 345 | unsigned char *cmd, int bytes, int direction, int timeout, int retries, int do_wait) |
316 | { | 346 | { |
317 | unsigned char *bp; | 347 | unsigned char *bp; |
348 | unsigned short use_sg; | ||
318 | #ifdef OSST_INJECT_ERRORS | 349 | #ifdef OSST_INJECT_ERRORS |
319 | static int inject = 0; | 350 | static int inject = 0; |
320 | static int repeat = 0; | 351 | static int repeat = 0; |
321 | #endif | 352 | #endif |
353 | struct completion *waiting; | ||
354 | |||
355 | /* if async, make sure there's no command outstanding */ | ||
356 | if (!do_wait && ((STp->buffer)->last_SRpnt)) { | ||
357 | printk(KERN_ERR "%s: Async command already active.\n", | ||
358 | tape_name(STp)); | ||
359 | if (signal_pending(current)) | ||
360 | (STp->buffer)->syscall_result = (-EINTR); | ||
361 | else | ||
362 | (STp->buffer)->syscall_result = (-EBUSY); | ||
363 | return NULL; | ||
364 | } | ||
365 | |||
322 | if (SRpnt == NULL) { | 366 | if (SRpnt == NULL) { |
323 | if ((SRpnt = scsi_allocate_request(STp->device, GFP_ATOMIC)) == NULL) { | 367 | SRpnt = osst_allocate_request(); |
324 | printk(KERN_ERR "%s:E: Can't get SCSI request.\n", tape_name(STp)); | 368 | if (SRpnt == NULL) { |
369 | printk(KERN_ERR "%s: Can't allocate SCSI request.\n", | ||
370 | tape_name(STp)); | ||
325 | if (signal_pending(current)) | 371 | if (signal_pending(current)) |
326 | (STp->buffer)->syscall_result = (-EINTR); | 372 | (STp->buffer)->syscall_result = (-EINTR); |
327 | else | 373 | else |
328 | (STp->buffer)->syscall_result = (-EBUSY); | 374 | (STp->buffer)->syscall_result = (-EBUSY); |
329 | return NULL; | 375 | return NULL; |
330 | } | 376 | } |
377 | SRpnt->stp = STp; | ||
331 | } | 378 | } |
332 | 379 | ||
333 | init_completion(&STp->wait); | 380 | /* If async IO, set last_SRpnt. This ptr tells write_behind_check |
334 | SRpnt->sr_use_sg = (bytes > (STp->buffer)->sg[0].length) ? | 381 | which IO is outstanding. It's nulled out when the IO completes. */ |
335 | (STp->buffer)->use_sg : 0; | 382 | if (!do_wait) |
336 | if (SRpnt->sr_use_sg) { | 383 | (STp->buffer)->last_SRpnt = SRpnt; |
384 | |||
385 | waiting = &STp->wait; | ||
386 | init_completion(waiting); | ||
387 | SRpnt->waiting = waiting; | ||
388 | |||
389 | use_sg = (bytes > STp->buffer->sg[0].length) ? STp->buffer->use_sg : 0; | ||
390 | if (use_sg) { | ||
337 | bp = (char *)&(STp->buffer->sg[0]); | 391 | bp = (char *)&(STp->buffer->sg[0]); |
338 | if (STp->buffer->sg_segs < SRpnt->sr_use_sg) | 392 | if (STp->buffer->sg_segs < use_sg) |
339 | SRpnt->sr_use_sg = STp->buffer->sg_segs; | 393 | use_sg = STp->buffer->sg_segs; |
340 | } | 394 | } |
341 | else | 395 | else |
342 | bp = (STp->buffer)->b_data; | 396 | bp = (STp->buffer)->b_data; |
343 | SRpnt->sr_data_direction = direction; | ||
344 | SRpnt->sr_cmd_len = 0; | ||
345 | SRpnt->sr_request->waiting = &(STp->wait); | ||
346 | SRpnt->sr_request->rq_status = RQ_SCSI_BUSY; | ||
347 | SRpnt->sr_request->rq_disk = STp->drive; | ||
348 | 397 | ||
349 | scsi_do_req(SRpnt, (void *)cmd, bp, bytes, osst_sleep_done, timeout, retries); | 398 | memcpy(SRpnt->cmd, cmd, sizeof(SRpnt->cmd)); |
399 | STp->buffer->cmdstat.have_sense = 0; | ||
400 | STp->buffer->syscall_result = 0; | ||
350 | 401 | ||
351 | if (do_wait) { | 402 | if (scsi_execute_async(STp->device, cmd, COMMAND_SIZE(cmd[0]), direction, bp, bytes, |
352 | wait_for_completion(SRpnt->sr_request->waiting); | 403 | use_sg, timeout, retries, SRpnt, osst_sleep_done, GFP_KERNEL)) |
353 | SRpnt->sr_request->waiting = NULL; | 404 | /* could not allocate the buffer or request was too large */ |
405 | (STp->buffer)->syscall_result = (-EBUSY); | ||
406 | else if (do_wait) { | ||
407 | wait_for_completion(waiting); | ||
408 | SRpnt->waiting = NULL; | ||
354 | STp->buffer->syscall_result = osst_chk_result(STp, SRpnt); | 409 | STp->buffer->syscall_result = osst_chk_result(STp, SRpnt); |
355 | #ifdef OSST_INJECT_ERRORS | 410 | #ifdef OSST_INJECT_ERRORS |
356 | if (STp->buffer->syscall_result == 0 && | 411 | if (STp->buffer->syscall_result == 0 && |
@@ -383,21 +438,22 @@ static void osst_write_behind_check(struct osst_tape *STp) | |||
383 | STp->nbr_finished++; | 438 | STp->nbr_finished++; |
384 | #endif | 439 | #endif |
385 | wait_for_completion(&(STp->wait)); | 440 | wait_for_completion(&(STp->wait)); |
386 | (STp->buffer)->last_SRpnt->sr_request->waiting = NULL; | 441 | STp->buffer->last_SRpnt->waiting = NULL; |
387 | 442 | ||
388 | STp->buffer->syscall_result = osst_chk_result(STp, STp->buffer->last_SRpnt); | 443 | STp->buffer->syscall_result = osst_chk_result(STp, STp->buffer->last_SRpnt); |
389 | 444 | ||
390 | if ((STp->buffer)->syscall_result) | 445 | if (STp->buffer->syscall_result) |
391 | (STp->buffer)->syscall_result = | 446 | STp->buffer->syscall_result = |
392 | osst_write_error_recovery(STp, &((STp->buffer)->last_SRpnt), 1); | 447 | osst_write_error_recovery(STp, &(STp->buffer->last_SRpnt), 1); |
393 | else | 448 | else |
394 | STp->first_frame_position++; | 449 | STp->first_frame_position++; |
395 | 450 | ||
396 | scsi_release_request((STp->buffer)->last_SRpnt); | 451 | osst_release_request(STp->buffer->last_SRpnt); |
397 | 452 | ||
398 | if (STbuffer->writing < STbuffer->buffer_bytes) | 453 | if (STbuffer->writing < STbuffer->buffer_bytes) |
399 | printk(KERN_WARNING "osst :A: write_behind_check: something left in buffer!\n"); | 454 | printk(KERN_WARNING "osst :A: write_behind_check: something left in buffer!\n"); |
400 | 455 | ||
456 | STbuffer->last_SRpnt = NULL; | ||
401 | STbuffer->buffer_bytes -= STbuffer->writing; | 457 | STbuffer->buffer_bytes -= STbuffer->writing; |
402 | STbuffer->writing = 0; | 458 | STbuffer->writing = 0; |
403 | 459 | ||
@@ -606,11 +662,11 @@ err_out: | |||
606 | /* | 662 | /* |
607 | * Wait for the unit to become Ready | 663 | * Wait for the unit to become Ready |
608 | */ | 664 | */ |
609 | static int osst_wait_ready(struct osst_tape * STp, struct scsi_request ** aSRpnt, | 665 | static int osst_wait_ready(struct osst_tape * STp, struct osst_request ** aSRpnt, |
610 | unsigned timeout, int initial_delay) | 666 | unsigned timeout, int initial_delay) |
611 | { | 667 | { |
612 | unsigned char cmd[MAX_COMMAND_SIZE]; | 668 | unsigned char cmd[MAX_COMMAND_SIZE]; |
613 | struct scsi_request * SRpnt; | 669 | struct osst_request * SRpnt; |
614 | unsigned long startwait = jiffies; | 670 | unsigned long startwait = jiffies; |
615 | #if DEBUG | 671 | #if DEBUG |
616 | int dbg = debugging; | 672 | int dbg = debugging; |
@@ -630,10 +686,10 @@ static int osst_wait_ready(struct osst_tape * STp, struct scsi_request ** aSRpnt | |||
630 | if (!SRpnt) return (-EBUSY); | 686 | if (!SRpnt) return (-EBUSY); |
631 | 687 | ||
632 | while ( STp->buffer->syscall_result && time_before(jiffies, startwait + timeout*HZ) && | 688 | while ( STp->buffer->syscall_result && time_before(jiffies, startwait + timeout*HZ) && |
633 | (( SRpnt->sr_sense_buffer[2] == 2 && SRpnt->sr_sense_buffer[12] == 4 && | 689 | (( SRpnt->sense[2] == 2 && SRpnt->sense[12] == 4 && |
634 | (SRpnt->sr_sense_buffer[13] == 1 || SRpnt->sr_sense_buffer[13] == 8) ) || | 690 | (SRpnt->sense[13] == 1 || SRpnt->sense[13] == 8) ) || |
635 | ( SRpnt->sr_sense_buffer[2] == 6 && SRpnt->sr_sense_buffer[12] == 0x28 && | 691 | ( SRpnt->sense[2] == 6 && SRpnt->sense[12] == 0x28 && |
636 | SRpnt->sr_sense_buffer[13] == 0 ) )) { | 692 | SRpnt->sense[13] == 0 ) )) { |
637 | #if DEBUG | 693 | #if DEBUG |
638 | if (debugging) { | 694 | if (debugging) { |
639 | printk(OSST_DEB_MSG "%s:D: Sleeping in onstream wait ready\n", name); | 695 | printk(OSST_DEB_MSG "%s:D: Sleeping in onstream wait ready\n", name); |
@@ -657,8 +713,8 @@ static int osst_wait_ready(struct osst_tape * STp, struct scsi_request ** aSRpnt | |||
657 | #if DEBUG | 713 | #if DEBUG |
658 | printk(OSST_DEB_MSG "%s:D: Abnormal exit from onstream wait ready\n", name); | 714 | printk(OSST_DEB_MSG "%s:D: Abnormal exit from onstream wait ready\n", name); |
659 | printk(OSST_DEB_MSG "%s:D: Result = %d, Sense: 0=%02x, 2=%02x, 12=%02x, 13=%02x\n", name, | 715 | printk(OSST_DEB_MSG "%s:D: Result = %d, Sense: 0=%02x, 2=%02x, 12=%02x, 13=%02x\n", name, |
660 | STp->buffer->syscall_result, SRpnt->sr_sense_buffer[0], SRpnt->sr_sense_buffer[2], | 716 | STp->buffer->syscall_result, SRpnt->sense[0], SRpnt->sense[2], |
661 | SRpnt->sr_sense_buffer[12], SRpnt->sr_sense_buffer[13]); | 717 | SRpnt->sense[12], SRpnt->sense[13]); |
662 | #endif | 718 | #endif |
663 | return (-EIO); | 719 | return (-EIO); |
664 | } | 720 | } |
@@ -671,10 +727,10 @@ static int osst_wait_ready(struct osst_tape * STp, struct scsi_request ** aSRpnt | |||
671 | /* | 727 | /* |
672 | * Wait for a tape to be inserted in the unit | 728 | * Wait for a tape to be inserted in the unit |
673 | */ | 729 | */ |
674 | static int osst_wait_for_medium(struct osst_tape * STp, struct scsi_request ** aSRpnt, unsigned timeout) | 730 | static int osst_wait_for_medium(struct osst_tape * STp, struct osst_request ** aSRpnt, unsigned timeout) |
675 | { | 731 | { |
676 | unsigned char cmd[MAX_COMMAND_SIZE]; | 732 | unsigned char cmd[MAX_COMMAND_SIZE]; |
677 | struct scsi_request * SRpnt; | 733 | struct osst_request * SRpnt; |
678 | unsigned long startwait = jiffies; | 734 | unsigned long startwait = jiffies; |
679 | #if DEBUG | 735 | #if DEBUG |
680 | int dbg = debugging; | 736 | int dbg = debugging; |
@@ -691,8 +747,7 @@ static int osst_wait_for_medium(struct osst_tape * STp, struct scsi_request ** a | |||
691 | if (!SRpnt) return (-EBUSY); | 747 | if (!SRpnt) return (-EBUSY); |
692 | 748 | ||
693 | while ( STp->buffer->syscall_result && time_before(jiffies, startwait + timeout*HZ) && | 749 | while ( STp->buffer->syscall_result && time_before(jiffies, startwait + timeout*HZ) && |
694 | SRpnt->sr_sense_buffer[2] == 2 && SRpnt->sr_sense_buffer[12] == 0x3a && | 750 | SRpnt->sense[2] == 2 && SRpnt->sense[12] == 0x3a && SRpnt->sense[13] == 0 ) { |
695 | SRpnt->sr_sense_buffer[13] == 0 ) { | ||
696 | #if DEBUG | 751 | #if DEBUG |
697 | if (debugging) { | 752 | if (debugging) { |
698 | printk(OSST_DEB_MSG "%s:D: Sleeping in onstream wait medium\n", name); | 753 | printk(OSST_DEB_MSG "%s:D: Sleeping in onstream wait medium\n", name); |
@@ -711,13 +766,13 @@ static int osst_wait_for_medium(struct osst_tape * STp, struct scsi_request ** a | |||
711 | #if DEBUG | 766 | #if DEBUG |
712 | debugging = dbg; | 767 | debugging = dbg; |
713 | #endif | 768 | #endif |
714 | if ( STp->buffer->syscall_result && SRpnt->sr_sense_buffer[2] != 2 && | 769 | if ( STp->buffer->syscall_result && SRpnt->sense[2] != 2 && |
715 | SRpnt->sr_sense_buffer[12] != 4 && SRpnt->sr_sense_buffer[13] == 1) { | 770 | SRpnt->sense[12] != 4 && SRpnt->sense[13] == 1) { |
716 | #if DEBUG | 771 | #if DEBUG |
717 | printk(OSST_DEB_MSG "%s:D: Abnormal exit from onstream wait medium\n", name); | 772 | printk(OSST_DEB_MSG "%s:D: Abnormal exit from onstream wait medium\n", name); |
718 | printk(OSST_DEB_MSG "%s:D: Result = %d, Sense: 0=%02x, 2=%02x, 12=%02x, 13=%02x\n", name, | 773 | printk(OSST_DEB_MSG "%s:D: Result = %d, Sense: 0=%02x, 2=%02x, 12=%02x, 13=%02x\n", name, |
719 | STp->buffer->syscall_result, SRpnt->sr_sense_buffer[0], SRpnt->sr_sense_buffer[2], | 774 | STp->buffer->syscall_result, SRpnt->sense[0], SRpnt->sense[2], |
720 | SRpnt->sr_sense_buffer[12], SRpnt->sr_sense_buffer[13]); | 775 | SRpnt->sense[12], SRpnt->sense[13]); |
721 | #endif | 776 | #endif |
722 | return 0; | 777 | return 0; |
723 | } | 778 | } |
@@ -727,7 +782,7 @@ static int osst_wait_for_medium(struct osst_tape * STp, struct scsi_request ** a | |||
727 | return 1; | 782 | return 1; |
728 | } | 783 | } |
729 | 784 | ||
730 | static int osst_position_tape_and_confirm(struct osst_tape * STp, struct scsi_request ** aSRpnt, int frame) | 785 | static int osst_position_tape_and_confirm(struct osst_tape * STp, struct osst_request ** aSRpnt, int frame) |
731 | { | 786 | { |
732 | int retval; | 787 | int retval; |
733 | 788 | ||
@@ -741,10 +796,10 @@ static int osst_position_tape_and_confirm(struct osst_tape * STp, struct scsi_re | |||
741 | /* | 796 | /* |
742 | * Wait for write(s) to complete | 797 | * Wait for write(s) to complete |
743 | */ | 798 | */ |
744 | static int osst_flush_drive_buffer(struct osst_tape * STp, struct scsi_request ** aSRpnt) | 799 | static int osst_flush_drive_buffer(struct osst_tape * STp, struct osst_request ** aSRpnt) |
745 | { | 800 | { |
746 | unsigned char cmd[MAX_COMMAND_SIZE]; | 801 | unsigned char cmd[MAX_COMMAND_SIZE]; |
747 | struct scsi_request * SRpnt; | 802 | struct osst_request * SRpnt; |
748 | int result = 0; | 803 | int result = 0; |
749 | int delay = OSST_WAIT_WRITE_COMPLETE; | 804 | int delay = OSST_WAIT_WRITE_COMPLETE; |
750 | #if DEBUG | 805 | #if DEBUG |
@@ -761,8 +816,8 @@ static int osst_flush_drive_buffer(struct osst_tape * STp, struct scsi_request * | |||
761 | *aSRpnt = SRpnt; | 816 | *aSRpnt = SRpnt; |
762 | if (!SRpnt) return (-EBUSY); | 817 | if (!SRpnt) return (-EBUSY); |
763 | if (STp->buffer->syscall_result) { | 818 | if (STp->buffer->syscall_result) { |
764 | if ((SRpnt->sr_sense_buffer[2] & 0x0f) == 2 && SRpnt->sr_sense_buffer[12] == 4) { | 819 | if ((SRpnt->sense[2] & 0x0f) == 2 && SRpnt->sense[12] == 4) { |
765 | if (SRpnt->sr_sense_buffer[13] == 8) { | 820 | if (SRpnt->sense[13] == 8) { |
766 | delay = OSST_WAIT_LONG_WRITE_COMPLETE; | 821 | delay = OSST_WAIT_LONG_WRITE_COMPLETE; |
767 | } | 822 | } |
768 | } else | 823 | } else |
@@ -775,7 +830,7 @@ static int osst_flush_drive_buffer(struct osst_tape * STp, struct scsi_request * | |||
775 | } | 830 | } |
776 | 831 | ||
777 | #define OSST_POLL_PER_SEC 10 | 832 | #define OSST_POLL_PER_SEC 10 |
778 | static int osst_wait_frame(struct osst_tape * STp, struct scsi_request ** aSRpnt, int curr, int minlast, int to) | 833 | static int osst_wait_frame(struct osst_tape * STp, struct osst_request ** aSRpnt, int curr, int minlast, int to) |
779 | { | 834 | { |
780 | unsigned long startwait = jiffies; | 835 | unsigned long startwait = jiffies; |
781 | char * name = tape_name(STp); | 836 | char * name = tape_name(STp); |
@@ -830,9 +885,9 @@ static int osst_wait_frame(struct osst_tape * STp, struct scsi_request ** aSRpnt | |||
830 | return -EBUSY; | 885 | return -EBUSY; |
831 | } | 886 | } |
832 | 887 | ||
833 | static int osst_recover_wait_frame(struct osst_tape * STp, struct scsi_request ** aSRpnt, int writing) | 888 | static int osst_recover_wait_frame(struct osst_tape * STp, struct osst_request ** aSRpnt, int writing) |
834 | { | 889 | { |
835 | struct scsi_request * SRpnt; | 890 | struct osst_request * SRpnt; |
836 | unsigned char cmd[MAX_COMMAND_SIZE]; | 891 | unsigned char cmd[MAX_COMMAND_SIZE]; |
837 | unsigned long startwait = jiffies; | 892 | unsigned long startwait = jiffies; |
838 | int retval = 1; | 893 | int retval = 1; |
@@ -853,7 +908,7 @@ static int osst_recover_wait_frame(struct osst_tape * STp, struct scsi_request * | |||
853 | 908 | ||
854 | while (retval && time_before (jiffies, startwait + 5*60*HZ)) { | 909 | while (retval && time_before (jiffies, startwait + 5*60*HZ)) { |
855 | 910 | ||
856 | if (STp->buffer->syscall_result && (SRpnt->sr_sense_buffer[2] & 0x0f) != 2) { | 911 | if (STp->buffer->syscall_result && (SRpnt->sense[2] & 0x0f) != 2) { |
857 | 912 | ||
858 | /* some failure - not just not-ready */ | 913 | /* some failure - not just not-ready */ |
859 | retval = osst_write_error_recovery(STp, aSRpnt, 0); | 914 | retval = osst_write_error_recovery(STp, aSRpnt, 0); |
@@ -878,9 +933,9 @@ static int osst_recover_wait_frame(struct osst_tape * STp, struct scsi_request * | |||
878 | if (STp->buffer->syscall_result) | 933 | if (STp->buffer->syscall_result) |
879 | printk(KERN_WARNING | 934 | printk(KERN_WARNING |
880 | "%s:W: Recover_wait_frame(read) cannot handle %02x:%02x:%02x\n", name, | 935 | "%s:W: Recover_wait_frame(read) cannot handle %02x:%02x:%02x\n", name, |
881 | (*aSRpnt)->sr_sense_buffer[ 2] & 0x0f, | 936 | (*aSRpnt)->sense[ 2] & 0x0f, |
882 | (*aSRpnt)->sr_sense_buffer[12], | 937 | (*aSRpnt)->sense[12], |
883 | (*aSRpnt)->sr_sense_buffer[13]); | 938 | (*aSRpnt)->sense[13]); |
884 | 939 | ||
885 | return retval; | 940 | return retval; |
886 | } | 941 | } |
@@ -888,10 +943,10 @@ static int osst_recover_wait_frame(struct osst_tape * STp, struct scsi_request * | |||
888 | /* | 943 | /* |
889 | * Read the next OnStream tape frame at the current location | 944 | * Read the next OnStream tape frame at the current location |
890 | */ | 945 | */ |
891 | static int osst_read_frame(struct osst_tape * STp, struct scsi_request ** aSRpnt, int timeout) | 946 | static int osst_read_frame(struct osst_tape * STp, struct osst_request ** aSRpnt, int timeout) |
892 | { | 947 | { |
893 | unsigned char cmd[MAX_COMMAND_SIZE]; | 948 | unsigned char cmd[MAX_COMMAND_SIZE]; |
894 | struct scsi_request * SRpnt; | 949 | struct osst_request * SRpnt; |
895 | int retval = 0; | 950 | int retval = 0; |
896 | #if DEBUG | 951 | #if DEBUG |
897 | os_aux_t * aux = STp->buffer->aux; | 952 | os_aux_t * aux = STp->buffer->aux; |
@@ -929,10 +984,10 @@ static int osst_read_frame(struct osst_tape * STp, struct scsi_request ** aSRpnt | |||
929 | if (debugging) | 984 | if (debugging) |
930 | printk(OSST_DEB_MSG "%s:D: Sense: %2x %2x %2x %2x %2x %2x %2x %2x\n", | 985 | printk(OSST_DEB_MSG "%s:D: Sense: %2x %2x %2x %2x %2x %2x %2x %2x\n", |
931 | name, | 986 | name, |
932 | SRpnt->sr_sense_buffer[0], SRpnt->sr_sense_buffer[1], | 987 | SRpnt->sense[0], SRpnt->sense[1], |
933 | SRpnt->sr_sense_buffer[2], SRpnt->sr_sense_buffer[3], | 988 | SRpnt->sense[2], SRpnt->sense[3], |
934 | SRpnt->sr_sense_buffer[4], SRpnt->sr_sense_buffer[5], | 989 | SRpnt->sense[4], SRpnt->sense[5], |
935 | SRpnt->sr_sense_buffer[6], SRpnt->sr_sense_buffer[7]); | 990 | SRpnt->sense[6], SRpnt->sense[7]); |
936 | #endif | 991 | #endif |
937 | } | 992 | } |
938 | else | 993 | else |
@@ -959,10 +1014,10 @@ static int osst_read_frame(struct osst_tape * STp, struct scsi_request ** aSRpnt | |||
959 | return (retval); | 1014 | return (retval); |
960 | } | 1015 | } |
961 | 1016 | ||
962 | static int osst_initiate_read(struct osst_tape * STp, struct scsi_request ** aSRpnt) | 1017 | static int osst_initiate_read(struct osst_tape * STp, struct osst_request ** aSRpnt) |
963 | { | 1018 | { |
964 | struct st_partstat * STps = &(STp->ps[STp->partition]); | 1019 | struct st_partstat * STps = &(STp->ps[STp->partition]); |
965 | struct scsi_request * SRpnt ; | 1020 | struct osst_request * SRpnt ; |
966 | unsigned char cmd[MAX_COMMAND_SIZE]; | 1021 | unsigned char cmd[MAX_COMMAND_SIZE]; |
967 | int retval = 0; | 1022 | int retval = 0; |
968 | char * name = tape_name(STp); | 1023 | char * name = tape_name(STp); |
@@ -996,7 +1051,7 @@ static int osst_initiate_read(struct osst_tape * STp, struct scsi_request ** aSR | |||
996 | return retval; | 1051 | return retval; |
997 | } | 1052 | } |
998 | 1053 | ||
999 | static int osst_get_logical_frame(struct osst_tape * STp, struct scsi_request ** aSRpnt, | 1054 | static int osst_get_logical_frame(struct osst_tape * STp, struct osst_request ** aSRpnt, |
1000 | int frame_seq_number, int quiet) | 1055 | int frame_seq_number, int quiet) |
1001 | { | 1056 | { |
1002 | struct st_partstat * STps = &(STp->ps[STp->partition]); | 1057 | struct st_partstat * STps = &(STp->ps[STp->partition]); |
@@ -1125,7 +1180,7 @@ static int osst_get_logical_frame(struct osst_tape * STp, struct scsi_request ** | |||
1125 | return (STps->eof); | 1180 | return (STps->eof); |
1126 | } | 1181 | } |
1127 | 1182 | ||
1128 | static int osst_seek_logical_blk(struct osst_tape * STp, struct scsi_request ** aSRpnt, int logical_blk_num) | 1183 | static int osst_seek_logical_blk(struct osst_tape * STp, struct osst_request ** aSRpnt, int logical_blk_num) |
1129 | { | 1184 | { |
1130 | struct st_partstat * STps = &(STp->ps[STp->partition]); | 1185 | struct st_partstat * STps = &(STp->ps[STp->partition]); |
1131 | char * name = tape_name(STp); | 1186 | char * name = tape_name(STp); |
@@ -1234,7 +1289,7 @@ error: | |||
1234 | #define OSST_SECTOR_SHIFT 9 | 1289 | #define OSST_SECTOR_SHIFT 9 |
1235 | #define OSST_SECTOR_MASK 0x03F | 1290 | #define OSST_SECTOR_MASK 0x03F |
1236 | 1291 | ||
1237 | static int osst_get_sector(struct osst_tape * STp, struct scsi_request ** aSRpnt) | 1292 | static int osst_get_sector(struct osst_tape * STp, struct osst_request ** aSRpnt) |
1238 | { | 1293 | { |
1239 | int sector; | 1294 | int sector; |
1240 | #if DEBUG | 1295 | #if DEBUG |
@@ -1264,7 +1319,7 @@ static int osst_get_sector(struct osst_tape * STp, struct scsi_request ** aSRpnt | |||
1264 | return sector; | 1319 | return sector; |
1265 | } | 1320 | } |
1266 | 1321 | ||
1267 | static int osst_seek_sector(struct osst_tape * STp, struct scsi_request ** aSRpnt, int sector) | 1322 | static int osst_seek_sector(struct osst_tape * STp, struct osst_request ** aSRpnt, int sector) |
1268 | { | 1323 | { |
1269 | struct st_partstat * STps = &(STp->ps[STp->partition]); | 1324 | struct st_partstat * STps = &(STp->ps[STp->partition]); |
1270 | int frame = sector >> OSST_FRAME_SHIFT, | 1325 | int frame = sector >> OSST_FRAME_SHIFT, |
@@ -1327,10 +1382,10 @@ static int osst_seek_sector(struct osst_tape * STp, struct scsi_request ** aSRpn | |||
1327 | * Precondition for this function to work: all frames in the | 1382 | * Precondition for this function to work: all frames in the |
1328 | * drive's buffer must be of one type (DATA, MARK or EOD)! | 1383 | * drive's buffer must be of one type (DATA, MARK or EOD)! |
1329 | */ | 1384 | */ |
1330 | static int osst_read_back_buffer_and_rewrite(struct osst_tape * STp, struct scsi_request ** aSRpnt, | 1385 | static int osst_read_back_buffer_and_rewrite(struct osst_tape * STp, struct osst_request ** aSRpnt, |
1331 | unsigned int frame, unsigned int skip, int pending) | 1386 | unsigned int frame, unsigned int skip, int pending) |
1332 | { | 1387 | { |
1333 | struct scsi_request * SRpnt = * aSRpnt; | 1388 | struct osst_request * SRpnt = * aSRpnt; |
1334 | unsigned char * buffer, * p; | 1389 | unsigned char * buffer, * p; |
1335 | unsigned char cmd[MAX_COMMAND_SIZE]; | 1390 | unsigned char cmd[MAX_COMMAND_SIZE]; |
1336 | int flag, new_frame, i; | 1391 | int flag, new_frame, i; |
@@ -1474,8 +1529,8 @@ static int osst_read_back_buffer_and_rewrite(struct osst_tape * STp, struct scsi | |||
1474 | SRpnt = osst_do_scsi(SRpnt, STp, cmd, 0, DMA_NONE, STp->timeout, | 1529 | SRpnt = osst_do_scsi(SRpnt, STp, cmd, 0, DMA_NONE, STp->timeout, |
1475 | MAX_RETRIES, 1); | 1530 | MAX_RETRIES, 1); |
1476 | 1531 | ||
1477 | if (SRpnt->sr_sense_buffer[2] == 2 && SRpnt->sr_sense_buffer[12] == 4 && | 1532 | if (SRpnt->sense[2] == 2 && SRpnt->sense[12] == 4 && |
1478 | (SRpnt->sr_sense_buffer[13] == 1 || SRpnt->sr_sense_buffer[13] == 8)) { | 1533 | (SRpnt->sense[13] == 1 || SRpnt->sense[13] == 8)) { |
1479 | /* in the process of becoming ready */ | 1534 | /* in the process of becoming ready */ |
1480 | msleep(100); | 1535 | msleep(100); |
1481 | continue; | 1536 | continue; |
@@ -1492,17 +1547,17 @@ static int osst_read_back_buffer_and_rewrite(struct osst_tape * STp, struct scsi | |||
1492 | } | 1547 | } |
1493 | *aSRpnt = SRpnt; | 1548 | *aSRpnt = SRpnt; |
1494 | if (flag) { | 1549 | if (flag) { |
1495 | if ((SRpnt->sr_sense_buffer[ 2] & 0x0f) == 13 && | 1550 | if ((SRpnt->sense[ 2] & 0x0f) == 13 && |
1496 | SRpnt->sr_sense_buffer[12] == 0 && | 1551 | SRpnt->sense[12] == 0 && |
1497 | SRpnt->sr_sense_buffer[13] == 2) { | 1552 | SRpnt->sense[13] == 2) { |
1498 | printk(KERN_ERR "%s:E: Volume overflow in write error recovery\n", name); | 1553 | printk(KERN_ERR "%s:E: Volume overflow in write error recovery\n", name); |
1499 | vfree(buffer); | 1554 | vfree(buffer); |
1500 | return (-EIO); /* hit end of tape = fail */ | 1555 | return (-EIO); /* hit end of tape = fail */ |
1501 | } | 1556 | } |
1502 | i = ((SRpnt->sr_sense_buffer[3] << 24) | | 1557 | i = ((SRpnt->sense[3] << 24) | |
1503 | (SRpnt->sr_sense_buffer[4] << 16) | | 1558 | (SRpnt->sense[4] << 16) | |
1504 | (SRpnt->sr_sense_buffer[5] << 8) | | 1559 | (SRpnt->sense[5] << 8) | |
1505 | SRpnt->sr_sense_buffer[6] ) - new_frame; | 1560 | SRpnt->sense[6] ) - new_frame; |
1506 | p = &buffer[i * OS_DATA_SIZE]; | 1561 | p = &buffer[i * OS_DATA_SIZE]; |
1507 | #if DEBUG | 1562 | #if DEBUG |
1508 | printk(OSST_DEB_MSG "%s:D: Additional write error at %d\n", name, new_frame+i); | 1563 | printk(OSST_DEB_MSG "%s:D: Additional write error at %d\n", name, new_frame+i); |
@@ -1525,11 +1580,11 @@ static int osst_read_back_buffer_and_rewrite(struct osst_tape * STp, struct scsi | |||
1525 | return 0; | 1580 | return 0; |
1526 | } | 1581 | } |
1527 | 1582 | ||
1528 | static int osst_reposition_and_retry(struct osst_tape * STp, struct scsi_request ** aSRpnt, | 1583 | static int osst_reposition_and_retry(struct osst_tape * STp, struct osst_request ** aSRpnt, |
1529 | unsigned int frame, unsigned int skip, int pending) | 1584 | unsigned int frame, unsigned int skip, int pending) |
1530 | { | 1585 | { |
1531 | unsigned char cmd[MAX_COMMAND_SIZE]; | 1586 | unsigned char cmd[MAX_COMMAND_SIZE]; |
1532 | struct scsi_request * SRpnt; | 1587 | struct osst_request * SRpnt; |
1533 | char * name = tape_name(STp); | 1588 | char * name = tape_name(STp); |
1534 | int expected = 0; | 1589 | int expected = 0; |
1535 | int attempts = 1000 / skip; | 1590 | int attempts = 1000 / skip; |
@@ -1581,9 +1636,9 @@ static int osst_reposition_and_retry(struct osst_tape * STp, struct scsi_request | |||
1581 | *aSRpnt = SRpnt; | 1636 | *aSRpnt = SRpnt; |
1582 | 1637 | ||
1583 | if (STp->buffer->syscall_result) { /* additional write error */ | 1638 | if (STp->buffer->syscall_result) { /* additional write error */ |
1584 | if ((SRpnt->sr_sense_buffer[ 2] & 0x0f) == 13 && | 1639 | if ((SRpnt->sense[ 2] & 0x0f) == 13 && |
1585 | SRpnt->sr_sense_buffer[12] == 0 && | 1640 | SRpnt->sense[12] == 0 && |
1586 | SRpnt->sr_sense_buffer[13] == 2) { | 1641 | SRpnt->sense[13] == 2) { |
1587 | printk(KERN_ERR | 1642 | printk(KERN_ERR |
1588 | "%s:E: Volume overflow in write error recovery\n", | 1643 | "%s:E: Volume overflow in write error recovery\n", |
1589 | name); | 1644 | name); |
@@ -1628,9 +1683,9 @@ static int osst_reposition_and_retry(struct osst_tape * STp, struct scsi_request | |||
1628 | * Error recovery algorithm for the OnStream tape. | 1683 | * Error recovery algorithm for the OnStream tape. |
1629 | */ | 1684 | */ |
1630 | 1685 | ||
1631 | static int osst_write_error_recovery(struct osst_tape * STp, struct scsi_request ** aSRpnt, int pending) | 1686 | static int osst_write_error_recovery(struct osst_tape * STp, struct osst_request ** aSRpnt, int pending) |
1632 | { | 1687 | { |
1633 | struct scsi_request * SRpnt = * aSRpnt; | 1688 | struct osst_request * SRpnt = * aSRpnt; |
1634 | struct st_partstat * STps = & STp->ps[STp->partition]; | 1689 | struct st_partstat * STps = & STp->ps[STp->partition]; |
1635 | char * name = tape_name(STp); | 1690 | char * name = tape_name(STp); |
1636 | int retval = 0; | 1691 | int retval = 0; |
@@ -1639,20 +1694,20 @@ static int osst_write_error_recovery(struct osst_tape * STp, struct scsi_request | |||
1639 | 1694 | ||
1640 | rw_state = STps->rw; | 1695 | rw_state = STps->rw; |
1641 | 1696 | ||
1642 | if ((SRpnt->sr_sense_buffer[ 2] & 0x0f) != 3 | 1697 | if ((SRpnt->sense[ 2] & 0x0f) != 3 |
1643 | || SRpnt->sr_sense_buffer[12] != 12 | 1698 | || SRpnt->sense[12] != 12 |
1644 | || SRpnt->sr_sense_buffer[13] != 0) { | 1699 | || SRpnt->sense[13] != 0) { |
1645 | #if DEBUG | 1700 | #if DEBUG |
1646 | printk(OSST_DEB_MSG "%s:D: Write error recovery cannot handle %02x:%02x:%02x\n", name, | 1701 | printk(OSST_DEB_MSG "%s:D: Write error recovery cannot handle %02x:%02x:%02x\n", name, |
1647 | SRpnt->sr_sense_buffer[2], SRpnt->sr_sense_buffer[12], SRpnt->sr_sense_buffer[13]); | 1702 | SRpnt->sense[2], SRpnt->sense[12], SRpnt->sense[13]); |
1648 | #endif | 1703 | #endif |
1649 | return (-EIO); | 1704 | return (-EIO); |
1650 | } | 1705 | } |
1651 | frame = (SRpnt->sr_sense_buffer[3] << 24) | | 1706 | frame = (SRpnt->sense[3] << 24) | |
1652 | (SRpnt->sr_sense_buffer[4] << 16) | | 1707 | (SRpnt->sense[4] << 16) | |
1653 | (SRpnt->sr_sense_buffer[5] << 8) | | 1708 | (SRpnt->sense[5] << 8) | |
1654 | SRpnt->sr_sense_buffer[6]; | 1709 | SRpnt->sense[6]; |
1655 | skip = SRpnt->sr_sense_buffer[9]; | 1710 | skip = SRpnt->sense[9]; |
1656 | 1711 | ||
1657 | #if DEBUG | 1712 | #if DEBUG |
1658 | printk(OSST_DEB_MSG "%s:D: Detected physical bad frame at %u, advised to skip %d\n", name, frame, skip); | 1713 | printk(OSST_DEB_MSG "%s:D: Detected physical bad frame at %u, advised to skip %d\n", name, frame, skip); |
@@ -1707,7 +1762,7 @@ static int osst_write_error_recovery(struct osst_tape * STp, struct scsi_request | |||
1707 | return retval; | 1762 | return retval; |
1708 | } | 1763 | } |
1709 | 1764 | ||
1710 | static int osst_space_over_filemarks_backward(struct osst_tape * STp, struct scsi_request ** aSRpnt, | 1765 | static int osst_space_over_filemarks_backward(struct osst_tape * STp, struct osst_request ** aSRpnt, |
1711 | int mt_op, int mt_count) | 1766 | int mt_op, int mt_count) |
1712 | { | 1767 | { |
1713 | char * name = tape_name(STp); | 1768 | char * name = tape_name(STp); |
@@ -1806,7 +1861,7 @@ found: | |||
1806 | * | 1861 | * |
1807 | * Just scans for the filemark sequentially. | 1862 | * Just scans for the filemark sequentially. |
1808 | */ | 1863 | */ |
1809 | static int osst_space_over_filemarks_forward_slow(struct osst_tape * STp, struct scsi_request ** aSRpnt, | 1864 | static int osst_space_over_filemarks_forward_slow(struct osst_tape * STp, struct osst_request ** aSRpnt, |
1810 | int mt_op, int mt_count) | 1865 | int mt_op, int mt_count) |
1811 | { | 1866 | { |
1812 | int cnt = 0; | 1867 | int cnt = 0; |
@@ -1860,7 +1915,7 @@ static int osst_space_over_filemarks_forward_slow(struct osst_tape * STp, struct | |||
1860 | /* | 1915 | /* |
1861 | * Fast linux specific version of OnStream FSF | 1916 | * Fast linux specific version of OnStream FSF |
1862 | */ | 1917 | */ |
1863 | static int osst_space_over_filemarks_forward_fast(struct osst_tape * STp, struct scsi_request ** aSRpnt, | 1918 | static int osst_space_over_filemarks_forward_fast(struct osst_tape * STp, struct osst_request ** aSRpnt, |
1864 | int mt_op, int mt_count) | 1919 | int mt_op, int mt_count) |
1865 | { | 1920 | { |
1866 | char * name = tape_name(STp); | 1921 | char * name = tape_name(STp); |
@@ -2011,10 +2066,10 @@ static int osst_space_over_filemarks_forward_fast(struct osst_tape * STp, struct | |||
2011 | * to test the error recovery mechanism. | 2066 | * to test the error recovery mechanism. |
2012 | */ | 2067 | */ |
2013 | #if DEBUG | 2068 | #if DEBUG |
2014 | static void osst_set_retries(struct osst_tape * STp, struct scsi_request ** aSRpnt, int retries) | 2069 | static void osst_set_retries(struct osst_tape * STp, struct osst_request ** aSRpnt, int retries) |
2015 | { | 2070 | { |
2016 | unsigned char cmd[MAX_COMMAND_SIZE]; | 2071 | unsigned char cmd[MAX_COMMAND_SIZE]; |
2017 | struct scsi_request * SRpnt = * aSRpnt; | 2072 | struct osst_request * SRpnt = * aSRpnt; |
2018 | char * name = tape_name(STp); | 2073 | char * name = tape_name(STp); |
2019 | 2074 | ||
2020 | memset(cmd, 0, MAX_COMMAND_SIZE); | 2075 | memset(cmd, 0, MAX_COMMAND_SIZE); |
@@ -2043,7 +2098,7 @@ static void osst_set_retries(struct osst_tape * STp, struct scsi_request ** aSRp | |||
2043 | #endif | 2098 | #endif |
2044 | 2099 | ||
2045 | 2100 | ||
2046 | static int osst_write_filemark(struct osst_tape * STp, struct scsi_request ** aSRpnt) | 2101 | static int osst_write_filemark(struct osst_tape * STp, struct osst_request ** aSRpnt) |
2047 | { | 2102 | { |
2048 | int result; | 2103 | int result; |
2049 | int this_mark_ppos = STp->first_frame_position; | 2104 | int this_mark_ppos = STp->first_frame_position; |
@@ -2071,7 +2126,7 @@ static int osst_write_filemark(struct osst_tape * STp, struct scsi_request ** aS | |||
2071 | return result; | 2126 | return result; |
2072 | } | 2127 | } |
2073 | 2128 | ||
2074 | static int osst_write_eod(struct osst_tape * STp, struct scsi_request ** aSRpnt) | 2129 | static int osst_write_eod(struct osst_tape * STp, struct osst_request ** aSRpnt) |
2075 | { | 2130 | { |
2076 | int result; | 2131 | int result; |
2077 | #if DEBUG | 2132 | #if DEBUG |
@@ -2094,7 +2149,7 @@ static int osst_write_eod(struct osst_tape * STp, struct scsi_request ** aSRpnt) | |||
2094 | return result; | 2149 | return result; |
2095 | } | 2150 | } |
2096 | 2151 | ||
2097 | static int osst_write_filler(struct osst_tape * STp, struct scsi_request ** aSRpnt, int where, int count) | 2152 | static int osst_write_filler(struct osst_tape * STp, struct osst_request ** aSRpnt, int where, int count) |
2098 | { | 2153 | { |
2099 | char * name = tape_name(STp); | 2154 | char * name = tape_name(STp); |
2100 | 2155 | ||
@@ -2119,7 +2174,7 @@ static int osst_write_filler(struct osst_tape * STp, struct scsi_request ** aSRp | |||
2119 | return osst_flush_drive_buffer(STp, aSRpnt); | 2174 | return osst_flush_drive_buffer(STp, aSRpnt); |
2120 | } | 2175 | } |
2121 | 2176 | ||
2122 | static int __osst_write_header(struct osst_tape * STp, struct scsi_request ** aSRpnt, int where, int count) | 2177 | static int __osst_write_header(struct osst_tape * STp, struct osst_request ** aSRpnt, int where, int count) |
2123 | { | 2178 | { |
2124 | char * name = tape_name(STp); | 2179 | char * name = tape_name(STp); |
2125 | int result; | 2180 | int result; |
@@ -2146,7 +2201,7 @@ static int __osst_write_header(struct osst_tape * STp, struct scsi_request ** aS | |||
2146 | return result; | 2201 | return result; |
2147 | } | 2202 | } |
2148 | 2203 | ||
2149 | static int osst_write_header(struct osst_tape * STp, struct scsi_request ** aSRpnt, int locate_eod) | 2204 | static int osst_write_header(struct osst_tape * STp, struct osst_request ** aSRpnt, int locate_eod) |
2150 | { | 2205 | { |
2151 | os_header_t * header; | 2206 | os_header_t * header; |
2152 | int result; | 2207 | int result; |
@@ -2220,7 +2275,7 @@ static int osst_write_header(struct osst_tape * STp, struct scsi_request ** aSRp | |||
2220 | return result; | 2275 | return result; |
2221 | } | 2276 | } |
2222 | 2277 | ||
2223 | static int osst_reset_header(struct osst_tape * STp, struct scsi_request ** aSRpnt) | 2278 | static int osst_reset_header(struct osst_tape * STp, struct osst_request ** aSRpnt) |
2224 | { | 2279 | { |
2225 | if (STp->header_cache != NULL) | 2280 | if (STp->header_cache != NULL) |
2226 | memset(STp->header_cache, 0, sizeof(os_header_t)); | 2281 | memset(STp->header_cache, 0, sizeof(os_header_t)); |
@@ -2233,7 +2288,7 @@ static int osst_reset_header(struct osst_tape * STp, struct scsi_request ** aSRp | |||
2233 | return osst_write_header(STp, aSRpnt, 1); | 2288 | return osst_write_header(STp, aSRpnt, 1); |
2234 | } | 2289 | } |
2235 | 2290 | ||
2236 | static int __osst_analyze_headers(struct osst_tape * STp, struct scsi_request ** aSRpnt, int ppos) | 2291 | static int __osst_analyze_headers(struct osst_tape * STp, struct osst_request ** aSRpnt, int ppos) |
2237 | { | 2292 | { |
2238 | char * name = tape_name(STp); | 2293 | char * name = tape_name(STp); |
2239 | os_header_t * header; | 2294 | os_header_t * header; |
@@ -2410,7 +2465,7 @@ static int __osst_analyze_headers(struct osst_tape * STp, struct scsi_request ** | |||
2410 | return 1; | 2465 | return 1; |
2411 | } | 2466 | } |
2412 | 2467 | ||
2413 | static int osst_analyze_headers(struct osst_tape * STp, struct scsi_request ** aSRpnt) | 2468 | static int osst_analyze_headers(struct osst_tape * STp, struct osst_request ** aSRpnt) |
2414 | { | 2469 | { |
2415 | int position, ppos; | 2470 | int position, ppos; |
2416 | int first, last; | 2471 | int first, last; |
@@ -2465,7 +2520,7 @@ static int osst_analyze_headers(struct osst_tape * STp, struct scsi_request ** a | |||
2465 | return 1; | 2520 | return 1; |
2466 | } | 2521 | } |
2467 | 2522 | ||
2468 | static int osst_verify_position(struct osst_tape * STp, struct scsi_request ** aSRpnt) | 2523 | static int osst_verify_position(struct osst_tape * STp, struct osst_request ** aSRpnt) |
2469 | { | 2524 | { |
2470 | int frame_position = STp->first_frame_position; | 2525 | int frame_position = STp->first_frame_position; |
2471 | int frame_seq_numbr = STp->frame_seq_number; | 2526 | int frame_seq_numbr = STp->frame_seq_number; |
@@ -2541,11 +2596,11 @@ static unsigned int osst_parse_firmware_rev (const char * str) | |||
2541 | /* | 2596 | /* |
2542 | * Configure the OnStream SCII tape drive for default operation | 2597 | * Configure the OnStream SCII tape drive for default operation |
2543 | */ | 2598 | */ |
2544 | static int osst_configure_onstream(struct osst_tape *STp, struct scsi_request ** aSRpnt) | 2599 | static int osst_configure_onstream(struct osst_tape *STp, struct osst_request ** aSRpnt) |
2545 | { | 2600 | { |
2546 | unsigned char cmd[MAX_COMMAND_SIZE]; | 2601 | unsigned char cmd[MAX_COMMAND_SIZE]; |
2547 | char * name = tape_name(STp); | 2602 | char * name = tape_name(STp); |
2548 | struct scsi_request * SRpnt = * aSRpnt; | 2603 | struct osst_request * SRpnt = * aSRpnt; |
2549 | osst_mode_parameter_header_t * header; | 2604 | osst_mode_parameter_header_t * header; |
2550 | osst_block_size_page_t * bs; | 2605 | osst_block_size_page_t * bs; |
2551 | osst_capabilities_page_t * cp; | 2606 | osst_capabilities_page_t * cp; |
@@ -2712,7 +2767,7 @@ static int osst_configure_onstream(struct osst_tape *STp, struct scsi_request ** | |||
2712 | 2767 | ||
2713 | /* Step over EOF if it has been inadvertently crossed (ioctl not used because | 2768 | /* Step over EOF if it has been inadvertently crossed (ioctl not used because |
2714 | it messes up the block number). */ | 2769 | it messes up the block number). */ |
2715 | static int cross_eof(struct osst_tape *STp, struct scsi_request ** aSRpnt, int forward) | 2770 | static int cross_eof(struct osst_tape *STp, struct osst_request ** aSRpnt, int forward) |
2716 | { | 2771 | { |
2717 | int result; | 2772 | int result; |
2718 | char * name = tape_name(STp); | 2773 | char * name = tape_name(STp); |
@@ -2741,10 +2796,10 @@ static int cross_eof(struct osst_tape *STp, struct scsi_request ** aSRpnt, int f | |||
2741 | 2796 | ||
2742 | /* Get the tape position. */ | 2797 | /* Get the tape position. */ |
2743 | 2798 | ||
2744 | static int osst_get_frame_position(struct osst_tape *STp, struct scsi_request ** aSRpnt) | 2799 | static int osst_get_frame_position(struct osst_tape *STp, struct osst_request ** aSRpnt) |
2745 | { | 2800 | { |
2746 | unsigned char scmd[MAX_COMMAND_SIZE]; | 2801 | unsigned char scmd[MAX_COMMAND_SIZE]; |
2747 | struct scsi_request * SRpnt; | 2802 | struct osst_request * SRpnt; |
2748 | int result = 0; | 2803 | int result = 0; |
2749 | char * name = tape_name(STp); | 2804 | char * name = tape_name(STp); |
2750 | 2805 | ||
@@ -2769,14 +2824,14 @@ static int osst_get_frame_position(struct osst_tape *STp, struct scsi_request ** | |||
2769 | *aSRpnt = SRpnt; | 2824 | *aSRpnt = SRpnt; |
2770 | 2825 | ||
2771 | if (STp->buffer->syscall_result) | 2826 | if (STp->buffer->syscall_result) |
2772 | result = ((SRpnt->sr_sense_buffer[2] & 0x0f) == 3) ? -EIO : -EINVAL; /* 3: Write Error */ | 2827 | result = ((SRpnt->sense[2] & 0x0f) == 3) ? -EIO : -EINVAL; /* 3: Write Error */ |
2773 | 2828 | ||
2774 | if (result == -EINVAL) | 2829 | if (result == -EINVAL) |
2775 | printk(KERN_ERR "%s:E: Can't read tape position.\n", name); | 2830 | printk(KERN_ERR "%s:E: Can't read tape position.\n", name); |
2776 | else { | 2831 | else { |
2777 | if (result == -EIO) { /* re-read position - this needs to preserve media errors */ | 2832 | if (result == -EIO) { /* re-read position - this needs to preserve media errors */ |
2778 | unsigned char mysense[16]; | 2833 | unsigned char mysense[16]; |
2779 | memcpy (mysense, SRpnt->sr_sense_buffer, 16); | 2834 | memcpy (mysense, SRpnt->sense, 16); |
2780 | memset (scmd, 0, MAX_COMMAND_SIZE); | 2835 | memset (scmd, 0, MAX_COMMAND_SIZE); |
2781 | scmd[0] = READ_POSITION; | 2836 | scmd[0] = READ_POSITION; |
2782 | STp->buffer->b_data = mybuf; STp->buffer->buffer_size = 24; | 2837 | STp->buffer->b_data = mybuf; STp->buffer->buffer_size = 24; |
@@ -2785,10 +2840,10 @@ static int osst_get_frame_position(struct osst_tape *STp, struct scsi_request ** | |||
2785 | #if DEBUG | 2840 | #if DEBUG |
2786 | printk(OSST_DEB_MSG "%s:D: Reread position, reason=[%02x:%02x:%02x], result=[%s%02x:%02x:%02x]\n", | 2841 | printk(OSST_DEB_MSG "%s:D: Reread position, reason=[%02x:%02x:%02x], result=[%s%02x:%02x:%02x]\n", |
2787 | name, mysense[2], mysense[12], mysense[13], STp->buffer->syscall_result?"":"ok:", | 2842 | name, mysense[2], mysense[12], mysense[13], STp->buffer->syscall_result?"":"ok:", |
2788 | SRpnt->sr_sense_buffer[2],SRpnt->sr_sense_buffer[12],SRpnt->sr_sense_buffer[13]); | 2843 | SRpnt->sense[2],SRpnt->sense[12],SRpnt->sense[13]); |
2789 | #endif | 2844 | #endif |
2790 | if (!STp->buffer->syscall_result) | 2845 | if (!STp->buffer->syscall_result) |
2791 | memcpy (SRpnt->sr_sense_buffer, mysense, 16); | 2846 | memcpy (SRpnt->sense, mysense, 16); |
2792 | else | 2847 | else |
2793 | printk(KERN_WARNING "%s:W: Double error in get position\n", name); | 2848 | printk(KERN_WARNING "%s:W: Double error in get position\n", name); |
2794 | } | 2849 | } |
@@ -2825,10 +2880,10 @@ static int osst_get_frame_position(struct osst_tape *STp, struct scsi_request ** | |||
2825 | 2880 | ||
2826 | 2881 | ||
2827 | /* Set the tape block */ | 2882 | /* Set the tape block */ |
2828 | static int osst_set_frame_position(struct osst_tape *STp, struct scsi_request ** aSRpnt, int ppos, int skip) | 2883 | static int osst_set_frame_position(struct osst_tape *STp, struct osst_request ** aSRpnt, int ppos, int skip) |
2829 | { | 2884 | { |
2830 | unsigned char scmd[MAX_COMMAND_SIZE]; | 2885 | unsigned char scmd[MAX_COMMAND_SIZE]; |
2831 | struct scsi_request * SRpnt; | 2886 | struct osst_request * SRpnt; |
2832 | struct st_partstat * STps; | 2887 | struct st_partstat * STps; |
2833 | int result = 0; | 2888 | int result = 0; |
2834 | int pp = (ppos == 3000 && !skip)? 0 : ppos; | 2889 | int pp = (ppos == 3000 && !skip)? 0 : ppos; |
@@ -2883,7 +2938,7 @@ static int osst_set_frame_position(struct osst_tape *STp, struct scsi_request ** | |||
2883 | return result; | 2938 | return result; |
2884 | } | 2939 | } |
2885 | 2940 | ||
2886 | static int osst_write_trailer(struct osst_tape *STp, struct scsi_request ** aSRpnt, int leave_at_EOT) | 2941 | static int osst_write_trailer(struct osst_tape *STp, struct osst_request ** aSRpnt, int leave_at_EOT) |
2887 | { | 2942 | { |
2888 | struct st_partstat * STps = &(STp->ps[STp->partition]); | 2943 | struct st_partstat * STps = &(STp->ps[STp->partition]); |
2889 | int result = 0; | 2944 | int result = 0; |
@@ -2910,12 +2965,12 @@ out: | |||
2910 | /* osst versions of st functions - augmented and stripped to suit OnStream only */ | 2965 | /* osst versions of st functions - augmented and stripped to suit OnStream only */ |
2911 | 2966 | ||
2912 | /* Flush the write buffer (never need to write if variable blocksize). */ | 2967 | /* Flush the write buffer (never need to write if variable blocksize). */ |
2913 | static int osst_flush_write_buffer(struct osst_tape *STp, struct scsi_request ** aSRpnt) | 2968 | static int osst_flush_write_buffer(struct osst_tape *STp, struct osst_request ** aSRpnt) |
2914 | { | 2969 | { |
2915 | int offset, transfer, blks = 0; | 2970 | int offset, transfer, blks = 0; |
2916 | int result = 0; | 2971 | int result = 0; |
2917 | unsigned char cmd[MAX_COMMAND_SIZE]; | 2972 | unsigned char cmd[MAX_COMMAND_SIZE]; |
2918 | struct scsi_request * SRpnt = *aSRpnt; | 2973 | struct osst_request * SRpnt = *aSRpnt; |
2919 | struct st_partstat * STps; | 2974 | struct st_partstat * STps; |
2920 | char * name = tape_name(STp); | 2975 | char * name = tape_name(STp); |
2921 | 2976 | ||
@@ -2923,13 +2978,13 @@ static int osst_flush_write_buffer(struct osst_tape *STp, struct scsi_request ** | |||
2923 | if (SRpnt == (STp->buffer)->last_SRpnt) | 2978 | if (SRpnt == (STp->buffer)->last_SRpnt) |
2924 | #if DEBUG | 2979 | #if DEBUG |
2925 | { printk(OSST_DEB_MSG | 2980 | { printk(OSST_DEB_MSG |
2926 | "%s:D: aSRpnt points to scsi_request that write_behind_check will release -- cleared\n", name); | 2981 | "%s:D: aSRpnt points to osst_request that write_behind_check will release -- cleared\n", name); |
2927 | #endif | 2982 | #endif |
2928 | *aSRpnt = SRpnt = NULL; | 2983 | *aSRpnt = SRpnt = NULL; |
2929 | #if DEBUG | 2984 | #if DEBUG |
2930 | } else if (SRpnt) | 2985 | } else if (SRpnt) |
2931 | printk(OSST_DEB_MSG | 2986 | printk(OSST_DEB_MSG |
2932 | "%s:D: aSRpnt does not point to scsi_request that write_behind_check will release -- strange\n", name); | 2987 | "%s:D: aSRpnt does not point to osst_request that write_behind_check will release -- strange\n", name); |
2933 | #endif | 2988 | #endif |
2934 | osst_write_behind_check(STp); | 2989 | osst_write_behind_check(STp); |
2935 | if ((STp->buffer)->syscall_result) { | 2990 | if ((STp->buffer)->syscall_result) { |
@@ -3007,12 +3062,12 @@ static int osst_flush_write_buffer(struct osst_tape *STp, struct scsi_request ** | |||
3007 | #if DEBUG | 3062 | #if DEBUG |
3008 | printk(OSST_DEB_MSG | 3063 | printk(OSST_DEB_MSG |
3009 | "%s:D: write sense [0]=0x%02x [2]=%02x [12]=%02x [13]=%02x\n", | 3064 | "%s:D: write sense [0]=0x%02x [2]=%02x [12]=%02x [13]=%02x\n", |
3010 | name, SRpnt->sr_sense_buffer[0], SRpnt->sr_sense_buffer[2], | 3065 | name, SRpnt->sense[0], SRpnt->sense[2], |
3011 | SRpnt->sr_sense_buffer[12], SRpnt->sr_sense_buffer[13]); | 3066 | SRpnt->sense[12], SRpnt->sense[13]); |
3012 | #endif | 3067 | #endif |
3013 | if ((SRpnt->sr_sense_buffer[0] & 0x70) == 0x70 && | 3068 | if ((SRpnt->sense[0] & 0x70) == 0x70 && |
3014 | (SRpnt->sr_sense_buffer[2] & 0x40) && /* FIXME - SC-30 drive doesn't assert EOM bit */ | 3069 | (SRpnt->sense[2] & 0x40) && /* FIXME - SC-30 drive doesn't assert EOM bit */ |
3015 | (SRpnt->sr_sense_buffer[2] & 0x0f) == NO_SENSE) { | 3070 | (SRpnt->sense[2] & 0x0f) == NO_SENSE) { |
3016 | STp->dirty = 0; | 3071 | STp->dirty = 0; |
3017 | (STp->buffer)->buffer_bytes = 0; | 3072 | (STp->buffer)->buffer_bytes = 0; |
3018 | result = (-ENOSPC); | 3073 | result = (-ENOSPC); |
@@ -3040,7 +3095,7 @@ static int osst_flush_write_buffer(struct osst_tape *STp, struct scsi_request ** | |||
3040 | 3095 | ||
3041 | /* Flush the tape buffer. The tape will be positioned correctly unless | 3096 | /* Flush the tape buffer. The tape will be positioned correctly unless |
3042 | seek_next is true. */ | 3097 | seek_next is true. */ |
3043 | static int osst_flush_buffer(struct osst_tape * STp, struct scsi_request ** aSRpnt, int seek_next) | 3098 | static int osst_flush_buffer(struct osst_tape * STp, struct osst_request ** aSRpnt, int seek_next) |
3044 | { | 3099 | { |
3045 | struct st_partstat * STps; | 3100 | struct st_partstat * STps; |
3046 | int backspace = 0, result = 0; | 3101 | int backspace = 0, result = 0; |
@@ -3102,10 +3157,10 @@ static int osst_flush_buffer(struct osst_tape * STp, struct scsi_request ** aSRp | |||
3102 | return result; | 3157 | return result; |
3103 | } | 3158 | } |
3104 | 3159 | ||
3105 | static int osst_write_frame(struct osst_tape * STp, struct scsi_request ** aSRpnt, int synchronous) | 3160 | static int osst_write_frame(struct osst_tape * STp, struct osst_request ** aSRpnt, int synchronous) |
3106 | { | 3161 | { |
3107 | unsigned char cmd[MAX_COMMAND_SIZE]; | 3162 | unsigned char cmd[MAX_COMMAND_SIZE]; |
3108 | struct scsi_request * SRpnt; | 3163 | struct osst_request * SRpnt; |
3109 | int blks; | 3164 | int blks; |
3110 | #if DEBUG | 3165 | #if DEBUG |
3111 | char * name = tape_name(STp); | 3166 | char * name = tape_name(STp); |
@@ -3166,9 +3221,9 @@ static int osst_write_frame(struct osst_tape * STp, struct scsi_request ** aSRpn | |||
3166 | if (debugging) | 3221 | if (debugging) |
3167 | printk(OSST_DEB_MSG "%s:D: Error on write:\n", name); | 3222 | printk(OSST_DEB_MSG "%s:D: Error on write:\n", name); |
3168 | #endif | 3223 | #endif |
3169 | if ((SRpnt->sr_sense_buffer[0] & 0x70) == 0x70 && | 3224 | if ((SRpnt->sense[0] & 0x70) == 0x70 && |
3170 | (SRpnt->sr_sense_buffer[2] & 0x40)) { | 3225 | (SRpnt->sense[2] & 0x40)) { |
3171 | if ((SRpnt->sr_sense_buffer[2] & 0x0f) == VOLUME_OVERFLOW) | 3226 | if ((SRpnt->sense[2] & 0x0f) == VOLUME_OVERFLOW) |
3172 | return (-ENOSPC); | 3227 | return (-ENOSPC); |
3173 | } | 3228 | } |
3174 | else { | 3229 | else { |
@@ -3185,7 +3240,7 @@ static int osst_write_frame(struct osst_tape * STp, struct scsi_request ** aSRpn | |||
3185 | return 0; | 3240 | return 0; |
3186 | } | 3241 | } |
3187 | 3242 | ||
3188 | /* Lock or unlock the drive door. Don't use when struct scsi_request allocated. */ | 3243 | /* Lock or unlock the drive door. Don't use when struct osst_request allocated. */ |
3189 | static int do_door_lock(struct osst_tape * STp, int do_lock) | 3244 | static int do_door_lock(struct osst_tape * STp, int do_lock) |
3190 | { | 3245 | { |
3191 | int retval, cmd; | 3246 | int retval, cmd; |
@@ -3233,7 +3288,7 @@ static ssize_t osst_write(struct file * filp, const char __user * buf, size_t co | |||
3233 | int write_threshold; | 3288 | int write_threshold; |
3234 | int doing_write = 0; | 3289 | int doing_write = 0; |
3235 | const char __user * b_point; | 3290 | const char __user * b_point; |
3236 | struct scsi_request * SRpnt = NULL; | 3291 | struct osst_request * SRpnt = NULL; |
3237 | struct st_modedef * STm; | 3292 | struct st_modedef * STm; |
3238 | struct st_partstat * STps; | 3293 | struct st_partstat * STps; |
3239 | struct osst_tape * STp = filp->private_data; | 3294 | struct osst_tape * STp = filp->private_data; |
@@ -3424,7 +3479,7 @@ if (SRpnt) printk(KERN_ERR "%s:A: Not supposed to have SRpnt at line %d\n", name | |||
3424 | #if DEBUG | 3479 | #if DEBUG |
3425 | if (debugging) | 3480 | if (debugging) |
3426 | printk(OSST_DEB_MSG "%s:D: Writing %d bytes to file %d block %d lblk %d fseq %d fppos %d\n", | 3481 | printk(OSST_DEB_MSG "%s:D: Writing %d bytes to file %d block %d lblk %d fseq %d fppos %d\n", |
3427 | name, count, STps->drv_file, STps->drv_block, | 3482 | name, (int) count, STps->drv_file, STps->drv_block, |
3428 | STp->logical_blk_num, STp->frame_seq_number, STp->first_frame_position); | 3483 | STp->logical_blk_num, STp->frame_seq_number, STp->first_frame_position); |
3429 | #endif | 3484 | #endif |
3430 | b_point = buf; | 3485 | b_point = buf; |
@@ -3460,7 +3515,7 @@ if (SRpnt) printk(KERN_ERR "%s:A: Not supposed to have SRpnt at line %d\n", name | |||
3460 | #if DEBUG | 3515 | #if DEBUG |
3461 | if (debugging) | 3516 | if (debugging) |
3462 | printk(OSST_DEB_MSG "%s:D: EOM with %d bytes unwritten.\n", | 3517 | printk(OSST_DEB_MSG "%s:D: EOM with %d bytes unwritten.\n", |
3463 | name, transfer); | 3518 | name, (int) transfer); |
3464 | #endif | 3519 | #endif |
3465 | } | 3520 | } |
3466 | else { | 3521 | else { |
@@ -3478,7 +3533,7 @@ if (SRpnt) printk(KERN_ERR "%s:A: Not supposed to have SRpnt at line %d\n", name | |||
3478 | 3533 | ||
3479 | if (retval < 0) { | 3534 | if (retval < 0) { |
3480 | if (SRpnt != NULL) { | 3535 | if (SRpnt != NULL) { |
3481 | scsi_release_request(SRpnt); | 3536 | osst_release_request(SRpnt); |
3482 | SRpnt = NULL; | 3537 | SRpnt = NULL; |
3483 | } | 3538 | } |
3484 | STp->buffer->buffer_bytes = 0; | 3539 | STp->buffer->buffer_bytes = 0; |
@@ -3540,7 +3595,7 @@ if (SRpnt) printk(KERN_ERR "%s:A: Not supposed to have SRpnt at line %d\n", name | |||
3540 | retval = total; | 3595 | retval = total; |
3541 | 3596 | ||
3542 | out: | 3597 | out: |
3543 | if (SRpnt != NULL) scsi_release_request(SRpnt); | 3598 | if (SRpnt != NULL) osst_release_request(SRpnt); |
3544 | 3599 | ||
3545 | up(&STp->lock); | 3600 | up(&STp->lock); |
3546 | 3601 | ||
@@ -3556,7 +3611,7 @@ static ssize_t osst_read(struct file * filp, char __user * buf, size_t count, lo | |||
3556 | int special; | 3611 | int special; |
3557 | struct st_modedef * STm; | 3612 | struct st_modedef * STm; |
3558 | struct st_partstat * STps; | 3613 | struct st_partstat * STps; |
3559 | struct scsi_request * SRpnt = NULL; | 3614 | struct osst_request * SRpnt = NULL; |
3560 | struct osst_tape * STp = filp->private_data; | 3615 | struct osst_tape * STp = filp->private_data; |
3561 | char * name = tape_name(STp); | 3616 | char * name = tape_name(STp); |
3562 | 3617 | ||
@@ -3664,7 +3719,7 @@ static ssize_t osst_read(struct file * filp, char __user * buf, size_t count, lo | |||
3664 | #if DEBUG | 3719 | #if DEBUG |
3665 | if (debugging && STps->eof != ST_NOEOF) | 3720 | if (debugging && STps->eof != ST_NOEOF) |
3666 | printk(OSST_DEB_MSG "%s:D: EOF up (%d). Left %d, needed %d.\n", name, | 3721 | printk(OSST_DEB_MSG "%s:D: EOF up (%d). Left %d, needed %d.\n", name, |
3667 | STps->eof, (STp->buffer)->buffer_bytes, count - total); | 3722 | STps->eof, (STp->buffer)->buffer_bytes, (int) (count - total)); |
3668 | #endif | 3723 | #endif |
3669 | /* force multiple of block size, note block_size may have been adjusted */ | 3724 | /* force multiple of block size, note block_size may have been adjusted */ |
3670 | transfer = (((STp->buffer)->buffer_bytes < count - total ? | 3725 | transfer = (((STp->buffer)->buffer_bytes < count - total ? |
@@ -3725,7 +3780,7 @@ static ssize_t osst_read(struct file * filp, char __user * buf, size_t count, lo | |||
3725 | retval = total; | 3780 | retval = total; |
3726 | 3781 | ||
3727 | out: | 3782 | out: |
3728 | if (SRpnt != NULL) scsi_release_request(SRpnt); | 3783 | if (SRpnt != NULL) osst_release_request(SRpnt); |
3729 | 3784 | ||
3730 | up(&STp->lock); | 3785 | up(&STp->lock); |
3731 | 3786 | ||
@@ -3913,7 +3968,7 @@ static int osst_set_options(struct osst_tape *STp, long options) | |||
3913 | 3968 | ||
3914 | 3969 | ||
3915 | /* Internal ioctl function */ | 3970 | /* Internal ioctl function */ |
3916 | static int osst_int_ioctl(struct osst_tape * STp, struct scsi_request ** aSRpnt, | 3971 | static int osst_int_ioctl(struct osst_tape * STp, struct osst_request ** aSRpnt, |
3917 | unsigned int cmd_in, unsigned long arg) | 3972 | unsigned int cmd_in, unsigned long arg) |
3918 | { | 3973 | { |
3919 | int timeout; | 3974 | int timeout; |
@@ -3921,7 +3976,7 @@ static int osst_int_ioctl(struct osst_tape * STp, struct scsi_request ** aSRpnt, | |||
3921 | int i, ioctl_result; | 3976 | int i, ioctl_result; |
3922 | int chg_eof = 1; | 3977 | int chg_eof = 1; |
3923 | unsigned char cmd[MAX_COMMAND_SIZE]; | 3978 | unsigned char cmd[MAX_COMMAND_SIZE]; |
3924 | struct scsi_request * SRpnt = * aSRpnt; | 3979 | struct osst_request * SRpnt = * aSRpnt; |
3925 | struct st_partstat * STps; | 3980 | struct st_partstat * STps; |
3926 | int fileno, blkno, at_sm, frame_seq_numbr, logical_blk_num; | 3981 | int fileno, blkno, at_sm, frame_seq_numbr, logical_blk_num; |
3927 | int datalen = 0, direction = DMA_NONE; | 3982 | int datalen = 0, direction = DMA_NONE; |
@@ -4279,14 +4334,14 @@ os_bypass: | |||
4279 | } else if (cmd_in == MTERASE) { | 4334 | } else if (cmd_in == MTERASE) { |
4280 | STp->header_ok = 0; | 4335 | STp->header_ok = 0; |
4281 | } else if (SRpnt) { /* SCSI command was not completely successful. */ | 4336 | } else if (SRpnt) { /* SCSI command was not completely successful. */ |
4282 | if (SRpnt->sr_sense_buffer[2] & 0x40) { | 4337 | if (SRpnt->sense[2] & 0x40) { |
4283 | STps->eof = ST_EOM_OK; | 4338 | STps->eof = ST_EOM_OK; |
4284 | STps->drv_block = 0; | 4339 | STps->drv_block = 0; |
4285 | } | 4340 | } |
4286 | if (chg_eof) | 4341 | if (chg_eof) |
4287 | STps->eof = ST_NOEOF; | 4342 | STps->eof = ST_NOEOF; |
4288 | 4343 | ||
4289 | if ((SRpnt->sr_sense_buffer[2] & 0x0f) == BLANK_CHECK) | 4344 | if ((SRpnt->sense[2] & 0x0f) == BLANK_CHECK) |
4290 | STps->eof = ST_EOD; | 4345 | STps->eof = ST_EOD; |
4291 | 4346 | ||
4292 | if (cmd_in == MTLOAD && osst_wait_for_medium(STp, &SRpnt, 60)) | 4347 | if (cmd_in == MTLOAD && osst_wait_for_medium(STp, &SRpnt, 60)) |
@@ -4304,7 +4359,7 @@ static int os_scsi_tape_open(struct inode * inode, struct file * filp) | |||
4304 | unsigned short flags; | 4359 | unsigned short flags; |
4305 | int i, b_size, new_session = 0, retval = 0; | 4360 | int i, b_size, new_session = 0, retval = 0; |
4306 | unsigned char cmd[MAX_COMMAND_SIZE]; | 4361 | unsigned char cmd[MAX_COMMAND_SIZE]; |
4307 | struct scsi_request * SRpnt = NULL; | 4362 | struct osst_request * SRpnt = NULL; |
4308 | struct osst_tape * STp; | 4363 | struct osst_tape * STp; |
4309 | struct st_modedef * STm; | 4364 | struct st_modedef * STm; |
4310 | struct st_partstat * STps; | 4365 | struct st_partstat * STps; |
@@ -4412,17 +4467,17 @@ static int os_scsi_tape_open(struct inode * inode, struct file * filp) | |||
4412 | retval = (STp->buffer)->syscall_result; /* FIXME - valid? */ | 4467 | retval = (STp->buffer)->syscall_result; /* FIXME - valid? */ |
4413 | goto err_out; | 4468 | goto err_out; |
4414 | } | 4469 | } |
4415 | if ((SRpnt->sr_sense_buffer[0] & 0x70) == 0x70 && | 4470 | if ((SRpnt->sense[0] & 0x70) == 0x70 && |
4416 | (SRpnt->sr_sense_buffer[2] & 0x0f) == NOT_READY && | 4471 | (SRpnt->sense[2] & 0x0f) == NOT_READY && |
4417 | SRpnt->sr_sense_buffer[12] == 4 ) { | 4472 | SRpnt->sense[12] == 4 ) { |
4418 | #if DEBUG | 4473 | #if DEBUG |
4419 | printk(OSST_DEB_MSG "%s:D: Unit not ready, cause %x\n", name, SRpnt->sr_sense_buffer[13]); | 4474 | printk(OSST_DEB_MSG "%s:D: Unit not ready, cause %x\n", name, SRpnt->sense[13]); |
4420 | #endif | 4475 | #endif |
4421 | if (filp->f_flags & O_NONBLOCK) { | 4476 | if (filp->f_flags & O_NONBLOCK) { |
4422 | retval = -EAGAIN; | 4477 | retval = -EAGAIN; |
4423 | goto err_out; | 4478 | goto err_out; |
4424 | } | 4479 | } |
4425 | if (SRpnt->sr_sense_buffer[13] == 2) { /* initialize command required (LOAD) */ | 4480 | if (SRpnt->sense[13] == 2) { /* initialize command required (LOAD) */ |
4426 | memset (cmd, 0, MAX_COMMAND_SIZE); | 4481 | memset (cmd, 0, MAX_COMMAND_SIZE); |
4427 | cmd[0] = START_STOP; | 4482 | cmd[0] = START_STOP; |
4428 | cmd[1] = 1; | 4483 | cmd[1] = 1; |
@@ -4430,10 +4485,10 @@ static int os_scsi_tape_open(struct inode * inode, struct file * filp) | |||
4430 | SRpnt = osst_do_scsi(SRpnt, STp, cmd, 0, DMA_NONE, | 4485 | SRpnt = osst_do_scsi(SRpnt, STp, cmd, 0, DMA_NONE, |
4431 | STp->timeout, MAX_RETRIES, 1); | 4486 | STp->timeout, MAX_RETRIES, 1); |
4432 | } | 4487 | } |
4433 | osst_wait_ready(STp, &SRpnt, (SRpnt->sr_sense_buffer[13]==1?15:3) * 60, 0); | 4488 | osst_wait_ready(STp, &SRpnt, (SRpnt->sense[13]==1?15:3) * 60, 0); |
4434 | } | 4489 | } |
4435 | if ((SRpnt->sr_sense_buffer[0] & 0x70) == 0x70 && | 4490 | if ((SRpnt->sense[0] & 0x70) == 0x70 && |
4436 | (SRpnt->sr_sense_buffer[2] & 0x0f) == UNIT_ATTENTION) { /* New media? */ | 4491 | (SRpnt->sense[2] & 0x0f) == UNIT_ATTENTION) { /* New media? */ |
4437 | #if DEBUG | 4492 | #if DEBUG |
4438 | printk(OSST_DEB_MSG "%s:D: Unit wants attention\n", name); | 4493 | printk(OSST_DEB_MSG "%s:D: Unit wants attention\n", name); |
4439 | #endif | 4494 | #endif |
@@ -4446,8 +4501,8 @@ static int os_scsi_tape_open(struct inode * inode, struct file * filp) | |||
4446 | 4501 | ||
4447 | SRpnt = osst_do_scsi(SRpnt, STp, cmd, 0, DMA_NONE, | 4502 | SRpnt = osst_do_scsi(SRpnt, STp, cmd, 0, DMA_NONE, |
4448 | STp->timeout, MAX_RETRIES, 1); | 4503 | STp->timeout, MAX_RETRIES, 1); |
4449 | if ((SRpnt->sr_sense_buffer[0] & 0x70) != 0x70 || | 4504 | if ((SRpnt->sense[0] & 0x70) != 0x70 || |
4450 | (SRpnt->sr_sense_buffer[2] & 0x0f) != UNIT_ATTENTION) | 4505 | (SRpnt->sense[2] & 0x0f) != UNIT_ATTENTION) |
4451 | break; | 4506 | break; |
4452 | } | 4507 | } |
4453 | 4508 | ||
@@ -4473,7 +4528,7 @@ static int os_scsi_tape_open(struct inode * inode, struct file * filp) | |||
4473 | * open without reconfiguring and re-reading the headers | 4528 | * open without reconfiguring and re-reading the headers |
4474 | */ | 4529 | */ |
4475 | if (!STp->buffer->syscall_result && STp->header_ok && | 4530 | if (!STp->buffer->syscall_result && STp->header_ok && |
4476 | !SRpnt->sr_result && SRpnt->sr_sense_buffer[0] == 0) { | 4531 | !SRpnt->result && SRpnt->sense[0] == 0) { |
4477 | 4532 | ||
4478 | memset(cmd, 0, MAX_COMMAND_SIZE); | 4533 | memset(cmd, 0, MAX_COMMAND_SIZE); |
4479 | cmd[0] = MODE_SENSE; | 4534 | cmd[0] = MODE_SENSE; |
@@ -4512,7 +4567,7 @@ static int os_scsi_tape_open(struct inode * inode, struct file * filp) | |||
4512 | } | 4567 | } |
4513 | STp->buffer->buffer_blocks = OS_DATA_SIZE / STp->block_size; | 4568 | STp->buffer->buffer_blocks = OS_DATA_SIZE / STp->block_size; |
4514 | STp->fast_open = 1; | 4569 | STp->fast_open = 1; |
4515 | scsi_release_request(SRpnt); | 4570 | osst_release_request(SRpnt); |
4516 | return 0; | 4571 | return 0; |
4517 | } | 4572 | } |
4518 | #if DEBUG | 4573 | #if DEBUG |
@@ -4525,7 +4580,7 @@ static int os_scsi_tape_open(struct inode * inode, struct file * filp) | |||
4525 | STp->fast_open = 0; | 4580 | STp->fast_open = 0; |
4526 | 4581 | ||
4527 | if ((STp->buffer)->syscall_result != 0 && /* in all error conditions except no medium */ | 4582 | if ((STp->buffer)->syscall_result != 0 && /* in all error conditions except no medium */ |
4528 | (SRpnt->sr_sense_buffer[2] != 2 || SRpnt->sr_sense_buffer[12] != 0x3A) ) { | 4583 | (SRpnt->sense[2] != 2 || SRpnt->sense[12] != 0x3A) ) { |
4529 | 4584 | ||
4530 | memset(cmd, 0, MAX_COMMAND_SIZE); | 4585 | memset(cmd, 0, MAX_COMMAND_SIZE); |
4531 | cmd[0] = MODE_SELECT; | 4586 | cmd[0] = MODE_SELECT; |
@@ -4555,11 +4610,11 @@ static int os_scsi_tape_open(struct inode * inode, struct file * filp) | |||
4555 | 4610 | ||
4556 | SRpnt = osst_do_scsi(SRpnt, STp, cmd, 0, DMA_NONE, | 4611 | SRpnt = osst_do_scsi(SRpnt, STp, cmd, 0, DMA_NONE, |
4557 | STp->timeout, MAX_RETRIES, 1); | 4612 | STp->timeout, MAX_RETRIES, 1); |
4558 | if ((SRpnt->sr_sense_buffer[0] & 0x70) != 0x70 || | 4613 | if ((SRpnt->sense[0] & 0x70) != 0x70 || |
4559 | (SRpnt->sr_sense_buffer[2] & 0x0f) == NOT_READY) | 4614 | (SRpnt->sense[2] & 0x0f) == NOT_READY) |
4560 | break; | 4615 | break; |
4561 | 4616 | ||
4562 | if ((SRpnt->sr_sense_buffer[2] & 0x0f) == UNIT_ATTENTION) { | 4617 | if ((SRpnt->sense[2] & 0x0f) == UNIT_ATTENTION) { |
4563 | STp->pos_unknown = 0; | 4618 | STp->pos_unknown = 0; |
4564 | STp->partition = STp->new_partition = 0; | 4619 | STp->partition = STp->new_partition = 0; |
4565 | if (STp->can_partitions) | 4620 | if (STp->can_partitions) |
@@ -4583,13 +4638,13 @@ static int os_scsi_tape_open(struct inode * inode, struct file * filp) | |||
4583 | 4638 | ||
4584 | if ((STp->buffer)->syscall_result != 0) { | 4639 | if ((STp->buffer)->syscall_result != 0) { |
4585 | if ((STp->device)->scsi_level >= SCSI_2 && | 4640 | if ((STp->device)->scsi_level >= SCSI_2 && |
4586 | (SRpnt->sr_sense_buffer[0] & 0x70) == 0x70 && | 4641 | (SRpnt->sense[0] & 0x70) == 0x70 && |
4587 | (SRpnt->sr_sense_buffer[2] & 0x0f) == NOT_READY && | 4642 | (SRpnt->sense[2] & 0x0f) == NOT_READY && |
4588 | SRpnt->sr_sense_buffer[12] == 0x3a) { /* Check ASC */ | 4643 | SRpnt->sense[12] == 0x3a) { /* Check ASC */ |
4589 | STp->ready = ST_NO_TAPE; | 4644 | STp->ready = ST_NO_TAPE; |
4590 | } else | 4645 | } else |
4591 | STp->ready = ST_NOT_READY; | 4646 | STp->ready = ST_NOT_READY; |
4592 | scsi_release_request(SRpnt); | 4647 | osst_release_request(SRpnt); |
4593 | SRpnt = NULL; | 4648 | SRpnt = NULL; |
4594 | STp->density = 0; /* Clear the erroneous "residue" */ | 4649 | STp->density = 0; /* Clear the erroneous "residue" */ |
4595 | STp->write_prot = 0; | 4650 | STp->write_prot = 0; |
@@ -4649,14 +4704,14 @@ static int os_scsi_tape_open(struct inode * inode, struct file * filp) | |||
4649 | 4704 | ||
4650 | osst_analyze_headers(STp, &SRpnt); | 4705 | osst_analyze_headers(STp, &SRpnt); |
4651 | 4706 | ||
4652 | scsi_release_request(SRpnt); | 4707 | osst_release_request(SRpnt); |
4653 | SRpnt = NULL; | 4708 | SRpnt = NULL; |
4654 | 4709 | ||
4655 | return 0; | 4710 | return 0; |
4656 | 4711 | ||
4657 | err_out: | 4712 | err_out: |
4658 | if (SRpnt != NULL) | 4713 | if (SRpnt != NULL) |
4659 | scsi_release_request(SRpnt); | 4714 | osst_release_request(SRpnt); |
4660 | normalize_buffer(STp->buffer); | 4715 | normalize_buffer(STp->buffer); |
4661 | STp->header_ok = 0; | 4716 | STp->header_ok = 0; |
4662 | STp->in_use = 0; | 4717 | STp->in_use = 0; |
@@ -4673,7 +4728,7 @@ static int os_scsi_tape_flush(struct file * filp) | |||
4673 | struct osst_tape * STp = filp->private_data; | 4728 | struct osst_tape * STp = filp->private_data; |
4674 | struct st_modedef * STm = &(STp->modes[STp->current_mode]); | 4729 | struct st_modedef * STm = &(STp->modes[STp->current_mode]); |
4675 | struct st_partstat * STps = &(STp->ps[STp->partition]); | 4730 | struct st_partstat * STps = &(STp->ps[STp->partition]); |
4676 | struct scsi_request * SRpnt = NULL; | 4731 | struct osst_request * SRpnt = NULL; |
4677 | char * name = tape_name(STp); | 4732 | char * name = tape_name(STp); |
4678 | 4733 | ||
4679 | if (file_count(filp) > 1) | 4734 | if (file_count(filp) > 1) |
@@ -4736,7 +4791,7 @@ out: | |||
4736 | if (result == 0 && result2 < 0) | 4791 | if (result == 0 && result2 < 0) |
4737 | result = result2; | 4792 | result = result2; |
4738 | } | 4793 | } |
4739 | if (SRpnt) scsi_release_request(SRpnt); | 4794 | if (SRpnt) osst_release_request(SRpnt); |
4740 | 4795 | ||
4741 | if (STp->abort_count || STp->recover_count) { | 4796 | if (STp->abort_count || STp->recover_count) { |
4742 | printk(KERN_INFO "%s:I:", name); | 4797 | printk(KERN_INFO "%s:I:", name); |
@@ -4790,7 +4845,7 @@ static int osst_ioctl(struct inode * inode,struct file * file, | |||
4790 | unsigned int blk; | 4845 | unsigned int blk; |
4791 | struct st_modedef * STm; | 4846 | struct st_modedef * STm; |
4792 | struct st_partstat * STps; | 4847 | struct st_partstat * STps; |
4793 | struct scsi_request * SRpnt = NULL; | 4848 | struct osst_request * SRpnt = NULL; |
4794 | struct osst_tape * STp = file->private_data; | 4849 | struct osst_tape * STp = file->private_data; |
4795 | char * name = tape_name(STp); | 4850 | char * name = tape_name(STp); |
4796 | void __user * p = (void __user *)arg; | 4851 | void __user * p = (void __user *)arg; |
@@ -5104,14 +5159,14 @@ static int osst_ioctl(struct inode * inode,struct file * file, | |||
5104 | retval = -EFAULT; | 5159 | retval = -EFAULT; |
5105 | goto out; | 5160 | goto out; |
5106 | } | 5161 | } |
5107 | if (SRpnt) scsi_release_request(SRpnt); | 5162 | if (SRpnt) osst_release_request(SRpnt); |
5108 | 5163 | ||
5109 | up(&STp->lock); | 5164 | up(&STp->lock); |
5110 | 5165 | ||
5111 | return scsi_ioctl(STp->device, cmd_in, p); | 5166 | return scsi_ioctl(STp->device, cmd_in, p); |
5112 | 5167 | ||
5113 | out: | 5168 | out: |
5114 | if (SRpnt) scsi_release_request(SRpnt); | 5169 | if (SRpnt) osst_release_request(SRpnt); |
5115 | 5170 | ||
5116 | up(&STp->lock); | 5171 | up(&STp->lock); |
5117 | 5172 | ||
diff --git a/drivers/scsi/osst.h b/drivers/scsi/osst.h index b72e1c76f52c..011d4d6ca9f9 100644 --- a/drivers/scsi/osst.h +++ b/drivers/scsi/osst.h | |||
@@ -518,7 +518,8 @@ struct osst_buffer { | |||
518 | int writing; | 518 | int writing; |
519 | int midlevel_result; | 519 | int midlevel_result; |
520 | int syscall_result; | 520 | int syscall_result; |
521 | struct scsi_request *last_SRpnt; | 521 | struct osst_request *last_SRpnt; |
522 | struct st_cmdstatus cmdstat; | ||
522 | unsigned char *b_data; | 523 | unsigned char *b_data; |
523 | os_aux_t *aux; /* onstream AUX structure at end of each block */ | 524 | os_aux_t *aux; /* onstream AUX structure at end of each block */ |
524 | unsigned short use_sg; /* zero or number of s/g segments for this adapter */ | 525 | unsigned short use_sg; /* zero or number of s/g segments for this adapter */ |
@@ -626,6 +627,15 @@ struct osst_tape { | |||
626 | struct gendisk *drive; | 627 | struct gendisk *drive; |
627 | } ; | 628 | } ; |
628 | 629 | ||
630 | /* scsi tape command */ | ||
631 | struct osst_request { | ||
632 | unsigned char cmd[MAX_COMMAND_SIZE]; | ||
633 | unsigned char sense[SCSI_SENSE_BUFFERSIZE]; | ||
634 | int result; | ||
635 | struct osst_tape *stp; | ||
636 | struct completion *waiting; | ||
637 | }; | ||
638 | |||
629 | /* Values of write_type */ | 639 | /* Values of write_type */ |
630 | #define OS_WRITE_DATA 0 | 640 | #define OS_WRITE_DATA 0 |
631 | #define OS_WRITE_EOD 1 | 641 | #define OS_WRITE_EOD 1 |