Overview
chat GPT에게 물어보자. NVMe Reservation의 usage가 무엇일까?
The NVMe (Non-Volatile Memory Express) reservation feature is commonly used in various storage environments to manage exclusive access to NVMe namespaces or controllers. Here are some specific use cases where NVMe reservations are employed:
- Clustered File Systems: In distributed file systems or clustered storage environments, multiple hosts share access to a common set of storage resources. Reservations are utilized to coordinate access and prevent simultaneous modifications by multiple hosts, ensuring data consistency and preventing conflicts.
- High Availability and Failover: Reservations are leveraged to implement high availability and failover mechanisms in storage systems. By acquiring a reservation, a host can establish itself as the active or primary node responsible for managing and accessing the storage resource. In the event of a failover or node failure, another host can acquire the reservation and take over the active role.
- Storage Virtualization: In storage virtualization scenarios, where a single physical NVMe device is partitioned into multiple virtualized storage resources, reservations help ensure exclusive access to specific virtualized namespaces. Each virtualized storage entity can acquire a reservation to prevent interference from other entities sharing the same physical device.
- Database Systems: Reservations are useful in database environments to guarantee exclusive access to storage resources during critical operations such as database backup, recovery, or maintenance tasks. By acquiring a reservation, the database server ensures that no other host or process interferes with these operations, maintaining data integrity and consistency.
- Resource Isolation: Reservations can be used to isolate specific namespaces or controllers for dedicated purposes. For example, a host may reserve a particular NVMe namespace for performance-sensitive applications or for storing critical data, ensuring that other hosts do not access or impact its operations.
- Firmware Updates: During firmware updates of NVMe devices, reservations can be employed to prevent accidental access or modifications by other hosts. The host performing the firmware update acquires a reservation, ensuring exclusive control over the device during the update process.
- Exclusive Access Scenarios: There may be situations where a host requires exclusive access to a storage resource without interference from other hosts. Reservations allow the host to assert ownership and control, ensuring that no other host accesses or modifies the resource.
It's important to note that reservation usage requires proper coordination and adherence to reservation protocols. Reservations are managed through Reservation Acquire and Reservation Release commands sent by the host to the NVMe controller. Additionally, reservation conflicts and arbitration mechanisms are handled according to the reservation type and scope defined in the NVMe specification.
By utilizing reservations, hosts can establish exclusive access rights, prevent conflicts, ensure data integrity, and effectively manage shared NVMe storage resources in various storage environments.
GPT 대답을 요약하면, Host가 특정 Namespace를 독점으로 사용해야 하는 경우가 있다.
예를 들어, 여러 host가 하나의 SSD Device에 access 할 수 있는 환경이야. 동시에 access 해서 수정하면, 데이터 일관성이 깨질 수 있으니까, 하나의 host가 독점해서 사용해야겠지(여기서 말하는 host란, 하나의 application으로 생각된다)
즉, reservation은 둘 이상의 host에서 shared namespace에 대한 access를 제어하는데 사용할 수 있는 feature이다. 더 자세히 spec 내용을 뜯어보자. 들어가기에 앞서서, NVM Subsystem을 먼저 보고 가자.
NVM Subsystem
reservation에 들어가기에 앞서, NVM Subsystem이 어떻게 구성될 수 있는지를 알아야 한다. 어떤 경우에 shared namespace를 access 하는 경우가 발생하는 지를 알고자 한다.
NVM Subsystem 구성의 4가지 example을 보자.
![]() |
![]() |
![]() |
| Port : Function = 1 : 1 Controller : NS = 1 : 2 |
Port : Function = 1 : 2 Controller : NS = 1 : 2 (NS B는 shared NS) |
Port : Function = 1 : 1 (2 set) Controller : NS = 1 : 2 (NS B는 shared NS) |
![]() |
| Port : Function = 1 : 5 (PF 1개, VF 4개) Controller : NS = 1 : 2 (NS F는 shared NS) |
4가지 example을 통해, 아래의 내용을 도출할 수 있다.
- 하나의 port에는 하나 이상의 Physical Function이 존재한다.
- function과 nvme controller는 1대1 대응이다.
- 하나의 nvme controller는 하나 이상의 namespace를 access 할 수 있다.
Reservation Feature
nvme 1.4 spec을 바탕으로,
8.8 Reservations (Optional)
A reservation on a namespace restricts hosts access to that namespace.
namespace에 reservation 하는 것은, 다른 host 들이 해당 namespace에 접근하는 것을 제한하고자 하는 것이다.
A reservation requires an association between a host and a namespace. each controller in a multi-path I/O and namespace sharing environment is associated with exactly one host.
reservation은 host와 namepsace의 연결을 필요로 한다. 그런데, host와 namespace 사이에는 controller가 존재한다. 그러니까, controller와 host와의 연결도 필요하겠지. controller는 하나의 host와 연결된다. (2개 이상의 host와 연결도 가능하나, 이는 nvme spec에서 벗어나는 내용이다)
A host may be associated with multiple controllers. A host registers a Host Identifier (refer to section 5.21.1.26) with each controller with which that host is associated using a Set Features command (refer to section 5.21) prior to performing any operations associated with reservations.
host는 여러 controller와 연결될 수 있어. host와 controller는 어떻게 연결 지어? set feature command - host id로 연결 짓고 나서, reservation 동작을 할 수 있어.
The Host Identifier allows the NVM subsystem to identify controllers associated with the same host and preserve reservation properties across these controllers (i.e., a host issued command has the same reservation rights no matter which controller associated with the host processes the command).
host가 namespace에 direct로 연결되는 구조가 아니잖아. 사이에 controller가 있으니까, controller를 통해서 namespace와 연결되는 구조이다. reservation 관점에서는, 어떤 controller로 command가 들어오는 것이 중요한 게 아니라, 어떤 host id를 통해서 command가 들어왔는지가 중요하다.
Support for reservations by a namespace or controller is optional. A namespace indicates support for reservations by reporting a non-zero value in the Reservation Capabilities (RESCAP) field in the Identify Namespace data structure. A controller indicates support for reservations through the Optional NVM Command Support (ONCS) field in the Identify Controller data structure. If a host submits a command associated with reservations (i.e., Reservation Report, Reservation Register, Reservation Acquire, and Reservation Release) to a controller or a namespace that do not both support reservations, then the command is aborted by the controller with status Invalid Command Opcode.
임의의 controller - namespace로 reservation command가 들어왔어. 해당 controller, namespace가 reservation을 지원해야 정상적으로 command를 처리할 수 있다.
Controllers that make up an NVM subsystem shall all have the same support for reservations. Although strongly encouraged, namespaces that make up an NVM subsystem are not all required to have the same support for reservations.
NVM subsystem내의 controller들은 모두 같은 reservation support를 해야한다. 그러나, namespace는 각각 다르게 support를 해도 된다.
(질문) 왜 controllers들은 모두 같은 reservation support를 지원해야하지?
(답변) reservation이 host와 namespace의 연결이니까, 어떤 controller를 통해서는 그 연결을 맺을 수 없다고 하면, 그 controller에 의해서 host와 namespace 연결의 제약이 생기니까 그렇지 않을까?
5.21.1.26 Host Identifier (Feature Identifier 81h)
Controllers in an NVM subsystem that have the same Host Identifier are assumed to be associated with the same host and have the same reservation and registration rights. A Host Identifier value of 0h indicates that the host is not associated with any other controller in the NVM subsystem.
8.8.2 Registering
Prior to establishing a reservation on a namespace, a host shall become a registrant of that namespace by registering a reservation key.
host는 namespace에 reservation을 하기 전에, namespace에 reservation key를 등록함으로써, 해당 namespace에 registrant가 되어야 한다.
Registering a reservation key with a namespace creates an association between a host and a namespace. A host that is a registrant of a namespace may use any controller with which that host is associated (i.e., that has the same Host Identifier, refer to section 5.21.1.26) to access that namespace as a registrant. Thus, a host is only required to register on a single controller to become a registrant of the namespace on all controllers in the NVM subsystem that have access to the namespace and are associated with the host.
host와 namespace는 어떻게 연결 지어? host가 namespace에 reservation key를 등록함으로써 연결된다. host는 하나의 controller를 통해서 register를 하면 된다. 어차피, controller라는 것은 register를 하기 위해, 거쳐가는 곳이고 host id - namespace의 연결을 만드는 게 핵심이다.
A host registers a reservation key by executing a Reservation Register command (refer to section 6.11) on the namespace with the Reservation Register Action (RREGA) field cleared to 000b (i.e., Register Reservation Key) and supplying a reservation key in the New Reservation Key (NRKEY) field.
register시, reservation key값
A host that is a registrant of a namespace may register the same reservation key value multiple times with the namespace on the same or different controllers. For a Reservation Register command with the RREGA field cleared to 000b:
a) the IEKEY field shall be ignored; and
b) if a host that is already a registrant of a namespace attempts to register with that namespace using a different registration key value, then the command shall be aborted with status Reservation Conflict.
namespace - host id 연결이 이미 되어 있어. 근데 또 같은 host id로 register 하려고 host가 시도할 수 있겠지. 이 때는 reservation key값을 꼭 봐야 해(ignore key를 사용할 수 없다는 것으로 보인다. 등록할 때, key를 ignore 한다는 것 자체가 말이 안 되긴 하다) 같은 reservation key값으로 또 등록하는 것은 ok야. 그런데, reservation key값이 다르면, error 처리해.
There are no restrictions on the reservation key value used by hosts with different Host Identifiers. For example, multiple hosts may all register with the same reservation key value.
하나의 namespace에 여러 host id가 연결을 맺을 수 있어. 그리고 register에서 key값이 의미를 갖는 것은, host id - namespace 하나의 set에서 의미를 갖는 거야??? 마치 대문(namespace)은 하나인데, 대문 비밀번호(reservation key)를 유저별(host id)로 설정할 수 있다는 것이라고 이해하면 될 거 같다.
A host that is a registrant of a namespace may replace the existing reservation key value for that namespace by executing a Reservation Register command on the namespace with the:
a) RREGA field set to 010b (i.e., Replace Reservation Key);
b) current reservation key in the Current Reservation Key (CRKEY) field; and
c) new reservation key in the NRKEY field.
namespace - host id가 연결이 이미 되어 있어. 근데, key값만 바꾸고 싶은 어떻게 해? replace key를 하면 돼. 현재 key값을 알면, 새로운 key값으로 변경할 수 있는 거지. 그런데 기존 key값을 모르면 변경 못하는 거야? 아니야, replace key를 할 때는 Ignore key 필드가 의미를 갖거든. 할 수 있어.
8.8.3 Reservation Types
The NVM Express interface supports six types of reservations:
• Write Exclusive;
• Exclusive Access;
• Write Exclusive - Registrants Only;
• Exclusive Access - Registrants Only;
• Write Exclusive - All Registrants; and
• Exclusive Access - All Registrants.
The differences between these reservation types are: the type of access that is excluded (i.e., writes or all accesses), whether registrants have the same access rights as the reservation holder, and whether registrants are also considered to be reservation holders.
(질문) registrants가 reservation holder와 같은 권한을 가지는지와, registrants가 reservation holder로 간주되는지가 어떻게 다른 걸까? reservation holder로 간주하는 것과 권한을 갖는 것이 어떻게 다른 거지?
(답변) holder만 release를 할 수 있기 때문 아닐까? registrants가 hold와 같은 권한을 갖는다고 해서, holder처럼 release를 할 수는 없을 거 같은데.
Reservations and registrations persist across all Controller Level Resets and all NVM Subsystem Resets except reset due to power loss.
reservation과 registration은 controller level reset과 NSSR에 대해서 persist 하게 유지되어야 하는구나. 이는 feature와는 다르다.
8.8.4 Unregistering
A host that is a registrant of a namespace may unregister with the namespace by executing a Reservation Register command (refer to section 6.11) on the namespace with the RREGA field set to 001b (i.e., Unregister Reservation Key) and supplying its current reservation key in the CRKEY field. If the contents of the CRKEY field do not match the key currently associated with the host, then the command is aborted with a status of Reservation Conflict. If the host is not a registrant, then the command is aborted with a status of Reservation Conflict.
Successful completion of an unregister operation causes the host to no longer be a registrant of that namespace. A host may unregister without regard to its current reservation key value by setting the IEKEY bit to '1' in the Reservation Register command.
namespace와 host id 연결 해제할 수 있어? unregister 하면 된다. current key값을 알면 할 수 있어. key값을 모르면? host가 ignore key로 설정하고 unregister하면 된다. 마치 세대원이 기존 집 비밀번호를 몰라도 변경할 수 있잖아. 내가 세대원이라고.
Unregistering by a host may cause a reservation held by the host to be released. If a host is the last remaining reservation holder (i.e., All Registrants) or is the only reservation holder, then the reservation is released when the host unregisters.
reservation holder가 하나인 상황에서, unregister를 하면 reservation도 release가 된다.
If a reservation is released and the type of the released reservation was Registrants Only, then a reservation released notification occurs on all controllers associated with a registered host other than the host that issued the Reservation Register command.
registrants only는 하나의 host id만 namespace를 점유하고 있다는 것이다. 근데 해당 host id가 namespace와의 w점유를 해제한다면, reservation이 release 된다. 그리고 다른 host id들이 연결된 controller를 통해서 이 사실을 알 수 있도록 noti 한다. 이는 즉, 다른 host id들에게 너희가 이제 점유해도 된다는 것을 알려주려나 보다.
(질문) holder가 reservation release 했다고 해서, 다른 host id에게 device를 통해서 알려주는 이유는 뭘까? host 자기가 더 잘 알 텐데
(답변) host가 holder가 누구고 이런 것조차 직접 관리하기 싫으니까, device한테 짬 시킨다고 이해하면 될까?
(질문) all registrants와 registants only의 차이는?
(답변) all registrants는, namespace와 연결된 host id라면, namespace를 배타적으로 사용할 수 있다. registrants only는, 연결된 host id 중에 단 하나만 namespace를 배타적으로 사용할 수 있다.
8.8.5 Acquiring a Reservation
In order for a host to obtain a reservation on a namespace, that host shall be a registrant of that namespace. A registrant obtains a reservation by executing a Reservation Acquire command (refer to section 6.10), clearing the Reservation Acquire Action (RACQA) field to 000b (Acquire), and supplying the current reservation key associated with the host in the Current Reservation Key (CRKEY) field. The CRKEY value shall match that used by the registrant to register with the namespace. If the CRKEY value does not match, then the command is aborted with status Reservation Conflict. If the host is not a registrant, then the command is aborted with a status of Reservation Conflict.
host와 namespace 연결된 상태에서, reservation을 획득할 수 있다. 이때, key값이 일치해야 한다.
Only one reservation is allowed at a time on a namespace. If a registrant attempts to obtain a reservation on a namespace that already has a reservation holder, then the command is aborted with status Reservation Conflict. If a reservation holder attempts to obtain a reservation of a different type on a namespace for which that host already is the reservation holder, then the command is aborted with status Reservation Conflict. It is not an error if a reservation holder attempts to obtain a reservation of the same type on a namespace for which that host already is the reservation holder. A reservation holder may preempt a reservation to change the reservation type.
namespace에 특정 host id가 이미 reservation 한 상태에서, 다른 host id가 reservation 시도를 할 수 있을까? 아니. 에러처리 한다. reservation한 host id가 또 reservation을 하는데, 기존 reservationt type과 다르게 reservation을 하는 건 가능해? 아니. 에러처리 한다.
8.8.6 Releasing a Reservation
Only a reservation holder may release in an orderly manner a reservation held on a namespace. A host releases a reservation by executing a Reservation Release command (refer to section 6.12), clearing the Reservation Release Action (RRELA) field to 000b (i.e., Release), setting the Reservation Type (RTYPE) field to the type of reservation being released, and supplying the current reservation key associated with the host in the Current Reservation Key (CRKEY) field. The CRKEY value shall match that used by the host to register with the namespace. If the key value doesn’t match, then the command is aborted with status Reservation Conflict. If the RTYPE field does not match the type of the current reservation, then the command completes with status Invalid Field in Command.
reservation holder만 release 할 수 있다. reservation type에 상관없이 holder는 1개야. key값 및 reservation type이 일치해야 정상 처리된다.
An attempt by a registrant to release a reservation using the Reservation Release command in the absence of a reservation held on the namespace or when the host is not the reservation holder shall cause the command to complete successfully, but shall have no effect on the controller or namespace.
reservation holder가 아닌데, release를 시도한다면, 정상 처리한다. 그러나, 아무 일도 일어나지 않는다.
When a reservation is released as a result of actions described in this section and the reservation type is not Write Exclusive or Exclusive Access, a reservation released notification occurs on all controllers in the NVM subsystem that are associated with hosts that are registrants except for controllers that are associated with the host that issued the Reservation Release command.
reservation type이 Write Exclusive or Exclusive Access가 아닌 경우, 다른 host id에게 holder가 release 됐다는 것을 알려준다.
(질문) 위 문장을 바탕으로 register type 중에 registrants only, all registrants가 안 붙어 있는 type(Write Exclusive or Exclusive Access)은, 이는 하나의 registrants만 가능하다고 이해된다. 근데, register 할 때, register type이 없기 때문에, 여러 개의 register가 있을 수 있어. 그러면, 여러 host id가 namespace에 연결되어 있는 상황에서, 다른 host id가 아무것도 안 붙어있는 type으로 점유할 때, 다른 registrants는 어떻게 해야 할까? unregister라도 해야 하는 거 아니야?
(답변) 확인 중
8.8.7 Preempting a Reservation or Registration
A host that is a registrant may preempt a reservation and/or registration by executing a Reservation Acquire command (refer to section 6.10), setting the Reservation Acquire Action (RACQA) field to 001b (Preempt), and supplying the current reservation key associated with the host in the Current Reservation Key (CRKEY) field. The CRKEY value shall match that used by the registrant to register with the namespace. If the CRKEY value does not match, then the command is aborted with status Reservation Conflict. The preempt actions that occur are dependent on the type of reservation held on the namespace, if any, and the value of the Preempt Reservation Key (PRKEY) field in the command. If the host is not a registrant, then the command is aborted with a status of Reservation Conflict. The remainder of this section assumes that the host is a registrant.
reservation aquire command로 reservation 또는 registration을 선점할 수 있다.
reservation type에 따라서 선점 action이 정해진다.
아래에서 all registrants인 경우, 아닌 경우를 나눠서 서술하고 있는데, 이 부분이 잘 이해가 가지 않는다.
If the existing reservation type is not Write Exclusive - All Registrants and not Exclusive Access - All Registrants, then the actions performed by the command depend on the value of the PRKEY field as follows:
all registrants는 host id 여러 개가 등록된 상태에서, 하나의 host id가 namespace를 선점하고, 다른 등록자들도 holder와 같은 권한을 갖는 type이다. 그런데, 기존 reservation type이 이 type이 아니라면, reservation holder 권한을 갖는 것이 holder 하나라고 본다.
a) If the PRKEY field value matches the reservation key of the current reservation holder, then the following occur as an atomic operation:
• all registrants with a matching registration key other than the host that issued the command are unregistered;
• the reservation is released; and
• a new reservation is created of the type specified by the Reservation Type (RTYPE) field in the command for the host that issued the command as the reservation key holder;
or
a) PRKEY와 holder의 reservation key가 일치한다면,
- command를 issue 한 host 외에 reservation key가 동일한 등록자들은 등록이 해제된다.
(질문) 왜 굳이 이렇게 해야 하는 거야? reservation key가 가지는 의미가 뭔데? 이게 host id - reservation key의 그룹으로 의미를 가지는 것이 아니라, reservation key 자체만으로 의미가 있다는 건데...
reservation key 값이 말 그대로 key인데,
(답변)?
- reservation이 release 된다.
- 새로운 type의 reservation이 생성된다.
b) If the PRKEY field value does not match that of the current reservation holder and is not equal to 0h, then registrants whose reservation key matches the value of the PRKEY field are unregistered. If the PRKEY field value does not match that of the current reservation holder and is equal to 0h, then the command is aborted with status Invalid Field in Command.
b) PRKEY와 holder의 reservation key가 일치하지 않는다면,
- key가 0이 아닌 경우, key가 일치하는 등록자가 등록 취소된다. 이런 경우가 왜 있을까? host 입장에서는 namespace에 prrempt 할 때, reservation key값으로 하는 거고, 이게 어떤 host id가 reservation holder 인지 모를 수도 있으니까?
즉, preempt 한다는 것이 무언가를 뺏어 오는 것인데, key값이 맞는 친구의 권한을 뺏어 오는 것이다. 그 key랑 일치하는 host id가 reservation holder이면, reservation 권한을 가져오는 것이다. reservation holder가 아닌 registrant이면 등록 권한을 가져오는 것이다. 이렇게 이해된다.
- key가 0인 경우, 에러 처리한다.
(질문) key 값을 0으로 register 하는 것은 가능합니까?
If the existing reservation type is Write Exclusive - All Registrants or Exclusive Access - All Registrants, then the actions performed by the command depend on the value of the PRKEY field as follows:
a) If the PRKEY field value is 0h, then the following occurs as an atomic operation:
• all registrants other than the host that issued the command are unregistered;
• the reservation is released; and
• a new reservation is created of the type specified by the Reservation Type (RTYPE) field in the command for the host that issued the command as the reservation key holder; or
b) If the PRKEY value is non-zero, then registrants whose reservation key matches the value of the PRKEY field are unregistered. If the PRKEY value is non-zero and there are no registrants whose reservation key matches the value of the PRKEY field, the controller should return an error of Reservation Conflict.
기존 reservation type이 all registrants인 경우,
a) PRKEY가 0인 경우,
- command issue 한 host id를 제외하고, 다른 registrants는 해제된다.
- reservation이 release
- command issue한 host id가 reservation 한다.
b) PRKEY가 0이 아닌 경우,
- PRKEY와 일치하는 registrants의 등록을 해제한다.
If there is no reservation held on the namespace, then execution of the command causes registrants whose reservation key match the value of the PRKEY field to be unregistered.
If the existing reservation type is not Write Exclusive - All Registrants and not Exclusive Access - All Registrants, then a reservation holder may preempt itself using the above mechanism. When a host preempts itself the following occurs as an atomic operation:
• registration of the host is maintained;
• the reservation is released; and
• a new reservation is created for the host of the type specified by the RTYPE field.
A host may abort commands as a side effect of preempting a reservation by executing a Reservation Acquire command (refer to section 6.10) and setting the RACQA field to 010b (Preempt and Abort). The behavior of such a command is exactly the same as that described above with the RACQA field set to 001b (Preempt), with two exceptions:
1. After the atomic operation changes namespace reservation and registration state, all controllers associated with any host whose reservation or registration is preempted by that atomic operation are requested to abort all commands being processed that were addressed to the namespace specified in the Namespace Identifier field (i.e., the NSID field in the Reservation Acquire command) (refer to section 4.13 for the definition of “being processed”); and
2. Completion of the Reservation Acquire command shall not occur until all commands that are requested to be aborted are completed, regardless of whether or not each command is actually aborted.
8.8.8 Clearing a Reservation
A host that is a registrant may clear a reservation (i.e., force the release of a reservation held on the namespace and unregister all registrants) by executing a Reservation Release command (refer to section 6.12), setting the Reservation Release Action (RRELA) field to 001b (i.e., Clear), and supplying the current reservation key associated with the host in the Current Reservation Key (CRKEY) field. If the value in the CRKEY field does not match the value used by the host to register with the namespace, then the command shall be aborted with status Reservation Conflict. If the host is not a registrant, then the command is aborted with a status of Reservation Conflict. When a command to clear a reservation is executed the following occur as an atomic operation: the reservation held on the namespace, if any, is released, and all registrants are unregistered from the namespace.
A reservation preempted notification occurs on all controllers in the NVM subsystem that are associated with hosts that have their registrations removed as a result of actions taken in this section except those associated with the host that issued the Reservation Release command.
등록자인 호스트는 예약 해제 명령(섹션 6.12 참조)을 실행하고 예약 해제 액션(RRELA) 필드를 001b(즉, 지우기)로 설정하여 예약을 해제할 수 있습니다, 호스트와 연결된 현재 예약 키를 CRKEY(현재 예약 키) 필드에 제공합니다. CRKEY 필드의 값이 호스트가 네임스페이스에 등록하는 데 사용하는 값과 일치하지 않으면 명령이 예약 충돌 상태로 중단되어야 합니다. 호스트가 등록자가 아닌 경우 명령이 중단되고 예약 충돌 상태가 표시됩니다. 예약을 지우는 명령이 실행되면 다음과 같은 작업이 원자적 작업으로 수행됩니다. 네임스페이스에 유지된 예약이 있으면 해제되고 모든 등록자가 네임스페이스에서 등록 취소됩니다.
예약 우선 알림은 예약 릴리스 명령을 실행한 호스트와 관련된 작업을 제외하고 이 섹션에서 수행한 작업의 결과로 해당 등록이 제거된 호스트와 연결된 NVM 하위 시스템의 모든 컨트롤러에서 발생합니다.
8.8.9 Reporting Reservation Status
A host may determine the current reservation status associated with a namespace by executing a Reservation Report command (refer to section 6.13).
Overview

