Commit 69ca9ecd authored by Kai Mäkisara's avatar Kai Mäkisara Committed by Linus Torvalds

[PATCH] SCSI tape ILI and timeout fixes

This contains the following changes:
 - ILI fixed to work with really old drives
 - message printed in case block larger than read()
 - long timeout used when creating a tape partition
parent d8ff1505
...@@ -1658,9 +1658,14 @@ static long read_tape(Scsi_Tape *STp, long count, Scsi_Request ** aSRpnt) ...@@ -1658,9 +1658,14 @@ static long read_tape(Scsi_Tape *STp, long count, Scsi_Request ** aSRpnt)
if (SRpnt->sr_sense_buffer[2] & 0x20) { /* ILI */ if (SRpnt->sr_sense_buffer[2] & 0x20) { /* ILI */
if (STp->block_size == 0) { if (STp->block_size == 0) {
if (transfer < 0) { if (transfer <= 0) {
if (transfer < 0)
printk(KERN_NOTICE
"%s: Failed to read %d byte block with %d byte transfer.\n",
name, bytes - transfer, bytes);
if (STps->drv_block >= 0) if (STps->drv_block >= 0)
STps->drv_block += 1; STps->drv_block += 1;
STbp->buffer_bytes = 0;
return (-ENOMEM); return (-ENOMEM);
} }
STbp->buffer_bytes = bytes - transfer; STbp->buffer_bytes = bytes - transfer;
...@@ -1727,6 +1732,9 @@ static long read_tape(Scsi_Tape *STp, long count, Scsi_Request ** aSRpnt) ...@@ -1727,6 +1732,9 @@ static long read_tape(Scsi_Tape *STp, long count, Scsi_Request ** aSRpnt)
} else /* Some other extended sense code */ } else /* Some other extended sense code */
retval = (-EIO); retval = (-EIO);
} }
if (STbp->buffer_bytes < 0) /* Caused by bogus sense data */
STbp->buffer_bytes = 0;
} }
/* End of extended sense test */ /* End of extended sense test */
else { /* Non-extended sense */ else { /* Non-extended sense */
...@@ -2136,8 +2144,8 @@ static int read_mode_page(Scsi_Tape *STp, int page, int omit_block_descs) ...@@ -2136,8 +2144,8 @@ static int read_mode_page(Scsi_Tape *STp, int page, int omit_block_descs)
/* Send the mode page in the tape buffer to the drive. Assumes that the mode data /* Send the mode page in the tape buffer to the drive. Assumes that the mode data
in the buffer is correctly formatted. */ in the buffer is correctly formatted. The long timeout is used if slow is non-zero. */
static int write_mode_page(Scsi_Tape *STp, int page) static int write_mode_page(Scsi_Tape *STp, int page, int slow)
{ {
int pgo; int pgo;
unsigned char cmd[MAX_COMMAND_SIZE]; unsigned char cmd[MAX_COMMAND_SIZE];
...@@ -2156,7 +2164,7 @@ static int write_mode_page(Scsi_Tape *STp, int page) ...@@ -2156,7 +2164,7 @@ static int write_mode_page(Scsi_Tape *STp, int page)
(STp->buffer)->b_data[pgo + MP_OFF_PAGE_NBR] &= MP_MSK_PAGE_NBR; (STp->buffer)->b_data[pgo + MP_OFF_PAGE_NBR] &= MP_MSK_PAGE_NBR;
SRpnt = st_do_scsi(SRpnt, STp, cmd, cmd[4], SCSI_DATA_WRITE, SRpnt = st_do_scsi(SRpnt, STp, cmd, cmd[4], SCSI_DATA_WRITE,
STp->timeout, 0, TRUE); (slow ? STp->long_timeout : STp->timeout), 0, TRUE);
if (SRpnt == NULL) if (SRpnt == NULL)
return (STp->buffer)->syscall_result; return (STp->buffer)->syscall_result;
...@@ -2223,7 +2231,7 @@ static int st_compression(Scsi_Tape * STp, int state) ...@@ -2223,7 +2231,7 @@ static int st_compression(Scsi_Tape * STp, int state)
b_data[mpoffs + CP_OFF_C_ALGO] = 0; /* no compression */ b_data[mpoffs + CP_OFF_C_ALGO] = 0; /* no compression */
} }
retval = write_mode_page(STp, COMPRESSION_PAGE); retval = write_mode_page(STp, COMPRESSION_PAGE, FALSE);
if (retval) { if (retval) {
DEBC(printk(ST_DEB_MSG "%s: Compression change failed.\n", name)); DEBC(printk(ST_DEB_MSG "%s: Compression change failed.\n", name));
return (-EIO); return (-EIO);
...@@ -3022,7 +3030,7 @@ static int partition_tape(Scsi_Tape *STp, int size) ...@@ -3022,7 +3030,7 @@ static int partition_tape(Scsi_Tape *STp, int size)
bp[pgo + PP_OFF_RESERVED] = 0; bp[pgo + PP_OFF_RESERVED] = 0;
bp[pgo + PP_OFF_FLAGS] = PP_BIT_IDP | PP_MSK_PSUM_MB; bp[pgo + PP_OFF_FLAGS] = PP_BIT_IDP | PP_MSK_PSUM_MB;
result = write_mode_page(STp, PART_PAGE); result = write_mode_page(STp, PART_PAGE, TRUE);
if (result) { if (result) {
printk(KERN_INFO "%s: Partitioning of tape failed.\n", name); printk(KERN_INFO "%s: Partitioning of tape failed.\n", name);
result = (-EIO); result = (-EIO);
......
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