author | ahrens |
Mon, 07 Jul 2008 13:39:21 -0700 | |
changeset 7046 | 361307ae060d |
parent 6987 | 877c018eb06c |
child 7147 | 1e1d75c88283 |
permissions | -rw-r--r-- |
789 | 1 |
/* |
2 |
* CDDL HEADER START |
|
3 |
* |
|
4 |
* The contents of this file are subject to the terms of the |
|
1544 | 5 |
* Common Development and Distribution License (the "License"). |
6 |
* You may not use this file except in compliance with the License. |
|
789 | 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 |
/* |
|
5810 | 22 |
* Copyright 2008 Sun Microsystems, Inc. All rights reserved. |
789 | 23 |
* Use is subject to license terms. |
24 |
*/ |
|
25 |
||
26 |
#ifndef _SYS_SPA_H |
|
27 |
#define _SYS_SPA_H |
|
28 |
||
29 |
#pragma ident "%Z%%M% %I% %E% SMI" |
|
30 |
||
31 |
#include <sys/avl.h> |
|
32 |
#include <sys/zfs_context.h> |
|
33 |
#include <sys/nvpair.h> |
|
34 |
#include <sys/sysmacros.h> |
|
35 |
#include <sys/types.h> |
|
36 |
#include <sys/fs/zfs.h> |
|
37 |
||
38 |
#ifdef __cplusplus |
|
39 |
extern "C" { |
|
40 |
#endif |
|
41 |
||
42 |
/* |
|
43 |
* Forward references that lots of things need. |
|
44 |
*/ |
|
45 |
typedef struct spa spa_t; |
|
46 |
typedef struct vdev vdev_t; |
|
47 |
typedef struct metaslab metaslab_t; |
|
48 |
typedef struct zilog zilog_t; |
|
49 |
typedef struct traverse_handle traverse_handle_t; |
|
5450 | 50 |
typedef struct spa_aux_vdev spa_aux_vdev_t; |
789 | 51 |
struct dsl_pool; |
52 |
||
53 |
/* |
|
54 |
* General-purpose 32-bit and 64-bit bitfield encodings. |
|
55 |
*/ |
|
56 |
#define BF32_DECODE(x, low, len) P2PHASE((x) >> (low), 1U << (len)) |
|
57 |
#define BF64_DECODE(x, low, len) P2PHASE((x) >> (low), 1ULL << (len)) |
|
58 |
#define BF32_ENCODE(x, low, len) (P2PHASE((x), 1U << (len)) << (low)) |
|
59 |
#define BF64_ENCODE(x, low, len) (P2PHASE((x), 1ULL << (len)) << (low)) |
|
60 |
||
61 |
#define BF32_GET(x, low, len) BF32_DECODE(x, low, len) |
|
62 |
#define BF64_GET(x, low, len) BF64_DECODE(x, low, len) |
|
63 |
||
64 |
#define BF32_SET(x, low, len, val) \ |
|
2856 | 65 |
((x) ^= BF32_ENCODE((x >> low) ^ (val), low, len)) |
789 | 66 |
#define BF64_SET(x, low, len, val) \ |
2856 | 67 |
((x) ^= BF64_ENCODE((x >> low) ^ (val), low, len)) |
789 | 68 |
|
69 |
#define BF32_GET_SB(x, low, len, shift, bias) \ |
|
70 |
((BF32_GET(x, low, len) + (bias)) << (shift)) |
|
71 |
#define BF64_GET_SB(x, low, len, shift, bias) \ |
|
72 |
((BF64_GET(x, low, len) + (bias)) << (shift)) |
|
73 |
||
74 |
#define BF32_SET_SB(x, low, len, shift, bias, val) \ |
|
75 |
BF32_SET(x, low, len, ((val) >> (shift)) - (bias)) |
|
76 |
#define BF64_SET_SB(x, low, len, shift, bias, val) \ |
|
77 |
BF64_SET(x, low, len, ((val) >> (shift)) - (bias)) |
|
78 |
||
79 |
/* |
|
80 |
* We currently support nine block sizes, from 512 bytes to 128K. |
|
81 |
* We could go higher, but the benefits are near-zero and the cost |
|
82 |
* of COWing a giant block to modify one byte would become excessive. |
|
83 |
*/ |
|
84 |
#define SPA_MINBLOCKSHIFT 9 |
|
85 |
#define SPA_MAXBLOCKSHIFT 17 |
|
86 |
#define SPA_MINBLOCKSIZE (1ULL << SPA_MINBLOCKSHIFT) |
|
87 |
#define SPA_MAXBLOCKSIZE (1ULL << SPA_MAXBLOCKSHIFT) |
|
88 |
||
89 |
#define SPA_BLOCKSIZES (SPA_MAXBLOCKSHIFT - SPA_MINBLOCKSHIFT + 1) |
|
90 |
||
91 |
/* |
|
92 |
* The DVA size encodings for LSIZE and PSIZE support blocks up to 32MB. |
|
93 |
* The ASIZE encoding should be at least 64 times larger (6 more bits) |
|
94 |
* to support up to 4-way RAID-Z mirror mode with worst-case gang block |
|
95 |
* overhead, three DVAs per bp, plus one more bit in case we do anything |
|
96 |
* else that expands the ASIZE. |
|
97 |
*/ |
|
98 |
#define SPA_LSIZEBITS 16 /* LSIZE up to 32M (2^16 * 512) */ |
|
99 |
#define SPA_PSIZEBITS 16 /* PSIZE up to 32M (2^16 * 512) */ |
|
100 |
#define SPA_ASIZEBITS 24 /* ASIZE up to 64 times larger */ |
|
101 |
||
102 |
/* |
|
103 |
* All SPA data is represented by 128-bit data virtual addresses (DVAs). |
|
104 |
* The members of the dva_t should be considered opaque outside the SPA. |
|
105 |
*/ |
|
106 |
typedef struct dva { |
|
107 |
uint64_t dva_word[2]; |
|
108 |
} dva_t; |
|
109 |
||
110 |
/* |
|
111 |
* Each block has a 256-bit checksum -- strong enough for cryptographic hashes. |
|
112 |
*/ |
|
113 |
typedef struct zio_cksum { |
|
114 |
uint64_t zc_word[4]; |
|
115 |
} zio_cksum_t; |
|
116 |
||
117 |
/* |
|
118 |
* Each block is described by its DVAs, time of birth, checksum, etc. |
|
119 |
* The word-by-word, bit-by-bit layout of the blkptr is as follows: |
|
120 |
* |
|
121 |
* 64 56 48 40 32 24 16 8 0 |
|
122 |
* +-------+-------+-------+-------+-------+-------+-------+-------+ |
|
123 |
* 0 | vdev1 | GRID | ASIZE | |
|
124 |
* +-------+-------+-------+-------+-------+-------+-------+-------+ |
|
125 |
* 1 |G| offset1 | |
|
126 |
* +-------+-------+-------+-------+-------+-------+-------+-------+ |
|
127 |
* 2 | vdev2 | GRID | ASIZE | |
|
128 |
* +-------+-------+-------+-------+-------+-------+-------+-------+ |
|
129 |
* 3 |G| offset2 | |
|
130 |
* +-------+-------+-------+-------+-------+-------+-------+-------+ |
|
131 |
* 4 | vdev3 | GRID | ASIZE | |
|
132 |
* +-------+-------+-------+-------+-------+-------+-------+-------+ |
|
133 |
* 5 |G| offset3 | |
|
134 |
* +-------+-------+-------+-------+-------+-------+-------+-------+ |
|
135 |
* 6 |E| lvl | type | cksum | comp | PSIZE | LSIZE | |
|
136 |
* +-------+-------+-------+-------+-------+-------+-------+-------+ |
|
137 |
* 7 | padding | |
|
138 |
* +-------+-------+-------+-------+-------+-------+-------+-------+ |
|
139 |
* 8 | padding | |
|
140 |
* +-------+-------+-------+-------+-------+-------+-------+-------+ |
|
141 |
* 9 | padding | |
|
142 |
* +-------+-------+-------+-------+-------+-------+-------+-------+ |
|
143 |
* a | birth txg | |
|
144 |
* +-------+-------+-------+-------+-------+-------+-------+-------+ |
|
145 |
* b | fill count | |
|
146 |
* +-------+-------+-------+-------+-------+-------+-------+-------+ |
|
147 |
* c | checksum[0] | |
|
148 |
* +-------+-------+-------+-------+-------+-------+-------+-------+ |
|
149 |
* d | checksum[1] | |
|
150 |
* +-------+-------+-------+-------+-------+-------+-------+-------+ |
|
151 |
* e | checksum[2] | |
|
152 |
* +-------+-------+-------+-------+-------+-------+-------+-------+ |
|
153 |
* f | checksum[3] | |
|
154 |
* +-------+-------+-------+-------+-------+-------+-------+-------+ |
|
155 |
* |
|
156 |
* Legend: |
|
157 |
* |
|
158 |
* vdev virtual device ID |
|
159 |
* offset offset into virtual device |
|
160 |
* LSIZE logical size |
|
161 |
* PSIZE physical size (after compression) |
|
162 |
* ASIZE allocated size (including RAID-Z parity and gang block headers) |
|
163 |
* GRID RAID-Z layout information (reserved for future use) |
|
164 |
* cksum checksum function |
|
165 |
* comp compression function |
|
166 |
* G gang block indicator |
|
167 |
* E endianness |
|
168 |
* type DMU object type |
|
169 |
* lvl level of indirection |
|
170 |
* birth txg transaction group in which the block was born |
|
171 |
* fill count number of non-zero blocks under this bp |
|
172 |
* checksum[4] 256-bit checksum of the data this bp describes |
|
173 |
*/ |
|
174 |
typedef struct blkptr { |
|
175 |
dva_t blk_dva[3]; /* 128-bit Data Virtual Address */ |
|
176 |
uint64_t blk_prop; /* size, compression, type, etc */ |
|
177 |
uint64_t blk_pad[3]; /* Extra space for the future */ |
|
178 |
uint64_t blk_birth; /* transaction group at birth */ |
|
179 |
uint64_t blk_fill; /* fill count */ |
|
180 |
zio_cksum_t blk_cksum; /* 256-bit checksum */ |
|
181 |
} blkptr_t; |
|
182 |
||
183 |
#define SPA_BLKPTRSHIFT 7 /* blkptr_t is 128 bytes */ |
|
184 |
#define SPA_DVAS_PER_BP 3 /* Number of DVAs in a bp */ |
|
185 |
||
186 |
/* |
|
187 |
* Macros to get and set fields in a bp or DVA. |
|
188 |
*/ |
|
189 |
#define DVA_GET_ASIZE(dva) \ |
|
190 |
BF64_GET_SB((dva)->dva_word[0], 0, 24, SPA_MINBLOCKSHIFT, 0) |
|
191 |
#define DVA_SET_ASIZE(dva, x) \ |
|
192 |
BF64_SET_SB((dva)->dva_word[0], 0, 24, SPA_MINBLOCKSHIFT, 0, x) |
|
193 |
||
194 |
#define DVA_GET_GRID(dva) BF64_GET((dva)->dva_word[0], 24, 8) |
|
195 |
#define DVA_SET_GRID(dva, x) BF64_SET((dva)->dva_word[0], 24, 8, x) |
|
196 |
||
197 |
#define DVA_GET_VDEV(dva) BF64_GET((dva)->dva_word[0], 32, 32) |
|
198 |
#define DVA_SET_VDEV(dva, x) BF64_SET((dva)->dva_word[0], 32, 32, x) |
|
199 |
||
200 |
#define DVA_GET_OFFSET(dva) \ |
|
201 |
BF64_GET_SB((dva)->dva_word[1], 0, 63, SPA_MINBLOCKSHIFT, 0) |
|
202 |
#define DVA_SET_OFFSET(dva, x) \ |
|
203 |
BF64_SET_SB((dva)->dva_word[1], 0, 63, SPA_MINBLOCKSHIFT, 0, x) |
|
204 |
||
205 |
#define DVA_GET_GANG(dva) BF64_GET((dva)->dva_word[1], 63, 1) |
|
206 |
#define DVA_SET_GANG(dva, x) BF64_SET((dva)->dva_word[1], 63, 1, x) |
|
207 |
||
208 |
#define BP_GET_LSIZE(bp) \ |
|
209 |
(BP_IS_HOLE(bp) ? 0 : \ |
|
210 |
BF64_GET_SB((bp)->blk_prop, 0, 16, SPA_MINBLOCKSHIFT, 1)) |
|
211 |
#define BP_SET_LSIZE(bp, x) \ |
|
212 |
BF64_SET_SB((bp)->blk_prop, 0, 16, SPA_MINBLOCKSHIFT, 1, x) |
|
213 |
||
214 |
#define BP_GET_PSIZE(bp) \ |
|
215 |
BF64_GET_SB((bp)->blk_prop, 16, 16, SPA_MINBLOCKSHIFT, 1) |
|
216 |
#define BP_SET_PSIZE(bp, x) \ |
|
217 |
BF64_SET_SB((bp)->blk_prop, 16, 16, SPA_MINBLOCKSHIFT, 1, x) |
|
218 |
||
219 |
#define BP_GET_COMPRESS(bp) BF64_GET((bp)->blk_prop, 32, 8) |
|
220 |
#define BP_SET_COMPRESS(bp, x) BF64_SET((bp)->blk_prop, 32, 8, x) |
|
221 |
||
222 |
#define BP_GET_CHECKSUM(bp) BF64_GET((bp)->blk_prop, 40, 8) |
|
223 |
#define BP_SET_CHECKSUM(bp, x) BF64_SET((bp)->blk_prop, 40, 8, x) |
|
224 |
||
225 |
#define BP_GET_TYPE(bp) BF64_GET((bp)->blk_prop, 48, 8) |
|
226 |
#define BP_SET_TYPE(bp, x) BF64_SET((bp)->blk_prop, 48, 8, x) |
|
227 |
||
228 |
#define BP_GET_LEVEL(bp) BF64_GET((bp)->blk_prop, 56, 5) |
|
229 |
#define BP_SET_LEVEL(bp, x) BF64_SET((bp)->blk_prop, 56, 5, x) |
|
230 |
||
231 |
#define BP_GET_BYTEORDER(bp) (0 - BF64_GET((bp)->blk_prop, 63, 1)) |
|
232 |
#define BP_SET_BYTEORDER(bp, x) BF64_SET((bp)->blk_prop, 63, 1, x) |
|
233 |
||
234 |
#define BP_GET_ASIZE(bp) \ |
|
235 |
(DVA_GET_ASIZE(&(bp)->blk_dva[0]) + DVA_GET_ASIZE(&(bp)->blk_dva[1]) + \ |
|
2082 | 236 |
DVA_GET_ASIZE(&(bp)->blk_dva[2])) |
237 |
||
238 |
#define BP_GET_UCSIZE(bp) \ |
|
239 |
((BP_GET_LEVEL(bp) > 0 || dmu_ot[BP_GET_TYPE(bp)].ot_metadata) ? \ |
|
240 |
BP_GET_PSIZE(bp) : BP_GET_LSIZE(bp)); |
|
789 | 241 |
|
1775
e51e26b432c0
6410698 ZFS metadata needs to be more highly replicated (ditto blocks)
billm
parents:
1760
diff
changeset
|
242 |
#define BP_GET_NDVAS(bp) \ |
e51e26b432c0
6410698 ZFS metadata needs to be more highly replicated (ditto blocks)
billm
parents:
1760
diff
changeset
|
243 |
(!!DVA_GET_ASIZE(&(bp)->blk_dva[0]) + \ |
e51e26b432c0
6410698 ZFS metadata needs to be more highly replicated (ditto blocks)
billm
parents:
1760
diff
changeset
|
244 |
!!DVA_GET_ASIZE(&(bp)->blk_dva[1]) + \ |
e51e26b432c0
6410698 ZFS metadata needs to be more highly replicated (ditto blocks)
billm
parents:
1760
diff
changeset
|
245 |
!!DVA_GET_ASIZE(&(bp)->blk_dva[2])) |
e51e26b432c0
6410698 ZFS metadata needs to be more highly replicated (ditto blocks)
billm
parents:
1760
diff
changeset
|
246 |
|
e51e26b432c0
6410698 ZFS metadata needs to be more highly replicated (ditto blocks)
billm
parents:
1760
diff
changeset
|
247 |
#define BP_COUNT_GANG(bp) \ |
e51e26b432c0
6410698 ZFS metadata needs to be more highly replicated (ditto blocks)
billm
parents:
1760
diff
changeset
|
248 |
(DVA_GET_GANG(&(bp)->blk_dva[0]) + \ |
e51e26b432c0
6410698 ZFS metadata needs to be more highly replicated (ditto blocks)
billm
parents:
1760
diff
changeset
|
249 |
DVA_GET_GANG(&(bp)->blk_dva[1]) + \ |
e51e26b432c0
6410698 ZFS metadata needs to be more highly replicated (ditto blocks)
billm
parents:
1760
diff
changeset
|
250 |
DVA_GET_GANG(&(bp)->blk_dva[2])) |
e51e26b432c0
6410698 ZFS metadata needs to be more highly replicated (ditto blocks)
billm
parents:
1760
diff
changeset
|
251 |
|
789 | 252 |
#define DVA_EQUAL(dva1, dva2) \ |
253 |
((dva1)->dva_word[1] == (dva2)->dva_word[1] && \ |
|
254 |
(dva1)->dva_word[0] == (dva2)->dva_word[0]) |
|
255 |
||
3093
71525e4187d5
6490569 verify arc bufs are not modified when they shouldn't be
ahrens
parents:
2926
diff
changeset
|
256 |
#define ZIO_CHECKSUM_EQUAL(zc1, zc2) \ |
71525e4187d5
6490569 verify arc bufs are not modified when they shouldn't be
ahrens
parents:
2926
diff
changeset
|
257 |
(0 == (((zc1).zc_word[0] - (zc2).zc_word[0]) | \ |
71525e4187d5
6490569 verify arc bufs are not modified when they shouldn't be
ahrens
parents:
2926
diff
changeset
|
258 |
((zc1).zc_word[1] - (zc2).zc_word[1]) | \ |
71525e4187d5
6490569 verify arc bufs are not modified when they shouldn't be
ahrens
parents:
2926
diff
changeset
|
259 |
((zc1).zc_word[2] - (zc2).zc_word[2]) | \ |
71525e4187d5
6490569 verify arc bufs are not modified when they shouldn't be
ahrens
parents:
2926
diff
changeset
|
260 |
((zc1).zc_word[3] - (zc2).zc_word[3]))) |
71525e4187d5
6490569 verify arc bufs are not modified when they shouldn't be
ahrens
parents:
2926
diff
changeset
|
261 |
|
71525e4187d5
6490569 verify arc bufs are not modified when they shouldn't be
ahrens
parents:
2926
diff
changeset
|
262 |
|
789 | 263 |
#define DVA_IS_VALID(dva) (DVA_GET_ASIZE(dva) != 0) |
264 |
||
265 |
#define ZIO_SET_CHECKSUM(zcp, w0, w1, w2, w3) \ |
|
266 |
{ \ |
|
267 |
(zcp)->zc_word[0] = w0; \ |
|
268 |
(zcp)->zc_word[1] = w1; \ |
|
269 |
(zcp)->zc_word[2] = w2; \ |
|
270 |
(zcp)->zc_word[3] = w3; \ |
|
271 |
} |
|
272 |
||
1775
e51e26b432c0
6410698 ZFS metadata needs to be more highly replicated (ditto blocks)
billm
parents:
1760
diff
changeset
|
273 |
#define BP_IDENTITY(bp) (&(bp)->blk_dva[0]) |
e51e26b432c0
6410698 ZFS metadata needs to be more highly replicated (ditto blocks)
billm
parents:
1760
diff
changeset
|
274 |
#define BP_IS_GANG(bp) DVA_GET_GANG(BP_IDENTITY(bp)) |
789 | 275 |
#define BP_IS_HOLE(bp) ((bp)->blk_birth == 0) |
3547
e396e0a440b1
6512391 DMU should leverage ZIO dependencies to achieve greater parallelism
maybee
parents:
3444
diff
changeset
|
276 |
#define BP_IS_OLDER(bp, txg) (!BP_IS_HOLE(bp) && (bp)->blk_birth < (txg)) |
789 | 277 |
|
5329 | 278 |
#define BP_ZERO_DVAS(bp) \ |
789 | 279 |
{ \ |
280 |
(bp)->blk_dva[0].dva_word[0] = 0; \ |
|
281 |
(bp)->blk_dva[0].dva_word[1] = 0; \ |
|
282 |
(bp)->blk_dva[1].dva_word[0] = 0; \ |
|
283 |
(bp)->blk_dva[1].dva_word[1] = 0; \ |
|
284 |
(bp)->blk_dva[2].dva_word[0] = 0; \ |
|
285 |
(bp)->blk_dva[2].dva_word[1] = 0; \ |
|
5329 | 286 |
(bp)->blk_birth = 0; \ |
287 |
} |
|
288 |
||
289 |
#define BP_ZERO(bp) \ |
|
290 |
{ \ |
|
291 |
BP_ZERO_DVAS(bp) \ |
|
789 | 292 |
(bp)->blk_prop = 0; \ |
293 |
(bp)->blk_pad[0] = 0; \ |
|
294 |
(bp)->blk_pad[1] = 0; \ |
|
295 |
(bp)->blk_pad[2] = 0; \ |
|
296 |
(bp)->blk_fill = 0; \ |
|
297 |
ZIO_SET_CHECKSUM(&(bp)->blk_cksum, 0, 0, 0, 0); \ |
|
298 |
} |
|
299 |
||
300 |
/* |
|
301 |
* Note: the byteorder is either 0 or -1, both of which are palindromes. |
|
302 |
* This simplifies the endianness handling a bit. |
|
303 |
*/ |
|
304 |
#ifdef _BIG_ENDIAN |
|
305 |
#define ZFS_HOST_BYTEORDER (0ULL) |
|
306 |
#else |
|
307 |
#define ZFS_HOST_BYTEORDER (-1ULL) |
|
308 |
#endif |
|
309 |
||
310 |
#define BP_SHOULD_BYTESWAP(bp) (BP_GET_BYTEORDER(bp) != ZFS_HOST_BYTEORDER) |
|
311 |
||
1775
e51e26b432c0
6410698 ZFS metadata needs to be more highly replicated (ditto blocks)
billm
parents:
1760
diff
changeset
|
312 |
#define BP_SPRINTF_LEN 320 |
896 | 313 |
|
789 | 314 |
#include <sys/dmu.h> |
315 |
||
3290 | 316 |
#define BP_GET_BUFC_TYPE(bp) \ |
317 |
(((BP_GET_LEVEL(bp) > 0) || (dmu_ot[BP_GET_TYPE(bp)].ot_metadata)) ? \ |
|
318 |
ARC_BUFC_METADATA : ARC_BUFC_DATA); |
|
789 | 319 |
/* |
320 |
* Routines found in spa.c |
|
321 |
*/ |
|
322 |
||
323 |
/* state manipulation functions */ |
|
324 |
extern int spa_open(const char *pool, spa_t **, void *tag); |
|
1544 | 325 |
extern int spa_get_stats(const char *pool, nvlist_t **config, |
326 |
char *altroot, size_t buflen); |
|
5094 | 327 |
extern int spa_create(const char *pool, nvlist_t *config, nvlist_t *props, |
4715
e8d212dda064
6535695 Panic: shpp->sh_eof == shpp->sh_pool_create_len, file: ../../common/fs/zfs/spa_history.c, line: 235
ek110237
parents:
4620
diff
changeset
|
328 |
const char *history_str); |
6423 | 329 |
extern void spa_check_rootconf(char *devpath, char **the_dev_p, |
330 |
nvlist_t **the_conf_p, uint64_t *the_txg_p); |
|
331 |
extern boolean_t spa_rootdev_validate(nvlist_t *nv); |
|
332 |
extern int spa_import_rootpool(char *devpath); |
|
5094 | 333 |
extern int spa_import(const char *pool, nvlist_t *config, nvlist_t *props); |
6643
3a34b0dbb107
6625086 changing cachefile doesn't remove old cache on last user
eschrock
parents:
6423
diff
changeset
|
334 |
extern int spa_import_faulted(const char *, nvlist_t *, nvlist_t *); |
789 | 335 |
extern nvlist_t *spa_tryimport(nvlist_t *tryconfig); |
336 |
extern int spa_destroy(char *pool); |
|
1775
e51e26b432c0
6410698 ZFS metadata needs to be more highly replicated (ditto blocks)
billm
parents:
1760
diff
changeset
|
337 |
extern int spa_export(char *pool, nvlist_t **oldconfig); |
1544 | 338 |
extern int spa_reset(char *pool); |
339 |
extern void spa_async_request(spa_t *spa, int flag); |
|
7046
361307ae060d
6343667 scrub/resilver has to start over when a snapshot is taken
ahrens
parents:
6987
diff
changeset
|
340 |
extern void spa_async_unrequest(spa_t *spa, int flag); |
1544 | 341 |
extern void spa_async_suspend(spa_t *spa); |
342 |
extern void spa_async_resume(spa_t *spa); |
|
343 |
extern spa_t *spa_inject_addref(char *pool); |
|
344 |
extern void spa_inject_delref(spa_t *spa); |
|
345 |
||
4451 | 346 |
#define SPA_ASYNC_REMOVE 0x01 |
347 |
#define SPA_ASYNC_RESILVER_DONE 0x02 |
|
1544 | 348 |
#define SPA_ASYNC_RESILVER 0x08 |
1635
0ab1193d47cb
6398664 zpool detach: missing argument to error message causes core dump
bonwick
parents:
1544
diff
changeset
|
349 |
#define SPA_ASYNC_CONFIG_UPDATE 0x10 |
789 | 350 |
|
351 |
/* device manipulation */ |
|
352 |
extern int spa_vdev_add(spa_t *spa, nvlist_t *nvroot); |
|
1544 | 353 |
extern int spa_vdev_attach(spa_t *spa, uint64_t guid, nvlist_t *nvroot, |
789 | 354 |
int replacing); |
1544 | 355 |
extern int spa_vdev_detach(spa_t *spa, uint64_t guid, int replace_done); |
2082 | 356 |
extern int spa_vdev_remove(spa_t *spa, uint64_t guid, boolean_t unspare); |
1354
81359ee1ee63
6362672 import gets confused about overlapping slices
eschrock
parents:
896
diff
changeset
|
357 |
extern int spa_vdev_setpath(spa_t *spa, uint64_t guid, const char *newpath); |
789 | 358 |
|
2082 | 359 |
/* spare state (which is global across all pools) */ |
3377
a2fa338530c1
6393525 vdev_reopen() should verify that it's still the same device
eschrock
parents:
3290
diff
changeset
|
360 |
extern void spa_spare_add(vdev_t *vd); |
a2fa338530c1
6393525 vdev_reopen() should verify that it's still the same device
eschrock
parents:
3290
diff
changeset
|
361 |
extern void spa_spare_remove(vdev_t *vd); |
a2fa338530c1
6393525 vdev_reopen() should verify that it's still the same device
eschrock
parents:
3290
diff
changeset
|
362 |
extern boolean_t spa_spare_exists(uint64_t guid, uint64_t *pool); |
a2fa338530c1
6393525 vdev_reopen() should verify that it's still the same device
eschrock
parents:
3290
diff
changeset
|
363 |
extern void spa_spare_activate(vdev_t *vd); |
2082 | 364 |
|
5450 | 365 |
/* L2ARC state (which is global across all pools) */ |
366 |
extern void spa_l2cache_add(vdev_t *vd); |
|
367 |
extern void spa_l2cache_remove(vdev_t *vd); |
|
368 |
extern boolean_t spa_l2cache_exists(uint64_t guid, uint64_t *pool); |
|
369 |
extern void spa_l2cache_activate(vdev_t *vd); |
|
370 |
extern void spa_l2cache_drop(spa_t *spa); |
|
371 |
extern void spa_l2cache_space_update(vdev_t *vd, int64_t space, int64_t alloc); |
|
372 |
||
789 | 373 |
/* scrubbing */ |
7046
361307ae060d
6343667 scrub/resilver has to start over when a snapshot is taken
ahrens
parents:
6987
diff
changeset
|
374 |
extern int spa_scrub(spa_t *spa, pool_scrub_type_t type); |
789 | 375 |
|
376 |
/* spa syncing */ |
|
377 |
extern void spa_sync(spa_t *spa, uint64_t txg); /* only for DMU use */ |
|
378 |
extern void spa_sync_allpools(void); |
|
379 |
||
6987
877c018eb06c
6628282 arc_stats.arcstat_l2_writes_sent.value.ui64) == (arc_stats.arcstat_l2_writes_done.value.ui64)
brendan
parents:
6673
diff
changeset
|
380 |
/* spa namespace global mutex */ |
877c018eb06c
6628282 arc_stats.arcstat_l2_writes_sent.value.ui64) == (arc_stats.arcstat_l2_writes_done.value.ui64)
brendan
parents:
6673
diff
changeset
|
381 |
extern kmutex_t spa_namespace_lock; |
877c018eb06c
6628282 arc_stats.arcstat_l2_writes_sent.value.ui64) == (arc_stats.arcstat_l2_writes_done.value.ui64)
brendan
parents:
6673
diff
changeset
|
382 |
|
789 | 383 |
/* |
384 |
* SPA configuration functions in spa_config.c |
|
385 |
*/ |
|
1635
0ab1193d47cb
6398664 zpool detach: missing argument to error message causes core dump
bonwick
parents:
1544
diff
changeset
|
386 |
|
0ab1193d47cb
6398664 zpool detach: missing argument to error message causes core dump
bonwick
parents:
1544
diff
changeset
|
387 |
#define SPA_CONFIG_UPDATE_POOL 0 |
0ab1193d47cb
6398664 zpool detach: missing argument to error message causes core dump
bonwick
parents:
1544
diff
changeset
|
388 |
#define SPA_CONFIG_UPDATE_VDEVS 1 |
0ab1193d47cb
6398664 zpool detach: missing argument to error message causes core dump
bonwick
parents:
1544
diff
changeset
|
389 |
|
6643
3a34b0dbb107
6625086 changing cachefile doesn't remove old cache on last user
eschrock
parents:
6423
diff
changeset
|
390 |
extern void spa_config_sync(spa_t *, boolean_t, boolean_t); |
789 | 391 |
extern void spa_config_load(void); |
392 |
extern nvlist_t *spa_all_configs(uint64_t *); |
|
393 |
extern void spa_config_set(spa_t *spa, nvlist_t *config); |
|
394 |
extern nvlist_t *spa_config_generate(spa_t *spa, vdev_t *vd, uint64_t txg, |
|
395 |
int getstats); |
|
1635
0ab1193d47cb
6398664 zpool detach: missing argument to error message causes core dump
bonwick
parents:
1544
diff
changeset
|
396 |
extern void spa_config_update(spa_t *spa, int what); |
6423 | 397 |
extern void spa_config_update_common(spa_t *spa, int what, boolean_t isroot); |
789 | 398 |
|
399 |
/* |
|
400 |
* Miscellaneous SPA routines in spa_misc.c |
|
401 |
*/ |
|
402 |
||
403 |
/* Namespace manipulation */ |
|
404 |
extern spa_t *spa_lookup(const char *name); |
|
1635
0ab1193d47cb
6398664 zpool detach: missing argument to error message causes core dump
bonwick
parents:
1544
diff
changeset
|
405 |
extern spa_t *spa_add(const char *name, const char *altroot); |
789 | 406 |
extern void spa_remove(spa_t *spa); |
407 |
extern spa_t *spa_next(spa_t *prev); |
|
408 |
||
409 |
/* Refcount functions */ |
|
410 |
extern void spa_open_ref(spa_t *spa, void *tag); |
|
411 |
extern void spa_close(spa_t *spa, void *tag); |
|
412 |
extern boolean_t spa_refcount_zero(spa_t *spa); |
|
413 |
||
414 |
/* Pool configuration lock */ |
|
1544 | 415 |
extern void spa_config_enter(spa_t *spa, krw_t rw, void *tag); |
416 |
extern void spa_config_exit(spa_t *spa, void *tag); |
|
789 | 417 |
extern boolean_t spa_config_held(spa_t *spa, krw_t rw); |
418 |
||
419 |
/* Pool vdev add/remove lock */ |
|
420 |
extern uint64_t spa_vdev_enter(spa_t *spa); |
|
421 |
extern int spa_vdev_exit(spa_t *spa, vdev_t *vd, uint64_t txg, int error); |
|
422 |
||
423 |
/* Accessor functions */ |
|
424 |
extern krwlock_t *spa_traverse_rwlock(spa_t *spa); |
|
7046
361307ae060d
6343667 scrub/resilver has to start over when a snapshot is taken
ahrens
parents:
6987
diff
changeset
|
425 |
extern boolean_t spa_traverse_wanted(spa_t *spa); |
789 | 426 |
extern struct dsl_pool *spa_get_dsl(spa_t *spa); |
427 |
extern blkptr_t *spa_get_rootblkptr(spa_t *spa); |
|
428 |
extern void spa_set_rootblkptr(spa_t *spa, const blkptr_t *bp); |
|
429 |
extern void spa_altroot(spa_t *, char *, size_t); |
|
430 |
extern int spa_sync_pass(spa_t *spa); |
|
431 |
extern char *spa_name(spa_t *spa); |
|
432 |
extern uint64_t spa_guid(spa_t *spa); |
|
433 |
extern uint64_t spa_last_synced_txg(spa_t *spa); |
|
434 |
extern uint64_t spa_first_txg(spa_t *spa); |
|
2082 | 435 |
extern uint64_t spa_version(spa_t *spa); |
789 | 436 |
extern int spa_state(spa_t *spa); |
437 |
extern uint64_t spa_freeze_txg(spa_t *spa); |
|
438 |
extern uint64_t spa_get_alloc(spa_t *spa); |
|
439 |
extern uint64_t spa_get_space(spa_t *spa); |
|
2082 | 440 |
extern uint64_t spa_get_dspace(spa_t *spa); |
789 | 441 |
extern uint64_t spa_get_asize(spa_t *spa, uint64_t lsize); |
1775
e51e26b432c0
6410698 ZFS metadata needs to be more highly replicated (ditto blocks)
billm
parents:
1760
diff
changeset
|
442 |
extern uint64_t spa_version(spa_t *spa); |
e51e26b432c0
6410698 ZFS metadata needs to be more highly replicated (ditto blocks)
billm
parents:
1760
diff
changeset
|
443 |
extern int spa_max_replication(spa_t *spa); |
789 | 444 |
extern int spa_busy(void); |
5329 | 445 |
extern uint8_t spa_get_failmode(spa_t *spa); |
789 | 446 |
|
447 |
/* Miscellaneous support routines */ |
|
448 |
extern int spa_rename(const char *oldname, const char *newname); |
|
449 |
extern boolean_t spa_guid_exists(uint64_t pool_guid, uint64_t device_guid); |
|
450 |
extern char *spa_strdup(const char *); |
|
451 |
extern void spa_strfree(char *); |
|
452 |
extern uint64_t spa_get_random(uint64_t range); |
|
1807
35c8b566d7af
6410711 intent log blocks don't get invited to pool parties
bonwick
parents:
1775
diff
changeset
|
453 |
extern void sprintf_blkptr(char *buf, int len, const blkptr_t *bp); |
789 | 454 |
extern void spa_freeze(spa_t *spa); |
5094 | 455 |
extern void spa_upgrade(spa_t *spa, uint64_t version); |
789 | 456 |
extern void spa_evict_all(void); |
6643
3a34b0dbb107
6625086 changing cachefile doesn't remove old cache on last user
eschrock
parents:
6423
diff
changeset
|
457 |
extern vdev_t *spa_lookup_by_guid(spa_t *spa, uint64_t guid, |
3a34b0dbb107
6625086 changing cachefile doesn't remove old cache on last user
eschrock
parents:
6423
diff
changeset
|
458 |
boolean_t l2cache); |
2082 | 459 |
extern boolean_t spa_has_spare(spa_t *, uint64_t guid); |
460 |
extern uint64_t bp_get_dasize(spa_t *spa, const blkptr_t *bp); |
|
4620 | 461 |
extern boolean_t spa_has_slogs(spa_t *spa); |
6673
be079d6124af
6697301 deadlock between ZFS and devfs can hang system
eschrock
parents:
6643
diff
changeset
|
462 |
extern boolean_t spa_is_root(spa_t *spa); |
1544 | 463 |
|
2926 | 464 |
/* history logging */ |
4543 | 465 |
typedef enum history_log_type { |
466 |
LOG_CMD_POOL_CREATE, |
|
467 |
LOG_CMD_NORMAL, |
|
468 |
LOG_INTERNAL |
|
469 |
} history_log_type_t; |
|
470 |
||
471 |
typedef struct history_arg { |
|
472 |
const char *ha_history_str; |
|
473 |
history_log_type_t ha_log_type; |
|
474 |
history_internal_events_t ha_event; |
|
475 |
char ha_zone[MAXPATHLEN]; |
|
476 |
} history_arg_t; |
|
477 |
||
478 |
extern char *spa_his_ievent_table[]; |
|
479 |
||
2926 | 480 |
extern void spa_history_create_obj(spa_t *spa, dmu_tx_t *tx); |
481 |
extern int spa_history_get(spa_t *spa, uint64_t *offset, uint64_t *len_read, |
|
482 |
char *his_buf); |
|
483 |
extern int spa_history_log(spa_t *spa, const char *his_buf, |
|
4543 | 484 |
history_log_type_t what); |
485 |
void spa_history_internal_log(history_internal_events_t event, spa_t *spa, |
|
486 |
dmu_tx_t *tx, cred_t *cr, const char *fmt, ...); |
|
2926 | 487 |
|
1544 | 488 |
/* error handling */ |
489 |
struct zbookmark; |
|
490 |
struct zio; |
|
491 |
extern void spa_log_error(spa_t *spa, struct zio *zio); |
|
492 |
extern void zfs_ereport_post(const char *class, spa_t *spa, vdev_t *vd, |
|
493 |
struct zio *zio, uint64_t stateoroffset, uint64_t length); |
|
4451 | 494 |
extern void zfs_post_remove(spa_t *spa, vdev_t *vd); |
495 |
extern void zfs_post_autoreplace(spa_t *spa, vdev_t *vd); |
|
1544 | 496 |
extern uint64_t spa_get_errlog_size(spa_t *spa); |
497 |
extern int spa_get_errlog(spa_t *spa, void *uaddr, size_t *count); |
|
498 |
extern void spa_errlog_rotate(spa_t *spa); |
|
499 |
extern void spa_errlog_drain(spa_t *spa); |
|
500 |
extern void spa_errlog_sync(spa_t *spa, uint64_t txg); |
|
501 |
extern void spa_get_errlists(spa_t *spa, avl_tree_t *last, avl_tree_t *scrub); |
|
789 | 502 |
|
5810 | 503 |
/* vdev cache */ |
504 |
extern void vdev_cache_stat_init(void); |
|
505 |
extern void vdev_cache_stat_fini(void); |
|
506 |
||
789 | 507 |
/* Initialization and termination */ |
508 |
extern void spa_init(int flags); |
|
509 |
extern void spa_fini(void); |
|
6423 | 510 |
extern void spa_boot_init(); |
789 | 511 |
|
3912 | 512 |
/* properties */ |
5094 | 513 |
extern int spa_prop_set(spa_t *spa, nvlist_t *nvp); |
514 |
extern int spa_prop_get(spa_t *spa, nvlist_t **nvp); |
|
515 |
extern void spa_prop_clear_bootfs(spa_t *spa, uint64_t obj, dmu_tx_t *tx); |
|
3912 | 516 |
|
4451 | 517 |
/* asynchronous event notification */ |
518 |
extern void spa_event_notify(spa_t *spa, vdev_t *vdev, const char *name); |
|
519 |
||
789 | 520 |
#ifdef ZFS_DEBUG |
3700
3a7e0afcf1b4
6523936 BAD TRAP: type=8 (#df Double fault) rp=fec266f8 addr=0
ek110237
parents:
3697
diff
changeset
|
521 |
#define dprintf_bp(bp, fmt, ...) do { \ |
3a7e0afcf1b4
6523936 BAD TRAP: type=8 (#df Double fault) rp=fec266f8 addr=0
ek110237
parents:
3697
diff
changeset
|
522 |
if (zfs_flags & ZFS_DEBUG_DPRINTF) { \ |
3a7e0afcf1b4
6523936 BAD TRAP: type=8 (#df Double fault) rp=fec266f8 addr=0
ek110237
parents:
3697
diff
changeset
|
523 |
char *__blkbuf = kmem_alloc(BP_SPRINTF_LEN, KM_SLEEP); \ |
3a7e0afcf1b4
6523936 BAD TRAP: type=8 (#df Double fault) rp=fec266f8 addr=0
ek110237
parents:
3697
diff
changeset
|
524 |
sprintf_blkptr(__blkbuf, BP_SPRINTF_LEN, (bp)); \ |
3a7e0afcf1b4
6523936 BAD TRAP: type=8 (#df Double fault) rp=fec266f8 addr=0
ek110237
parents:
3697
diff
changeset
|
525 |
dprintf(fmt " %s\n", __VA_ARGS__, __blkbuf); \ |
3a7e0afcf1b4
6523936 BAD TRAP: type=8 (#df Double fault) rp=fec266f8 addr=0
ek110237
parents:
3697
diff
changeset
|
526 |
kmem_free(__blkbuf, BP_SPRINTF_LEN); \ |
789 | 527 |
} \ |
528 |
_NOTE(CONSTCOND) } while (0) |
|
529 |
#else |
|
530 |
#define dprintf_bp(bp, fmt, ...) |
|
531 |
#endif |
|
532 |
||
533 |
extern int spa_mode; /* mode, e.g. FREAD | FWRITE */ |
|
534 |
||
535 |
#ifdef __cplusplus |
|
536 |
} |
|
537 |
#endif |
|
538 |
||
539 |
#endif /* _SYS_SPA_H */ |