xref: /freebsd/sys/contrib/openzfs/include/sys/objlist.h (revision 61145dc2b94f12f6a47344fb9aac702321880e43)
1 // SPDX-License-Identifier: CDDL-1.0
2 /*
3  * CDDL HEADER START
4  *
5  * This file and its contents are supplied under the terms of the
6  * Common Development and Distribution License ("CDDL"), version 1.0.
7  * You may only use this file in accordance with the terms of version
8  * 1.0 of the CDDL.
9  *
10  * A full copy of the text of the CDDL should have accompanied this
11  * source.  A copy of the CDDL is also available via the Internet at
12  * http://www.illumos.org/license/CDDL.
13  *
14  * CDDL HEADER END
15  */
16 /*
17  * Copyright (c) 2018 by Delphix. All rights reserved.
18  */
19 
20 #ifndef	_OBJLIST_H
21 #define	_OBJLIST_H
22 
23 #ifdef	__cplusplus
24 extern "C" {
25 #endif
26 
27 #include	<sys/zfs_context.h>
28 
29 typedef struct objlist_node {
30 	list_node_t	on_node;
31 	uint64_t	on_object;
32 } objlist_node_t;
33 
34 typedef struct objlist {
35 	list_t		ol_list; /* List of struct objnode. */
36 	/*
37 	 * Last object looked up. Used to assert that objects are being looked
38 	 * up in ascending order.
39 	 */
40 	uint64_t	ol_last_lookup;
41 } objlist_t;
42 
43 objlist_t *objlist_create(void);
44 void objlist_destroy(objlist_t *);
45 boolean_t objlist_exists(objlist_t *, uint64_t);
46 void objlist_insert(objlist_t *, uint64_t);
47 
48 #ifdef	__cplusplus
49 }
50 #endif
51 
52 #endif	/* _OBJLIST_H */
53