2 .\" Copyright (c) 2005 Sun Microsystems, Inc. All Rights Reserved.
3 .\" The contents of this file are subject to the terms of the Common Development and Distribution License (the "License"). You may not use this file except in compliance with the License.
4 .\" You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE or http://www.opensolaris.org/os/licensing. See the License for the specific language governing permissions and limitations under the License.
5 .\" When distributing Covered Code, include this CDDL HEADER in each file and include the License file at usr/src/OPENSOLARIS.LICENSE. If applicable, add the following below this CDDL HEADER, with the fields enclosed by brackets "[]" replaced with your own identifying information: Portions Copyright [yyyy] [name of copyright owner]
6 .TH MHD 7I "Mar 18, 2011"
8 mhd \- multihost disk control operations
12 \fB#include\fR \fB<sys/mhd.h>\fR
18 The \fBmhd\fR \fBioctl\fR(2) control access rights of a multihost disk, using
19 disk reservations on the disk device.
22 The stability level of this interface (see \fBattributes\fR(5)) is evolving. As
23 a result, the interface is subject to change and you should limit your use of
27 The mhd ioctls fall into two major categories: (1) ioctls for non-shared
28 multihost disks and (2) ioctls for shared multihost disks.
31 One ioctl, \fBMHIOCENFAILFAST\fR, is applicable to both non-shared and shared
32 multihost disks. It is described after the first two categories.
35 All the ioctls require root privilege.
38 For all of the ioctls, the caller should obtain the file descriptor for the
39 device by calling \fBopen\fR(2) with the \fBO_NDELAY\fR flag; without the
40 \fBO_NDELAY\fR flag, the open may fail due to another host already having a
41 conflicting reservation on the device. Some of the ioctls below permit the
42 caller to forcibly clear a conflicting reservation held by another host,
43 however, in order to call the ioctl, the caller must first obtain the open file
45 .SS "Non-shared multihost disks"
48 Non-shared multihost disks ioctls consist of \fBMHIOCTKOWN\fR,
49 \fBMHIOCRELEASE\fR, \fBHIOCSTATUS\fR, and \fBMHIOCQRESERVE\fR. These ioctl
50 requests control the access rights of non-shared multihost disks. A non-shared
51 multihost disk is one that supports serialized, mutually exclusive I/O mastery
52 by the connected hosts. This is in contrast to the shared-disk model, in which
53 concurrent access is allowed from more than one host (see below).
56 A non-shared multihost disk can be in one of two states:
61 Exclusive access state, where only one connected host has I/O access
67 Non-exclusive access state, where all connected hosts have I/O access. An
68 external hardware reset can cause the disk to enter the non-exclusive access
73 Each multihost disk driver views the machine on which it's running as the
74 "local host"; each views all other machines as "remote hosts". For each I/O or
75 ioctl request, the requesting host is the local host.
78 Note that the non-shared ioctls are designed to work with SCSI-2 disks. The
79 SCSI-2 RESERVE/RELEASE command set is the underlying hardware facility in the
80 device that supports the non-shared ioctls.
83 The function prototypes for the non-shared ioctls are:
87 ioctl(fd, MHIOCTKOWN);
88 ioctl(fd, MHIOCRELEASE);
89 ioctl(fd, MHIOCSTATUS);
90 ioctl(fd, MHIOCQRESERVE);
97 \fB\fBMHIOCTKOWN\fR \fR
100 Forcefully acquires exclusive access rights to the multihost disk for the local
101 host. Revokes all access rights to the multihost disk from remote hosts.
102 Causes the disk to enter the exclusive access state.
104 Implementation Note: Reservations (exclusive access rights) broken via random
105 resets should be reinstated by the driver upon their detection, for example, in
106 the automatic probe function described below.
112 \fB\fBMHIOCRELEASE\fR \fR
115 Relinquishes exclusive access rights to the multihost disk for the local host.
116 On success, causes the disk to enter the non- exclusive access state.
122 \fB\fBMHIOCSTATUS\fR \fR
125 Probes a multihost disk to determine whether the local host has access rights
126 to the disk. Returns \fB0\fR if the local host has access to the disk,
127 \fB1\fR if it doesn't, and \fB-1\fR with errno set to \fBEIO\fR if the probe
128 failed for some other reason.
134 \fB\fBMHIOCQRESERVE\fR \fR
137 Issues, simply and only, a SCSI-2 Reserve command. If the attempt to reserve
138 fails due to the SCSI error Reservation Conflict (which implies that some other
139 host has the device reserved), then the ioctl will return \fB-1\fR with errno
140 set to \fBEACCES\fR. The \fBMHIOCQRESERVE\fR ioctl does NOT issue a bus device
141 reset or bus reset prior to attempting the SCSI-2 reserve command. It also
142 does not take care of re-instating reservations that disappear due to bus
143 resets or bus device resets; if that behavior is desired, then the caller can
144 call \fBMHIOCTKOWN\fR after the \fBMHIOCQRESERVE\fR has returned success. If
145 the device does not support the SCSI-2 Reserve command, then the ioctl returns
146 \fB-1\fR with \fBerrno\fR set to \fBENOTSUP.\fR The \fBMHIOCQRESERVE\fR ioctl
147 is intended to be used by high-availability or clustering software for a
148 "quorum" disk, hence, the "Q" in the name of the ioctl.
151 .SS "Shared Multihost Disks"
154 Shared multihost disks ioctls control access to shared multihost disks. The
155 ioctls are merely a veneer on the SCSI-3 Persistent Reservation facility.
156 Therefore, the underlying semantic model is not described in detail here, see
157 instead the SCSI-3 standard. The SCSI-3 Persistent Reservations support the
158 concept of a group of hosts all sharing access to a disk.
161 The function prototypes and descriptions for the shared multihost ioctls are as
166 \fB\fBioctl\fR(\fBfd\fR, \fBMHIOCGRP_INKEYS\fR, (\fBmhioc_inkeys_t\fR)
171 Issues the SCSI-3 command Persistent Reserve In Read Keys to the device. On
172 input, the field \fBk->li\fR should be initialized by the caller with
173 \fBk->li.listsize\fR reflecting how big of an array the caller has allocated
174 for the \fBk->li.list\fR field and with \fBk->li.listlen\fR \fB==\fR \fB0.\fR
175 On return, the field \fBk->li.listlen\fR is updated to indicate the number of
176 reservation keys the device currently has: if this value is larger than
177 \fBk->li.listsize\fR then that indicates that the caller should have passed a
178 bigger \fBk->li.list\fR array with a bigger \fBk->li.listsize.\fR The number of
179 array elements actually written by the callee into \fBk->li.list\fR is the
180 minimum of \fBk->li.listlen\fR and \fBk->li.listsize.\fR The field
181 k->generation is updated with the generation information returned by the SCSI-3
182 Read Keys query. If the device does not support SCSI-3 Persistent Reservations,
183 then this ioctl returns \fB-1\fR with \fBerrno\fR set to \fBENOTSUP\fR.
189 \fB\fBioctl\fR(\fBfd\fR, \fBMHIOCGRP_INRESV\fR, (\fBmhioc_inresvs_t\fR)
194 Issues the SCSI-3 command Persistent Reserve In Read Reservations to the
195 device. Remarks similar to \fBMHIOCGRP_INKEYS\fR apply to the array
196 manipulation. If the device does not support SCSI-3 Persistent Reservations,
197 then this ioctl returns \fB-1\fR with \fBerrno\fR set to \fBENOTSUP\fR.
203 \fB\fBioctl\fR(\fBfd\fR, \fBMHIOCGRP_REGISTER\fR, (\fBmhioc_register_t\fR)
208 Issues the SCSI-3 command Persistent Reserve Out Register. The fields of
209 structure \fIr\fR are all inputs; none of the fields are modified by the ioctl.
210 The field \fBr->aptpl\fR should be set to true to specify that registrations
211 and reservations should persist across device power failures, or to false to
212 specify that registrations and reservations should be cleared upon device power
213 failure; true is the recommended setting. The field \fBr->oldkey\fR is the key
214 that the caller believes the device may already have for this host initiator;
215 if the caller believes that that this host initiator is not already registered
216 with this device, it should pass the special key of all zeros. To achieve the
217 effect of unregistering with the device, the caller should pass its current key
218 for the \fBr->oldkey\fR field and an \fBr->newkey\fR field containing the
219 special key of all zeros. If the device returns the SCSI error code
220 Reservation Conflict, this ioctl returns \fB-1\fR with \fBerrno\fR set to
227 \fB\fBioctl\fR(\fBfd\fR, \fBMHIOCGRP_RESERVE\fR, (\fBmhioc_resv_desc_t\fR)
232 Issues the SCSI-3 command Persistent Reserve Out Reserve. The fields of
233 structure \fIr\fR are all inputs; none of the fields are modified by the ioctl.
234 If the device returns the SCSI error code Reservation Conflict, this ioctl
235 returns \fB-1\fR with \fBerrno\fR set to \fBEACCES.\fR
241 \fB\fBioctl\fR(\fBfd\fR, \fBMHIOCGRP_PREEMPTANDABORT\fR,
242 (\fBmhioc_preemptandabort_t\fR) \fI*r\fR\fB);\fR\fR
246 Issues the SCSI-3 command Persistent Reserve Out Preempt-And-Abort. The fields
247 of structure \fIr\fR are all inputs; none of the fields are modified by the
248 ioctl. The key of the victim host is specified by the field
249 \fBr->victim_key\fR. The field \fBr->resvdesc\fR supplies the preempter's key
250 and the reservation that it is requesting as part of the SCSI-3
251 Preempt-And-Abort command. If the device returns the SCSI error code
252 Reservation Conflict, this ioctl returns \fB-1\fR with \fBerrno\fR set to
259 \fB\fBioctl\fR(\fBfd\fR, \fBMHIOCGRP_PREEMPT\fR,
260 (\fBmhioc_preemptandabort_t\fR) \fI*r\fR\fB);\fR\fR
264 Similar to \fBMHIOCGRP_PREEMPTANDABORT\fR, but instead issues the SCSI-3
265 command Persistent Reserve Out Preempt. (Note: This command is not
272 \fB\fBioctl\fR(\fBfd\fR, \fBMHIOCGRP_CLEAR\fR, (\fBmhioc_resv_key_t\fR)
277 Issues the SCSI-3 command Persistent Reserve Out Clear. The input parameter
278 \fIr\fR is the reservation key of the caller, which should have been already
279 registered with the device, by an earlier call to \fBMHIOCGRP_REGISTER\fR.
284 For each device, the non-shared ioctls should not be mixed with the Persistent
285 Reserve Out shared ioctls, and vice-versa, otherwise, the underlying device is
286 likely to return errors, because SCSI does not permit SCSI-2 reservations to be
287 mixed with SCSI-3 reservations on a single device. It is, however, legitimate
288 to call the Persistent Reserve In ioctls, because these are query only.
289 Issuing the \fBMHIOCGRP_INKEYS\fR ioctl is the recommended way for a caller to
290 determine if the device supports SCSI-3 Persistent Reservations (the ioctl
291 will return \fB-1\fR with \fBerrno\fR set to \fBENOTSUP\fR if the device does
293 .SS "MHIOCENFAILFAST Ioctl"
296 The \fBMHIOCENFAILFAST\fR ioctl is applicable for both non-shared and shared
297 disks, and may be used with either the non-shared or shared ioctls.
301 \fB\fBioctl\fR(\fBfd\fR, \fBMHIOENFAILFAST\fR, (unsigned int \fI*\fR)
302 \fImillisecs\fR\fB);\fR\fR
306 Enables or disables the failfast option in the multihost disk driver and
307 enables or disables automatic probing of a multihost disk, described below.
308 The argument is an unsigned integer specifying the number of milliseconds to
309 wait between executions of the automatic probe function. An argument of zero
310 disables the failfast option and disables automatic probing. If the
311 \fBMHIOCENFAILFAST\fR ioctl is never called, the effect is defined to be that
312 both the failfast option and automatic probing are disabled.
315 .SS "Automatic Probing"
318 The \fBMHIOCENFAILFAST\fR ioctl sets up a timeout in the driver to periodically
319 schedule automatic probes of the disk. The automatic probe function works in
320 this manner: The driver is scheduled to probe the multihost disk every n
321 milliseconds, rounded up to the next integral multiple of the system clock's
326 the local host no longer has access rights to the multihost disk, and
331 access rights were expected to be held by the local host,
335 the driver immediately panics the machine to comply with the failfast model.
338 If the driver makes this discovery outside the timeout function, especially
339 during a read or write operation, it is imperative that it panic the system
344 Each request returns \fB-1\fR on failure and sets \fBerrno\fR to indicate the
361 Access rights were denied.
370 The multihost disk or controller was unable to successfully complete the
377 \fB\fBEOPNOTSUP\fR \fR
380 The multihost disk does not support the operation. For example, it does not
381 support the SCSI-2 Reserve/Release command set, or the SCSI-3 Persistent
382 Reservation command set.
388 See \fBattributes\fR(5) for a description of the following attributes:
396 ATTRIBUTE TYPE ATTRIBUTE VALUE
404 \fBioctl\fR(2), \fBopen\fR(2), \fBattributes\fR(5), open(2)