xref: /illumos-gate/usr/src/uts/common/fs/zfs/sys/bplist.h (revision 80ab886d233f514d54c2a6bdeb9fdfd951bd6881)
1 /*
2  * CDDL HEADER START
3  *
4  * The contents of this file are subject to the terms of the
5  * Common Development and Distribution License (the "License").
6  * You may not use this file except in compliance with the License.
7  *
8  * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
9  * or http://www.opensolaris.org/os/licensing.
10  * See the License for the specific language governing permissions
11  * and limitations under the License.
12  *
13  * When distributing Covered Code, include this CDDL HEADER in each
14  * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
15  * If applicable, add the following below this CDDL HEADER, with the
16  * fields enclosed by brackets "[]" replaced with your own identifying
17  * information: Portions Copyright [yyyy] [name of copyright owner]
18  *
19  * CDDL HEADER END
20  */
21 /*
22  * Copyright 2006 Sun Microsystems, Inc.  All rights reserved.
23  * Use is subject to license terms.
24  */
25 
26 #ifndef	_SYS_BPLIST_H
27 #define	_SYS_BPLIST_H
28 
29 #pragma ident	"%Z%%M%	%I%	%E% SMI"
30 
31 #include <sys/dmu.h>
32 #include <sys/spa.h>
33 #include <sys/txg.h>
34 #include <sys/zfs_context.h>
35 
36 #ifdef	__cplusplus
37 extern "C" {
38 #endif
39 
40 typedef struct bplist_phys {
41 	/*
42 	 * This is the bonus buffer for the dead lists.  The object's
43 	 * contents is an array of bpl_entries blkptr_t's, representing
44 	 * a total of bpl_bytes physical space.
45 	 */
46 	uint64_t	bpl_entries;
47 	uint64_t	bpl_bytes;
48 } bplist_phys_t;
49 
50 typedef struct bplist_q {
51 	blkptr_t	bpq_blk;
52 	void		*bpq_next;
53 } bplist_q_t;
54 
55 typedef struct bplist {
56 	kmutex_t	bpl_lock;
57 	objset_t	*bpl_mos;
58 	uint64_t	bpl_object;
59 	int		bpl_blockshift;
60 	int		bpl_bpshift;
61 	bplist_q_t	*bpl_queue;
62 	bplist_phys_t	*bpl_phys;
63 	dmu_buf_t	*bpl_dbuf;
64 	dmu_buf_t	*bpl_cached_dbuf;
65 } bplist_t;
66 
67 extern uint64_t bplist_create(objset_t *mos, int blocksize, dmu_tx_t *tx);
68 extern void bplist_destroy(objset_t *mos, uint64_t object, dmu_tx_t *tx);
69 extern int bplist_open(bplist_t *bpl, objset_t *mos, uint64_t object);
70 extern void bplist_close(bplist_t *bpl);
71 extern boolean_t bplist_empty(bplist_t *bpl);
72 extern int bplist_iterate(bplist_t *bpl, uint64_t *itorp, blkptr_t *bp);
73 extern int bplist_enqueue(bplist_t *bpl, blkptr_t *bp, dmu_tx_t *tx);
74 extern void bplist_enqueue_deferred(bplist_t *bpl, blkptr_t *bp);
75 extern void bplist_sync(bplist_t *bpl, dmu_tx_t *tx);
76 extern void bplist_vacate(bplist_t *bpl, dmu_tx_t *tx);
77 
78 #ifdef	__cplusplus
79 }
80 #endif
81 
82 #endif /* _SYS_BPLIST_H */
83