1SG_PERSIST(8)                      SG3_UTILS                     SG_PERSIST(8)
2
3
4

NAME

6       sg_persist  -  use  SCSI PERSISTENT RESERVE command to access registra‐
7       tions and reservations
8

SYNOPSIS

10       sg_persist [OPTIONS] DEVICE
11
12       sg_persist [OPTIONS] --device=DEVICE
13
14       sg_persist --help | --version
15

DESCRIPTION

17       This utility allows Persistent reservations  and  registrations  to  be
18       queried  and  changed.  Persistent  reservations  and registrations are
19       queried by sub-commands (called "service actions" in SPC-4) of the SCSI
20       PERSISTENT  RESERVE IN (PRIN) command. Persistent reservations and reg‐
21       istrations are changed by sub-commands of the SCSI  PERSISTENT  RESERVE
22       OUT (PROUT) command.
23
24       There  is a two stage process to obtain a persistent reservation. First
25       an application (an I_T nexus in  standard's  jargon)  must  register  a
26       reservation  key.  If  that  is  accepted (and it should be unless some
27       other I_T nexus has registered that key) then the application  can  try
28       and  reserve the device.  The reserve operation must specify the reser‐
29       vation key and a "type" (see the --prout-type=TYPE option).
30
31       It is relatively safe to query the state of Persistent reservations and
32       registrations.  With  no options this utility defaults to the READ KEYS
33       sub-command of the PRIN  command.  Other  PRIN  sub-commands  are  READ
34       RESERVATION, REPORT CAPABILITIES and READ FULL STATUS.
35
36       Before trying to change Persistent reservations and registrations users
37       should be aware of what they are doing. The relevant  sections  of  the
38       SCSI  Primary  Commands document (i.e. SPC-4 whose most recent draft is
39       revision 20 dated 22 May  2009)  are  sections  5.7  (titled  "Reserva‐
40       tions"),  6.13 (for the PRIN command) and 6.14 (for the PROUT command).
41       To safeguard against accidental use, the --out  option  must  be  given
42       when a PROUT sub-command (e.g.  --register) is used.
43
44       The  older  SCSI RESERVE and RELEASE commands (both 6 and 10 byte vari‐
45       ants) are not supported by this utility. In SPC-3, RESERVE and  RELEASE
46       are  deprecated,  replaced  by  Persistent  Reservations.  RESERVE  and
47       RELEASE have been removed from SPC-4 and Annex B  is  provided  showing
48       how to convert to persistent reservation commands. See a utility called
49       'scsires' for support of the SCSI RESERVE and RELEASE commands.
50
51       The DEVICE is required by all  variants  of  this  utility  apart  from
52       --help.  The  DEVICE  can be given either as an argument (typically but
53       not necessarily the last one) or via the --device=DEVICE option.
54
55       SPC-4 does not use the term "sub-command". It uses  the  term  "service
56       action"  for this and for part of a field's name in the parameter block
57       associated with the PROUT command  (i.e.  "service  action  reservation
58       key").  To  lessen  the  potential confusion the term "sub-command" has
59       been introduced.
60

OPTIONS

62       Arguments to long options are mandatory for short options as well.  The
63       following options are sorted in alphabetical order, based on their long
64       option name.
65
66       -l, --alloc-length=LEN
67              specify the allocation length of the PRIN command. LEN is a  hex
68              value.   By default this value is set to the size of the data-in
69              buffer (8192).  This parameter is of use for  verification  that
70              response to PRIN commands with various allocation lengths is per
71              section 4.3.5.6 of SPC-4 revision  18.   Valid  LEN  values  are
72              0-8192.
73
74       -C, --clear
75              Clear  is  a  sub-command  of the PROUT command. It releases the
76              persistent reservation (if any)  and  clears  all  registrations
77              from the device. It is required to supply a reservation key that
78              is   registered   for   this   I_T_L   nexus   (identified    by
79              --param-rk=RK).
80
81       -d, --device=DEVICE
82              DEVICE  to  send SCSI commands to. The DEVICE can either be pro‐
83              vided via this option or via a freestanding argument. For  exam‐
84              ple,  these  two: 'sg_persist --device=/dev/sg2' and 'sg_persist
85              /dev/sg2' are equivalent.
86
87       -h, --help
88              output a usage message.
89
90       -H, --hex
91              the response to a valid PRIN sub-command will be output in hexa‐
92              decimal.   By  default  (i.e.  without  this option) if the PRIN
93              sub-command is recognised then the response will be  decoded  as
94              per SPC-4.
95
96       -i, --in
97              specify  that  a SCSI PERSISTENT RESERVE IN command is required.
98              This is the default.
99
100       -n, --no-inquiry
101              the default action is to do a standard SCSI INQUIRY command  and
102              output  make,  product  and revision strings plus the peripheral
103              device type prior to executing a PRIN  or  PROUT  command.  With
104              this option the INQUIRY command is skipped.
105
106       -o, --out
107              specify that a SCSI PERSISTENT RESERVE OUT command is required.
108
109       -Y, --param-alltgpt
110              set  the  'all  target  ports' (ALL_TG_PT) flag in the parameter
111              block of the PROUT command. Only  relevant  for  'register'  and
112              'register and ignore existing key' sub-commands.
113
114       -Z, --param-aptpl
115              set  the  'activate  persist through power loss' (APTPL) flag in
116              the parameter block of the PROUT command. Relevant  for  'regis‐
117              ter', 'register and ignore existing key' and 'register and move'
118              sub-commands.
119
120       -K, --param-rk=RK
121              specify the reservation key found in the parameter block of  the
122              PROUT  command.  RK  is  assumed to be hex (up to 8 bytes long).
123              Default value is 0. This option is needed by most PROUT sub-com‐
124              mands.
125
126       -S, --param-sark=SARK
127              specify  the service action reservation key found in the parame‐
128              ter block of the PROUT command. SARK is assumed to be hex (up to
129              8  bytes  long).   Default  value is 0. This option is needed by
130              some PROUT sub-commands.
131
132       -P, --preempt
133              Preempt is a sub-command of  the  PROUT  command.  Preempts  the
134              existing      persistent      reservation     (identified     by
135              --param-sark=SARK) with the registration key that is  registered
136              for  this  I_T_L  nexus  (identified by --param-rk=RK). If a new
137              reservation is establised as a result of the preemption then the
138              supplied  --prout-type=TYPE  is  used  as  the type for this new
139              reservation.
140
141       -A, --preempt-abort
142              Preempt and Abort is a sub-command of the  PROUT  command.  Pre‐
143              empts   the   existing  persistent  reservation  (identified  by
144              --param-sark=SARK) with the registration key that is  registered
145              for  this  I_T_L  nexus  (identified by --param-rk=RK). If a new
146              reservation is establised as a result of the preemption then the
147              supplied  --prout-type=TYPE  is  used  as  the type for this new
148              reservation. ACA and other pending tasks are aborted.
149
150       -T, --prout-type=TYPE
151              specify the PROUT command's 'type'  argument.  Required  by  the
152              'register-move',  'reserve', 'release' and 'preempt (and abort)'
153              sub-commands. Valid TYPE values: 1-> write exclusive, 3-> exclu‐
154              sive  access, 5-> write exclusive - registrants only, 6-> exclu‐
155              sive access - registrants only, 7-> write exclusive - all regis‐
156              trants, 8-> exclusive access - all registrants. Default value is
157              0 (which is an invalid type). Each "persistent reservation type"
158              is  explained in more detail in a subsection of that name in the
159              read reservation section of the PRIN command  (section  6.13.3.4
160              of SPC-4 revision 9).
161
162       -s, --read-full-status
163              Read  Full Status is a sub-command of the PRIN command. For each
164              registration with the given SCSI device, it lists  the  reserva‐
165              tion  key  and associated information. TransportIDs, if supplied
166              in the response, are decoded.
167
168       -k, --read-keys
169              Read Keys is a sub-command of the PRIN command.  Lists  all  the
170              reservation  keys registered (i.e. registrations) with the given
171              SCSI device. This is the default sub-command for the  SCSI  PRIN
172              command.
173
174       -r, --read-reservation
175              Read  Reservation  is  a  sub-command  of the PRIN command. List
176              information about the current holder of the reservation  on  the
177              DEVICE.  If  there is no current reservation this will be noted.
178              Information about the current holder of the reservation includes
179              its reservation key, scope and type.
180
181       -s, --read-status
182              same as --read-full-status.
183
184       -G, --register
185              Register is a sub-command of the PROUT command. It has 3 differ‐
186              ent actions depending on associated parameters.  a)  add  a  new
187              registration with '--param-rk=0' and '--param-sark=<new_rk>'; b)
188              Change an existing registration with  '--param-rk=<old_rk>'  and
189              '--param-sark=<new_rk>';  or  c) Delete an existing registration
190              with '--param-rk=<old_rk>' and '--param-sark=0'.
191
192       -I, --register-ignore
193              Register and Ignore Existing Key is a sub-command of  the  PROUT
194              command.   Similar  to  --register  except  that when changing a
195              reservation  key   the   old   key   is   not   specified.   The
196              '--param-sark=<new_rk>' option should also be given.
197
198       -M, --register-move
199              register  (another  initiator) and move (the reservation held by
200              the current initiator to that other initiator) is a  sub-command
201              of  the PROUT command.  It requires the transportID of the other
202              initiator. [The standard uses the term I_T nexus but  the  point
203              to stress is that there are two initiators (the one sending this
204              command and another  one)  but  only  one  logical  unit.]   The
205              --prout-type=TYPE  and  --param-rk=RK options need to match that
206              of the existing reservation while --param-sark=SARK option spec‐
207              ifies  the  reservation key of the new (i.e. destination) regis‐
208              tration.
209
210       -Q, --relative-target-port=RTPI
211              relative target port identifier that reservation is to be  moved
212              to  by PROUT 'register and move' sub-command. RTPI is assumed to
213              be hex in the range 0 to ffff inclusive. Defaults to 0 .
214
215       -L, --release
216              Release is a sub-command of the PROUT command. It  releases  the
217              current   persistent   reservation.  The  --prout-type=TYPE  and
218              --param-rk=RK options, matching the reservation,  must  also  be
219              specified.
220
221       -c, --report-capabilities
222              Report  Capabilities  is  a  sub-command of the PRIN command. It
223              lists information about the aspects of  persistent  reservations
224              that the DEVICE supports.
225
226       -R, --reserve
227              Reserve  is a sub-command of the PROUT command. It creates a new
228              persistent reservation (if permitted). The --prout-type=TYPE and
229              --param-rk=RK options must also be specified.
230
231       -X, --transport-id=TIDS
232              The  TIDS  argument  can  take one of several forms. It can be a
233              comma (or single space) separated list of ASCII hex bytes repre‐
234              senting  a single TransportID as defined in SPC-4. They are usu‐
235              ally 24 bytes long apart from in iSCSI. The TIDS argument may be
236              a  transport  specific  form  (e.g. "sas,5000c50005b32001"). The
237              TIDS argument may be "-" in which case one or more  TransportIDs
238              can  be  read  from stdin.  The TIDS argument may be of the form
239              "file=<name>" in which case one or more TransportIDs can be read
240              from a file called <name>. See the "TRANSPORT IDs" section below
241              for more information.
242
243       -U, --unreg
244              optional  when  the  PROUT  register  and  move  sub-command  is
245              invoked.  If given it will unregister the current initiator (I_T
246              nexus) after the other initiator has  been  registered  and  the
247              reservation  moved  to  it.  When  not  given the initiator (I_T
248              nexus) that sent the PROUT command remains registered.
249
250       -v, --verbose
251              print out cdb of issued commands prior  to  execution.  If  used
252              twice  prints  out the parameter block associated with the PROUT
253              command prior to its execution as well. If used  thrice  decodes
254              given transportID(s) as well. To see the response to a PRIN com‐
255              mand in low level form use the --hex option.
256
257       -V, --version
258              print out version string. Ignore all other parameters.
259
260       -?     output usage message. Ignore all other parameters.
261

TRANSPORT IDs

263       TransportIDs are used in persistent reservations  to  identify  initia‐
264       tors.   The  format  of  a TransportID differs depending on the type of
265       transport being used. Their format is  described  in  SPC-4  (in  draft
266       revision 20 see section 7.5.4).
267
268       A TransportID is required for the PROUT 'register and move' sub-command
269       and the PROUT 'register' sub-command can have zero, one or more  Trans‐
270       portIDs.
271
272       When the --transport-id=TIDS option is given then the TIDS argument may
273       be a comma (or single space) separated list of  ASCII  hex  bytes  that
274       represent  a  single TransportID as defined in SPC-4. Alternatively the
275       TIDS argument may be a transport specific string starting  with  either
276       "fcp,",  "spi,", "sbp,", "srp,", "iqn", or "sas,". The "iqn" form is an
277       iSCSI qualified name. Apart from "iqn"  the  other  transport  specific
278       leadin string may be given in upper case (e.g. "FCP,").
279
280       The  "fcp,"  form should be followed by 16 ASCII hex digits that repre‐
281       sent an initiator's N_PORT_NAME. The "spi," form should be followed  by
282       "<scsi_address>,<relative_target_port_identifier>"  (both  decimal num‐
283       bers).  The "sbp," form should be followed by 16 ASCII hex digits  that
284       represent  an  initiator's  EUI-64 name. The "srp," form should be fol‐
285       lowed by 32 ASCII hex digits that represent an initiator  port  identi‐
286       fier.  The  "sas,"  form should be followed by 16 ASCII hex digits that
287       represent an initiator's port SAS address.
288
289       There are two iSCSI qualified name forms. The shorter form contains the
290       iSCSI  name  of  the  initiator  port  (e.g. "iqn.5886.com.acme.diskar‐
291       rays-sn-a8675309"). The longer form adds the initiator session id (ISID
292       in  hex)  separated by ",i,0x".  For example "iqn.5886.com.acme.diskar‐
293       rays-sn-a8675309,i,0x1234567890ab".  On the command line to stop  punc‐
294       tuation  in an iSCSI name being (mis)-interpreted by the shell, putting
295       the option argument containing the  iSCSI  name  in  double  quotes  is
296       advised. iSCSI names are encoded in UTF-8 so if non (7 bit) ASCII char‐
297       acters appear in the iSCSI name on the command line, there will be dif‐
298       ficulties  if  they are not encoded in UTF-8. The locale can be changed
299       temporarily by prefixing the command line invocation of sg_persist with
300       "LANG=en_US.utf-8" for example.
301
302       Alternatively the TIDS argument may specify a file (or pipe) from which
303       one or more TransportIDs may be read. If the TIDS argument is "-"  then
304       stdin  (standard  input)  is  read. If the TIDS argument is of the form
305       "file=<name>" than a file called <name> is read.  A valid SPC-4  Trans‐
306       portID is built from the transport specific string outlined in the pre‐
307       vious paragraphs. The parsing of the data read  is  realtively  simple.
308       Empty  lines are ignored. Everything from and including a "#" on a line
309       is ignored. Leading spaces and tabs  are  ignored.  There  can  be  one
310       transportID  per  line. The transportID can either be a comma, space or
311       tab separated list of ASCII hex bytes that represent a  TransportID  as
312       defined  in  SPC-4.  Padding  with zero bytes to a minimum length of 24
313       bytes is performed if necessary. The transportID may also be  transport
314       specific string type discussed above.
315
316       In SPC-3 the SPEC_I_PT bit set to one and TransportIDs were allowed for
317       the PROUT register and ignore existing key sub-command. In  SPC-4  that
318       is  disallowed  yielding  a  CHECK  CONDITION  status  with and ILLEGAL
319       REQUEST sense key and an additional sense code set to INVALID FIELD  IN
320       PARAMETER LIST.
321

