Commit a0a7d715 authored by Kai Mäkisara's avatar Kai Mäkisara Committed by Linus Torvalds

[PATCH] SCSI tape direct transfers for 2.5.31

This adds direct write and read from/to the user space to/from the SCSI
adapter.  If something (e.g., too high address) prevents direct
transfer, the existing driver buffer code is used.  The patch contains
functions to map and pin the user buffer pages so that this patch is not
dependent on kiobufs.  Similar functions are already used in sg.c.
parent 6681892b
...@@ -2,7 +2,7 @@ This file contains brief information about the SCSI tape driver. ...@@ -2,7 +2,7 @@ This file contains brief information about the SCSI tape driver.
The driver is currently maintained by Kai M{kisara (email The driver is currently maintained by Kai M{kisara (email
Kai.Makisara@metla.fi) Kai.Makisara@metla.fi)
Last modified: Mon Jul 15 16:30:40 2002 by makisara Last modified: Fri Jul 26 16:01:39 2002 by makisara
BASICS BASICS
...@@ -105,22 +105,31 @@ The default is BSD semantics. ...@@ -105,22 +105,31 @@ The default is BSD semantics.
BUFFERING BUFFERING
The driver uses tape buffers allocated at run-time when needed and it The driver tries to do tranfers directly to/from user space. If this
is freed when the device file is closed. One buffer is used for each is not possible, a driver buffer allocated at run-time is used. If
open tape device. direct i/o is not possible for the whole transfer, the driver buffer
is used (i.e., bounce buffers for individual pages are not
The size of the buffers is always at least one tape block. In fixed used). Direct i/o can be impossible because of several reasons, e.g.:
- one or more pages are at addresses not reachable by the HBA
- the number of pages in the transfer exceeds the number of
scatter/gather segments permitted by the HBA
- one or more pages can't be locked into memory (should not happen in
any reasonable situation)
The size of the driver buffers is always at least one tape block. In fixed
block mode, the minimum buffer size is defined (in 1024 byte units) by block mode, the minimum buffer size is defined (in 1024 byte units) by
ST_FIXED_BUFFER_BLOCKS. With small block size this allows buffering of ST_FIXED_BUFFER_BLOCKS. With small block size this allows buffering of
several blocks and using one SCSI read or write to transfer all of the several blocks and using one SCSI read or write to transfer all of the
blocks. Buffering of data across write calls in fixed block mode is blocks. Buffering of data across write calls in fixed block mode is
allowed if ST_BUFFER_WRITES is non-zero. Buffer allocation uses chunks of allowed if ST_BUFFER_WRITES is non-zero and direct i/o is not used.
memory having sizes 2^n * (page size). Because of this the actual Buffer allocation uses chunks of memory having sizes 2^n * (page
buffer size may be larger than the minimum allowable buffer size. size). Because of this the actual buffer size may be larger than the
minimum allowable buffer size.
Asynchronous writing. Writing the buffer contents to the tape is Asynchronous writing. Writing the buffer contents to the tape is
started and the write call returns immediately. The status is checked started and the write call returns immediately. The status is checked
at the next tape operation. at the next tape operation. Asynchronous writes are not done with
direct i/o.
Buffered writes and asynchronous writes may in some rare cases cause Buffered writes and asynchronous writes may in some rare cases cause
problems in multivolume operations if there is not enough space on the problems in multivolume operations if there is not enough space on the
...@@ -181,9 +190,10 @@ are configurable when the driver is loaded as a module. The keywords are: ...@@ -181,9 +190,10 @@ are configurable when the driver is loaded as a module. The keywords are:
buffer_kbs=xxx the buffer size for fixed block mode is set buffer_kbs=xxx the buffer size for fixed block mode is set
to xxx kilobytes to xxx kilobytes
write_threshold_kbs=xxx the write threshold in kilobytes set to xxx write_threshold_kbs=xxx the write threshold in kilobytes set to xxx
max_buffers=xxx the maximum number of tape buffer set to xxx
max_sg_segs=xxx the maximum number of scatter/gather max_sg_segs=xxx the maximum number of scatter/gather
segments segments
try_direct_io=x try direct transfer between user buffer and
tape drive if this is non-zero
Note that if the buffer size is changed but the write threshold is not Note that if the buffer size is changed but the write threshold is not
set, the write threshold is set to the new buffer size - 2 kB. set, the write threshold is set to the new buffer size - 2 kB.
......
This diff is collapsed.
...@@ -12,6 +12,7 @@ ...@@ -12,6 +12,7 @@
typedef struct { typedef struct {
unsigned char in_use; unsigned char in_use;
unsigned char dma; /* DMA-able buffer */ unsigned char dma; /* DMA-able buffer */
unsigned char do_dio;
int buffer_size; int buffer_size;
int buffer_blocks; int buffer_blocks;
int buffer_bytes; int buffer_bytes;
...@@ -21,7 +22,7 @@ typedef struct { ...@@ -21,7 +22,7 @@ typedef struct {
int syscall_result; int syscall_result;
Scsi_Request *last_SRpnt; Scsi_Request *last_SRpnt;
unsigned char *b_data; unsigned char *b_data;
unsigned short use_sg; /* zero or maximum number of s/g segments for this adapter */ unsigned short use_sg; /* zero or max number of s/g segments for this adapter */
unsigned short sg_segs; /* number of segments in s/g list */ unsigned short sg_segs; /* number of segments in s/g list */
unsigned short orig_frp_segs; /* number of segments allocated at first try */ unsigned short orig_frp_segs; /* number of segments allocated at first try */
unsigned short frp_segs; /* number of buffer segments */ unsigned short frp_segs; /* number of buffer segments */
...@@ -91,12 +92,15 @@ typedef struct { ...@@ -91,12 +92,15 @@ typedef struct {
unsigned char cln_sense_value; unsigned char cln_sense_value;
unsigned char cln_sense_mask; unsigned char cln_sense_mask;
unsigned char use_pf; /* Set Page Format bit in all mode selects? */ unsigned char use_pf; /* Set Page Format bit in all mode selects? */
unsigned char try_dio; /* try direct i/o? */
unsigned char c_algo; /* compression algorithm */ unsigned char c_algo; /* compression algorithm */
int tape_type; int tape_type;
int write_threshold; int write_threshold;
int timeout; /* timeout for normal commands */ int timeout; /* timeout for normal commands */
int long_timeout; /* timeout for commands known to take long time */ int long_timeout; /* timeout for commands known to take long time */
unsigned long max_pfn; /* the maximum page number reachable by the HBA */
/* Mode characteristics */ /* Mode characteristics */
ST_mode modes[ST_NBR_MODES]; ST_mode modes[ST_NBR_MODES];
int current_mode; int current_mode;
...@@ -135,6 +139,10 @@ typedef struct { ...@@ -135,6 +139,10 @@ typedef struct {
unsigned char write_pending; unsigned char write_pending;
int nbr_finished; int nbr_finished;
int nbr_waits; int nbr_waits;
int nbr_requests;
int nbr_dio;
int nbr_pages;
int nbr_combinable;
unsigned char last_cmnd[6]; unsigned char last_cmnd[6];
unsigned char last_sense[16]; unsigned char last_sense[16];
#endif #endif
......
/* /*
The compile-time configurable defaults for the Linux SCSI tape driver. The compile-time configurable defaults for the Linux SCSI tape driver.
Copyright 1995-2000 Kai Makisara. Copyright 1995-2002 Kai Makisara.
Last modified: Sun May 5 15:09:56 2002 by makisara Last modified: Fri Jul 26 15:54:31 2002 by makisara
*/ */
#ifndef _ST_OPTIONS_H #ifndef _ST_OPTIONS_H
#define _ST_OPTIONS_H #define _ST_OPTIONS_H
/* If TRY_DIRECT_IO is non-zero, the driver tries to transfer data directly
between the user buffer and tape drive. If this is not possible, driver
buffer is used. If TRY_DIRECT_IO is zero, driver buffer is always used. */
#define TRY_DIRECT_IO 1
/* The driver does not wait for some operations to finish before returning /* The driver does not wait for some operations to finish before returning
to the user program if ST_NOWAIT is non-zero. This helps if the SCSI to the user program if ST_NOWAIT is non-zero. This helps if the SCSI
adapter does not support multiple outstanding commands. However, the user adapter does not support multiple outstanding commands. However, the user
...@@ -40,7 +45,7 @@ ...@@ -40,7 +45,7 @@
#define ST_WRITE_THRESHOLD_BLOCKS 30 #define ST_WRITE_THRESHOLD_BLOCKS 30
/* Maximum number of scatter/gather segments */ /* Maximum number of scatter/gather segments */
#define ST_MAX_SG 64 #define ST_MAX_SG 256
/* The number of scatter/gather segments to allocate at first try (must be /* The number of scatter/gather segments to allocate at first try (must be
smaller or equal to the maximum). */ smaller or equal to the maximum). */
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment