1

I am trying to write a program to block a LUN using SCSI 2 reservations.

In SCSI 2 reservations, can the LUN be reserved by the same host with a different path or the I-T-L nexus is only a single path.

Eg : Lets say the host tries to reserve the already reserved LUN from the same target but with the different port of the target. Is this possible?

Basically the LUN reservation would still be the same host but would be from different paths.

[EDIT] I have got the required response for the above mentioned problem but have another query. Lets say the host has reservation on LUN X and a connection drops or the host issues logout. What happens to the reservation? Whether it depends on the host driver to clear the reservation and clear its data or the reservation remains and other hosts would get a conflict if they try to reserve the same LUN. I tried googling it but could not find the specs related to this issue.

lokesharo
  • 305
  • 2
  • 11
  • I just noticed your edit, and responded below. Typically on StackOverflow if you have additional questions - even questions in the same area - it's best to post them as their own (individual) questions. Once the scope of a question gets too broad, the answers aren't as useful to others. It works best when a question and an answer have laser focus. Thanks though, and keep asking questions! – Mike Andrews Jun 26 '15 at 15:50

1 Answers1

1

Each I_T_L nexus is a single path. When you use the RESERVE(6) or RESERVE(10) commands described in SPC-2, that's what you're reserving. So, only one path can be active at a time. If that's what you want, then you're good! (Edit: to be clear, the second I_T_L nexus to issue RESERVE gets a reservation conflict.)

If your initiator and target can handle it, the PERSISTENT RESERVE/RELEASE commands in SPC-3 offer much more flexibility. You can register each nexus with the LU and then set an "exclusive-access registrants-only" reservation that blocks access to everyone else, but permits it to the registered nexuses.

An example of this can be seen in the description of a bug in the SCSI fence script used in the Redhat clustering software. The existing solution didn't interoperate with multipath I/O, because the redundant paths kept hitting reservation conflicts. The solution was to register all paths: https://bugzilla.redhat.com/show_bug.cgi?id=661134

[EDIT] to respond to your additional question: if the connection drops, the reservation is still held. From SPC-2:

This command shall request that the entire logical unit be reserved for the exclusive use of the initiator until the reservation is superseded by another valid RESERVE command from the same initiator or until released by a RELEASE command from the same initiator that made the reservation, by a TARGET RESET task management function performed by any initiator, by a hard reset condition, or by a power on cycle.

Mike Andrews
  • 3,045
  • 18
  • 28
  • Only one path can be active at a time. That sounds right. But lets say the host has SCSI 2 reservation from the Target1 Port1 and if the host again tries to reserve the same LUN from Target1 Port2, would that result in a reservation conflict? – lokesharo May 28 '15 at 08:31
  • Yes, with SCSI-2 (SPC-2) reservations, it would result in a conflict. It's a different I_T_L nexus. This sort of configuration is one of the things that prompted the design of persistent reservations in SPC-3. Check out this email thread on T10 for some more clarification: ftp://www.t10.org/t10/t10r/2007/r0701022.htm – Mike Andrews May 28 '15 at 14:19