xref: /freebsd/sys/contrib/openzfs/lib/libzutil/zutil_import.h (revision f81cdf24ba5436367377f7c8e8f51f6df2a75ca7)
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 https://opensource.org/licenses/CDDL-1.0.
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 2015 Nexenta Systems, Inc. All rights reserved.
23  * Copyright (c) 2005, 2010, Oracle and/or its affiliates. All rights reserved.
24  * Copyright (c) 2012, 2018 by Delphix. All rights reserved.
25  * Copyright 2015 RackTop Systems.
26  * Copyright (c) 2016, Intel Corporation.
27  */
28 #ifndef _LIBZUTIL_ZUTIL_IMPORT_H_
29 #define	_LIBZUTIL_ZUTIL_IMPORT_H_
30 
31 #define	IMPORT_ORDER_PREFERRED_1	1
32 #define	IMPORT_ORDER_PREFERRED_2	2
33 #define	IMPORT_ORDER_SCAN_OFFSET	10
34 #define	IMPORT_ORDER_DEFAULT		100
35 
36 int label_paths(libpc_handle_t *hdl, nvlist_t *label, const char **path,
37     const char **devid);
38 int zpool_find_import_blkid(libpc_handle_t *hdl, pthread_mutex_t *lock,
39     avl_tree_t **slice_cache);
40 
41 void * zutil_alloc(libpc_handle_t *hdl, size_t size);
42 char *zutil_strdup(libpc_handle_t *hdl, const char *str);
43 
44 typedef struct rdsk_node {
45 	char *rn_name;			/* Full path to device */
46 	int rn_order;			/* Preferred order (low to high) */
47 	int rn_num_labels;		/* Number of valid labels */
48 	uint64_t rn_vdev_guid;		/* Expected vdev guid when set */
49 	libpc_handle_t *rn_hdl;
50 	nvlist_t *rn_config;		/* Label config */
51 	avl_tree_t *rn_avl;
52 	avl_node_t rn_node;
53 	pthread_mutex_t *rn_lock;
54 	boolean_t rn_labelpaths;
55 } rdsk_node_t;
56 
57 int slice_cache_compare(const void *, const void *);
58 
59 void zpool_open_func(void *);
60 
61 #endif /* _LIBZUTIL_ZUTIL_IMPORT_H_ */
62