xref: /freebsd/sys/contrib/openzfs/include/sys/bplist.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) 2005, 2010, Oracle and/or its affiliates. All rights reserved.
14  * Copyright (c) 2018 by Delphix. All rights reserved.
15  */
16 
17 #ifndef	_SYS_BPLIST_H
18 #define	_SYS_BPLIST_H
19 
20 #include <sys/zfs_context.h>
21 #include <sys/spa.h>
22 
23 #ifdef	__cplusplus
24 extern "C" {
25 #endif
26 
27 typedef struct bplist_entry {
28 	blkptr_t	bpe_blk;
29 	list_node_t	bpe_node;
30 } bplist_entry_t;
31 
32 typedef struct bplist {
33 	kmutex_t	bpl_lock;
34 	list_t		bpl_list;
35 } bplist_t;
36 
37 typedef int bplist_itor_t(void *arg, const blkptr_t *bp, dmu_tx_t *tx);
38 
39 void bplist_create(bplist_t *bpl);
40 void bplist_destroy(bplist_t *bpl);
41 void bplist_append(bplist_t *bpl, const blkptr_t *bp);
42 void bplist_iterate(bplist_t *bpl, bplist_itor_t *func,
43     void *arg, dmu_tx_t *tx);
44 void bplist_clear(bplist_t *bpl);
45 
46 #ifdef	__cplusplus
47 }
48 #endif
49 
50 #endif /* _SYS_BPLIST_H */
51