NOTES

323       In  the  2.4  series of Linux kernels the DEVICE must be a SCSI generic
324       (sg) device. In the 2.6 series any SCSI  device  name  (e.g.  /dev/sdc,
325       /dev/st1m  or  /dev/sg3)  can  be  specified.   For example "sg_persist
326       --read-keys /dev/sdb" will work in the 2.6 series kernels.
327
328       The only scope for PROUT commands supported in  the  current  draft  of
329       SPC-4  is  "LU_SCOPE".  Hence there seems to be no point in offering an
330       option to set scope to another value.
331
332       Most errors with the PROUT sub-commands  (e.g.  missing  or  mismatched
333       --prout-type=TYPE)  will  result in a RESERVATION CONFLICT status. This
334       can be a bit confusing when you know there is only one (active) initia‐
335       tor: the "conflict" is with the SPC standard, not another initiator.
336
337       Some  recent  disks  accept  some  PRIN and PROUT sub-commands when the
338       media is stopped. One exception was setting the APTPL  flag  (with  the
339       --param-aptpl option) during a key register operation, it complained if
340       the disk one stopped. The error indicated it wanted the  disk  spun  up
341       and when that happened, the registration was successful.
342

EXAMPLES

344       These  examples  use  Linux  device names. For suitable device names in
345       other supported Operating Systems see the sg3_utils(8) man page.
346
347       Due to the various option defaults the simplest  example  executes  the
348       'read keys' sub-command of the PRIN command:
349
350          sg_persist /dev/sdb
351
352       This is the same as the following (long-winded) command:
353
354          sg_persist --in --read-keys --device=/dev/sdb
355
356       To read the current reservation either the '--read-reservation' form or
357       the shorter '-r' can be used:
358
359          sg_persist -r /dev/sdb
360
361       To register the new reservation key 0x123abc  the  following  could  be
362       used:
363
364          sg_persist --out --register --param-sark=123abc /dev/sdb
365
366       Given the above registration succeeds, to reserve the DEVICE (with type
367       'write exclusive') the following could be used:
368
369          sg_persist --out --reserve --param-rk=123abc
370                     --prout-type=1 /dev/sdb
371
372       To release the reservation the following can be given  (note  that  the
373       --param-rk  and --prout-type arguments must match those of the reserva‐
374       tion):
375
376          sg_persist --out --release --param-rk=123abc
377                     --prout-type=1 /dev/sdb
378
379       Finally to unregister a reservation key (and not effect other registra‐
380       tions  which  is  what '--clear' would do) the command is a little sur‐
381       prising:
382
383          sg_persist --out --register --param-rk=123abc /dev/sdb
384
385       Now have a close look at the difference between the register and unreg‐
386       ister examples above.
387
388       An  example  file that is suitably formatted to pass transportIDs via a
389       '--transport-id=file=transport_ids.txt' option  can  be  found  in  the
390       examples sub-directory of the sg3_utils package. There is also a simple
391       test script called sg_persist_tst.sh in the same directory.
392
393       The above sequence of commands was tested  successfully  on  a  Seagate
394       Savvio 10K.3 disk which has a SAS interface.
395

EXIT STATUS

397       The exit status of sg_persist is 0 when it is successful. Otherwise see
398       the sg3_utils(8) man page.
399

AUTHOR

401       Written by Douglas Gilbert
402

REPORTING BUGS

404       Report bugs to <dgilbert at interlog dot com>.
405
407       Copyright © 2004-2012 Douglas Gilbert
408       This software is distributed under the GPL version 2. There is NO  war‐
409       ranty;  not  even  for MERCHANTABILITY or FITNESS FOR A PARTICULAR PUR‐
410       POSE.
411

SEE ALSO

413       sg3_utils(sg3_utils), scsires(internet)
414
415
416
417sg3_utils-1.35                   December 2012                   SG_PERSIST(8)
Impressum