162306a36Sopenharmony_ci===============================================
262306a36Sopenharmony_ciBlock layer support for Persistent Reservations
362306a36Sopenharmony_ci===============================================
462306a36Sopenharmony_ci
562306a36Sopenharmony_ciThe Linux kernel supports a user space interface for simplified
662306a36Sopenharmony_ciPersistent Reservations which map to block devices that support
762306a36Sopenharmony_cithese (like SCSI). Persistent Reservations allow restricting
862306a36Sopenharmony_ciaccess to block devices to specific initiators in a shared storage
962306a36Sopenharmony_cisetup.
1062306a36Sopenharmony_ci
1162306a36Sopenharmony_ciThis document gives a general overview of the support ioctl commands.
1262306a36Sopenharmony_ciFor a more detailed reference please refer to the SCSI Primary
1362306a36Sopenharmony_ciCommands standard, specifically the section on Reservations and the
1462306a36Sopenharmony_ci"PERSISTENT RESERVE IN" and "PERSISTENT RESERVE OUT" commands.
1562306a36Sopenharmony_ci
1662306a36Sopenharmony_ciAll implementations are expected to ensure the reservations survive
1762306a36Sopenharmony_cia power loss and cover all connections in a multi path environment.
1862306a36Sopenharmony_ciThese behaviors are optional in SPC but will be automatically applied
1962306a36Sopenharmony_ciby Linux.
2062306a36Sopenharmony_ci
2162306a36Sopenharmony_ci
2262306a36Sopenharmony_ciThe following types of reservations are supported:
2362306a36Sopenharmony_ci--------------------------------------------------
2462306a36Sopenharmony_ci
2562306a36Sopenharmony_ci - PR_WRITE_EXCLUSIVE
2662306a36Sopenharmony_ci	Only the initiator that owns the reservation can write to the
2762306a36Sopenharmony_ci	device.  Any initiator can read from the device.
2862306a36Sopenharmony_ci
2962306a36Sopenharmony_ci - PR_EXCLUSIVE_ACCESS
3062306a36Sopenharmony_ci	Only the initiator that owns the reservation can access the
3162306a36Sopenharmony_ci	device.
3262306a36Sopenharmony_ci
3362306a36Sopenharmony_ci - PR_WRITE_EXCLUSIVE_REG_ONLY
3462306a36Sopenharmony_ci	Only initiators with a registered key can write to the device,
3562306a36Sopenharmony_ci	Any initiator can read from the device.
3662306a36Sopenharmony_ci
3762306a36Sopenharmony_ci - PR_EXCLUSIVE_ACCESS_REG_ONLY
3862306a36Sopenharmony_ci	Only initiators with a registered key can access the device.
3962306a36Sopenharmony_ci
4062306a36Sopenharmony_ci - PR_WRITE_EXCLUSIVE_ALL_REGS
4162306a36Sopenharmony_ci
4262306a36Sopenharmony_ci	Only initiators with a registered key can write to the device,
4362306a36Sopenharmony_ci	Any initiator can read from the device.
4462306a36Sopenharmony_ci	All initiators with a registered key are considered reservation
4562306a36Sopenharmony_ci	holders.
4662306a36Sopenharmony_ci	Please reference the SPC spec on the meaning of a reservation
4762306a36Sopenharmony_ci	holder if you want to use this type.
4862306a36Sopenharmony_ci
4962306a36Sopenharmony_ci - PR_EXCLUSIVE_ACCESS_ALL_REGS
5062306a36Sopenharmony_ci	Only initiators with a registered key can access the device.
5162306a36Sopenharmony_ci	All initiators with a registered key are considered reservation
5262306a36Sopenharmony_ci	holders.
5362306a36Sopenharmony_ci	Please reference the SPC spec on the meaning of a reservation
5462306a36Sopenharmony_ci	holder if you want to use this type.
5562306a36Sopenharmony_ci
5662306a36Sopenharmony_ci
5762306a36Sopenharmony_ciThe following ioctl are supported:
5862306a36Sopenharmony_ci----------------------------------
5962306a36Sopenharmony_ci
6062306a36Sopenharmony_ci1. IOC_PR_REGISTER
6162306a36Sopenharmony_ci^^^^^^^^^^^^^^^^^^
6262306a36Sopenharmony_ci
6362306a36Sopenharmony_ciThis ioctl command registers a new reservation if the new_key argument
6462306a36Sopenharmony_ciis non-null.  If no existing reservation exists old_key must be zero,
6562306a36Sopenharmony_ciif an existing reservation should be replaced old_key must contain
6662306a36Sopenharmony_cithe old reservation key.
6762306a36Sopenharmony_ci
6862306a36Sopenharmony_ciIf the new_key argument is 0 it unregisters the existing reservation passed
6962306a36Sopenharmony_ciin old_key.
7062306a36Sopenharmony_ci
7162306a36Sopenharmony_ci
7262306a36Sopenharmony_ci2. IOC_PR_RESERVE
7362306a36Sopenharmony_ci^^^^^^^^^^^^^^^^^
7462306a36Sopenharmony_ci
7562306a36Sopenharmony_ciThis ioctl command reserves the device and thus restricts access for other
7662306a36Sopenharmony_cidevices based on the type argument.  The key argument must be the existing
7762306a36Sopenharmony_cireservation key for the device as acquired by the IOC_PR_REGISTER,
7862306a36Sopenharmony_ciIOC_PR_REGISTER_IGNORE, IOC_PR_PREEMPT or IOC_PR_PREEMPT_ABORT commands.
7962306a36Sopenharmony_ci
8062306a36Sopenharmony_ci
8162306a36Sopenharmony_ci3. IOC_PR_RELEASE
8262306a36Sopenharmony_ci^^^^^^^^^^^^^^^^^
8362306a36Sopenharmony_ci
8462306a36Sopenharmony_ciThis ioctl command releases the reservation specified by key and flags
8562306a36Sopenharmony_ciand thus removes any access restriction implied by it.
8662306a36Sopenharmony_ci
8762306a36Sopenharmony_ci
8862306a36Sopenharmony_ci4. IOC_PR_PREEMPT
8962306a36Sopenharmony_ci^^^^^^^^^^^^^^^^^
9062306a36Sopenharmony_ci
9162306a36Sopenharmony_ciThis ioctl command releases the existing reservation referred to by
9262306a36Sopenharmony_ciold_key and replaces it with a new reservation of type for the
9362306a36Sopenharmony_cireservation key new_key.
9462306a36Sopenharmony_ci
9562306a36Sopenharmony_ci
9662306a36Sopenharmony_ci5. IOC_PR_PREEMPT_ABORT
9762306a36Sopenharmony_ci^^^^^^^^^^^^^^^^^^^^^^^
9862306a36Sopenharmony_ci
9962306a36Sopenharmony_ciThis ioctl command works like IOC_PR_PREEMPT except that it also aborts
10062306a36Sopenharmony_ciany outstanding command sent over a connection identified by old_key.
10162306a36Sopenharmony_ci
10262306a36Sopenharmony_ci6. IOC_PR_CLEAR
10362306a36Sopenharmony_ci^^^^^^^^^^^^^^^
10462306a36Sopenharmony_ci
10562306a36Sopenharmony_ciThis ioctl command unregisters both key and any other reservation key
10662306a36Sopenharmony_ciregistered with the device and drops any existing reservation.
10762306a36Sopenharmony_ci
10862306a36Sopenharmony_ci
10962306a36Sopenharmony_ciFlags
11062306a36Sopenharmony_ci-----
11162306a36Sopenharmony_ci
11262306a36Sopenharmony_ciAll the ioctls have a flag field.  Currently only one flag is supported:
11362306a36Sopenharmony_ci
11462306a36Sopenharmony_ci - PR_FL_IGNORE_KEY
11562306a36Sopenharmony_ci	Ignore the existing reservation key.  This is commonly supported for
11662306a36Sopenharmony_ci	IOC_PR_REGISTER, and some implementation may support the flag for
11762306a36Sopenharmony_ci	IOC_PR_RESERVE.
11862306a36Sopenharmony_ci
11962306a36Sopenharmony_ciFor all unknown flags the kernel will return -EOPNOTSUPP.
120