aboutsummaryrefslogtreecommitdiff
path: root/sg_rbuf.8
blob: 4ef569997079d4ba11defcb936225ec1018918e5 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
.TH SG_RBUF "8" "October 2006" "sg3_utils-1.22" SG3_UTILS
.SH NAME
sg_rbuf \- reads data using SCSI READ BUFFER command
.SH SYNOPSIS
.B sg_rbuf
[\fI-b=<num_KiB>\fR] [\fI-d\fR] [\fI-m\fR] [\fI-q\fR]
[\fI-s=<num_MiB>\fR] [\fI-t\fR] [\fI-v\fR] [\fI-V\fR] \fI<scsi_device>\fR
.SH DESCRIPTION
.\" Add any additional description here
.PP
This command reads data with the SCSI READ BUFFER command
and then discards it. Typically the data being read is from
a disk's memory cache. It is assumed that the data
is sourced quickly (although this is not guaranteed by the SCSI
standards) so that it is faster than reading data from the
media. This command is designed for timing transfer speeds
across a SCSI transport.
.TP
-b=<num_KiB>
size of each transfer (in Kilobytes == 1024). The default is
the actual available buffer size returned by the READ
BUFFER (descriptor) command. The maximum is the same as the
default, hence this argument can only be used to reduce the size
of each transfer to less than the device's actual available buffer
size.
.TP
-d
use direct IO if available. This option is only available if
the given device is a sg driver device node (e.g. /dev/sg1).
In this case the sg driver will attempt
to configure the DMA from the SCSI adapter to transfer directly
into user memory. This will eliminate the copy via kernel buffers.
If not available then this will be reported and indirect IO will
be done instead.
.TP
-m
use memory mapped IO if available. This option is only available if
the given device is a sg driver device node (e.g. /dev/sg1).
In this case the sg driver will attempt
to configure the DMA from the SCSI adapter to transfer directly
into user memory. This will eliminate the copy via kernel buffers.
.TP
-q
only transfer the data into kernel buffers (typically by DMA from
the SCSI adapter card) and do not move it into the user space.
This option is only available if the given device is a sg driver
device node (e.g. /dev/sg1).
.TP
-s=<num_MiB>
size of total transfer (in Megabytes == 1024^2). The default is
200 MiB, the maximum is 4095 MiB. The actual number of bytes
transferred may be slightly less since all transfers are the
same size (and an integer division is involved rounding towards zero).
.TP
-t
times the bulk data transfer component of this command. The elapsed time
is printed out plus a MB/sec calculation. In this case "MB" is 1,000,000
bytes. The gettimeofday() system call is used internally for the time
calculation.
.TP
-v
increase level of verbosity (print out SCSI command bytes before
executing it). '-vv' and '-vvv' are also accepted yielding greater
verbosity.
.TP
-V
print out version string then exit.
.PP
This command is typically used on modern SCSI disks which have
a RAM cache on their drive electronics. If no IO to the magnetic
media, or slower devices like flash RAM, is involved then
the disk may be able to source data fast enough to saturate
the bandwidth of the SCSI transport. The bottleneck may then be
the DMA element in the HBA, the Linux drivers or the host machine's
hardware (e.g. speed of RAM).
.SH EXAMPLES
.PP
On the test system /dev/sg0 corresponds to a fast disk
on a U2W SCSI bus (max 80 MB/sec). The disk specifications
state that its cache is 4 MB.
.br
   $ time ./sg_rbuf /dev/sg0
.br
READ BUFFER reports: buffer capacity=3434944,
.br
    offset boundary=6
.br
Read 200 MiB (actual 199 MiB, 209531584 bytes),
.br
    buffer size=3354 KiB
.br
real 0m5.072s, user 0m0.000s, sys 0m2.280s
.PP
So that is approximately 40 MB/sec at 40 % utilization. Now with
the addition of the "-q" option this throughput improves and the
utilization drops to 0%.
.br
   $ time ./sg_rbuf -q /dev/sg0
.br
READ BUFFER reports: buffer capacity=3434944,
.br
    offset boundary=6
.br
Read 200 MiB (actual 199 MiB, 209531584 bytes),
.br
    buffer size=3354 KiB
.br
real 0m2.784s, user 0m0.000s, sys 0m0.000s
.SH EXIT STATUS
The exit status of sg_rbuf is 0 when it is successful. Otherwise see
the sg3_utils(8) man page.
.SH AUTHOR
Written by Doug Gilbert
.SH "REPORTING BUGS"
Report bugs to <dgilbert at interlog dot com>.
.SH COPYRIGHT
Copyright \(co 2000-2006 Douglas Gilbert
.br
This software is distributed under the GPL version 2. There is NO
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
.SH "SEE ALSO"
.B sg_test_rwbuf(sg3_utils)