如何向SCSI设备0xF应用客户端日志页写入自定义数据?
根据《SCSI命令参考手册》记载,多数SCSI设备预留了自定义日志存储区域,即0xF页(应用客户端日志页),目前正在寻找向该区域写入数据的方法。
最初尝试使用sg_logs命令完成写入操作,但未成功。目前无法定位问题根源:不确定是命令参数传递有误,还是发送的报文内容不符合要求。sg_logs的man手册中对该场景的说明为:
The Application Client log page has 64 log parameters with parameters codes 0 to 63.
Each can hold 252 bytes of user binary data. That 252 bytes (or less) of user data, with
a 4 byte prefix (for a total of 256 bytes) can be provided with the--in=FNoption. A
typical prefix would be0,n,83,fc. The "n" is the parameter code in hex so the last log
parameter would be0,3f,83,fc. That log parameter could be read back at some later
time with--page=0xf --filter=0x<n>.
实际执行的命令如下:
sg_logs --in=- --page=0xf --select /dev/sda -s -vvv 0 0 83 fc aa bb cc dd
其中aa bb cc dd是计划写入日志页的目标内容。
命令执行后返回如下输出,无法直接定位故障原因:
open /dev/sda with flags=0x802 inquiry cdb: 12 00 00 00 24 00 duration=0 ms HGST HUH721212AL5204 C3D0 log select cdb: 4c 01 4f 00 00 00 00 00 08 00 log select parameter list 00 00 83 fc aa bb cc dd duration=2 ms log select: Descriptor format, current; Sense key: Illegal Request Additional sense: Invalid field in cdb Descriptor type: Sense key specific: Field pointer: Error in Command: byte 2 bit 5 Descriptor type: Field replaceable unit code: 0x0 Descriptor type: Vendor specific [0x80] f8 23 Raw sense data (in hex): 72 05 24 00 00 00 00 10 02 06 00 00 cd 00 02 00 03 02 00 00 80 02 f8 23
从报错信息判断,需要深入理解SCSI设备通信机制以及*CDB(命令描述符块)*的构造方式,但手头参考的《SCSI命令参考手册》对相关内容的描述过于泛化,无法明确问题排查方向,希望能获得相关的参考信息。
内容的提问来源于stack exchange,提问作者gtristan

