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