Sunday, 26 April 2015

How can I view, create, and remove SCSI persistent reservations and keys. from redhat

APPLIES TO:


Redhat Enterprise Linux 5, 6, 7
Oracle Enterprise Linux 5, 6, 7
SUSE Linux Enterprise Server 9,10, 11, 12

SYMPTOMS


Can't read/write to lun.
Can't join cluster.

Also you can see something like that in your dmesg:
[6902380.608058] sd 11:0:0:1: [sdc] tag#16 FAILED Result: hostbyte=DID_OK driverbyte=DRIVER_OK
[6902380.608060] sd 11:0:0:1: [sdc] tag#16 CDB: Read(10) 28 00 00 1f ff 80 00 00 08 00
[6902380.608061] blk_update_request: critical nexus error, dev sdc, sector 2097024
[6902380.608064] Buffer I/O error on dev sdc1, logical block 261872, async page read
[6902380.609007] sd 11:0:0:1: reservation conflict
[6902380.609011] sd 11:0:0:1: [sdc] tag#14 FAILED Result: hostbyte=DID_OK driverbyte=DRIVER_OK
[6902380.609013] sd 11:0:0:1: [sdc] tag#14 CDB: Read(10) 28 00 00 00 08 00 00 00 01 00
[6902380.609015] blk_update_request: critical nexus error, dev sdc, sector 2048
[6902380.609523] sd 11:0:0:1: reservation conflict
[6902380.609526] blk_update_request: critical nexus error, dev sdc, sector 0


Scsi persistent reservation, usualy used in cluster environment, it's allow scsi initiator to reserve LUN to exclusive access.

SOLUTION


Install sg3_utils package. (in case of SLES, use zypper)
# yum install sg3_utils


To view the keys registered on a LUN use the following command:
# sg_persist --in -k -d /dev/sdd

To view the reservations currently out on a device use the following command:
# sg_persist --in -r -d /dev/sdd

Keys are 6 or 8 digit HEX numbers. Key numbers can be arbitrary. For example 0xDEADBEEF or 0x123ABC To register a key on a LUN use the following command:
# sg_persist --out --register --param-sark=0xDEADBEEF /dev/sdd

You can take out a reservation on behalf of a key with the following command:
# sg_persist --out --reserve --param-rk=0xDEADBEEF --prout-type=1 /dev/sdd
The reservation types are defined in the SCSI Primary Commands spec. Here are the reservation types from the sg_persist manpage

1-> write exclusive
3-> exclusive access
5-> write exclusive - registrants only
6-> exclusive access - registrants only
7-> write exclusive - all registrants
8-> exclusive access - all registrants.



to  release a registration:

# sg_persist --out --release --param-rk=0xDEADBEEF  --prout-type=5 /dev/sdd

to unregister a key:

# sg_persist --out --register --param-rk=0xDEADBEEF  /dev/sdd

clear the reservation and all registered keys:

# sg_persist --out --clear --param-rk=0xDEADBEEF   /dev/sdd





No comments:

Post a Comment