sg 驱动程序在 /proc/scsi/sg 目录中提供了关于 SCSI 子系统和 sg 驱动程序当前内部状态的信息。超级用户可以通过向这些 “伪” 文件写入值来更改一些 sg 驱动程序的默认设置[1]。
以下文件对所有人都是可读的
allow_dio 0 indicates direct IO disable, 1 for enabled debug debug information including active request data def_reserved_size default buffer size reserved for each file descriptor devices one line of numeric data per device device_hdr single line of column names corresponding to 'devices' device_strs one line of vendor, product and rev info per device hosts one line of numeric data per host host_hdr single line of column names corresponding to 'hosts' host_strs one line of host information (string) per host version sg version as a number followed by a string representation |
“devices” 和 “device_strs” 中的每一行都对应于一个 sg 设备。例如,第一行对应于/dev/sg0。行号(从 0 开始)也对应于 sg 次设备号。此映射是 sg 本地的,通常与 cat /proc/scsi/scsi 命令报告的 SCSI 中间层驱动程序给出的映射相同。当使用 “remove-single-device” 和 “add-single-device” 时,这两个映射可能会有所不同(有关更多信息,请参见 SCSI-2.4-HOWTO)。
“hosts” 和 “host_strs” 中的每一行都对应于一个 SCSI 主机。例如,第一行对应于通常表示为 “scsi0” 的主机。此映射在整个 SCSI 子系统中是不变的。[因此,这些条目可以说可以迁移到中间层。]
“device_hdr” 中的列标题如下所示。如果设备不存在(并且在其后存在一个设备),则会输出一行 “-1” 条目。每个条目之间用空格分隔(目前是制表符)
host host number (indexes 'hosts' table, origin 0) chan channel number of device id SCSI id of device lun Logical Unit number of device type SCSI type (e.g. 0->disk, 5->cdrom, 6->scanner) opens number of opens (by sd, sr, sr and sg) at this time depth maximum queue depth supported by device busy number of commands being processed by host for this device online 1 indicates device is in normal online state, 0->offline |
“host_hdr” 中的列标题如下所示。每个条目之间用空格分隔(目前是制表符)
uid unique id (non-zero if multiple hosts of same type) busy number of commands being processed for this host cpl maximum number of command per lun (may be 0 if "device depth" is given sgat maximum elements of scatter gather the adapter (pseudo) DMA can accommodate isa 0 -> non-ISA adapter, 1 -> ISA adapter. ISA adapters are assumed to have a 24 bit address bus limit (16 MB). emu 0 -> real SCSI adapter, 1 -> emulated SCSI adapter (e.g. ide-scsi device driver) |
“def_reserved_size” 既是可读的又是可写的。它只能由 root 用户写入。它被初始化为 “sg.h” 文件中 DEF_RESERVED_SIZE 的值。接受 0 到 1048576(即 2 ** 20)之间的值,并且可以使用以下语法从命令行设置
$ echo "262144" > /proc/scsi/sg/def_reserved_size |
“allow_dio” 既是可读的又是可写的。它只能由 root 用户写入。当它为 0(默认值)时,任何执行直接 IO 的请求(即通过设置 SG_FLAG_DIRECT_IO)都将被忽略,而将改为执行间接 IO。
[1] | 一个奇怪的特性是/proc/scsi/sg目录在没有 SCSI 设备(或伪设备,例如 USB 大容量存储)连接到系统时不会出现。原因是,在没有 SCSI 设备的情况下,SCSI 中间层不会初始化 sg 驱动程序(即使它已作为模块加载)。当 sg 驱动程序是一个模块并且 rmmod sg 成功执行时,/proc/scsi/sg目录及其内容将被删除。 |