xref: /onnv-gate/usr/src/uts/common/fs/zfs/sys/bpobj.h (revision 12470:54258108784b)
1*12470SMatthew.Ahrens@Sun.COM /*
2*12470SMatthew.Ahrens@Sun.COM  * CDDL HEADER START
3*12470SMatthew.Ahrens@Sun.COM  *
4*12470SMatthew.Ahrens@Sun.COM  * The contents of this file are subject to the terms of the
5*12470SMatthew.Ahrens@Sun.COM  * Common Development and Distribution License (the "License").
6*12470SMatthew.Ahrens@Sun.COM  * You may not use this file except in compliance with the License.
7*12470SMatthew.Ahrens@Sun.COM  *
8*12470SMatthew.Ahrens@Sun.COM  * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
9*12470SMatthew.Ahrens@Sun.COM  * or http://www.opensolaris.org/os/licensing.
10*12470SMatthew.Ahrens@Sun.COM  * See the License for the specific language governing permissions
11*12470SMatthew.Ahrens@Sun.COM  * and limitations under the License.
12*12470SMatthew.Ahrens@Sun.COM  *
13*12470SMatthew.Ahrens@Sun.COM  * When distributing Covered Code, include this CDDL HEADER in each
14*12470SMatthew.Ahrens@Sun.COM  * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
15*12470SMatthew.Ahrens@Sun.COM  * If applicable, add the following below this CDDL HEADER, with the
16*12470SMatthew.Ahrens@Sun.COM  * fields enclosed by brackets "[]" replaced with your own identifying
17*12470SMatthew.Ahrens@Sun.COM  * information: Portions Copyright [yyyy] [name of copyright owner]
18*12470SMatthew.Ahrens@Sun.COM  *
19*12470SMatthew.Ahrens@Sun.COM  * CDDL HEADER END
20*12470SMatthew.Ahrens@Sun.COM  */
21*12470SMatthew.Ahrens@Sun.COM /*
22*12470SMatthew.Ahrens@Sun.COM  * Copyright (c) 2010, Oracle and/or its affiliates. All rights reserved.
23*12470SMatthew.Ahrens@Sun.COM  */
24*12470SMatthew.Ahrens@Sun.COM 
25*12470SMatthew.Ahrens@Sun.COM #ifndef	_SYS_BPOBJ_H
26*12470SMatthew.Ahrens@Sun.COM #define	_SYS_BPOBJ_H
27*12470SMatthew.Ahrens@Sun.COM 
28*12470SMatthew.Ahrens@Sun.COM #include <sys/dmu.h>
29*12470SMatthew.Ahrens@Sun.COM #include <sys/spa.h>
30*12470SMatthew.Ahrens@Sun.COM #include <sys/txg.h>
31*12470SMatthew.Ahrens@Sun.COM #include <sys/zio.h>
32*12470SMatthew.Ahrens@Sun.COM #include <sys/zfs_context.h>
33*12470SMatthew.Ahrens@Sun.COM 
34*12470SMatthew.Ahrens@Sun.COM #ifdef	__cplusplus
35*12470SMatthew.Ahrens@Sun.COM extern "C" {
36*12470SMatthew.Ahrens@Sun.COM #endif
37*12470SMatthew.Ahrens@Sun.COM 
38*12470SMatthew.Ahrens@Sun.COM typedef struct bpobj_phys {
39*12470SMatthew.Ahrens@Sun.COM 	/*
40*12470SMatthew.Ahrens@Sun.COM 	 * This is the bonus buffer for the dead lists.  The object's
41*12470SMatthew.Ahrens@Sun.COM 	 * contents is an array of bpo_entries blkptr_t's, representing
42*12470SMatthew.Ahrens@Sun.COM 	 * a total of bpo_bytes physical space.
43*12470SMatthew.Ahrens@Sun.COM 	 */
44*12470SMatthew.Ahrens@Sun.COM 	uint64_t	bpo_num_blkptrs;
45*12470SMatthew.Ahrens@Sun.COM 	uint64_t	bpo_bytes;
46*12470SMatthew.Ahrens@Sun.COM 	uint64_t	bpo_comp;
47*12470SMatthew.Ahrens@Sun.COM 	uint64_t	bpo_uncomp;
48*12470SMatthew.Ahrens@Sun.COM 	uint64_t	bpo_subobjs;
49*12470SMatthew.Ahrens@Sun.COM 	uint64_t	bpo_num_subobjs;
50*12470SMatthew.Ahrens@Sun.COM } bpobj_phys_t;
51*12470SMatthew.Ahrens@Sun.COM 
52*12470SMatthew.Ahrens@Sun.COM #define	BPOBJ_SIZE_V0	(2 * sizeof (uint64_t))
53*12470SMatthew.Ahrens@Sun.COM #define	BPOBJ_SIZE_V1	(4 * sizeof (uint64_t))
54*12470SMatthew.Ahrens@Sun.COM 
55*12470SMatthew.Ahrens@Sun.COM typedef struct bpobj {
56*12470SMatthew.Ahrens@Sun.COM 	kmutex_t	bpo_lock;
57*12470SMatthew.Ahrens@Sun.COM 	objset_t	*bpo_os;
58*12470SMatthew.Ahrens@Sun.COM 	uint64_t	bpo_object;
59*12470SMatthew.Ahrens@Sun.COM 	int		bpo_epb;
60*12470SMatthew.Ahrens@Sun.COM 	uint8_t		bpo_havecomp;
61*12470SMatthew.Ahrens@Sun.COM 	uint8_t		bpo_havesubobj;
62*12470SMatthew.Ahrens@Sun.COM 	bpobj_phys_t	*bpo_phys;
63*12470SMatthew.Ahrens@Sun.COM 	dmu_buf_t	*bpo_dbuf;
64*12470SMatthew.Ahrens@Sun.COM 	dmu_buf_t	*bpo_cached_dbuf;
65*12470SMatthew.Ahrens@Sun.COM } bpobj_t;
66*12470SMatthew.Ahrens@Sun.COM 
67*12470SMatthew.Ahrens@Sun.COM typedef int bpobj_itor_t(void *arg, const blkptr_t *bp, dmu_tx_t *tx);
68*12470SMatthew.Ahrens@Sun.COM 
69*12470SMatthew.Ahrens@Sun.COM uint64_t bpobj_alloc(objset_t *mos, int blocksize, dmu_tx_t *tx);
70*12470SMatthew.Ahrens@Sun.COM void bpobj_free(objset_t *os, uint64_t obj, dmu_tx_t *tx);
71*12470SMatthew.Ahrens@Sun.COM 
72*12470SMatthew.Ahrens@Sun.COM int bpobj_open(bpobj_t *bpo, objset_t *mos, uint64_t object);
73*12470SMatthew.Ahrens@Sun.COM void bpobj_close(bpobj_t *bpo);
74*12470SMatthew.Ahrens@Sun.COM 
75*12470SMatthew.Ahrens@Sun.COM int bpobj_iterate(bpobj_t *bpo, bpobj_itor_t func, void *arg, dmu_tx_t *tx);
76*12470SMatthew.Ahrens@Sun.COM int bpobj_iterate_nofree(bpobj_t *bpo, bpobj_itor_t func, void *, dmu_tx_t *);
77*12470SMatthew.Ahrens@Sun.COM int bpobj_iterate_dbg(bpobj_t *bpo, uint64_t *itorp, blkptr_t *bp);
78*12470SMatthew.Ahrens@Sun.COM 
79*12470SMatthew.Ahrens@Sun.COM void bpobj_enqueue_subobj(bpobj_t *bpo, uint64_t subobj, dmu_tx_t *tx);
80*12470SMatthew.Ahrens@Sun.COM void bpobj_enqueue(bpobj_t *bpo, const blkptr_t *bp, dmu_tx_t *tx);
81*12470SMatthew.Ahrens@Sun.COM 
82*12470SMatthew.Ahrens@Sun.COM int bpobj_space(bpobj_t *bpo,
83*12470SMatthew.Ahrens@Sun.COM     uint64_t *usedp, uint64_t *compp, uint64_t *uncompp);
84*12470SMatthew.Ahrens@Sun.COM int bpobj_space_range(bpobj_t *bpo, uint64_t mintxg, uint64_t maxtxg,
85*12470SMatthew.Ahrens@Sun.COM     uint64_t *usedp, uint64_t *compp, uint64_t *uncompp);
86*12470SMatthew.Ahrens@Sun.COM 
87*12470SMatthew.Ahrens@Sun.COM #ifdef	__cplusplus
88*12470SMatthew.Ahrens@Sun.COM }
89*12470SMatthew.Ahrens@Sun.COM #endif
90*12470SMatthew.Ahrens@Sun.COM 
91*12470SMatthew.Ahrens@Sun.COM #endif /* _SYS_BPOBJ_H */
92