pr.txt 3.6 KB

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