From linux-kernel@vger.kernel.org Tue Jan 6 00:36:01 2004 Date: Sat, 03 Jan 2004 19:37:28 +0000 From: Linux Kernel Mailing List To: bk-commits-24@vger.kernel.org Subject: [PATCH] SCSI tape bug fix (variable block mode, ChangeSet 1.1361, 2004/01/03 17:37:28-02:00, Kai.Makisara@kolumbus.fi [PATCH] SCSI tape bug fix (variable block mode, Marcelo, I submit the patch at the end of this message for inclusion into the 2.4.24 kernel. The patch is against 2.4.24-pre3. The problem was noticed by a user who also provided excellent analysis why the corruption occurred. A small test program was able to prove the analysis. After this the fix was trivial. Thanks, Kai Diffstat: drivers/scsi/st.c | 30 +++++++++++++++--------------- 1 files changed, 15 insertions(+), 15 deletions(-) Text for changelog: Move checking the status of previous write before possible buffer extension. Prevents possible data corruption in variable block mode if the buffer is being extended more than once. # This patch includes the following deltas: # ChangeSet 1.1360 -> 1.1361 # drivers/scsi/st.c 1.13 -> 1.14 # st.c | 30 +++++++++++++++--------------- 1 files changed, 15 insertions(+), 15 deletions(-) diff -Nru a/drivers/scsi/st.c b/drivers/scsi/st.c --- a/drivers/scsi/st.c Sat Jan 3 12:02:14 2004 +++ b/drivers/scsi/st.c Sat Jan 3 12:02:14 2004 @@ -9,10 +9,10 @@ Steve Hirsch, Andreas Koppenh"ofer, Michael Leodolter, Eyal Lebedinsky, Michael Schaefer, J"org Weule, and Eric Youngdale. - Copyright 1992 - 2003 Kai Makisara + Copyright 1992 - 2004 Kai Makisara email Kai.Makisara@kolumbus.fi - Last modified: Sun Apr 6 22:44:42 2003 by makisara + Last modified: Fri Jan 2 17:50:08 2004 by makisara Some small formal changes - aeb, 950809 Last modified: 18-JAN-1998 Richard Gooch Devfs support @@ -21,7 +21,7 @@ error handling will be discarded. */ -static char *verstr = "20030406"; +static char *verstr = "20040102"; #include @@ -1277,6 +1277,18 @@ goto out; } + if ((STp->buffer)->writing) { + write_behind_check(STp); + if ((STp->buffer)->syscall_result) { + DEBC(printk(ST_DEB_MSG "st%d: Async write error (write) %x.\n", + dev, (STp->buffer)->midlevel_result)); + if ((STp->buffer)->midlevel_result == INT_MAX) + STps->eof = ST_EOM_OK; + else + STps->eof = ST_EOM_ERROR; + } + } + if (STp->block_size == 0) { if (STp->max_block > 0 && (count < STp->min_block || count > STp->max_block)) { @@ -1321,18 +1333,6 @@ goto out; } } - } - } - - if ((STp->buffer)->writing) { - write_behind_check(STp); - if ((STp->buffer)->syscall_result) { - DEBC(printk(ST_DEB_MSG "st%d: Async write error (write) %x.\n", - dev, (STp->buffer)->midlevel_result)); - if ((STp->buffer)->midlevel_result == INT_MAX) - STps->eof = ST_EOM_OK; - else - STps->eof = ST_EOM_ERROR; } } - To unsubscribe from this list: send the line "unsubscribe bk-commits-24" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html