- controller는 하나의 host와 associate 할 수 있다.
- host는 여러 controller와 associate할 수 있다.
- host는 reservation 동작을 요청하기 전에, host는 각각의 controller에 host id를 등록한다.
- host는 reservation key를 register 함으로써, host id와 namespace 사이에 association을 생성한다.
- host id는 reservation key를 몰라도, key를 바꾸거나 unregister 할 수 있다. 단, reservation acquire 또는 preemt는 할 수 없다.
Reservation Command
| command | function |
| Reservation Acquire | Acquire; reservation 권한을 얻는다. Preempt; 남의 reservation 권한을 빼앗는다. Preempt and Abort |
| Reservation Register | Register reservation key Unregister reservation key Replace reservation key |
| Reservation Release | Release; 내 reservation 권한을 뱉는다. Clear |
| Reservation Report | namespace의 registrants와 reservation status 등의 data structure를 return한다. 단, registrants와 연결된 controller 개수만큼!!! |
Reservation Type

6개의 reservation type이 있다.
Write Exclusive - none, registrants only, all registrants의 차이는 뭘까? 셋의 차이가 nvme spec 1.4에 명확하게 설명은 되어 있지 않다. 내가 못 찾는 걸 수도 있지만. 이해하기로는,
- none은 namespace에 registrant가 1개뿐인 경우로 보인다. 그래서, 그 registrant가 reservation holder가 되면, 다른 registrant는 존재하지 않는다.
- registrants only는 registrants는 여러 host id가 존재할 수 있다. 그러나, 특정 host id만 reservation holder 권한을 갖는 것으로 보인다.
- all registrants는 registrants이기만 하면, reservation holder 권한을 갖는 것으로 보인다.
Registering: host id가 namespace를 독점하기 위해서는 register부터 해야 해!
host는 임의의 host id로 namespace에 reservation을 하기 전에, namespace에 reservation key를 등록함으로써, 해당 namespace에 registrant가 되어야 한다.
하나의 namespace에 여러 host id가 register 할 수 있다. 이건 마치, 계정(namespace)은 하나인데, user별(host id)로 비밀번호(reservation key)를 설정할 수 있다는 것으로 보인다.
기존에 등록된 reservation key값을 바꾸거나, 등록 해제하고 싶으면 어떻게 할까? 할 수 있다. 심지어 등록한 key값을 몰라도 된다. 이건 마치, 비밀번호(key)를 몰라도 다시 변경하거나 user를 삭제할 수 있는 것처럼.
Acquiring a Reservation: reservation holder가 없으면, reservation을 get 할 수 있어!
host와 namespace 연결된 상태에서, reservation을 획득할 수 있다. 이때, key값이 일치해야 한다. 만약에 key값 모르면 어떻게 합니까? 그러면, unregister를 하거나 key값을 변경하면 되겠지 - 이건 key값 몰라도 할 수 있잖아.
임의의 namespace에 reservation holder가 있을 때, 다른 host id가 reservation acquire를 할 수 있을까? 아니! acquire는 namespace에 reservation holder가 없는 상태에서 reservation 권한을 얻는 것이다. preempt는 할 수 있지.
reservation holder가 기존 reservation type과 다르게 reservation을 acquire 할 수 있을까? 아니! 이것도 preempt로 해야 한다.
Releasing a Reservation: 나 reservation holder인데, reservation 권한 뱉을게
reservation holder는 release 할 수 있다. key값 및 reservation type이 일치해야 정상 처리된다.
reservation holder가 아닌데, release를 시도한다면, 정상 처리한다. 그러나, 아무 일도 안 일어난다. holder가 아니니까.

