4 * The contents of this file are subject to the terms of the
5 * Common Development and Distribution License (the "License").
6 * You may not use this file except in compliance with the License.
7 *
8 * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
9 * or http://www.opensolaris.org/os/licensing.
10 * See the License for the specific language governing permissions
11 * and limitations under the License.
12 *
13 * When distributing Covered Code, include this CDDL HEADER in each
14 * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
15 * If applicable, add the following below this CDDL HEADER, with the
16 * fields enclosed by brackets "[]" replaced with your own identifying
17 * information: Portions Copyright [yyyy] [name of copyright owner]
18 *
19 * CDDL HEADER END
20 */
21 /*
22 * Copyright 2009 Sun Microsystems, Inc. All rights reserved.
23 * Use is subject to license terms.
24 */
25
26 /*
27 * Storage Volume Character and Block Driver (SV)
28 *
29 * This driver implements a simplistic /dev/{r}dsk/ interface to a
30 * specified disk volume that is otherwise managed by the Prism
31 * software. The SV driver layers itself onto the underlying disk
32 * device driver by changing function pointers in the cb_ops
33 * structure.
34 *
35 * CONFIGURATION:
36 *
37 * 1. Configure the driver using the svadm utility.
38 * 2. Access the device as before through /dev/rdsk/c?t?d?s?
39 *
40 * LIMITATIONS:
41 *
42 * This driver should NOT be used to share a device between another
43 * DataServices user interface module (e.g., STE) and a user accessing
1219 rw_enter(&svp->sv_lock, RW_READER);
1220 }
1221
1222 odev = *devp;
1223
1224 if (maj && (fn = maj->sm_open) != 0) {
1225 if (!(maj->sm_flag & D_MP)) {
1226 UNSAFE_ENTER();
1227 ret = (*fn)(devp, flag, otyp, crp);
1228 UNSAFE_EXIT();
1229 } else {
1230 ret = (*fn)(devp, flag, otyp, crp);
1231 }
1232
1233 if (ret == 0) {
1234 /*
1235 * Re-acquire svp if the driver changed *devp.
1236 */
1237
1238 if (*devp != odev) {
1239 rw_exit(&svp->sv_lock);
1240
1241 svp = sv_dev_to_sv(*devp, NULL);
1242
1243 if (svp) {
1244 rw_enter(&svp->sv_lock, RW_READER);
1245 }
1246 }
1247 }
1248 } else {
1249 ret = ENODEV;
1250 }
1251
1252 if (svp && ret != 0 && svp->sv_state == SV_ENABLE) {
1253 /*
1254 * Underlying DDI open failed, but we have this
1255 * device SV enabled. If we can read some data
1256 * from the device, fake a successful open (this
1257 * probably means that this device is RDC'd and we
1258 * are getting the data from the secondary node).
|
4 * The contents of this file are subject to the terms of the
5 * Common Development and Distribution License (the "License").
6 * You may not use this file except in compliance with the License.
7 *
8 * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
9 * or http://www.opensolaris.org/os/licensing.
10 * See the License for the specific language governing permissions
11 * and limitations under the License.
12 *
13 * When distributing Covered Code, include this CDDL HEADER in each
14 * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
15 * If applicable, add the following below this CDDL HEADER, with the
16 * fields enclosed by brackets "[]" replaced with your own identifying
17 * information: Portions Copyright [yyyy] [name of copyright owner]
18 *
19 * CDDL HEADER END
20 */
21 /*
22 * Copyright 2009 Sun Microsystems, Inc. All rights reserved.
23 * Use is subject to license terms.
24 *
25 * Copyright 2011 Nexenta Systems, Inc. All rights reserved.
26 */
27
28 /*
29 * Storage Volume Character and Block Driver (SV)
30 *
31 * This driver implements a simplistic /dev/{r}dsk/ interface to a
32 * specified disk volume that is otherwise managed by the Prism
33 * software. The SV driver layers itself onto the underlying disk
34 * device driver by changing function pointers in the cb_ops
35 * structure.
36 *
37 * CONFIGURATION:
38 *
39 * 1. Configure the driver using the svadm utility.
40 * 2. Access the device as before through /dev/rdsk/c?t?d?s?
41 *
42 * LIMITATIONS:
43 *
44 * This driver should NOT be used to share a device between another
45 * DataServices user interface module (e.g., STE) and a user accessing
1221 rw_enter(&svp->sv_lock, RW_READER);
1222 }
1223
1224 odev = *devp;
1225
1226 if (maj && (fn = maj->sm_open) != 0) {
1227 if (!(maj->sm_flag & D_MP)) {
1228 UNSAFE_ENTER();
1229 ret = (*fn)(devp, flag, otyp, crp);
1230 UNSAFE_EXIT();
1231 } else {
1232 ret = (*fn)(devp, flag, otyp, crp);
1233 }
1234
1235 if (ret == 0) {
1236 /*
1237 * Re-acquire svp if the driver changed *devp.
1238 */
1239
1240 if (*devp != odev) {
1241 if (svp != NULL)
1242 rw_exit(&svp->sv_lock);
1243
1244 svp = sv_dev_to_sv(*devp, NULL);
1245
1246 if (svp) {
1247 rw_enter(&svp->sv_lock, RW_READER);
1248 }
1249 }
1250 }
1251 } else {
1252 ret = ENODEV;
1253 }
1254
1255 if (svp && ret != 0 && svp->sv_state == SV_ENABLE) {
1256 /*
1257 * Underlying DDI open failed, but we have this
1258 * device SV enabled. If we can read some data
1259 * from the device, fake a successful open (this
1260 * probably means that this device is RDC'd and we
1261 * are getting the data from the secondary node).
|