Commit e12fd31b authored by Willem Riede's avatar Willem Riede Committed by James Bottomley

One more update for osst in 2.5.53

Below is a patch for osst, against 2.5.53, which fixes a couple of bugs,
among which a pretty likely oops, and includes some cleanup. 
At this point I'm pretty satisfied that it works properly.
parent 99a6e15b
...@@ -16,15 +16,15 @@ ...@@ -16,15 +16,15 @@
Copyright 1992 - 2002 Kai Makisara / Willem Riede Copyright 1992 - 2002 Kai Makisara / Willem Riede
email Kai.Makisara@metla.fi / osst@riede.org email Kai.Makisara@metla.fi / osst@riede.org
$Header: /home/cvsroot/Driver/osst.c,v 1.65 2001/11/11 20:38:56 riede Exp $ $Header: /home/cvsroot/Driver/osst.c,v 1.68 2002/12/23 16:33:36 riede Exp $
Microscopic alterations - Rik Ling, 2000/12/21 Microscopic alterations - Rik Ling, 2000/12/21
Last st.c sync: Tue Oct 15 22:01:04 2002 by makisara Last st.c sync: Tue Oct 15 22:01:04 2002 by makisara
Some small formal changes - aeb, 950809 Some small formal changes - aeb, 950809
*/ */
static const char * cvsid = "$Id: osst.c,v 1.65 2001/11/11 20:38:56 riede Exp $"; static const char * cvsid = "$Id: osst.c,v 1.68 2002/12/23 16:33:36 riede Exp $";
const char * osst_version = "0.99.0p5"; const char * osst_version = "0.99.0";
/* The "failure to reconnect" firmware bug */ /* The "failure to reconnect" firmware bug */
#define OSST_FW_NEED_POLL_MIN 10601 /*(107A)*/ #define OSST_FW_NEED_POLL_MIN 10601 /*(107A)*/
...@@ -470,7 +470,7 @@ static void osst_init_aux(OS_Scsi_Tape * STp, int frame_type, int frame_seq_numb ...@@ -470,7 +470,7 @@ static void osst_init_aux(OS_Scsi_Tape * STp, int frame_type, int frame_seq_numb
*/ */
static int osst_verify_frame(OS_Scsi_Tape * STp, int frame_seq_number, int quiet) static int osst_verify_frame(OS_Scsi_Tape * STp, int frame_seq_number, int quiet)
{ {
char *name = tape_name(STp); char * name = tape_name(STp);
os_aux_t * aux = STp->buffer->aux; os_aux_t * aux = STp->buffer->aux;
os_partition_t * par = &(aux->partition); os_partition_t * par = &(aux->partition);
ST_partstat * STps = &(STp->ps[STp->partition]); ST_partstat * STps = &(STp->ps[STp->partition]);
...@@ -676,7 +676,7 @@ static int osst_wait_for_medium(OS_Scsi_Tape * STp, Scsi_Request ** aSRpnt, unsi ...@@ -676,7 +676,7 @@ static int osst_wait_for_medium(OS_Scsi_Tape * STp, Scsi_Request ** aSRpnt, unsi
long startwait = jiffies; long startwait = jiffies;
#if DEBUG #if DEBUG
int dbg = debugging; int dbg = debugging;
char *name = tape_name(STp); char * name = tape_name(STp);
printk(OSST_DEB_MSG "%s:D: Reached onstream wait for medium\n", name); printk(OSST_DEB_MSG "%s:D: Reached onstream wait for medium\n", name);
#endif #endif
...@@ -748,7 +748,7 @@ static int osst_flush_drive_buffer(OS_Scsi_Tape * STp, Scsi_Request ** aSRpnt) ...@@ -748,7 +748,7 @@ static int osst_flush_drive_buffer(OS_Scsi_Tape * STp, Scsi_Request ** aSRpnt)
int result = 0; int result = 0;
int delay = OSST_WAIT_WRITE_COMPLETE; int delay = OSST_WAIT_WRITE_COMPLETE;
#if DEBUG #if DEBUG
char *name = tape_name(STp); char * name = tape_name(STp);
printk(OSST_DEB_MSG "%s:D: Reached onstream flush drive buffer (write filemark)\n", name); printk(OSST_DEB_MSG "%s:D: Reached onstream flush drive buffer (write filemark)\n", name);
#endif #endif
...@@ -778,7 +778,7 @@ static int osst_flush_drive_buffer(OS_Scsi_Tape * STp, Scsi_Request ** aSRpnt) ...@@ -778,7 +778,7 @@ static int osst_flush_drive_buffer(OS_Scsi_Tape * STp, Scsi_Request ** aSRpnt)
static int osst_wait_frame(OS_Scsi_Tape * STp, Scsi_Request ** aSRpnt, int curr, int minlast, int to) static int osst_wait_frame(OS_Scsi_Tape * STp, Scsi_Request ** aSRpnt, int curr, int minlast, int to)
{ {
long startwait = jiffies; long startwait = jiffies;
char *name = tape_name(STp); char * name = tape_name(STp);
#if DEBUG #if DEBUG
char notyetprinted = 1; char notyetprinted = 1;
#endif #endif
...@@ -841,7 +841,7 @@ static int osst_read_frame(OS_Scsi_Tape * STp, Scsi_Request ** aSRpnt, int timeo ...@@ -841,7 +841,7 @@ static int osst_read_frame(OS_Scsi_Tape * STp, Scsi_Request ** aSRpnt, int timeo
int retval = 0; int retval = 0;
#if DEBUG #if DEBUG
os_aux_t * aux = STp->buffer->aux; os_aux_t * aux = STp->buffer->aux;
char *name = tape_name(STp); char * name = tape_name(STp);
#endif #endif
/* TODO: Error handling */ /* TODO: Error handling */
...@@ -888,10 +888,12 @@ static int osst_read_frame(OS_Scsi_Tape * STp, Scsi_Request ** aSRpnt, int timeo ...@@ -888,10 +888,12 @@ static int osst_read_frame(OS_Scsi_Tape * STp, Scsi_Request ** aSRpnt, int timeo
STp->first_frame_position++; STp->first_frame_position++;
#if DEBUG #if DEBUG
if (debugging) { if (debugging) {
char sig[8]; int i;
for (i=0;i<4;i++)
sig[i] = aux->application_sig[i]<32?'^':aux->application_sig[i];
sig[4] = '\0';
printk(OSST_DEB_MSG printk(OSST_DEB_MSG
"%s:D: AUX: %c%c%c%c UpdFrCt#%d Wpass#%d %s FrSeq#%d LogBlk#%d Qty=%d Sz=%d\n", name, "%s:D: AUX: %s UpdFrCt#%d Wpass#%d %s FrSeq#%d LogBlk#%d Qty=%d Sz=%d\n", name, sig,
aux->application_sig[0], aux->application_sig[1],
aux->application_sig[2], aux->application_sig[3],
ntohl(aux->update_frame_cntr), ntohs(aux->partition.wrt_pass_cntr), ntohl(aux->update_frame_cntr), ntohs(aux->partition.wrt_pass_cntr),
aux->frame_type==1?"EOD":aux->frame_type==2?"MARK": aux->frame_type==1?"EOD":aux->frame_type==2?"MARK":
aux->frame_type==8?"HEADR":aux->frame_type==0x80?"DATA":"FILL", aux->frame_type==8?"HEADR":aux->frame_type==0x80?"DATA":"FILL",
...@@ -913,7 +915,7 @@ static int osst_initiate_read(OS_Scsi_Tape * STp, Scsi_Request ** aSRpnt) ...@@ -913,7 +915,7 @@ static int osst_initiate_read(OS_Scsi_Tape * STp, Scsi_Request ** aSRpnt)
unsigned char cmd[MAX_COMMAND_SIZE]; unsigned char cmd[MAX_COMMAND_SIZE];
int retval = 0; int retval = 0;
#if DEBUG #if DEBUG
char *name = tape_name(STp); char * name = tape_name(STp);
#endif #endif
if (STps->rw != ST_READING) { /* Initialize read operation */ if (STps->rw != ST_READING) { /* Initialize read operation */
...@@ -947,7 +949,7 @@ static int osst_initiate_read(OS_Scsi_Tape * STp, Scsi_Request ** aSRpnt) ...@@ -947,7 +949,7 @@ static int osst_initiate_read(OS_Scsi_Tape * STp, Scsi_Request ** aSRpnt)
static int osst_get_logical_frame(OS_Scsi_Tape * STp, Scsi_Request ** aSRpnt, int frame_seq_number, int quiet) static int osst_get_logical_frame(OS_Scsi_Tape * STp, Scsi_Request ** aSRpnt, int frame_seq_number, int quiet)
{ {
ST_partstat * STps = &(STp->ps[STp->partition]); ST_partstat * STps = &(STp->ps[STp->partition]);
char *name = tape_name(STp); char * name = tape_name(STp);
int cnt = 0, int cnt = 0,
bad = 0, bad = 0,
past = 0, past = 0,
...@@ -1073,7 +1075,7 @@ static int osst_get_logical_frame(OS_Scsi_Tape * STp, Scsi_Request ** aSRpnt, in ...@@ -1073,7 +1075,7 @@ static int osst_get_logical_frame(OS_Scsi_Tape * STp, Scsi_Request ** aSRpnt, in
static int osst_seek_logical_blk(OS_Scsi_Tape * STp, Scsi_Request ** aSRpnt, int logical_blk_num) static int osst_seek_logical_blk(OS_Scsi_Tape * STp, Scsi_Request ** aSRpnt, int logical_blk_num)
{ {
ST_partstat * STps = &(STp->ps[STp->partition]); ST_partstat * STps = &(STp->ps[STp->partition]);
char *name = tape_name(STp); char * name = tape_name(STp);
int retries = 0; int retries = 0;
int frame_seq_estimate, ppos_estimate, move; int frame_seq_estimate, ppos_estimate, move;
...@@ -1183,7 +1185,7 @@ static int osst_get_sector(OS_Scsi_Tape * STp, Scsi_Request ** aSRpnt) ...@@ -1183,7 +1185,7 @@ static int osst_get_sector(OS_Scsi_Tape * STp, Scsi_Request ** aSRpnt)
{ {
int sector; int sector;
#if DEBUG #if DEBUG
char *name = tape_name(STp); char * name = tape_name(STp);
printk(OSST_DEB_MSG printk(OSST_DEB_MSG
"%s:D: Positioned at ppos %d, frame %d, lbn %d, file %d, blk %d, %cptr %d, eof %d\n", "%s:D: Positioned at ppos %d, frame %d, lbn %d, file %d, blk %d, %cptr %d, eof %d\n",
...@@ -1216,7 +1218,7 @@ static int osst_seek_sector(OS_Scsi_Tape * STp, Scsi_Request ** aSRpnt, int sect ...@@ -1216,7 +1218,7 @@ static int osst_seek_sector(OS_Scsi_Tape * STp, Scsi_Request ** aSRpnt, int sect
offset = (sector & OSST_SECTOR_MASK) << OSST_SECTOR_SHIFT, offset = (sector & OSST_SECTOR_MASK) << OSST_SECTOR_SHIFT,
r; r;
#if DEBUG #if DEBUG
char *name = tape_name(STp); char * name = tape_name(STp);
printk(OSST_DEB_MSG "%s:D: Seeking sector %d in frame %d at offset %d\n", printk(OSST_DEB_MSG "%s:D: Seeking sector %d in frame %d at offset %d\n",
name, sector, frame, offset); name, sector, frame, offset);
...@@ -1285,7 +1287,7 @@ static int osst_read_back_buffer_and_rewrite(OS_Scsi_Tape * STp, Scsi_Request ** ...@@ -1285,7 +1287,7 @@ static int osst_read_back_buffer_and_rewrite(OS_Scsi_Tape * STp, Scsi_Request **
- (nframes + pending - 1); - (nframes + pending - 1);
int logical_blk_num = ntohl(STp->buffer->aux->logical_blk_num) int logical_blk_num = ntohl(STp->buffer->aux->logical_blk_num)
- (nframes + pending - 1) * blks_per_frame; - (nframes + pending - 1) * blks_per_frame;
char *name = tape_name(STp); char * name = tape_name(STp);
long startwait = jiffies; long startwait = jiffies;
#if DEBUG #if DEBUG
int dbg = debugging; int dbg = debugging;
...@@ -1471,7 +1473,7 @@ static int osst_reposition_and_retry(OS_Scsi_Tape * STp, Scsi_Request ** aSRpnt, ...@@ -1471,7 +1473,7 @@ static int osst_reposition_and_retry(OS_Scsi_Tape * STp, Scsi_Request ** aSRpnt,
{ {
unsigned char cmd[MAX_COMMAND_SIZE]; unsigned char cmd[MAX_COMMAND_SIZE];
Scsi_Request * SRpnt; Scsi_Request * SRpnt;
char *name = tape_name(STp); char * name = tape_name(STp);
int expected = 0; int expected = 0;
int attempts = 1000 / skip; int attempts = 1000 / skip;
int flag = 1; int flag = 1;
...@@ -1574,7 +1576,7 @@ static int osst_write_error_recovery(OS_Scsi_Tape * STp, Scsi_Request ** aSRpnt, ...@@ -1574,7 +1576,7 @@ static int osst_write_error_recovery(OS_Scsi_Tape * STp, Scsi_Request ** aSRpnt,
{ {
Scsi_Request * SRpnt = * aSRpnt; Scsi_Request * SRpnt = * aSRpnt;
ST_partstat * STps = & STp->ps[STp->partition]; ST_partstat * STps = & STp->ps[STp->partition];
char *name = tape_name(STp); char * name = tape_name(STp);
int retval = 0; int retval = 0;
int rw_state; int rw_state;
unsigned int frame, skip; unsigned int frame, skip;
...@@ -1650,7 +1652,7 @@ static int osst_write_error_recovery(OS_Scsi_Tape * STp, Scsi_Request ** aSRpnt, ...@@ -1650,7 +1652,7 @@ static int osst_write_error_recovery(OS_Scsi_Tape * STp, Scsi_Request ** aSRpnt,
static int osst_space_over_filemarks_backward(OS_Scsi_Tape * STp, Scsi_Request ** aSRpnt, static int osst_space_over_filemarks_backward(OS_Scsi_Tape * STp, Scsi_Request ** aSRpnt,
int mt_op, int mt_count) int mt_op, int mt_count)
{ {
char *name = tape_name(STp); char * name = tape_name(STp);
int cnt; int cnt;
int last_mark_ppos = -1; int last_mark_ppos = -1;
...@@ -1751,7 +1753,7 @@ static int osst_space_over_filemarks_forward_slow(OS_Scsi_Tape * STp, Scsi_Reque ...@@ -1751,7 +1753,7 @@ static int osst_space_over_filemarks_forward_slow(OS_Scsi_Tape * STp, Scsi_Reque
{ {
int cnt = 0; int cnt = 0;
#if DEBUG #if DEBUG
char *name = tape_name(STp); char * name = tape_name(STp);
printk(OSST_DEB_MSG "%s:D: Reached space_over_filemarks_forward_slow %d %d\n", name, mt_op, mt_count); printk(OSST_DEB_MSG "%s:D: Reached space_over_filemarks_forward_slow %d %d\n", name, mt_op, mt_count);
#endif #endif
...@@ -1803,7 +1805,7 @@ static int osst_space_over_filemarks_forward_slow(OS_Scsi_Tape * STp, Scsi_Reque ...@@ -1803,7 +1805,7 @@ static int osst_space_over_filemarks_forward_slow(OS_Scsi_Tape * STp, Scsi_Reque
static int osst_space_over_filemarks_forward_fast(OS_Scsi_Tape * STp, Scsi_Request ** aSRpnt, static int osst_space_over_filemarks_forward_fast(OS_Scsi_Tape * STp, Scsi_Request ** aSRpnt,
int mt_op, int mt_count) int mt_op, int mt_count)
{ {
char *name = tape_name(STp); char * name = tape_name(STp);
int cnt = 0, int cnt = 0,
next_mark_ppos = -1; next_mark_ppos = -1;
...@@ -1955,7 +1957,7 @@ static void osst_set_retries(OS_Scsi_Tape * STp, Scsi_Request ** aSRpnt, int ret ...@@ -1955,7 +1957,7 @@ static void osst_set_retries(OS_Scsi_Tape * STp, Scsi_Request ** aSRpnt, int ret
{ {
unsigned char cmd[MAX_COMMAND_SIZE]; unsigned char cmd[MAX_COMMAND_SIZE];
Scsi_Request * SRpnt = * aSRpnt; Scsi_Request * SRpnt = * aSRpnt;
char *name = tape_name(STp); char * name = tape_name(STp);
memset(cmd, 0, MAX_COMMAND_SIZE); memset(cmd, 0, MAX_COMMAND_SIZE);
cmd[0] = MODE_SELECT; cmd[0] = MODE_SELECT;
...@@ -1989,7 +1991,7 @@ static int osst_write_filemark(OS_Scsi_Tape * STp, Scsi_Request ** aSRpnt) ...@@ -1989,7 +1991,7 @@ static int osst_write_filemark(OS_Scsi_Tape * STp, Scsi_Request ** aSRpnt)
int this_mark_ppos = STp->first_frame_position; int this_mark_ppos = STp->first_frame_position;
int this_mark_lbn = STp->logical_blk_num; int this_mark_lbn = STp->logical_blk_num;
#if DEBUG #if DEBUG
char *name = tape_name(STp); char * name = tape_name(STp);
#endif #endif
if (STp->raw) return 0; if (STp->raw) return 0;
...@@ -2015,7 +2017,7 @@ static int osst_write_eod(OS_Scsi_Tape * STp, Scsi_Request ** aSRpnt) ...@@ -2015,7 +2017,7 @@ static int osst_write_eod(OS_Scsi_Tape * STp, Scsi_Request ** aSRpnt)
{ {
int result; int result;
#if DEBUG #if DEBUG
char *name = tape_name(STp); char * name = tape_name(STp);
#endif #endif
if (STp->raw) return 0; if (STp->raw) return 0;
...@@ -2036,7 +2038,7 @@ static int osst_write_eod(OS_Scsi_Tape * STp, Scsi_Request ** aSRpnt) ...@@ -2036,7 +2038,7 @@ static int osst_write_eod(OS_Scsi_Tape * STp, Scsi_Request ** aSRpnt)
static int osst_write_filler(OS_Scsi_Tape * STp, Scsi_Request ** aSRpnt, int where, int count) static int osst_write_filler(OS_Scsi_Tape * STp, Scsi_Request ** aSRpnt, int where, int count)
{ {
char *name = tape_name(STp); char * name = tape_name(STp);
#if DEBUG #if DEBUG
printk(OSST_DEB_MSG "%s:D: Reached onstream write filler group %d\n", name, where); printk(OSST_DEB_MSG "%s:D: Reached onstream write filler group %d\n", name, where);
...@@ -2061,7 +2063,7 @@ static int osst_write_filler(OS_Scsi_Tape * STp, Scsi_Request ** aSRpnt, int whe ...@@ -2061,7 +2063,7 @@ static int osst_write_filler(OS_Scsi_Tape * STp, Scsi_Request ** aSRpnt, int whe
static int __osst_write_header(OS_Scsi_Tape * STp, Scsi_Request ** aSRpnt, int where, int count) static int __osst_write_header(OS_Scsi_Tape * STp, Scsi_Request ** aSRpnt, int where, int count)
{ {
char *name = tape_name(STp); char * name = tape_name(STp);
int result; int result;
#if DEBUG #if DEBUG
...@@ -2090,7 +2092,7 @@ static int osst_write_header(OS_Scsi_Tape * STp, Scsi_Request ** aSRpnt, int loc ...@@ -2090,7 +2092,7 @@ static int osst_write_header(OS_Scsi_Tape * STp, Scsi_Request ** aSRpnt, int loc
{ {
os_header_t * header; os_header_t * header;
int result; int result;
char *name = tape_name(STp); char * name = tape_name(STp);
#if DEBUG #if DEBUG
printk(OSST_DEB_MSG "%s:D: Writing tape header\n", name); printk(OSST_DEB_MSG "%s:D: Writing tape header\n", name);
...@@ -2175,7 +2177,7 @@ static int osst_reset_header(OS_Scsi_Tape * STp, Scsi_Request ** aSRpnt) ...@@ -2175,7 +2177,7 @@ static int osst_reset_header(OS_Scsi_Tape * STp, Scsi_Request ** aSRpnt)
static int __osst_analyze_headers(OS_Scsi_Tape * STp, Scsi_Request ** aSRpnt, int ppos) static int __osst_analyze_headers(OS_Scsi_Tape * STp, Scsi_Request ** aSRpnt, int ppos)
{ {
char *name = tape_name(STp); char * name = tape_name(STp);
os_header_t * header; os_header_t * header;
os_aux_t * aux; os_aux_t * aux;
char id_string[8]; char id_string[8];
...@@ -2355,7 +2357,7 @@ static int osst_analyze_headers(OS_Scsi_Tape * STp, Scsi_Request ** aSRpnt) ...@@ -2355,7 +2357,7 @@ static int osst_analyze_headers(OS_Scsi_Tape * STp, Scsi_Request ** aSRpnt)
int position, ppos; int position, ppos;
int first, last; int first, last;
int valid = 0; int valid = 0;
char *name = tape_name(STp); char * name = tape_name(STp);
position = osst_get_frame_position(STp, aSRpnt); position = osst_get_frame_position(STp, aSRpnt);
...@@ -2415,7 +2417,7 @@ static int osst_verify_position(OS_Scsi_Tape * STp, Scsi_Request ** aSRpnt) ...@@ -2415,7 +2417,7 @@ static int osst_verify_position(OS_Scsi_Tape * STp, Scsi_Request ** aSRpnt)
int prev_mark_ppos = -1; int prev_mark_ppos = -1;
int actual_mark_ppos, i, n; int actual_mark_ppos, i, n;
#if DEBUG #if DEBUG
char *name = tape_name(STp); char * name = tape_name(STp);
printk(OSST_DEB_MSG "%s:D: Verify that the tape is really the one we think before writing\n", name); printk(OSST_DEB_MSG "%s:D: Verify that the tape is really the one we think before writing\n", name);
#endif #endif
...@@ -2484,7 +2486,7 @@ static unsigned int osst_parse_firmware_rev (const char * str) ...@@ -2484,7 +2486,7 @@ static unsigned int osst_parse_firmware_rev (const char * str)
static int osst_configure_onstream(OS_Scsi_Tape *STp, Scsi_Request ** aSRpnt) static int osst_configure_onstream(OS_Scsi_Tape *STp, Scsi_Request ** aSRpnt)
{ {
unsigned char cmd[MAX_COMMAND_SIZE]; unsigned char cmd[MAX_COMMAND_SIZE];
char *name = tape_name(STp); char * name = tape_name(STp);
Scsi_Request * SRpnt = * aSRpnt; Scsi_Request * SRpnt = * aSRpnt;
osst_mode_parameter_header_t * header; osst_mode_parameter_header_t * header;
osst_block_size_page_t * bs; osst_block_size_page_t * bs;
...@@ -2655,7 +2657,7 @@ static int osst_configure_onstream(OS_Scsi_Tape *STp, Scsi_Request ** aSRpnt) ...@@ -2655,7 +2657,7 @@ static int osst_configure_onstream(OS_Scsi_Tape *STp, Scsi_Request ** aSRpnt)
static int cross_eof(OS_Scsi_Tape *STp, Scsi_Request ** aSRpnt, int forward) static int cross_eof(OS_Scsi_Tape *STp, Scsi_Request ** aSRpnt, int forward)
{ {
int result; int result;
char *name = tape_name(STp); char * name = tape_name(STp);
#if DEBUG #if DEBUG
if (debugging) if (debugging)
...@@ -2692,7 +2694,7 @@ static int osst_get_frame_position(OS_Scsi_Tape *STp, Scsi_Request ** aSRpnt) ...@@ -2692,7 +2694,7 @@ static int osst_get_frame_position(OS_Scsi_Tape *STp, Scsi_Request ** aSRpnt)
char mybuf[24]; char mybuf[24];
char * olddata = STp->buffer->b_data; char * olddata = STp->buffer->b_data;
int oldsize = STp->buffer->buffer_size; int oldsize = STp->buffer->buffer_size;
char *name = tape_name(STp); char * name = tape_name(STp);
if (STp->ready != ST_READY) return (-EIO); if (STp->ready != ST_READY) return (-EIO);
...@@ -2766,7 +2768,7 @@ static int osst_set_frame_position(OS_Scsi_Tape *STp, Scsi_Request ** aSRpnt, in ...@@ -2766,7 +2768,7 @@ static int osst_set_frame_position(OS_Scsi_Tape *STp, Scsi_Request ** aSRpnt, in
ST_partstat * STps; ST_partstat * STps;
int result = 0; int result = 0;
int pp = (ppos == 3000 && !skip)? 0 : ppos; int pp = (ppos == 3000 && !skip)? 0 : ppos;
char *name = tape_name(STp); char * name = tape_name(STp);
if (STp->ready != ST_READY) return (-EIO); if (STp->ready != ST_READY) return (-EIO);
...@@ -2829,7 +2831,7 @@ static int osst_flush_write_buffer(OS_Scsi_Tape *STp, Scsi_Request ** aSRpnt) ...@@ -2829,7 +2831,7 @@ static int osst_flush_write_buffer(OS_Scsi_Tape *STp, Scsi_Request ** aSRpnt)
unsigned char cmd[MAX_COMMAND_SIZE]; unsigned char cmd[MAX_COMMAND_SIZE];
Scsi_Request * SRpnt = *aSRpnt; Scsi_Request * SRpnt = *aSRpnt;
ST_partstat * STps; ST_partstat * STps;
char *name = tape_name(STp); char * name = tape_name(STp);
if ((STp->buffer)->writing) { if ((STp->buffer)->writing) {
if (SRpnt == (STp->buffer)->last_SRpnt) if (SRpnt == (STp->buffer)->last_SRpnt)
...@@ -2957,7 +2959,7 @@ static int osst_flush_buffer(OS_Scsi_Tape * STp, Scsi_Request ** aSRpnt, int see ...@@ -2957,7 +2959,7 @@ static int osst_flush_buffer(OS_Scsi_Tape * STp, Scsi_Request ** aSRpnt, int see
ST_partstat * STps; ST_partstat * STps;
int backspace = 0, result = 0; int backspace = 0, result = 0;
#if DEBUG #if DEBUG
char *name = tape_name(STp); char * name = tape_name(STp);
#endif #endif
/* /*
...@@ -3020,7 +3022,7 @@ static int osst_write_frame(OS_Scsi_Tape * STp, Scsi_Request ** aSRpnt, int sync ...@@ -3020,7 +3022,7 @@ static int osst_write_frame(OS_Scsi_Tape * STp, Scsi_Request ** aSRpnt, int sync
Scsi_Request * SRpnt; Scsi_Request * SRpnt;
int blks; int blks;
#if DEBUG #if DEBUG
char *name = tape_name(STp); char * name = tape_name(STp);
#endif #endif
if ((!STp-> raw) && (STp->first_frame_position == 0xbae)) { /* _must_ preserve buffer! */ if ((!STp-> raw) && (STp->first_frame_position == 0xbae)) { /* _must_ preserve buffer! */
...@@ -3143,12 +3145,12 @@ static ssize_t osst_write(struct file * filp, const char * buf, size_t count, lo ...@@ -3143,12 +3145,12 @@ static ssize_t osst_write(struct file * filp, const char * buf, size_t count, lo
ssize_t i, do_count, blks, transfer; ssize_t i, do_count, blks, transfer;
int write_threshold; int write_threshold;
int doing_write = 0; int doing_write = 0;
const char *b_point; const char * b_point;
Scsi_Request * SRpnt = NULL; Scsi_Request * SRpnt = NULL;
ST_mode * STm; ST_mode * STm;
ST_partstat * STps; ST_partstat * STps;
OS_Scsi_Tape * STp = filp->private_data; OS_Scsi_Tape * STp = filp->private_data;
char *name = tape_name(STp); char * name = tape_name(STp);
if (down_interruptible(&STp->lock)) if (down_interruptible(&STp->lock))
...@@ -3473,9 +3475,9 @@ static ssize_t osst_read(struct file * filp, char * buf, size_t count, loff_t *p ...@@ -3473,9 +3475,9 @@ static ssize_t osst_read(struct file * filp, char * buf, size_t count, loff_t *p
int special; int special;
ST_mode * STm; ST_mode * STm;
ST_partstat * STps; ST_partstat * STps;
Scsi_Request *SRpnt = NULL; Scsi_Request * SRpnt = NULL;
OS_Scsi_Tape * STp = filp->private_data; OS_Scsi_Tape * STp = filp->private_data;
char *name = tape_name(STp); char * name = tape_name(STp);
if (down_interruptible(&STp->lock)) if (down_interruptible(&STp->lock))
...@@ -3523,8 +3525,7 @@ static ssize_t osst_read(struct file * filp, char * buf, size_t count, loff_t *p ...@@ -3523,8 +3525,7 @@ static ssize_t osst_read(struct file * filp, char * buf, size_t count, loff_t *p
goto out; goto out;
} }
if (STp->do_auto_lock && STp->door_locked == ST_UNLOCKED && if (STp->do_auto_lock && STp->door_locked == ST_UNLOCKED && !do_door_lock(STp, 1))
!osst_int_ioctl(STp, &SRpnt, MTLOCK, 0))
STp->door_locked = ST_LOCKED_AUTO; STp->door_locked = ST_LOCKED_AUTO;
STps = &(STp->ps[STp->partition]); STps = &(STp->ps[STp->partition]);
...@@ -3685,8 +3686,8 @@ static int osst_set_options(OS_Scsi_Tape *STp, long options) ...@@ -3685,8 +3686,8 @@ static int osst_set_options(OS_Scsi_Tape *STp, long options)
{ {
int value; int value;
long code; long code;
ST_mode *STm; ST_mode * STm;
char *name = tape_name(STp); char * name = tape_name(STp);
STm = &(STp->modes[STp->current_mode]); STm = &(STp->modes[STp->current_mode]);
if (!STm->defined) { if (!STm->defined) {
...@@ -3848,7 +3849,7 @@ static int osst_int_ioctl(OS_Scsi_Tape * STp, Scsi_Request ** aSRpnt, unsigned i ...@@ -3848,7 +3849,7 @@ static int osst_int_ioctl(OS_Scsi_Tape * STp, Scsi_Request ** aSRpnt, unsigned i
ST_partstat * STps; ST_partstat * STps;
int fileno, blkno, at_sm, frame_seq_numbr, logical_blk_num; int fileno, blkno, at_sm, frame_seq_numbr, logical_blk_num;
int datalen = 0, direction = SCSI_DATA_NONE; int datalen = 0, direction = SCSI_DATA_NONE;
char *name = tape_name(STp); char * name = tape_name(STp);
if (STp->ready != ST_READY && cmd_in != MTLOAD) { if (STp->ready != ST_READY && cmd_in != MTLOAD) {
if (STp->ready == ST_NO_TAPE) if (STp->ready == ST_NO_TAPE)
...@@ -4214,7 +4215,7 @@ static int os_scsi_tape_open(struct inode * inode, struct file * filp) ...@@ -4214,7 +4215,7 @@ static int os_scsi_tape_open(struct inode * inode, struct file * filp)
OS_Scsi_Tape * STp; OS_Scsi_Tape * STp;
ST_mode * STm; ST_mode * STm;
ST_partstat * STps; ST_partstat * STps;
char *name; char * name;
int dev = TAPE_NR(inode->i_rdev); int dev = TAPE_NR(inode->i_rdev);
int mode = TAPE_MODE(inode->i_rdev); int mode = TAPE_MODE(inode->i_rdev);
...@@ -4267,44 +4268,32 @@ static int os_scsi_tape_open(struct inode * inode, struct file * filp) ...@@ -4267,44 +4268,32 @@ static int os_scsi_tape_open(struct inode * inode, struct file * filp)
STp->raw = TAPE_IS_RAW(inode->i_rdev); STp->raw = TAPE_IS_RAW(inode->i_rdev);
if (STp->raw) if (STp->raw)
STp->header_ok = 0; STp->header_ok = 0;
#if 0
/* Allocate a buffer for this user */
need_dma_buffer = STp->restr_dma;
for (i=0; i < osst_nbr_buffers; i++)
if (!osst_buffers[i]->in_use &&
(!need_dma_buffer || osst_buffers[i]->dma))
break;
if (i >= osst_nbr_buffers) {
STp->buffer = new_tape_buffer(FALSE, need_dma_buffer);
if (STp->buffer == NULL) {
printk(KERN_WARNING "%s:W: Can't allocate tape buffer.\n", name);
retval = (-EBUSY);
goto err_out;
}
}
else
STp->buffer = osst_buffers[i];
#endif /* now pre_allocated */
/* Allocate data segments for this device's tape buffer */ /* Allocate data segments for this device's tape buffer */
if (!enlarge_buffer(STp->buffer, STp->restr_dma)) { if (!enlarge_buffer(STp->buffer, STp->restr_dma)) {
printk(KERN_ERR "%s:E: Unable to allocate memory segments for tape buffer.\n", name); printk(KERN_ERR "%s:E: Unable to allocate memory segments for tape buffer.\n", name);
retval = (-EOVERFLOW); retval = (-EOVERFLOW);
goto err_out; goto err_out;
} }
(STp->buffer)->writing = 0; if (STp->buffer->buffer_size >= OS_FRAME_SIZE) {
(STp->buffer)->syscall_result = 0; for (i = 0, b_size = 0;
#if 0 (i < STp->buffer->sg_segs) && ((b_size + STp->buffer->sg[i].length) <= OS_DATA_SIZE);
(STp->buffer)->use_sg = STp->device->host->sg_tablesize; b_size += STp->buffer->sg[i++].length);
STp->buffer->aux = (os_aux_t *) (page_address(STp->buffer->sg[i].page) + OS_DATA_SIZE - b_size);
/* Compute the usable buffer size for this SCSI adapter */ #if DEBUG
if (!(STp->buffer)->use_sg) printk(OSST_DEB_MSG "%s:D: b_data points to %p in segment 0 at %p\n", name,
(STp->buffer)->buffer_size = (STp->buffer)->sg[0].length; STp->buffer->b_data, page_address(STp->buffer->sg[0].page));
else { printk(OSST_DEB_MSG "%s:D: AUX points to %p in segment %d at %p\n", name,
for (i=0, (STp->buffer)->buffer_size = 0; i < (STp->buffer)->use_sg && STp->buffer->aux, i, page_address(STp->buffer->sg[i].page));
i < (STp->buffer)->sg_segs; i++)
(STp->buffer)->buffer_size += (STp->buffer)->sg[i].length;
}
#endif #endif
} else {
STp->buffer->aux = NULL; /* this had better never happen! */
printk(KERN_NOTICE "%s:A: Framesize %d too large for buffer.\n", name, OS_FRAME_SIZE);
retval = (-EIO);
goto err_out;
}
STp->buffer->writing = 0;
STp->buffer->syscall_result = 0;
STp->dirty = 0; STp->dirty = 0;
for (i=0; i < ST_NBR_PARTITIONS; i++) { for (i=0; i < ST_NBR_PARTITIONS; i++) {
STps = &(STp->ps[i]); STps = &(STp->ps[i]);
...@@ -4410,7 +4399,7 @@ static int os_scsi_tape_open(struct inode * inode, struct file * filp) ...@@ -4410,7 +4399,7 @@ static int os_scsi_tape_open(struct inode * inode, struct file * filp)
i = STp->first_frame_position; i = STp->first_frame_position;
if (STp->header_ok && i == osst_get_frame_position(STp, &SRpnt)) { if (STp->header_ok && i == osst_get_frame_position(STp, &SRpnt)) {
if (STp->door_locked == ST_UNLOCKED) { if (STp->door_locked == ST_UNLOCKED) {
if (osst_int_ioctl(STp, &SRpnt, MTLOCK, 0)) if (do_door_lock(STp, 1))
printk(KERN_INFO "%s:I: Can't lock drive door\n", name); printk(KERN_INFO "%s:I: Can't lock drive door\n", name);
else else
STp->door_locked = ST_LOCKED_AUTO; STp->door_locked = ST_LOCKED_AUTO;
...@@ -4512,24 +4501,6 @@ static int os_scsi_tape_open(struct inode * inode, struct file * filp) ...@@ -4512,24 +4501,6 @@ static int os_scsi_tape_open(struct inode * inode, struct file * filp)
osst_configure_onstream(STp, &SRpnt); osst_configure_onstream(STp, &SRpnt);
if (STp->buffer->buffer_size >= OS_FRAME_SIZE) {
for (i = 0, b_size = 0;
(i < STp->buffer->sg_segs) && ((b_size + STp->buffer->sg[i].length) <= OS_DATA_SIZE);
b_size += STp->buffer->sg[i++].length);
STp->buffer->aux = (os_aux_t *) (page_address(STp->buffer->sg[i].page) + OS_DATA_SIZE - b_size);
#if DEBUG
printk(OSST_DEB_MSG "%s:D: b_data points to %p in segment 0 at %p\n", name,
STp->buffer->b_data, page_address(STp->buffer->sg[0].page));
printk(OSST_DEB_MSG "%s:D: AUX points to %p in segment %d at %p\n", name,
STp->buffer->aux, i, page_address(STp->buffer->sg[i].page));
#endif
} else {
STp->buffer->aux = NULL; /* this had better never happen! */
printk(KERN_NOTICE "%s:A: Framesize %d too large for buffer.\n", name, OS_FRAME_SIZE);
retval = (-EIO);
goto err_out;
}
STp->block_size = STp->raw ? OS_FRAME_SIZE : ( STp->block_size = STp->raw ? OS_FRAME_SIZE : (
(STm->default_blksize > 0) ? STm->default_blksize : OS_DATA_SIZE); (STm->default_blksize > 0) ? STm->default_blksize : OS_DATA_SIZE);
STp->buffer->buffer_blocks = STp->raw ? 1 : OS_DATA_SIZE / STp->block_size; STp->buffer->buffer_blocks = STp->raw ? 1 : OS_DATA_SIZE / STp->block_size;
...@@ -4569,7 +4540,7 @@ static int os_scsi_tape_open(struct inode * inode, struct file * filp) ...@@ -4569,7 +4540,7 @@ static int os_scsi_tape_open(struct inode * inode, struct file * filp)
* properly position the tape and check the ADR headers * properly position the tape and check the ADR headers
*/ */
if (STp->door_locked == ST_UNLOCKED) { if (STp->door_locked == ST_UNLOCKED) {
if (osst_int_ioctl(STp, &SRpnt, MTLOCK, 0)) if (do_door_lock(STp, 1))
printk(KERN_INFO "%s:I: Can't lock drive door\n", name); printk(KERN_INFO "%s:I: Can't lock drive door\n", name);
else else
STp->door_locked = ST_LOCKED_AUTO; STp->door_locked = ST_LOCKED_AUTO;
...@@ -4601,8 +4572,8 @@ static int os_scsi_tape_flush(struct file * filp) ...@@ -4601,8 +4572,8 @@ static int os_scsi_tape_flush(struct file * filp)
OS_Scsi_Tape * STp = filp->private_data; OS_Scsi_Tape * STp = filp->private_data;
ST_mode * STm = &(STp->modes[STp->current_mode]); ST_mode * STm = &(STp->modes[STp->current_mode]);
ST_partstat * STps = &(STp->ps[STp->partition]); ST_partstat * STps = &(STp->ps[STp->partition]);
Scsi_Request *SRpnt = NULL; Scsi_Request * SRpnt = NULL;
char *name = tape_name(STp); char * name = tape_name(STp);
if (file_count(filp) > 1) if (file_count(filp) > 1)
return 0; return 0;
...@@ -4729,11 +4700,11 @@ static int osst_ioctl(struct inode * inode,struct file * file, ...@@ -4729,11 +4700,11 @@ static int osst_ioctl(struct inode * inode,struct file * file,
{ {
int i, cmd_nr, cmd_type, retval = 0; int i, cmd_nr, cmd_type, retval = 0;
unsigned int blk; unsigned int blk;
ST_mode *STm; ST_mode * STm;
ST_partstat *STps; ST_partstat * STps;
Scsi_Request *SRpnt = NULL; Scsi_Request * SRpnt = NULL;
OS_Scsi_Tape *STp = file->private_data; OS_Scsi_Tape * STp = file->private_data;
char *name = tape_name(STp); char * name = tape_name(STp);
if (down_interruptible(&STp->lock)) if (down_interruptible(&STp->lock))
return -ERESTARTSYS; return -ERESTARTSYS;
...@@ -4813,6 +4784,8 @@ static int osst_ioctl(struct inode * inode,struct file * file, ...@@ -4813,6 +4784,8 @@ static int osst_ioctl(struct inode * inode,struct file * file,
i = mtc.mt_op == MTREW || mtc.mt_op == MTOFFL || i = mtc.mt_op == MTREW || mtc.mt_op == MTOFFL ||
mtc.mt_op == MTRETEN || mtc.mt_op == MTEOM || mtc.mt_op == MTRETEN || mtc.mt_op == MTEOM ||
mtc.mt_op == MTLOCK || mtc.mt_op == MTLOAD || mtc.mt_op == MTLOCK || mtc.mt_op == MTLOAD ||
mtc.mt_op == MTFSF || mtc.mt_op == MTFSFM ||
mtc.mt_op == MTBSF || mtc.mt_op == MTBSFM ||
mtc.mt_op == MTCOMPRESSION; mtc.mt_op == MTCOMPRESSION;
} }
i = osst_flush_buffer(STp, &SRpnt, i); i = osst_flush_buffer(STp, &SRpnt, i);
...@@ -5123,8 +5096,9 @@ static int enlarge_buffer(OSST_buffer *STbuffer, int need_dma) ...@@ -5123,8 +5096,9 @@ static int enlarge_buffer(OSST_buffer *STbuffer, int need_dma)
"osst :D: Expanded tape buffer (%d bytes, %d->%d segments, dma: %d, at: %p).\n", "osst :D: Expanded tape buffer (%d bytes, %d->%d segments, dma: %d, at: %p).\n",
got, STbuffer->orig_sg_segs, STbuffer->sg_segs, need_dma, STbuffer->b_data); got, STbuffer->orig_sg_segs, STbuffer->sg_segs, need_dma, STbuffer->b_data);
printk(OSST_DEB_MSG printk(OSST_DEB_MSG
"osst :D: segment sizes: first %d, last %d bytes.\n", "osst :D: segment sizes: first %d at %p, last %d bytes at %p.\n",
STbuffer->sg[0].length, STbuffer->sg[segs-1].length); STbuffer->sg[0].length, page_address(STbuffer->sg[0].page),
STbuffer->sg[segs-1].length, page_address(STbuffer->sg[segs-1].page));
} }
#endif #endif
...@@ -5413,8 +5387,8 @@ static int osst_attach(Scsi_Device * SDp) ...@@ -5413,8 +5387,8 @@ static int osst_attach(Scsi_Device * SDp)
OS_Scsi_Tape * tpnt; OS_Scsi_Tape * tpnt;
ST_mode * STm; ST_mode * STm;
ST_partstat * STps; ST_partstat * STps;
OSST_buffer *buffer; OSST_buffer * buffer;
struct gendisk *drive; struct gendisk * drive;
int i, mode, dev_num; int i, mode, dev_num;
if (SDp->type != TYPE_TAPE || !osst_supports(SDp)) if (SDp->type != TYPE_TAPE || !osst_supports(SDp))
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment