1 /*
2 * CDDL HEADER START
3 *
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 (c) 2000, 2010, Oracle and/or its affiliates. All rights reserved.
23 * Copyright (c) 2014 Nexenta Systems Inc. All rights reserved.
24 */
25
26 /*
27 * Multipath driver interface (MDI) implementation; see mdi_impldefs.h for a
28 * more detailed discussion of the overall mpxio architecture.
29 *
30 * Default locking order:
31 *
32 * _NOTE(LOCK_ORDER(mdi_mutex, mdi_vhci:vh_phci_mutex);
33 * _NOTE(LOCK_ORDER(mdi_mutex, mdi_vhci:vh_client_mutex);
34 * _NOTE(LOCK_ORDER(mdi_vhci:vh_phci_mutex, mdi_phci::ph_mutex);
35 * _NOTE(LOCK_ORDER(mdi_vhci:vh_client_mutex, mdi_client::ct_mutex);
36 * _NOTE(LOCK_ORDER(mdi_phci::ph_mutex mdi_pathinfo::pi_mutex))
37 * _NOTE(LOCK_ORDER(mdi_phci::ph_mutex mdi_client::ct_mutex))
38 * _NOTE(LOCK_ORDER(mdi_client::ct_mutex mdi_pathinfo::pi_mutex))
39 */
40
41 #include <sys/note.h>
42 #include <sys/types.h>
43 #include <sys/varargs.h>
44 #include <sys/param.h>
45 #include <sys/errno.h>
46 #include <sys/uio.h>
47 #include <sys/buf.h>
48 #include <sys/modctl.h>
49 #include <sys/open.h>
50 #include <sys/kmem.h>
51 #include <sys/poll.h>
52 #include <sys/conf.h>
53 #include <sys/bootconf.h>
54 #include <sys/cmn_err.h>
55 #include <sys/stat.h>
56 #include <sys/ddi.h>
57 #include <sys/sunddi.h>
58 #include <sys/ddipropdefs.h>
3653 */
3654 MDI_CLIENT_UNLOCK(ct);
3655 rv = ndi_devi_online(cdip, 0);
3656 MDI_CLIENT_LOCK(ct);
3657 if ((rv != NDI_SUCCESS) &&
3658 (MDI_CLIENT_STATE(ct) ==
3659 MDI_CLIENT_STATE_DEGRADED)) {
3660 MDI_DEBUG(1, (MDI_WARN, cdip,
3661 "!ndi_devi_online failed "
3662 "error %x", rv));
3663 }
3664 rv = NDI_SUCCESS;
3665 }
3666 break;
3667
3668 case MDI_CLIENT_STATE_FAILED:
3669 /*
3670 * This is the last path case for
3671 * non-user initiated events.
3672 */
3673 if (((flag & NDI_USER_REQ) == 0) &&
3674 cdip && (i_ddi_node_state(cdip) >=
3675 DS_INITIALIZED)) {
3676 MDI_CLIENT_UNLOCK(ct);
3677 rv = ndi_devi_offline(cdip,
3678 NDI_DEVFS_CLEAN);
3679 MDI_CLIENT_LOCK(ct);
3680
3681 if (rv != NDI_SUCCESS) {
3682 /*
3683 * ndi_devi_offline failed.
3684 * Reset client flags to
3685 * online as the path could not
3686 * be offlined.
3687 */
3688 MDI_DEBUG(1, (MDI_WARN, cdip,
3689 "!ndi_devi_offline failed: "
3690 "error %x", rv));
3691 MDI_CLIENT_SET_ONLINE(ct);
3692 }
3693 }
3694 break;
3695 }
3696 /*
3697 * Convert to MDI error code
3698 */
3699 switch (rv) {
3700 case NDI_SUCCESS:
3701 MDI_CLIENT_SET_REPORT_DEV_NEEDED(ct);
3702 i_mdi_report_path_state(ct, pip);
3703 rv = MDI_SUCCESS;
3704 break;
3705 case NDI_BUSY:
3706 rv = MDI_BUSY;
3707 break;
3708 default:
3709 rv = MDI_FAILURE;
3710 break;
3711 }
3712 }
3713 }
|
1 /*
2 * CDDL HEADER START
3 *
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 /*
23 * Copyright (c) 2000, 2010, Oracle and/or its affiliates. All rights reserved.
24 * Copyright (c) 2014 Nexenta Systems Inc. All rights reserved.
25 */
26
27 /*
28 * Multipath driver interface (MDI) implementation; see mdi_impldefs.h for a
29 * more detailed discussion of the overall mpxio architecture.
30 */
31
32 #include <sys/note.h>
33 #include <sys/types.h>
34 #include <sys/varargs.h>
35 #include <sys/param.h>
36 #include <sys/errno.h>
37 #include <sys/uio.h>
38 #include <sys/buf.h>
39 #include <sys/modctl.h>
40 #include <sys/open.h>
41 #include <sys/kmem.h>
42 #include <sys/poll.h>
43 #include <sys/conf.h>
44 #include <sys/bootconf.h>
45 #include <sys/cmn_err.h>
46 #include <sys/stat.h>
47 #include <sys/ddi.h>
48 #include <sys/sunddi.h>
49 #include <sys/ddipropdefs.h>
3644 */
3645 MDI_CLIENT_UNLOCK(ct);
3646 rv = ndi_devi_online(cdip, 0);
3647 MDI_CLIENT_LOCK(ct);
3648 if ((rv != NDI_SUCCESS) &&
3649 (MDI_CLIENT_STATE(ct) ==
3650 MDI_CLIENT_STATE_DEGRADED)) {
3651 MDI_DEBUG(1, (MDI_WARN, cdip,
3652 "!ndi_devi_online failed "
3653 "error %x", rv));
3654 }
3655 rv = NDI_SUCCESS;
3656 }
3657 break;
3658
3659 case MDI_CLIENT_STATE_FAILED:
3660 /*
3661 * This is the last path case for
3662 * non-user initiated events.
3663 */
3664 if ((flag & NDI_USER_REQ) ||
3665 cdip == NULL || i_ddi_node_state(cdip) <
3666 DS_INITIALIZED)
3667 break;
3668
3669 MDI_CLIENT_UNLOCK(ct);
3670 rv = ndi_devi_offline(cdip, NDI_DEVFS_CLEAN);
3671 MDI_CLIENT_LOCK(ct);
3672
3673 if (rv != NDI_SUCCESS) {
3674 /*
3675 * Reset client flags to online as the
3676 * path could not be offlined.
3677 */
3678 MDI_DEBUG(1, (MDI_WARN, cdip,
3679 "!ndi_devi_offline failed: %d",
3680 rv));
3681 MDI_CLIENT_SET_ONLINE(ct);
3682 }
3683 break;
3684 }
3685 /*
3686 * Convert to MDI error code
3687 */
3688 switch (rv) {
3689 case NDI_SUCCESS:
3690 MDI_CLIENT_SET_REPORT_DEV_NEEDED(ct);
3691 i_mdi_report_path_state(ct, pip);
3692 rv = MDI_SUCCESS;
3693 break;
3694 case NDI_BUSY:
3695 rv = MDI_BUSY;
3696 break;
3697 default:
3698 rv = MDI_FAILURE;
3699 break;
3700 }
3701 }
3702 }
|