Test linux SCSI-Persistent-Reservation (SPC-3)

Because brain-split, zfs will corrupt

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
$ which genhostid
/usr/sbin/genhostid
$ rpm -qf /usr/sbin/genhostid
initscripts-9.49.37-1.el7.x86_64

A $ genhostid
B $ genhostid
A $ sg_persist --out --register --param-sark=$(hostid) -d /dev/mapper/35000cca2515f34c4
HGST HUH721010AL5200 A21D
Peripheral device type: disk

B $ sg_persist --out --register --param-sark=$(hostid) -d /dev/mapper/35000cca2515f34c4
# reserve operate
B $ sg_persist --out --reserve --param-rk=0x$(hostid) --prout-type=1 /dev/mapper/35000cca2515f34c4

B $ sg_persist --in -r --no-inquiry -d /dev/mapper/35000cca2515f34c4
PR generation=0x5c, Reservation follows:
Key=0x7819de15
scope: LU_SCOPE, type: Write Exclusive

A $ dd if=/dev/zero of=/dev/mapper/35000cca2515f34c4 bs=1M count=10 oflag=sync
dd: error writing ‘/dev/mapper/35000cca2515f34c4’: Input/output error
1+0 records in
0+0 records out
0 bytes (0 B) copied, 0.0273762 s, 0.0 kB/s

B $ dd if=/dev/zero of=/dev/mapper/35000cca2515f34c4 bs=1M count=10 oflag=sync
10+0 records in
10+0 records out
10485760 bytes (10 MB) copied, 0.145223 s, 72.2 MB/s

# get the reservation
A $ sg_persist -n -o -A -d /dev/mapper/35000cca2515f34c4 -K $(hostid) -S 0x7819de15 -T 1 -v
Persistent Reservation Out cmd: 5f 05 01 00 00 00 00 00 18 00
PR out: command (Preempt and abort) successful

A $ sg_persist --in -r --no-inquiry -d /dev/mapper/35000cca2515f34c4
PR generation=0x5d, Reservation follows:
Key=0x77f7c343
scope: LU_SCOPE, type: Write Exclusivea

A $ dd if=/dev/zero of=/dev/mapper/35000cca2515f34c4 bs=1M count=10 oflag=sync
10+0 records in
10+0 records out
10485760 bytes (10 MB) copied, 0.142939 s, 73.4 MB/s

B $ dd if=/dev/zero of=/dev/mapper/35000cca2515f34c4 bs=1M count=10 oflag=sync
dd: error writing ‘/dev/mapper/35000cca2515f34c4’: Input/output error
1+0 records in
0+0 records out
0 bytes (0 B) copied, 0.0139251 s, 0.0 kB/s

B $ sg_persist -n -o -A -d /dev/mapper/35000cca2515f34c4 -K $(hostid) -S 0x77f7c343 -T 1 -v
Persistent Reservation Out cmd: 5f 05 01 00 00 00 00 00 18 00
PR out: command (Preempt and abort) successful

B $ dd if=/dev/zero of=/dev/mapper/35000cca2515f34c4 bs=1M count=10 oflag=sync
10+0 records in
10+0 records out
10485760 bytes (10 MB) copied, 0.149629 s, 70.1 MB/s

A $ dd if=/dev/zero of=/dev/mapper/35000cca2515f34c4 bs=1M count=10 oflag=sync
dd: error writing ‘/dev/mapper/35000cca2515f34c4’: Input/output error
1+0 records in
0+0 records out
0 bytes (0 B) copied, 0.0207658 s, 0.0 kB/s

Prout-type

1
2
3
4
5
6
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

Release reservation

1
2
3
4
5
$ sg_persist --out --release -K $(hostid) --prout-type=1 /dev/mapper/35000cca2515f34c4
HGST HUH721010AL5200 A21D
Peripheral device type: disk
$ sg_persist --in -r --no-inquiry -d /dev/mapper/35000cca2515f34c4
PR generation=0x5f, there is NO reservation held

Unregister key

1
2
3
4
5
$ sg_persist --out --register -K $(hostid) -d /dev/mapper/35000cca2515f34c4
HGST HUH721010AL5200 A21D
Peripheral device type: disk
$ sg_persist --in -k --no-inquiry -d /dev/mapper/35000cca2515f34c4
PR generation=0x60, there are NO registered reservation keys

Force mode ?

It releases the persistent reservation (if any) and clears all registrations from the device

1
$ sg_persist --out --clear -K $(hostid) /dev/mapper/35000cca2515f34c4

About multipath

1
2
no_path_retry queue
features "0"

How can I view create and remove scsi
Target_Core_Mod
Support for persistent reservations
SAP HANA Fiber Channel Storage Connector Admin Guide