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>
1461 */
1462 ct->ct_dip = NULL;
1463
1464 /*
1465 * Remove this client from our hash queue
1466 */
1467 i_mdi_client_delist_table(vh, ct);
1468
1469 /*
1470 * Uninitialize and free the component
1471 */
1472 kmem_free(ct->ct_drvname, strlen(ct->ct_drvname) + 1);
1473 kmem_free(ct->ct_guid, strlen(ct->ct_guid) + 1);
1474 kmem_free(ct->ct_lb_args, sizeof (client_lb_args_t));
1475 cv_destroy(&ct->ct_failover_cv);
1476 cv_destroy(&ct->ct_unstable_cv);
1477 cv_destroy(&ct->ct_powerchange_cv);
1478 mutex_destroy(&ct->ct_mutex);
1479 kmem_free(ct, sizeof (*ct));
1480
1481 if (cdip != NULL) {
1482 MDI_VHCI_CLIENT_UNLOCK(vh);
1483 (void) i_mdi_devinfo_remove(vdip, cdip, flags);
1484 MDI_VHCI_CLIENT_LOCK(vh);
1485 }
1486 return (rv);
1487 }
1488
1489 /*
1490 * i_mdi_client_find():
1491 * Find the client structure corresponding to a given guid
1492 * Caller should hold the vhci client lock.
1493 */
1494 static mdi_client_t *
1495 i_mdi_client_find(mdi_vhci_t *vh, char *cname, char *guid)
1496 {
1497 int index;
1498 struct client_hash *head;
1499 mdi_client_t *ct;
1500
1501 ASSERT(MDI_VHCI_CLIENT_LOCKED(vh));
1502
1503 index = i_mdi_get_hash_key(guid);
1504 head = &vh->vh_client_table[index];
1505
|
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 * Copyright (c) 2018, Joyent, Inc.
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 * Default locking order:
32 *
33 * _NOTE(LOCK_ORDER(mdi_mutex, mdi_vhci:vh_phci_mutex);
34 * _NOTE(LOCK_ORDER(mdi_mutex, mdi_vhci:vh_client_mutex);
35 * _NOTE(LOCK_ORDER(mdi_vhci:vh_phci_mutex, mdi_phci::ph_mutex);
36 * _NOTE(LOCK_ORDER(mdi_vhci:vh_client_mutex, mdi_client::ct_mutex);
37 * _NOTE(LOCK_ORDER(mdi_phci::ph_mutex mdi_pathinfo::pi_mutex))
38 * _NOTE(LOCK_ORDER(mdi_phci::ph_mutex mdi_client::ct_mutex))
39 * _NOTE(LOCK_ORDER(mdi_client::ct_mutex mdi_pathinfo::pi_mutex))
40 */
41
42 #include <sys/note.h>
43 #include <sys/types.h>
44 #include <sys/varargs.h>
1462 */
1463 ct->ct_dip = NULL;
1464
1465 /*
1466 * Remove this client from our hash queue
1467 */
1468 i_mdi_client_delist_table(vh, ct);
1469
1470 /*
1471 * Uninitialize and free the component
1472 */
1473 kmem_free(ct->ct_drvname, strlen(ct->ct_drvname) + 1);
1474 kmem_free(ct->ct_guid, strlen(ct->ct_guid) + 1);
1475 kmem_free(ct->ct_lb_args, sizeof (client_lb_args_t));
1476 cv_destroy(&ct->ct_failover_cv);
1477 cv_destroy(&ct->ct_unstable_cv);
1478 cv_destroy(&ct->ct_powerchange_cv);
1479 mutex_destroy(&ct->ct_mutex);
1480 kmem_free(ct, sizeof (*ct));
1481
1482 MDI_VHCI_CLIENT_UNLOCK(vh);
1483 (void) i_mdi_devinfo_remove(vdip, cdip, flags);
1484 MDI_VHCI_CLIENT_LOCK(vh);
1485
1486 return (rv);
1487 }
1488
1489 /*
1490 * i_mdi_client_find():
1491 * Find the client structure corresponding to a given guid
1492 * Caller should hold the vhci client lock.
1493 */
1494 static mdi_client_t *
1495 i_mdi_client_find(mdi_vhci_t *vh, char *cname, char *guid)
1496 {
1497 int index;
1498 struct client_hash *head;
1499 mdi_client_t *ct;
1500
1501 ASSERT(MDI_VHCI_CLIENT_LOCKED(vh));
1502
1503 index = i_mdi_get_hash_key(guid);
1504 head = &vh->vh_client_table[index];
1505
|