1SG_RBUF(8) SG3_UTILS SG_RBUF(8)
2
3
4
6 sg_rbuf - reads data using SCSI READ BUFFER command
7
9 sg_rbuf [--buffer=EACH] [--dio] [--help] [--mmap] [--quick]
10 [--size=OVERALL] [--test] [--verbose] [--version] DEVICE
11
12 sg_rbuf [-b=EACH_KIB] [-d] [-m] [-q] [-s=OVERALL_MIB] [-t] [-v] [-V]
13 DEVICE
14
16 This command reads data with the SCSI READ BUFFER command and then dis‐
17 cards it. Typically the data being read is from a disk's memory cache.
18 It is assumed that the data is sourced quickly (although this is not
19 guaranteed by the SCSI standards) so that it is faster than reading
20 data from the media. This command is designed for timing transfer
21 speeds across a SCSI transport.
22
23 To fetch the data with a SCSI READ BUFFER command and optionally decode
24 it see the sg_read_buffer utility. There is also a sg_write_buffer
25 utility useful for downloading firmware amongst other things.
26
27 This utility supports two command line syntaxes, the preferred one is
28 shown first in the synopsis and explained in this section. A later sec‐
29 tion on the old command line syntax outlines the second group of
30 options.
31
33 Arguments to long options are mandatory for short options as well.
34
35 -b, --buffer=EACH
36 where EACH is the number of bytes to be transferred by each READ
37 BUFFER command. The default is the actual available buffer size
38 returned by the READ BUFFER (descriptor) command. The maximum is
39 the same as the default, hence this argument can only be used to
40 reduce the size of each transfer to less than the device's
41 actual available buffer size.
42
43 -d, --dio
44 use direct IO if available. This option is only available if the
45 DEVICE is a sg driver device node (e.g. /dev/sg1). In this case
46 the sg driver will attempt to configure the DMA from the SCSI
47 adapter to transfer directly into user memory. This will elimi‐
48 nate the copy via kernel buffers. If not available then this
49 will be reported and indirect IO will be done instead.
50
51 -h, --help
52 print usage message then exit.
53
54 -m, --mmap
55 use memory mapped IO if available. This option is only available
56 if the DEVICE is a sg driver device node (e.g. /dev/sg1). In
57 this case the sg driver will attempt to configure the DMA from
58 the SCSI adapter to transfer directly into user memory. This
59 will eliminate the copy via kernel buffers.
60
61 -O, --old
62 switch to older style options.
63
64 -q, --quick
65 only transfer the data into kernel buffers (typically by DMA
66 from the SCSI adapter card) and do not move it into the user
67 space. This option is only available if the DEVICE is a sg
68 driver device node (e.g. /dev/sg1).
69
70 -s, --size=OVERALL
71 where OVERALL is the size of total transfer in bytes. The
72 default is 200 MiB (200*1024*1024 bytes). The actual number of
73 bytes transferred may be slightly less than requested since all
74 transfers are the same size (and an integer division is involved
75 rounding towards zero).
76
77 -t, --time
78 times the bulk data transfer component of this command. The
79 elapsed time is printed out plus a MB/sec calculation. In this
80 case "MB" is 1,000,000 bytes. The gettimeofday() system call is
81 used internally for the time calculation.
82
83 -v, --verbose
84 increase level of verbosity. Can be used multiple times.
85
86 -V, --version
87 print out version string then exit.
88
90 This command is typically used on modern SCSI disks which have a RAM
91 cache in their drive electronics. If no IO to the magnetic media, or
92 slower devices like flash RAM, is involved then the disk may be able to
93 source data fast enough to saturate the bandwidth of the SCSI trans‐
94 port. The bottleneck may then be the DMA element in the HBA, the Linux
95 drivers or the host machine's hardware (e.g. speed of RAM).
96
97 EACH and OVERALL may include one of these multiplicative suffixes: c C
98 *1; w W *2; b B *512; k K KiB *1,024; KB *1,000; m M MiB *1,048,576; MB
99 *1,000,000 . This pattern continues for "G", "T" and "P". The latter
100 two suffixes can only be used for OVERALL. Also a suffix of the form
101 "x<n>" multiplies the leading number by <n>. These multiplicative suf‐
102 fixes are compatible with GNU's dd command (since 2002) which claims
103 compliance with SI and with IEC 60027-2.
104
106 On the test system /dev/sg0 corresponds to a fast disk on a U2W SCSI
107 bus (max 80 MB/sec). The disk specifications state that its cache is 4
108 MB.
109 $ time ./sg_rbuf /dev/sg0
110 READ BUFFER reports: buffer capacity=3434944,
111 offset boundary=6
112 Read 200 MiB (actual 199 MiB, 209531584 bytes),
113 buffer size=3354 KiB
114 real 0m5.072s, user 0m0.000s, sys 0m2.280s
115
116 So that is approximately 40 MB/sec at 40 % utilization. Now with the
117 addition of the "-q" option this throughput improves and the utiliza‐
118 tion drops to 0%.
119 $ time ./sg_rbuf -q /dev/sg0
120 READ BUFFER reports: buffer capacity=3434944,
121 offset boundary=6
122 Read 200 MiB (actual 199 MiB, 209531584 bytes),
123 buffer size=3354 KiB
124 real 0m2.784s, user 0m0.000s, sys 0m0.000s
125
127 The exit status of sg_rbuf is 0 when it is successful. Otherwise see
128 the sg3_utils(8) man page.
129
131 The options in this section were the only ones available prior to
132 sg3_utils version 1.23 . In sg3_utils version 1.23 and later these
133 older options can be selected by either setting the SG3_UTILS_OLD_OPTS
134 environment variable or using '--old' (or '-O) as the first option.
135
136 -b=EACH_KIB
137 where EACH_KIB is the number of Kilobytes (i.e. 1024 byte units)
138 to be transferred by each READ BUFFER command. Similar to the
139 --buffer=EACH option in the main description but the units are
140 different.
141
142 -d use direct IO if available. Equivalent to the --dio option in
143 the main description.
144
145 -m use memory mapped IO if available. Equivalent to the --mmap
146 option in the main description.
147
148 -N switch to the newer style options.
149
150 -q only transfer the data into kernel buffers (typically by DMA
151 from the SCSI adapter card) and do not move it into the user
152 space. Equivalent to the --quick option in the main descrip‐
153 tion.
154
155 -s=OVERALL_MIB
156 where OVERALL_MIB is the size of total transfer in Megabytes
157 (1048576 bytes). Similar to the --size=OVERALL option in the
158 main description but the units are different.
159
160 -t times the bulk data transfer component of this command. Equiva‐
161 lent to the --time option in the main description.
162
163 -v increase level of verbosity. Can be used multiple times.
164
165 -V print out version string then exit.
166
168 Written by Doug Gilbert
169
171 Report bugs to <dgilbert at interlog dot com>.
172
174 Copyright © 2000-2007 Douglas Gilbert
175 This software is distributed under the GPL version 2. There is NO war‐
176 ranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PUR‐
177 POSE.
178
180 sg_read_buffer, sg_write_buffer, sg_test_rwbuf(all in sg3_utils)
181
182
183
184sg3_utils-1.23 January 2007 SG_RBUF(8)