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.
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.
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]
22 * Copyright 2008 Sun Microsystems, Inc. All rights reserved.
23 * Use is subject to license terms.
26 #ifndef _SYS_DMU_TRAVERSE_H
27 #define _SYS_DMU_TRAVERSE_H
29 #pragma ident "@(#)dmu_traverse.h 1.4 08/04/01 SMI"
31 #include <sys/zfs_context.h>
35 #include <sys/dnode.h>
42 #define ADVANCE_POST 0 /* post-order traversal */
43 #define ADVANCE_PRE 0x01 /* pre-order traversal */
44 #define ADVANCE_PRUNE 0x02 /* prune by prev snapshot birth time */
45 #define ADVANCE_DATA 0x04 /* read user data blocks */
46 #define ADVANCE_HOLES 0x08 /* visit holes */
47 #define ADVANCE_ZIL 0x10 /* visit intent log blocks */
48 #define ADVANCE_NOLOCK 0x20 /* Don't grab SPA sync lock */
50 #define ZB_NO_LEVEL -2
51 #define ZB_MAXLEVEL 32 /* Next power of 2 >= DN_MAX_LEVELS */
52 #define ZB_MAXBLKID (1ULL << 62)
53 #define ZB_MAXOBJSET (1ULL << 62)
54 #define ZB_MAXOBJECT (1ULL << 62)
56 #define ZB_MOS_CACHE 0
57 #define ZB_MDN_CACHE 1
64 zbookmark_t seg_start
;
69 typedef struct traverse_blk_cache
{
70 zbookmark_t bc_bookmark
;
73 dnode_phys_t
*bc_dnode
;
77 } traverse_blk_cache_t
;
79 typedef int (blkptr_cb_t
)(traverse_blk_cache_t
*bc
, spa_t
*spa
, void *arg
);
81 struct traverse_handle
{
89 traverse_blk_cache_t th_cache
[ZB_DEPTH
][ZB_MAXLEVEL
];
90 traverse_blk_cache_t th_zil_cache
;
94 uint64_t th_callbacks
;
97 zbookmark_t th_noread
;
98 zbookmark_t th_lastcb
;
101 int traverse_dsl_dataset(struct dsl_dataset
*ds
, uint64_t txg_start
,
102 int advance
, blkptr_cb_t func
, void *arg
);
103 int traverse_zvol(objset_t
*os
, int advance
, blkptr_cb_t func
, void *arg
);
105 traverse_handle_t
*traverse_init(spa_t
*spa
, blkptr_cb_t
*func
, void *arg
,
106 int advance
, int zio_flags
);
107 void traverse_fini(traverse_handle_t
*th
);
109 void traverse_add_dnode(traverse_handle_t
*th
,
110 uint64_t mintxg
, uint64_t maxtxg
, uint64_t objset
, uint64_t object
);
111 void traverse_add_objset(traverse_handle_t
*th
,
112 uint64_t mintxg
, uint64_t maxtxg
, uint64_t objset
);
113 void traverse_add_pool(traverse_handle_t
*th
, uint64_t mintxg
, uint64_t maxtxg
);
115 int traverse_more(traverse_handle_t
*th
);
121 #endif /* _SYS_DMU_TRAVERSE_H */