如何在 Solaris 11 中读取和清除 SCSI 保留

本文描述 sg3_utils工具,并提供了一些使用 sg_persist 命令读取和清除 SCSI 保留的示例。
命令 sg_persist 发送 SCSI PERSISTENT RESERVE(IN 或者 OUT)命令来操作注册和保留。

更多: zhilu jiaocheng

安装和配置 sg3_utils

这些实用程序最初是为 Linux 环境开发的,默认情况下不会安装,但可以使用以下命令从 Solaris 11 存储库安装软件包:

# pkg install sg3_utils

可以在此处找到有关 sg3_utils 和所有工具/命令的完整信息:
http://sg.danny.cz/sg/sg3_utils.html

此外,此处记录了较新版本中包含的更改:
https://github.com/hreinecke/sg3_utils/blob/master/ChangeLog

sg_persist 实用程序用于发送 SCSI PERSISTENT RESERVE(IN 或者 OUT)命令以查询或者操作注册和保留。
下面列出了几个重要的参数。

-c, -report-capabilities

报告功能是 PRIN 命令的子命令。
它列出了有关设备支持的持久保留方面的信息。
例如:

# sg_persist --report-capabilities /dev/rdsk/c0t5000CCA0536DD628d0s2
HGST HSCAC2DA2SUN1.6T A29A
Peripheral device type: disk
Report capabilities response:
Compatible Reservation Handling(CRH): 0
Specify Initiator Ports Capable(SIP_C): 1
All Target Ports Capable(ATP_C): 1
Persist Through Power Loss Capable(PTPL_C): 1
Type Mask Valid(TMV): 1
Allow Commands: 0
Persist Through Power Loss Active(PTPL_A): 1
Support indicated in Type mask:
Write Exclusive, all registrants: 0
Exclusive Access, registrants only: 1
Write Exclusive, registrants only: 1
Exclusive Access: 1
Write Exclusive: 1
Exclusive Access, all registrants: 0

-k, -read-keys

Read Keys 是 PRIN 命令的子命令。
列出使用给定 SCSI 设备注册(即注册)的所有保留密钥。
例如:

# sg_persist --read-keys /dev/rdsk/c0t5000CCA0536DD628d0s2
HGST HSCAC2DA2SUN1.6T A29A
Peripheral device type: disk
PR generation=0x9, 1 registered reservation key follows:
0x59ee067a00000001

-r, -read-reservation

Read Reservation 是 PRIN 命令的子命令。
在设备上列出有关当前预订持有者的信息。
如果当前没有预订,则会注明。
保留当前持有者的信息包括其保留键、范围和类型。
例如:

# sg_persist --read-reservation /dev/rdsk/c0t5000CCA0536DD628d0s2
HGST HSCAC2DA2SUN1.6T A29A
Peripheral device type: disk
PR generation=0x9, Reservation follows:
Key=0x59ee067a00000001
scope: LU_SCOPE, type: Write Exclusive, registrants only

-C, -clear

clear 是 PROUT 命令的子命令。
它释放持久保留(如果有)并清除设备中的所有注册。
需要提供为此 I_T_L 关系注册的保留密钥(由 -param-rk=RK 标识)。
例如:

# sg_persist --clear --param-rk=0x59ee067a00000001 /dev/rdsk/c0t5000CCA0536DD628d0s2
日期:2020-09-17 00:15:12 来源:oir作者:oir