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 */
24
25 /*
26 * Multipath driver interface (MDI) implementation; see mdi_impldefs.h for a
27 * more detailed discussion of the overall mpxio architecture.
28 *
29 * Default locking order:
30 *
31 * _NOTE(LOCK_ORDER(mdi_mutex, mdi_vhci:vh_phci_mutex);
32 * _NOTE(LOCK_ORDER(mdi_mutex, mdi_vhci:vh_client_mutex);
33 * _NOTE(LOCK_ORDER(mdi_vhci:vh_phci_mutex, mdi_phci::ph_mutex);
34 * _NOTE(LOCK_ORDER(mdi_vhci:vh_client_mutex, mdi_client::ct_mutex);
35 * _NOTE(LOCK_ORDER(mdi_phci::ph_mutex mdi_pathinfo::pi_mutex))
36 * _NOTE(LOCK_ORDER(mdi_phci::ph_mutex mdi_client::ct_mutex))
37 * _NOTE(LOCK_ORDER(mdi_client::ct_mutex mdi_pathinfo::pi_mutex))
38 */
39
40 #include <sys/note.h>
41 #include <sys/types.h>
42 #include <sys/varargs.h>
3639 rv = NDI_SUCCESS;
3640 i_mdi_client_update_state(ct);
3641 switch (MDI_CLIENT_STATE(ct)) {
3642 case MDI_CLIENT_STATE_OPTIMAL:
3643 case MDI_CLIENT_STATE_DEGRADED:
3644 if (cdip && !i_ddi_devi_attached(cdip) &&
3645 ((state == MDI_PATHINFO_STATE_ONLINE) ||
3646 (state == MDI_PATHINFO_STATE_STANDBY))) {
3647
3648 /*
3649 * Must do ndi_devi_online() through
3650 * hotplug thread for deferred
3651 * attach mechanism to work
3652 */
3653 MDI_CLIENT_UNLOCK(ct);
3654 rv = ndi_devi_online(cdip, 0);
3655 MDI_CLIENT_LOCK(ct);
3656 if ((rv != NDI_SUCCESS) &&
3657 (MDI_CLIENT_STATE(ct) ==
3658 MDI_CLIENT_STATE_DEGRADED)) {
3659 /*
3660 * ndi_devi_online failed.
3661 * Reset client flags to
3662 * offline.
3663 */
3664 MDI_DEBUG(1, (MDI_WARN, cdip,
3665 "!ndi_devi_online failed "
3666 "error %x", rv));
3667 MDI_CLIENT_SET_OFFLINE(ct);
3668 }
3669 if (rv != NDI_SUCCESS) {
3670 /* Reset the path state */
3671 MDI_PI_LOCK(pip);
3672 MDI_PI(pip)->pi_state =
3673 MDI_PI_OLD_STATE(pip);
3674 MDI_PI_UNLOCK(pip);
3675 }
3676 }
3677 break;
3678
3679 case MDI_CLIENT_STATE_FAILED:
3680 /*
3681 * This is the last path case for
3682 * non-user initiated events.
3683 */
3684 if (((flag & NDI_USER_REQ) == 0) &&
3685 cdip && (i_ddi_node_state(cdip) >=
3686 DS_INITIALIZED)) {
3687 MDI_CLIENT_UNLOCK(ct);
3688 rv = ndi_devi_offline(cdip,
3689 NDI_DEVFS_CLEAN);
3690 MDI_CLIENT_LOCK(ct);
3691
3692 if (rv != NDI_SUCCESS) {
3693 /*
3694 * ndi_devi_offline failed.
3695 * Reset client flags to
3696 * online as the path could not
|
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>
3640 rv = NDI_SUCCESS;
3641 i_mdi_client_update_state(ct);
3642 switch (MDI_CLIENT_STATE(ct)) {
3643 case MDI_CLIENT_STATE_OPTIMAL:
3644 case MDI_CLIENT_STATE_DEGRADED:
3645 if (cdip && !i_ddi_devi_attached(cdip) &&
3646 ((state == MDI_PATHINFO_STATE_ONLINE) ||
3647 (state == MDI_PATHINFO_STATE_STANDBY))) {
3648
3649 /*
3650 * Must do ndi_devi_online() through
3651 * hotplug thread for deferred
3652 * attach mechanism to work
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
|