aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/scsi/st.c
diff options
context:
space:
mode:
authorKai Makisara <Kai.Makisara@kolumbus.fi>2007-01-25 17:38:39 -0500
committerJames Bottomley <jejb@mulgrave.il.steeleye.com>2007-01-27 10:18:21 -0500
commit91614c054c9ffc26b47a5cb3135113aa0f6e6ff0 (patch)
tree83a618f1b3c02569b11d83f91e0b8492f06c61f9 /drivers/scsi/st.c
parent477ffb9d8732f30e7ab2d20f6ed0c22bad37a4a5 (diff)
[SCSI] st: A MTIOCTOP/MTWEOF within the early warning will cause the file number to be incorrect
On Wed, 24 Jan 2007, Andrew Morton wrote: > On Mon, 22 Jan 2007 13:07:20 -0800 > bugme-daemon@bugzilla.kernel.org wrote: > > > http://bugzilla.kernel.org/show_bug.cgi?id=7864 > > > > Summary: A MTIOCTOP/MTWEOF within the early warning will cause > > the file number to be incorrect > > Kernel Version: 2.6.19.2 > > Status: NEW > > Severity: low > > Owner: io_scsi@kernel-bugs.osdl.org > > Submitter: ce_reisinger@yahoo.com > > > > > > Write records to a SCSI tape until a write fails with a ENOSPC (you have reached > > early warning. > > Now perform a: > > struct mtget before, after; > > ioctl(fd, MTIOCGET, &before); > > struct mtop mtop = { MTWEOF, 1 }; > > ioctl(fd, MTIOCTOP, &mtop); > > ioctl(fd, MTIOCGET, &after); > > > > Check the value of mt_fileno in the before and after structures. Notice the > > after is 2 greater then the before. > > > > The problem appears to be in the block of code starting at line 2817 in st.c. > > This block is entered because the drive did return a CHECK CONDITION with NO > > SENSE and the SENSE_EOM bit set. At lines 2824/5 the fileno is incremented. But > > it has already been increased by the number of filemarks requested by the > > MTIOCTOP. I believe that the residue count in the sense data should be > > subtracted from fileno, not a increment as is done. > > > > Thanks. Could you please send us a tested patch to fix these things, as > per http://www.zip.com.au/~akpm/linux/patches/stuff/tpp.txt ? > The analysis is basically correct and explains the bug. According to the SCSI standards, the sense code is NO SENSE or RECOVERED ERROR in case writing filemark(s) succeeds. If it fails (partly or completely) the sense code is VOLUME OVERFLOW. The patch below is tested to fix the case when one filemark is successfully written after the EOM early warning. It should also fix the case at real EOM but this has not been tested. Carl, thanks for reporting the bug and providing the analysis for the fix. Signed-off-by: Kai Makisara <kai.makisara@kolumbus.fi> Signed-off-by: James Bottomley <James.Bottomley@SteelEye.com>
Diffstat (limited to 'drivers/scsi/st.c')
-rw-r--r--drivers/scsi/st.c19
1 files changed, 11 insertions, 8 deletions
diff --git a/drivers/scsi/st.c b/drivers/scsi/st.c
index e016e0906e1a..488ec7948a57 100644
--- a/drivers/scsi/st.c
+++ b/drivers/scsi/st.c
@@ -2816,15 +2816,18 @@ static int st_int_ioctl(struct scsi_tape *STp, unsigned int cmd_in, unsigned lon
2816 2816
2817 if (cmd_in == MTWEOF && 2817 if (cmd_in == MTWEOF &&
2818 cmdstatp->have_sense && 2818 cmdstatp->have_sense &&
2819 (cmdstatp->flags & SENSE_EOM) && 2819 (cmdstatp->flags & SENSE_EOM)) {
2820 (cmdstatp->sense_hdr.sense_key == NO_SENSE || 2820 if (cmdstatp->sense_hdr.sense_key == NO_SENSE ||
2821 cmdstatp->sense_hdr.sense_key == RECOVERED_ERROR) && 2821 cmdstatp->sense_hdr.sense_key == RECOVERED_ERROR) {
2822 undone == 0) { 2822 ioctl_result = 0; /* EOF(s) written successfully at EOM */
2823 ioctl_result = 0; /* EOF written successfully at EOM */ 2823 STps->eof = ST_NOEOF;
2824 if (fileno >= 0) 2824 } else { /* Writing EOF(s) failed */
2825 fileno++; 2825 if (fileno >= 0)
2826 fileno -= undone;
2827 if (undone < arg)
2828 STps->eof = ST_NOEOF;
2829 }
2826 STps->drv_file = fileno; 2830 STps->drv_file = fileno;
2827 STps->eof = ST_NOEOF;
2828 } else if ((cmd_in == MTFSF) || (cmd_in == MTFSFM)) { 2831 } else if ((cmd_in == MTFSF) || (cmd_in == MTFSFM)) {
2829 if (fileno >= 0) 2832 if (fileno >= 0)
2830 STps->drv_file = fileno - undone; 2833 STps->drv_file = fileno - undone;