xref: /freebsd/sys/contrib/openzfs/include/sys/objlist.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 (c) 2018 by Delphix. All rights reserved.
14  */
15 
16 #ifndef	_OBJLIST_H
17 #define	_OBJLIST_H
18 
19 #ifdef	__cplusplus
20 extern "C" {
21 #endif
22 
23 #include	<sys/zfs_context.h>
24 
25 typedef struct objlist_node {
26 	list_node_t	on_node;
27 	uint64_t	on_object;
28 } objlist_node_t;
29 
30 typedef struct objlist {
31 	list_t		ol_list; /* List of struct objnode. */
32 	/*
33 	 * Last object looked up. Used to assert that objects are being looked
34 	 * up in ascending order.
35 	 */
36 	uint64_t	ol_last_lookup;
37 } objlist_t;
38 
39 objlist_t *objlist_create(void);
40 void objlist_destroy(objlist_t *);
41 boolean_t objlist_exists(objlist_t *, uint64_t);
42 void objlist_insert(objlist_t *, uint64_t);
43 
44 #ifdef	__cplusplus
45 }
46 #endif
47 
48 #endif	/* _OBJLIST_H */
49