pr.rst 3.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119
  1. ===============================================
  2. Block layer support for Persistent Reservations
  3. ===============================================
  4. The Linux kernel supports a user space interface for simplified
  5. Persistent Reservations which map to block devices that support
  6. these (like SCSI). Persistent Reservations allow restricting
  7. access to block devices to specific initiators in a shared storage
  8. setup.
  9. This document gives a general overview of the support ioctl commands.
  10. For a more detailed reference please refer to the SCSI Primary
  11. Commands standard, specifically the section on Reservations and the
  12. "PERSISTENT RESERVE IN" and "PERSISTENT RESERVE OUT" commands.
  13. All implementations are expected to ensure the reservations survive
  14. a power loss and cover all connections in a multi path environment.
  15. These behaviors are optional in SPC but will be automatically applied
  16. by Linux.
  17. The following types of reservations are supported:
  18. --------------------------------------------------
  19. - PR_WRITE_EXCLUSIVE
  20. Only the initiator that owns the reservation can write to the
  21. device. Any initiator can read from the device.
  22. - PR_EXCLUSIVE_ACCESS
  23. Only the initiator that owns the reservation can access the
  24. device.
  25. - PR_WRITE_EXCLUSIVE_REG_ONLY
  26. Only initiators with a registered key can write to the device,
  27. Any initiator can read from the device.
  28. - PR_EXCLUSIVE_ACCESS_REG_ONLY
  29. Only initiators with a registered key can access the device.
  30. - PR_WRITE_EXCLUSIVE_ALL_REGS
  31. Only initiators with a registered key can write to the device,
  32. Any initiator can read from the device.
  33. All initiators with a registered key are considered reservation
  34. holders.
  35. Please reference the SPC spec on the meaning of a reservation
  36. holder if you want to use this type.
  37. - PR_EXCLUSIVE_ACCESS_ALL_REGS
  38. Only initiators with a registered key can access the device.
  39. All initiators with a registered key are considered reservation
  40. holders.
  41. Please reference the SPC spec on the meaning of a reservation
  42. holder if you want to use this type.
  43. The following ioctl are supported:
  44. ----------------------------------
  45. 1. IOC_PR_REGISTER
  46. ^^^^^^^^^^^^^^^^^^
  47. This ioctl command registers a new reservation if the new_key argument
  48. is non-null. If no existing reservation exists old_key must be zero,
  49. if an existing reservation should be replaced old_key must contain
  50. the old reservation key.
  51. If the new_key argument is 0 it unregisters the existing reservation passed
  52. in old_key.
  53. 2. IOC_PR_RESERVE
  54. ^^^^^^^^^^^^^^^^^
  55. This ioctl command reserves the device and thus restricts access for other
  56. devices based on the type argument. The key argument must be the existing
  57. reservation key for the device as acquired by the IOC_PR_REGISTER,
  58. IOC_PR_REGISTER_IGNORE, IOC_PR_PREEMPT or IOC_PR_PREEMPT_ABORT commands.
  59. 3. IOC_PR_RELEASE
  60. ^^^^^^^^^^^^^^^^^
  61. This ioctl command releases the reservation specified by key and flags
  62. and thus removes any access restriction implied by it.
  63. 4. IOC_PR_PREEMPT
  64. ^^^^^^^^^^^^^^^^^
  65. This ioctl command releases the existing reservation referred to by
  66. old_key and replaces it with a new reservation of type for the
  67. reservation key new_key.
  68. 5. IOC_PR_PREEMPT_ABORT
  69. ^^^^^^^^^^^^^^^^^^^^^^^
  70. This ioctl command works like IOC_PR_PREEMPT except that it also aborts
  71. any outstanding command sent over a connection identified by old_key.
  72. 6. IOC_PR_CLEAR
  73. ^^^^^^^^^^^^^^^
  74. This ioctl command unregisters both key and any other reservation key
  75. registered with the device and drops any existing reservation.
  76. Flags
  77. -----
  78. All the ioctls have a flag field. Currently only one flag is supported:
  79. - PR_FL_IGNORE_KEY
  80. Ignore the existing reservation key. This is commonly supported for
  81. IOC_PR_REGISTER, and some implementation may support the flag for
  82. IOC_PR_RESERVE.
  83. For all unknown flags the kernel will return -EOPNOTSUPP.