reservation type이 Write Exclusive or Exclusive Access가 아닌 경우, 다른 host id에게 holder가 release 됐다는 것을 알려준다. 왜 그럴까? registrants only나 all registrants가 아닌 type은, reservation holder를 제외하고, 다른 registrant라는 게 없으니까? 그렇게 나는 해당 type을 이해하고 있다. 그러니까, reservation holder가 reservation 권한을 뱉었으면, 다른 host id들이 이를 알려 주라는 것이다. 그래야, 다른 host id들이 필요하면, reservation acquire를 시도하거나 하겠지.
Preempting a Reservation or Registration: reservation key값으로, reservation, registration을 뺏어올게!
이게 제일 난해하다. 그렇게 생각하는 이유는?
- register나 release 할 때는 "host id - reservation key" set로 의미를 가졌다. 그러나, preempt에서는 reservation key값 자체만으로 action을 할 수 있다.
- reservation holder의 reservation type에 따라서, spec 내용이 다르다.
- reservation을 빼앗아 오는 것은 이해가 된다. 그러나, registration도 빼앗는 것은 이해가 가지 않는다. 일부러, 다른 host id의 register를 해제하도록 하는 usage는 뭘까? 아!!! 새로 preempt 하는 reservation type이 all registrants라면, registration을 unregister 하는 것이 의미가 있네.
1. reservation type이 none 또는 registrants only인 경우, (공통점은 reservation holder 권한을 갖는 것이 holder 하나뿐이라는 거다)
a) PRKEY == holder의 reservation key,
- command를 issue 한 host id 외에 reservation key가 동일한 등록자(host id)들은 등록 해제된다.
- reservation이 release 된다.
- command issue 한 host id가 reservation을 get 한다.
b) PRKEY!= holder의 reservation key, reservation 권한은 빼앗지 못하겠지.
- key가 0이 아닌 경우, reservation key가 동일한 등록자(host id)들은 등록이 해제된다.
- key가 0인 경우, 에러 처리한다.
2. reservation type이 all registrants인 경우,
registrants가 reservation holder와 동일 권한을 갖는다. 그렇다면, 모든 registrants로부터 reservation 권한을 가져와야 한다는 뜻이다. 그런데, key값은 registrants마다 다 다를 수가 있어, 어떻게 reservation key값으로 reservation 권한을 가져오지? 그래서 PRKEY가 0인지 아닌지에 따라서, action을 구분하는 것으로 보인다.
a) PRKEY가 0인 경우, (모든 registrants의 reservation 권한을 다 빼앗을 거야!)
- command를 issue 한 host id 외에 다른 등록자(host id)들은 등록 해제된다.
- reservation이 release 된다.
- command issue 한 host id가 reservation을 get 한다.
b) PRKEY가 0이 아닌 경우, (reservation 권한을 가져오려는 게 아니고)
- PRKEY와 일치하는 registrants의 등록을 해제한다.
Clearing a Reservation: registrant는 namespace의 모든 registrants와 reservation을 clear!
registrant는 reservation key값을 가지고, 해당 namespace의 reservation과 all registrants를 clear 할 수 있다.
reference
- chat GPT
- nvme spec 1.4
'컴퓨터 > SSD' 카테고리의 다른 글
| [NVMe][OCP] Telemetry (0) | 2024.12.29 |
|---|---|
| [PCIe] Enumeration (0) | 2023.06.22 |
| [NVMe] Feature (0) | 2023.05.21 |
| [PCIe] Reset (1) | 2023.05.01 |
| [NVMe] Controller Initialization (1) | 2023.04.11 |



