aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/scsi/st.c
diff options
context:
space:
mode:
authorLee Duncan <lduncan@suse.com>2012-03-01 15:41:01 -0500
committerJames Bottomley <JBottomley@Parallels.com>2012-03-27 03:26:34 -0400
commitc743e44fbb1f8668941e83de07662b1ecd33d083 (patch)
treec0a5eacf103f566942b8e8e7c222b3fa588657a4 /drivers/scsi/st.c
parent3194eef325c126d1f3bfa28317e2acd78292250d (diff)
[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>
Diffstat (limited to 'drivers/scsi/st.c')
-rw-r--r--drivers/scsi/st.c21
1 files changed, 18 insertions, 3 deletions
diff --git a/drivers/scsi/st.c b/drivers/scsi/st.c
index 9262cdfa4b23..8c663e16fd02 100644
--- a/drivers/scsi/st.c
+++ b/drivers/scsi/st.c
@@ -1106,6 +1106,12 @@ static int check_tape(struct scsi_tape *STp, struct file *filp)
1106 STp->drv_buffer)); 1106 STp->drv_buffer));
1107 } 1107 }
1108 STp->drv_write_prot = ((STp->buffer)->b_data[2] & 0x80) != 0; 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 st_release_request(SRpnt); 1116 st_release_request(SRpnt);
1111 SRpnt = NULL; 1117 SRpnt = NULL;
@@ -1314,6 +1320,8 @@ static int st_flush(struct file *filp, fl_owner_t id)
1314 1320
1315 memset(cmd, 0, MAX_COMMAND_SIZE); 1321 memset(cmd, 0, MAX_COMMAND_SIZE);
1316 cmd[0] = WRITE_FILEMARKS; 1322 cmd[0] = WRITE_FILEMARKS;
1323 if (STp->immediate_filemark)
1324 cmd[1] = 1;
1317 cmd[4] = 1 + STp->two_fm; 1325 cmd[4] = 1 + STp->two_fm;
1318 1326
1319 SRpnt = st_do_scsi(NULL, STp, cmd, 0, DMA_NONE, 1327 SRpnt = st_do_scsi(NULL, STp, cmd, 0, DMA_NONE,
@@ -2181,8 +2189,9 @@ static void st_log_options(struct scsi_tape * STp, struct st_modedef * STm, char
2181 name, STm->defaults_for_writes, STp->omit_blklims, STp->can_partitions, 2189 name, STm->defaults_for_writes, STp->omit_blklims, STp->can_partitions,
2182 STp->scsi2_logical); 2190 STp->scsi2_logical);
2183 printk(KERN_INFO 2191 printk(KERN_INFO
2184 "%s: sysv: %d nowait: %d sili: %d\n", name, STm->sysv, STp->immediate, 2192 "%s: sysv: %d nowait: %d sili: %d nowait_filemark: %d\n",
2185 STp->sili); 2193 name, STm->sysv, STp->immediate, STp->sili,
2194 STp->immediate_filemark);
2186 printk(KERN_INFO "%s: debugging: %d\n", 2195 printk(KERN_INFO "%s: debugging: %d\n",
2187 name, debugging); 2196 name, debugging);
2188 } 2197 }
@@ -2224,6 +2233,7 @@ static int st_set_options(struct scsi_tape *STp, long options)
2224 STp->can_partitions = (options & MT_ST_CAN_PARTITIONS) != 0; 2233 STp->can_partitions = (options & MT_ST_CAN_PARTITIONS) != 0;
2225 STp->scsi2_logical = (options & MT_ST_SCSI2LOGICAL) != 0; 2234 STp->scsi2_logical = (options & MT_ST_SCSI2LOGICAL) != 0;
2226 STp->immediate = (options & MT_ST_NOWAIT) != 0; 2235 STp->immediate = (options & MT_ST_NOWAIT) != 0;
2236 STp->immediate_filemark = (options & MT_ST_NOWAIT_EOF) != 0;
2227 STm->sysv = (options & MT_ST_SYSV) != 0; 2237 STm->sysv = (options & MT_ST_SYSV) != 0;
2228 STp->sili = (options & MT_ST_SILI) != 0; 2238 STp->sili = (options & MT_ST_SILI) != 0;
2229 DEB( debugging = (options & MT_ST_DEBUGGING) != 0; 2239 DEB( debugging = (options & MT_ST_DEBUGGING) != 0;
@@ -2255,6 +2265,8 @@ static int st_set_options(struct scsi_tape *STp, long options)
2255 STp->scsi2_logical = value; 2265 STp->scsi2_logical = value;
2256 if ((options & MT_ST_NOWAIT) != 0) 2266 if ((options & MT_ST_NOWAIT) != 0)
2257 STp->immediate = value; 2267 STp->immediate = value;
2268 if ((options & MT_ST_NOWAIT_EOF) != 0)
2269 STp->immediate_filemark = value;
2258 if ((options & MT_ST_SYSV) != 0) 2270 if ((options & MT_ST_SYSV) != 0)
2259 STm->sysv = value; 2271 STm->sysv = value;
2260 if ((options & MT_ST_SILI) != 0) 2272 if ((options & MT_ST_SILI) != 0)
@@ -2714,7 +2726,8 @@ static int st_int_ioctl(struct scsi_tape *STp, unsigned int cmd_in, unsigned lon
2714 cmd[0] = WRITE_FILEMARKS; 2726 cmd[0] = WRITE_FILEMARKS;
2715 if (cmd_in == MTWSM) 2727 if (cmd_in == MTWSM)
2716 cmd[1] = 2; 2728 cmd[1] = 2;
2717 if (cmd_in == MTWEOFI) 2729 if (cmd_in == MTWEOFI ||
2730 (cmd_in == MTWEOF && STp->immediate_filemark))
2718 cmd[1] |= 1; 2731 cmd[1] |= 1;
2719 cmd[2] = (arg >> 16); 2732 cmd[2] = (arg >> 16);
2720 cmd[3] = (arg >> 8); 2733 cmd[3] = (arg >> 8);
@@ -4093,6 +4106,7 @@ static int st_probe(struct device *dev)
4093 tpnt->scsi2_logical = ST_SCSI2LOGICAL; 4106 tpnt->scsi2_logical = ST_SCSI2LOGICAL;
4094 tpnt->sili = ST_SILI; 4107 tpnt->sili = ST_SILI;
4095 tpnt->immediate = ST_NOWAIT; 4108 tpnt->immediate = ST_NOWAIT;
4109 tpnt->immediate_filemark = 0;
4096 tpnt->default_drvbuffer = 0xff; /* No forced buffering */ 4110 tpnt->default_drvbuffer = 0xff; /* No forced buffering */
4097 tpnt->partition = 0; 4111 tpnt->partition = 0;
4098 tpnt->new_partition = 0; 4112 tpnt->new_partition = 0;
@@ -4478,6 +4492,7 @@ st_options_show(struct device *dev, struct device_attribute *attr, char *buf)
4478 options |= STp->scsi2_logical ? MT_ST_SCSI2LOGICAL : 0; 4492 options |= STp->scsi2_logical ? MT_ST_SCSI2LOGICAL : 0;
4479 options |= STm->sysv ? MT_ST_SYSV : 0; 4493 options |= STm->sysv ? MT_ST_SYSV : 0;
4480 options |= STp->immediate ? MT_ST_NOWAIT : 0; 4494 options |= STp->immediate ? MT_ST_NOWAIT : 0;
4495 options |= STp->immediate_filemark ? MT_ST_NOWAIT_EOF : 0;
4481 options |= STp->sili ? MT_ST_SILI : 0; 4496 options |= STp->sili ? MT_ST_SILI : 0;
4482 4497
4483 l = snprintf(buf, PAGE_SIZE, "0x%08x\n", options); 4498 l = snprintf(buf, PAGE_SIZE, "0x%08x\n", options);