Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

[SCSI] st: expand ability to write immediate filemarks

The st tape driver recently added the MTWEOFI ioctl, which writes
a tape filemark (EOF), like the MTWEOF ioctl, except that MTWEOFI
returns immediately. This makes certain applications, like backup
software, run much more quickly on buffered tape drives.

Since legacy applications do not know about this new MTWEOFI ioctl,
this patch adds a new ioctl option that tells the st driver to return
immediately when writing an EOF (i.e. a filemark). This new flag
is much like the existing flag that tells the st driver to perform
writes (and certain other IOs) immediately, but this new flag only
applies to writing EOFs.

This new feature is controlled via the MTSETDRVBUFFER ioctl, using
the newly-defined MT_ST_NOWAIT_EOF flag.

Use of this new feature is displayed via the sysfs tape "options"
attribute.

The st documentation was updated to mention this new flag, as well
as the problems that can occur from using it.

Signed-off-by: Lee Duncan <lduncan@suse.com>
Acked-by: Kai Makisara <kai.makisara@kolumbus.fi>
Signed-off-by: James Bottomley <JBottomley@Parallels.com>

authored by

Lee Duncan and committed by
James Bottomley
c743e44f 3194eef3

+24 -3
+4
Documentation/scsi/st.txt
··· 390 390 MT_ST_SYSV sets the SYSV semantics (mode) 391 391 MT_ST_NOWAIT enables immediate mode (i.e., don't wait for 392 392 the command to finish) for some commands (e.g., rewind) 393 + MT_ST_NOWAIT_EOF enables immediate filemark mode (i.e. when 394 + writing a filemark, don't wait for it to complete). Please 395 + see the BASICS note about MTWEOFI with respect to the 396 + possible dangers of writing immediate filemarks. 393 397 MT_ST_SILI enables setting the SILI bit in SCSI commands when 394 398 reading in variable block mode to enhance performance when 395 399 reading blocks shorter than the byte count; set this only
+18 -3
drivers/scsi/st.c
··· 1106 1106 STp->drv_buffer)); 1107 1107 } 1108 1108 STp->drv_write_prot = ((STp->buffer)->b_data[2] & 0x80) != 0; 1109 + if (!STp->drv_buffer && STp->immediate_filemark) { 1110 + printk(KERN_WARNING 1111 + "%s: non-buffered tape: disabling writing immediate filemarks\n", 1112 + name); 1113 + STp->immediate_filemark = 0; 1114 + } 1109 1115 } 1110 1116 st_release_request(SRpnt); 1111 1117 SRpnt = NULL; ··· 1320 1314 1321 1315 memset(cmd, 0, MAX_COMMAND_SIZE); 1322 1316 cmd[0] = WRITE_FILEMARKS; 1317 + if (STp->immediate_filemark) 1318 + cmd[1] = 1; 1323 1319 cmd[4] = 1 + STp->two_fm; 1324 1320 1325 1321 SRpnt = st_do_scsi(NULL, STp, cmd, 0, DMA_NONE, ··· 2189 2181 name, STm->defaults_for_writes, STp->omit_blklims, STp->can_partitions, 2190 2182 STp->scsi2_logical); 2191 2183 printk(KERN_INFO 2192 - "%s: sysv: %d nowait: %d sili: %d\n", name, STm->sysv, STp->immediate, 2193 - STp->sili); 2184 + "%s: sysv: %d nowait: %d sili: %d nowait_filemark: %d\n", 2185 + name, STm->sysv, STp->immediate, STp->sili, 2186 + STp->immediate_filemark); 2194 2187 printk(KERN_INFO "%s: debugging: %d\n", 2195 2188 name, debugging); 2196 2189 } ··· 2233 2224 STp->can_partitions = (options & MT_ST_CAN_PARTITIONS) != 0; 2234 2225 STp->scsi2_logical = (options & MT_ST_SCSI2LOGICAL) != 0; 2235 2226 STp->immediate = (options & MT_ST_NOWAIT) != 0; 2227 + STp->immediate_filemark = (options & MT_ST_NOWAIT_EOF) != 0; 2236 2228 STm->sysv = (options & MT_ST_SYSV) != 0; 2237 2229 STp->sili = (options & MT_ST_SILI) != 0; 2238 2230 DEB( debugging = (options & MT_ST_DEBUGGING) != 0; ··· 2265 2255 STp->scsi2_logical = value; 2266 2256 if ((options & MT_ST_NOWAIT) != 0) 2267 2257 STp->immediate = value; 2258 + if ((options & MT_ST_NOWAIT_EOF) != 0) 2259 + STp->immediate_filemark = value; 2268 2260 if ((options & MT_ST_SYSV) != 0) 2269 2261 STm->sysv = value; 2270 2262 if ((options & MT_ST_SILI) != 0) ··· 2726 2714 cmd[0] = WRITE_FILEMARKS; 2727 2715 if (cmd_in == MTWSM) 2728 2716 cmd[1] = 2; 2729 - if (cmd_in == MTWEOFI) 2717 + if (cmd_in == MTWEOFI || 2718 + (cmd_in == MTWEOF && STp->immediate_filemark)) 2730 2719 cmd[1] |= 1; 2731 2720 cmd[2] = (arg >> 16); 2732 2721 cmd[3] = (arg >> 8); ··· 4106 4093 tpnt->scsi2_logical = ST_SCSI2LOGICAL; 4107 4094 tpnt->sili = ST_SILI; 4108 4095 tpnt->immediate = ST_NOWAIT; 4096 + tpnt->immediate_filemark = 0; 4109 4097 tpnt->default_drvbuffer = 0xff; /* No forced buffering */ 4110 4098 tpnt->partition = 0; 4111 4099 tpnt->new_partition = 0; ··· 4492 4478 options |= STp->scsi2_logical ? MT_ST_SCSI2LOGICAL : 0; 4493 4479 options |= STm->sysv ? MT_ST_SYSV : 0; 4494 4480 options |= STp->immediate ? MT_ST_NOWAIT : 0; 4481 + options |= STp->immediate_filemark ? MT_ST_NOWAIT_EOF : 0; 4495 4482 options |= STp->sili ? MT_ST_SILI : 0; 4496 4483 4497 4484 l = snprintf(buf, PAGE_SIZE, "0x%08x\n", options);
+1
drivers/scsi/st.h
··· 120 120 unsigned char c_algo; /* compression algorithm */ 121 121 unsigned char pos_unknown; /* after reset position unknown */ 122 122 unsigned char sili; /* use SILI when reading in variable b mode */ 123 + unsigned char immediate_filemark; /* write filemark immediately */ 123 124 int tape_type; 124 125 int long_timeout; /* timeout for commands known to take long time */ 125 126
+1
include/linux/mtio.h
··· 194 194 #define MT_ST_SYSV 0x1000 195 195 #define MT_ST_NOWAIT 0x2000 196 196 #define MT_ST_SILI 0x4000 197 + #define MT_ST_NOWAIT_EOF 0x8000 197 198 198 199 /* The mode parameters to be controlled. Parameter chosen with bits 20-28 */ 199 200 #define MT_ST_CLEAR_DEFAULT 0xfffff