sg_persist man page on YellowDog
[printable version]
SG_PERSIST(8) SG3_UTILS SG_PERSIST(8)
NAME
sg_persist - sends a SCSI PERSISTENT RESERVE (IN or OUT) command to
manipulate registrations and reservations
SYNOPSIS
sg_persist [OPTIONS] DEVICE
sg_persist [OPTIONS] --device=DEVICE
sg_persist --help | --version
DESCRIPTION
This utility allows Persistent reservations and registrations to be
queried and changed. Persistent reservations and registrations are
queried by sub-commands (called "service actions" in SPC-4) of the SCSI
PERSISTENT RESERVE IN (PRIN) command. Persistent reservations and reg‐
istrations are changed by sub-commands of the SCSI PERSISTENT RESERVE
OUT (PROUT) command.
There is a two stage process to obtain a persistent reservation. First
an application (an I_T nexus in standard's jargon) must register a
reservation key. If that is accepted (and it should be unless some
other I_T nexus has registered that key) then the application can try
and reserve the device. The reserve operation must specify the reser‐
vation key and a "type" (see the --prout-type=TYPE option).
It is relatively safe to query the state of Persistent reservations and
registrations. With no options this utility defaults to the READ KEYS
sub-command of the PRIN command. Other PRIN sub-commands are READ
RESERVATION, REPORT CAPABILITIES and READ FULL STATUS.
Before trying to change Persistent reservations and registrations users
should be aware of what they are doing. The relevant sections of the
SCSI Primary Commands document (i.e. SPC-4 whose most recent draft is
revision 9 dated 17th February 2007) are sections 5.6 (titled "Reserva‐
tion"), 6.13 (for the PRIN command) and 6.14 (for the PROUT command).
To safeguard against accidental use, the --out option must be given
when a PROUT sub-command (e.g. --register) is used.
The older SCSI RESERVE and RELEASE commands (both 6 and 10 byte vari‐
ants) are not supported by this utility. In SPC-3, RESERVE and RELEASE
are deprecated, replaced by Persistent Reservations. RESERVE and
RELEASE have been removed from SPC-4 and Annex B is provided showing
how to convert to persistent reservation commands. See a utility called
'scsires' for support of the SCSI RESERVE and RELEASE commands.
The DEVICE is required by all variants of this utility apart from
--help. The DEVICE can be given either as an argument (typically but
not necessarily the last one) or via the --device=DEVICE option.
SPC-4 does not use the term "sub-command". It uses the term "service
action" for this and for part of a field's name in the parameter block
associated with the PROUT command (i.e. "service action reservation
key"). To lessen the potential confusion the term "sub-command" has
been introduced.
OPTIONS
Arguments to long options are mandatory for short options as well. The
following options are sorted in alphabetical order, based on their long
option name.
-C, --clear
Clear is a sub-command of the PROUT command. It releases the
persistent reservation (if any) and clears all registrations
from the device. It is required to supply a reservation key that
is registered for this I_T_L nexus (identified by
--param-rk=RK).
-d, --device=DEVICE
DEVICE to send SCSI commands to. The DEVICE can either be pro‐
vided via this option or via a freestanding argument. For exam‐
ple, these two: 'sg_persist --device=/dev/sg2' and 'sg_persist
/dev/sg2' are equivalent.
-h, --help
output a usage message.
-H, --hex
the response to a valid PRIN sub-command will be output in hexa‐
decimal. By default (i.e. without this option) if the PRIN
sub-command is recognised then the response will be decoded as
per SPC-4.
-i, --in
specify that a SCSI PERSISTENT RESERVE IN command is required.
This is the default.
-n, --no-inquiry
the default action is to do a standard SCSI INQUIRY command and
output make, product and revision strings plus the peripheral
device type prior to executing a PRIN or PROUT command. With
this option the INQUIRY command is skipped.
-o, --out
specify that a SCSI PERSISTENT RESERVE OUT command is required.
-Y, --param-alltgpt
set the 'all target ports' (ALL_TG_PT) flag in the parameter
block of the PROUT command. Only relevant for 'register' and
'register and ignore existing key' sub-commands.
-Z, --param-aptpl
set the 'activate persist through power loss' (APTPL) flag in
the parameter block of the PROUT command. Relevant for 'regis‐
ter', 'register and ignore existing key' and 'register and move'
sub-commands.
-K, --param-rk=RK
specify the reservation key found in the parameter block of the
PROUT command. RK is assumed to be hex (up to 8 bytes long).
Default value is 0. This option is needed by most PROUT sub-com‐
mands.
-S, --param-sark=SARK
specify the service action reservation key found in the parame‐
ter block of the PROUT command. SARK is assumed to be hex (up to
8 bytes long). Default value is 0. This option is needed by
some PROUT sub-commands.
-P, --preempt
Preempt is a sub-command of the PROUT command. Preempts the
existing persistent reservation (identified by
--param-sark=SARK) with the registration key that is registered
for this I_T_L nexus (identified by --param-rk=RK). The associ‐
ated --prout-type=TYPE option needs to match the type of the
reservation.
-A, --preempt-abort
Preempt and Abort is a sub-command of the PROUT command. Pre‐
empts the existing persistent reservation (identified by
--param-sark=SARK) with the registration key that is registered
for this I_T_L nexus (identified by --param-rk=RK). The associ‐
ated --prout-type=TYPE option needs to match the type of the
reservation. ACA and other pending tasks are aborted.
-T, --prout-type=TYPE
specify the PROUT command's 'type' argument. Required by the
'register-move', 'reserve', 'release' and 'preempt (and abort)'
sub-commands. Valid TYPE values: 1-> write exclusive, 3-> exclu‐
sive access, 5-> write exclusive - registrants only, 6-> exclu‐
sive access - registrants only, 7-> write exclusive - all regis‐
trants, 8-> exclusive access - all registrants. Default value is
0 (which is an invalid type). Each "persistent reservation type"
is explained in more detail in a subsection of that name in the
read reservation section of the PRIN command (section 6.13.3.4
of SPC-4 revision 9).
-s, --read-full-status
Read Full Status is a sub-command of the PRIN command. For each
registration with the given SCSI device, it lists the reserva‐
tion key and associated information. TransportIDs, if supplied
in the response, are decoded.
-k, --read-keys
Read Keys is a sub-command of the PRIN command. Lists all the
reservation keys registered (i.e. registrations) with the given
SCSI device. This is the default sub-command for the SCSI PRIN
command.
-r, --read-reservation
Read Reservation is a sub-command of the PRIN command. List
information about the current holder of the reservation on the
DEVICE. If there is no current reservation this will be noted.
Information about the current holder of the reservation includes
its reservation key, scope and type.
-s, --read-status
same as --read-full-status.
-G, --register
Register is a sub-command of the PROUT command. It has 3 differ‐
ent actions depending on associated parameters. a) add a new
registration with '--param-rk=0' and '--param-sark=<new_rk>'; b)
Change an existing registration with '--param-rk=<old_rk>' and
'--param-sark=<new_rk>'; or c) Delete an existing registration
with '--param-rk=<old_rk>' and '--param-sark=0'.
-I, --register-ignore
Register and Ignore Existing Key is a sub-command of the PROUT
command. Similar to --register except that when changing a
reservation key the old key is not specified. The '--prout-
sark=<new_rk>' option should also be given.
-M, --register-move
register (another initiator) and move (the reservation held by
the current initiator to that other initiator) is a sub-command
of the PROUT command. It requires the transportID of the other
initiator. [The standard uses the term I_T nexus but the point
to stress is that there are two initiators (the one sending this
command and another one) but only one logical unit.] The
--prout-type=TYPE and --param-rk=RK options need to match that
of the existing reservation while --param-sark=SARK option spec‐
ifies the reservation key of the new (i.e. destination) regis‐
tration.
-Q, --relative-target-port=RTPI
relative target port identifier that reservation is to be moved
to by PROUT 'register and move' sub-command. RTPI is assumed to
be hex in the range 0 to ffff inclusive. Defaults to 0 .
-L, --release
Release is a sub-command of the PROUT command. It releases the
current persistent reservation. The --prout-type=TYPE and
--param-rk=RK options, matching the reservation, must also be
specified.
-c, --report-capabilities
Report Capabilities is a sub-command of the PRIN command. It
lists information about the aspects of persistent reservations
that the DEVICE supports.
-R, --reserve
Reserve is a sub-command of the PROUT command. It creates a new
persistent reservation (if permitted). The --prout-type=TYPE and
--param-rk=RK options must also be specified.
-X, --transport-id=H,H...
a transportID is required for the PROUT 'register and move'
sub-command and is optional for the PROUT 'register' and 'regis‐
ter and ignore existing key' sub-commands. The latter two
sub-commands can take multiple transportIDs in a list but only
one is supported with this option variant (use the following
option variant that reads stdin if multiple transportIDs are
required). H,H... is a comma separated list of hex bytes which
represent the transportID. The list of hex numbers will be
padded out with zeros to 24 bytes which is the minimum length of
a transportID. A transportID longer than 24 bytes (e.g. for
iSCSI) is padded with zeros so its length is a multiple of 4.
-X, --transport-id=-
a transportID is required for the PROUT 'register and move'
sub-command and is optional for the PROUT 'register' and 'regis‐
ter and ignore existing key' sub-commands. The latter two
sub-commands can take multiple transportIDs in a list. The argu‐
ment is '-' which indicates stdin should be read for the trans‐
portID(s). Empty lines are ignored. Everything from and includ‐
ing a "#" on a line is ignored. Leading spaces and tabs are
ignored. All numbers are assumed to be hexadecimal and can be
separated by space, comma or tab. There can be one transportID
per line. TranportIDs will be padded out with zeros to 24 bytes
which is the minimum length of a transportID. A transportID
longer than 24 bytes (e.g. for iSCSI) is padded with zeros so
its length is a multiple of 4.
-U, --unreg
optional when the PROUT register and move sub-command is
invoked. If given it will unregister the current initiator (I_T
nexus) after the other initiator has been registered and the
reservation moved to it. When not given the initiator (I_T
nexus) that sent the PROUT command remains registered.
-v, --verbose
print out cdb of issued commands prior to execution. If used
twice prints out the parameter block associated with the PROUT
command prior to its execution as well. If used thrice decodes
given transportID(s) as well. To see the response to a PRIN com‐
mand in low level form use the --hex option.
-V, --version
print out version string. Ignore all other parameters.
-? output usage message. Ignore all other parameters.
NOTES
In the 2.4 series of Linux kernels the DEVICE must be a SCSI generic
(sg) device. In the 2.6 series any SCSI device name (e.g. /dev/sdc,
/dev/st1m or /dev/sg3) can be specified. For example "sg_persist
--read-keys /dev/sda" will work in the 2.6 series kernels.
The only scope for PROUT commands supported in the current draft of
SPC-4 is "LU_SCOPE". Hence there seems to be no point in offering an
option to set scope to another value.
Most errors with the PROUT sub-commands (e.g. missing or mismatched
--prout-type=TYPE) will result in a RESERVATION CONFLICT status. This
can be a bit confusing when you know there is only one (active) initia‐
tor: the "conflict" is with the SPC standard, not another initiator.
TransportIDs are defined in SPC-4 and their structures vary depending
on the underlying transport.
EXAMPLES
Due to defaults the simplest example executes the 'read keys' sub-com‐
mand of the PRIN command:
sg_persist /dev/sda
This is the same as the following (long-winded) command:
sg_persist --in --read-keys --device=/dev/sda
To read the current reservation either the '--read-reservation' form or
the shorter '-r' can be used:
sg_persist -r /dev/sda
To register the new reservation key 0x123abc the following could be
used:
sg_persist --out --register --param-sark=123abc /dev/sda
Given the above registration succeeds, to reserve the DEVICE (with type
'write exclusive') the following could be used:
sg_persist --out --reserve --param-rk=123abc
--prout-type=1 /dev/sda
To release the reservation the following can be given (note that the
--param-rk and --prout-type arguments must match those of the reserva‐
tion):
sg_persist --out --release --param-rk=123abc
--prout-type=1 /dev/sda
Finally to unregister a reservation key (and not effect other registra‐
tions which is what '--clear' would do) the command is a little sur‐
prising:
sg_persist --out --register --param-rk=123abc /dev/sda
Now have a close look at the difference between the register and unreg‐
ister examples above.
An example file that is suitably formatted to pass transportIDs via the
'--transport-id=-' option can be found in the examples sub-directory of
the sg3_utils package. That file is called 'transport_ids.txt'.
EXIT STATUS
The exit status of sg_persist is 0 when it is successful. Otherwise see
the sg3_utils(8) man page.
AUTHOR
Written by Doug Gilbert
REPORTING BUGS
Report bugs to <dgilbert at interlog dot com>.
COPYRIGHT
Copyright © 2004-2007 Douglas Gilbert
This software is distributed under the GPL version 2. There is NO war‐
ranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PUR‐
POSE.
SEE ALSO
scsires(internet), examples/sg_persist_tst.sh(sg3_utils tarball)
sg3_utils-1.25 October 2007 SG_PERSIST(8)
[top]
List of man pages available for YellowDog
Copyright (c) for man pages and the logo by the respective OS vendor.
For those who want to learn more, the polarhome community provides shell access and support.
[legal]
[privacy]
[GNU]
[policy]
[cookies]
[netiquette]
[sponsors]
[FAQ]
Polarhome, production since 1999.
Member of Polarhome portal.
Based on Fawad Halim's script.
....................................................................
|
Vote for polarhome
|