]> git.proxmox.com Git - mirror_zfs.git/blob - zfs/lib/libzcommon/include/sys/dmu_traverse.h
Remove stray stub kernel files which should be brought in my linux-kernel-module...
[mirror_zfs.git] / zfs / lib / libzcommon / include / sys / dmu_traverse.h
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 2008 Sun Microsystems, Inc. All rights reserved.
23 * Use is subject to license terms.
24 */
25
26 #ifndef _SYS_DMU_TRAVERSE_H
27 #define _SYS_DMU_TRAVERSE_H
28
29 #pragma ident "@(#)dmu_traverse.h 1.4 08/04/01 SMI"
30
31 #include <sys/zfs_context.h>
32 #include <sys/spa.h>
33 #include <sys/zio.h>
34 #include <sys/dmu.h>
35 #include <sys/dnode.h>
36 #include <sys/arc.h>
37
38 #ifdef __cplusplus
39 extern "C" {
40 #endif
41
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 */
49
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)
55
56 #define ZB_MOS_CACHE 0
57 #define ZB_MDN_CACHE 1
58 #define ZB_DN_CACHE 2
59 #define ZB_DEPTH 3
60
61 typedef struct zseg {
62 uint64_t seg_mintxg;
63 uint64_t seg_maxtxg;
64 zbookmark_t seg_start;
65 zbookmark_t seg_end;
66 list_node_t seg_node;
67 } zseg_t;
68
69 typedef struct traverse_blk_cache {
70 zbookmark_t bc_bookmark;
71 blkptr_t bc_blkptr;
72 void *bc_data;
73 dnode_phys_t *bc_dnode;
74 int bc_errno;
75 int bc_pad1;
76 uint64_t bc_pad2;
77 } traverse_blk_cache_t;
78
79 typedef int (blkptr_cb_t)(traverse_blk_cache_t *bc, spa_t *spa, void *arg);
80
81 struct traverse_handle {
82 spa_t *th_spa;
83 blkptr_cb_t *th_func;
84 void *th_arg;
85 uint16_t th_advance;
86 uint16_t th_locked;
87 int th_zio_flags;
88 list_t th_seglist;
89 traverse_blk_cache_t th_cache[ZB_DEPTH][ZB_MAXLEVEL];
90 traverse_blk_cache_t th_zil_cache;
91 uint64_t th_hits;
92 uint64_t th_arc_hits;
93 uint64_t th_reads;
94 uint64_t th_callbacks;
95 uint64_t th_syncs;
96 uint64_t th_restarts;
97 zbookmark_t th_noread;
98 zbookmark_t th_lastcb;
99 };
100
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);
104
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);
108
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);
114
115 int traverse_more(traverse_handle_t *th);
116
117 #ifdef __cplusplus
118 }
119 #endif
120
121 #endif /* _SYS_DMU_TRAVERSE_H */