aboutsummaryrefslogtreecommitdiffstats
path: root/include/scsi/sg.h
diff options
context:
space:
mode:
authorDouglas Gilbert <dougg@torque.net>2006-09-20 18:20:49 -0400
committerJames Bottomley <jejb@mulgrave.il.steeleye.com>2006-09-26 12:23:15 -0400
commit6460e75a104d10458817d2f5b2fbff775bf0b43a (patch)
tree88e2a88aef94282728d1c764d02e5efa7ef7fee4 /include/scsi/sg.h
parent8aee918a1cff2a3722ce76fc6fa5abe09aa98d1b (diff)
[SCSI] sg: fixes for large page_size
This sg driver patch addresses the problem with larger page sizes reported by Brian King in this post: http://marc.theaimsgroup.com/?l=linux-scsi&m=115867718623631&w=2 Some other related matters are also addressed. Some of these prevent oopses when the SG_SCATTER_SZ or scatter_elem_sz are set to inappropriate values. The scatter_elem_sz has been tested up to 4 MB which should make the largest data transfer with one SCSI command, 32 MB less one block, achievable with a relatively small number of elements in the scatter gather list. ChangeLog: - add scatter_elem_sz boot time parameter and sysfs module parameter that is initialized to SG_SCATTER_SZ - the driver will then adjust scatter_elem_sz to be the max(given(scatter_elem_sz), PAGE_SIZE) It will also round it up, if necessary, to be a power of two - clean up sg.h header, correct bad urls and some statements that are no longer valid - make the def_reserved_size sysfs module attribute writable Signed-off-by: Douglas Gilbert <dougg@torque.net> Signed-off-by: James Bottomley <James.Bottomley@SteelEye.com>
Diffstat (limited to 'include/scsi/sg.h')
-rw-r--r--include/scsi/sg.h61
1 files changed, 21 insertions, 40 deletions
diff --git a/include/scsi/sg.h b/include/scsi/sg.h
index 0a487fe26d4f..519c49a0fc11 100644
--- a/include/scsi/sg.h
+++ b/include/scsi/sg.h
@@ -11,26 +11,10 @@
11Original driver (sg.h): 11Original driver (sg.h):
12* Copyright (C) 1992 Lawrence Foard 12* Copyright (C) 1992 Lawrence Foard
13Version 2 and 3 extensions to driver: 13Version 2 and 3 extensions to driver:
14* Copyright (C) 1998 - 2003 Douglas Gilbert 14* Copyright (C) 1998 - 2006 Douglas Gilbert
15 15
16 Version: 3.5.29 (20030529) 16 Version: 3.5.34 (20060920)
17 This version is for 2.5 series kernels. 17 This version is for 2.6 series kernels.
18
19 Changes since 3.5.28 (20030308)
20 - fix bug introduced in version 3.1.24 (last segment of sgat list)
21 Changes since 3.5.27 (20020812)
22 - remove procfs entries: hosts, host_hdr + host_strs (now in sysfs)
23 - add sysfs sg driver params: def_reserved_size, allow_dio, version
24 - new boot option: "sg_allow_dio" and module parameter: "allow_dio"
25 - multiple internal changes due to scsi subsystem rework
26 Changes since 3.5.26 (20020708)
27 - re-add direct IO using Kai Makisara's work
28 - re-tab to 8, start using C99-isms
29 - simplify memory management
30 Changes since 3.5.25 (20020504)
31 - driverfs additions
32 - copy_to/from_user() fixes [William Stinson]
33 - disable kiobufs support
34 18
35 For a full changelog see http://www.torque.net/sg 19 For a full changelog see http://www.torque.net/sg
36 20
@@ -40,7 +24,7 @@ Map of SG verions to the Linux kernels in which they appear:
40 2.1.40 2.2.20 24 2.1.40 2.2.20
41 3.0.x optional version 3 sg driver for 2.2 series 25 3.0.x optional version 3 sg driver for 2.2 series
42 3.1.17++ 2.4.0++ 26 3.1.17++ 2.4.0++
43 3.5.23++ 2.5.0++ 27 3.5.30++ 2.6.0++
44 28
45Major new features in SG 3.x driver (cf SG 2.x drivers) 29Major new features in SG 3.x driver (cf SG 2.x drivers)
46 - SG_IO ioctl() combines function if write() and read() 30 - SG_IO ioctl() combines function if write() and read()
@@ -51,14 +35,15 @@ Major new features in SG 3.x driver (cf SG 2.x drivers)
51 data into kernel buffers and then use the CPU to copy the data into the 35 data into kernel buffers and then use the CPU to copy the data into the
52 user space (vice versa for writes). That is called "indirect" IO due to 36 user space (vice versa for writes). That is called "indirect" IO due to
53 the double handling of data. There are two methods offered to remove the 37 the double handling of data. There are two methods offered to remove the
54 redundant copy: 1) direct IO which uses the kernel kiobuf mechanism and 38 redundant copy: 1) direct IO and 2) using the mmap() system call to map
55 2) using the mmap() system call to map the reserve buffer (this driver has 39 the reserve buffer (this driver has one reserve buffer per fd) into the
56 one reserve buffer per fd) into the user space. Both have their advantages. 40 user space. Both have their advantages.
57 In terms of absolute speed mmap() is faster. If speed is not a concern, 41 In terms of absolute speed mmap() is faster. If speed is not a concern,
58 indirect IO should be fine. Read the documentation for more information. 42 indirect IO should be fine. Read the documentation for more information.
59 43
60 ** N.B. To use direct IO 'echo 1 > /proc/scsi/sg/allow_dio' may be 44 ** N.B. To use direct IO 'echo 1 > /proc/scsi/sg/allow_dio' or
61 needed. That pseudo file's content is defaulted to 0. ** 45 'echo 1 > /sys/module/sg/parameters/allow_dio' is needed.
46 That attribute is 0 by default. **
62 47
63 Historical note: this SCSI pass-through driver has been known as "sg" for 48 Historical note: this SCSI pass-through driver has been known as "sg" for
64 a decade. In broader kernel discussions "sg" is used to refer to scatter 49 a decade. In broader kernel discussions "sg" is used to refer to scatter
@@ -72,20 +57,17 @@ Major new features in SG 3.x driver (cf SG 2.x drivers)
72 http://www.torque.net/sg/p/sg_v3_ho.html 57 http://www.torque.net/sg/p/sg_v3_ho.html
73 This is a rendering from DocBook source [change the extension to "sgml" 58 This is a rendering from DocBook source [change the extension to "sgml"
74 or "xml"]. There are renderings in "ps", "pdf", "rtf" and "txt" (soon). 59 or "xml"]. There are renderings in "ps", "pdf", "rtf" and "txt" (soon).
60 The SG_IO ioctl is now found in other parts kernel (e.g. the block layer).
61 For more information see http://www.torque.net/sg/sg_io.html
75 62
76 The older, version 2 documents discuss the original sg interface in detail: 63 The older, version 2 documents discuss the original sg interface in detail:
77 http://www.torque.net/sg/p/scsi-generic.txt 64 http://www.torque.net/sg/p/scsi-generic.txt
78 http://www.torque.net/sg/p/scsi-generic_long.txt 65 http://www.torque.net/sg/p/scsi-generic_long.txt
79 A version of this document (potentially out of date) may also be found in 66 Also available: <kernel_source>/Documentation/scsi/scsi-generic.txt
80 the kernel source tree, probably at:
81 Documentation/scsi/scsi-generic.txt .
82 67
83 Utility and test programs are available at the sg web site. They are 68 Utility and test programs are available at the sg web site. They are
84 bundled as sg_utils (for the lk 2.2 series) and sg3_utils (for the 69 packaged as sg3_utils (for the lk 2.4 and 2.6 series) and sg_utils
85 lk 2.4 series). 70 (for the lk 2.2 series).
86
87 There is a HOWTO on the Linux SCSI subsystem in the lk 2.4 series at:
88 http://www.linuxdoc.org/HOWTO/SCSI-2.4-HOWTO
89*/ 71*/
90 72
91 73
@@ -238,13 +220,12 @@ typedef struct sg_req_info { /* used by SG_GET_REQUEST_TABLE ioctl() */
238#define SG_GET_ACCESS_COUNT 0x2289 220#define SG_GET_ACCESS_COUNT 0x2289
239 221
240 222
241#define SG_SCATTER_SZ (8 * 4096) /* PAGE_SIZE not available to user */ 223#define SG_SCATTER_SZ (8 * 4096)
242/* Largest size (in bytes) a single scatter-gather list element can have. 224/* Largest size (in bytes) a single scatter-gather list element can have.
243 The value must be a power of 2 and <= (PAGE_SIZE * 32) [131072 bytes on 225 The value used by the driver is 'max(SG_SCATTER_SZ, PAGE_SIZE)'.
244 i386]. The minimum value is PAGE_SIZE. If scatter-gather not supported 226 This value should be a power of 2 (and may be rounded up internally).
245 by adapter then this value is the largest data block that can be 227 If scatter-gather is not supported by adapter then this value is the
246 read/written by a single scsi command. The user can find the value of 228 largest data block that can be read/written by a single scsi command. */
247 PAGE_SIZE by calling getpagesize() defined in unistd.h . */
248 229
249#define SG_DEFAULT_RETRIES 0 230#define SG_DEFAULT_RETRIES 0
250 231