xref: /freebsd/sys/contrib/openzfs/lib/libzutil/zutil_import.h (revision 22649d4dba730d46244fd2dff4fd174903c8379f)
1 // SPDX-License-Identifier: CDDL-1.0
2 /*
3  * This file and its contents are supplied under the terms of the
4  * Common Development and Distribution License ("CDDL"), version 1.0.
5  * You may only use this file in accordance with the terms of version
6  * 1.0 of the CDDL.
7  *
8  * A full copy of the text of the CDDL should have accompanied this
9  * source.  A copy of the CDDL is also available via the Internet at
10  * https://opensource.org/license/CDDL-1.0.
11  */
12 /*
13  * Copyright 2015 Nexenta Systems, Inc. All rights reserved.
14  * Copyright (c) 2005, 2010, Oracle and/or its affiliates. All rights reserved.
15  * Copyright (c) 2012, 2018 by Delphix. All rights reserved.
16  * Copyright 2015 RackTop Systems.
17  * Copyright (c) 2016, Intel Corporation.
18  */
19 #ifndef _LIBZUTIL_ZUTIL_IMPORT_H_
20 #define	_LIBZUTIL_ZUTIL_IMPORT_H_
21 
22 #define	IMPORT_ORDER_PREFERRED_1	1
23 #define	IMPORT_ORDER_PREFERRED_2	2
24 #define	IMPORT_ORDER_SCAN_OFFSET	10
25 #define	IMPORT_ORDER_DEFAULT		100
26 
27 int label_paths(libpc_handle_t *hdl, nvlist_t *label, const char **path,
28     const char **devid);
29 int zpool_find_import_blkid(libpc_handle_t *hdl, pthread_mutex_t *lock,
30     avl_tree_t **slice_cache);
31 
32 void * zutil_alloc(libpc_handle_t *hdl, size_t size);
33 char *zutil_strdup(libpc_handle_t *hdl, const char *str);
34 
35 typedef struct rdsk_node {
36 	char *rn_name;			/* Full path to device */
37 	int rn_order;			/* Preferred order (low to high) */
38 	int rn_num_labels;		/* Number of valid labels */
39 	uint64_t rn_vdev_guid;		/* Expected vdev guid when set */
40 	libpc_handle_t *rn_hdl;
41 	nvlist_t *rn_config;		/* Label config */
42 	avl_tree_t *rn_avl;
43 	avl_node_t rn_node;
44 	pthread_mutex_t *rn_lock;
45 	boolean_t rn_labelpaths;
46 } rdsk_node_t;
47 
48 int slice_cache_compare(const void *, const void *);
49 
50 boolean_t zpool_dev_probe_ok(const char *path);
51 boolean_t zpool_dev_probe_ok_fd(int fd);
52 void zpool_open_func(void *);
53 
54 #endif /* _LIBZUTIL_ZUTIL_IMPORT_H_ */
55