Commit 3e51d3c924aea8a1f1372e6c615b0a37b528121d

Authored by Kai Makisara
Committed by James Bottomley
1 parent 56dd2c0691

[SCSI] st: add MTWEOFI to write filemarks without flushing drive buffer

This patch adds a new MTIOCTOP operation MTWEOFI that writes filemarks with
immediate bit set. This means that the drive does not flush its buffer and the
next file can be started immediately. This speeds up writing in applications
that have to write multiple small files.

Signed-off-by: Kai Makisara <kai.makisara@kolumbus.fi>
Signed-off-by: James Bottomley <James.Bottomley@suse.de>

Showing 3 changed files with 24 additions and 7 deletions Side-by-side Diff

Documentation/scsi/st.txt
... ... @@ -2,7 +2,7 @@
2 2 The driver is currently maintained by Kai Mäkisara (email
3 3 Kai.Makisara@kolumbus.fi)
4 4  
5   -Last modified: Sun Feb 24 21:59:07 2008 by kai.makisara
  5 +Last modified: Sun Aug 29 18:25:47 2010 by kai.makisara
6 6  
7 7  
8 8 BASICS
... ... @@ -85,6 +85,17 @@
85 85 optionally written. In both cases end of data is signified by
86 86 returning zero bytes for two consecutive reads.
87 87  
  88 +Writing filemarks without the immediate bit set in the SCSI command block acts
  89 +as a synchronization point, i.e., all remaining data form the drive buffers is
  90 +written to tape before the command returns. This makes sure that write errors
  91 +are caught at that point, but this takes time. In some applications, several
  92 +consecutive files must be written fast. The MTWEOFI operation can be used to
  93 +write the filemarks without flushing the drive buffer. Writing filemark at
  94 +close() is always flushing the drive buffers. However, if the previous
  95 +operation is MTWEOFI, close() does not write a filemark. This can be used if
  96 +the program wants to close/open the tape device between files and wants to
  97 +skip waiting.
  98 +
88 99 If rewind, offline, bsf, or seek is done and previous tape operation was
89 100 write, a filemark is written before moving tape.
90 101  
... ... @@ -301,6 +312,8 @@
301 312 MTFSS Space forward over count setmarks.
302 313 MTBSS Space backward over count setmarks.
303 314 MTWEOF Write count filemarks.
  315 +MTWEOFI Write count filemarks with immediate bit set (i.e., does not
  316 + wait until data is on tape)
304 317 MTWSM Write count setmarks.
305 318 MTREW Rewind tape.
306 319 MTOFFL Set device off line (often rewind plus eject).
... ... @@ -9,7 +9,7 @@
9 9 Steve Hirsch, Andreas Koppenh"ofer, Michael Leodolter, Eyal Lebedinsky,
10 10 Michael Schaefer, J"org Weule, and Eric Youngdale.
11 11  
12   - Copyright 1992 - 2008 Kai Makisara
  12 + Copyright 1992 - 2010 Kai Makisara
13 13 email Kai.Makisara@kolumbus.fi
14 14  
15 15 Some small formal changes - aeb, 950809
... ... @@ -17,7 +17,7 @@
17 17 Last modified: 18-JAN-1998 Richard Gooch <rgooch@atnf.csiro.au> Devfs support
18 18 */
19 19  
20   -static const char *verstr = "20081215";
  20 +static const char *verstr = "20100829";
21 21  
22 22 #include <linux/module.h>
23 23  
24 24  
25 25  
... ... @@ -2696,18 +2696,21 @@
2696 2696 }
2697 2697 break;
2698 2698 case MTWEOF:
  2699 + case MTWEOFI:
2699 2700 case MTWSM:
2700 2701 if (STp->write_prot)
2701 2702 return (-EACCES);
2702 2703 cmd[0] = WRITE_FILEMARKS;
2703 2704 if (cmd_in == MTWSM)
2704 2705 cmd[1] = 2;
  2706 + if (cmd_in == MTWEOFI)
  2707 + cmd[1] |= 1;
2705 2708 cmd[2] = (arg >> 16);
2706 2709 cmd[3] = (arg >> 8);
2707 2710 cmd[4] = arg;
2708 2711 timeout = STp->device->request_queue->rq_timeout;
2709 2712 DEBC(
2710   - if (cmd_in == MTWEOF)
  2713 + if (cmd_in != MTWSM)
2711 2714 printk(ST_DEB_MSG "%s: Writing %d filemarks.\n", name,
2712 2715 cmd[2] * 65536 + cmd[3] * 256 + cmd[4]);
2713 2716 else
... ... @@ -2883,8 +2886,8 @@
2883 2886 else if (chg_eof)
2884 2887 STps->eof = ST_NOEOF;
2885 2888  
2886   - if (cmd_in == MTWEOF)
2887   - STps->rw = ST_IDLE;
  2889 + if (cmd_in == MTWEOF || cmd_in == MTWEOFI)
  2890 + STps->rw = ST_IDLE; /* prevent automatic WEOF at close */
2888 2891 } else { /* SCSI command was not completely successful. Don't return
2889 2892 from this block without releasing the SCSI command block! */
2890 2893 struct st_cmdstatus *cmdstatp = &STp->buffer->cmdstat;
... ... @@ -2901,7 +2904,7 @@
2901 2904 else
2902 2905 undone = 0;
2903 2906  
2904   - if (cmd_in == MTWEOF &&
  2907 + if ((cmd_in == MTWEOF || cmd_in == MTWEOFI) &&
2905 2908 cmdstatp->have_sense &&
2906 2909 (cmdstatp->flags & SENSE_EOM)) {
2907 2910 if (cmdstatp->sense_hdr.sense_key == NO_SENSE ||
include/linux/mtio.h
... ... @@ -63,6 +63,7 @@
63 63 #define MTCOMPRESSION 32/* control compression with SCSI mode page 15 */
64 64 #define MTSETPART 33 /* Change the active tape partition */
65 65 #define MTMKPART 34 /* Format the tape with one or two partitions */
  66 +#define MTWEOFI 35 /* write an end-of-file record (mark) in immediate mode */
66 67  
67 68 /* structure for MTIOCGET - mag tape get status command */
68 69