xref: /illumos-gate/usr/src/uts/common/fs/zfs/sys/uberblock_impl.h (revision a07094369b21309434206d9b3601d162693466fc)
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, Version 1.0 only
6  * (the "License").  You may not use this file except in compliance
7  * with the License.
8  *
9  * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
10  * or http://www.opensolaris.org/os/licensing.
11  * See the License for the specific language governing permissions
12  * and limitations under the License.
13  *
14  * When distributing Covered Code, include this CDDL HEADER in each
15  * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
16  * If applicable, add the following below this CDDL HEADER, with the
17  * fields enclosed by brackets "[]" replaced with your own identifying
18  * information: Portions Copyright [yyyy] [name of copyright owner]
19  *
20  * CDDL HEADER END
21  */
22 /*
23  * Copyright 2005 Sun Microsystems, Inc.  All rights reserved.
24  * Use is subject to license terms.
25  */
26 
27 #ifndef _SYS_UBERBLOCK_IMPL_H
28 #define	_SYS_UBERBLOCK_IMPL_H
29 
30 #pragma ident	"%Z%%M%	%I%	%E% SMI"
31 
32 #include <sys/uberblock.h>
33 
34 #ifdef	__cplusplus
35 extern "C" {
36 #endif
37 
38 /*
39  * The uberblock version is incremented whenever an incompatible on-disk
40  * format change is made to the SPA, DMU, or ZAP.
41  *
42  * Note: the first two fields should never be moved.  When a storage pool
43  * is opened, the uberblock must be read off the disk before the version
44  * can be checked.  If the ub_version field is moved, we may not detect
45  * version mismatch.  If the ub_magic field is moved, applications that
46  * expect the magic number in the first word won't work.
47  */
48 
49 #define	UBERBLOCK_SHIFT		(10)
50 #define	UBERBLOCK_SIZE		(1ULL << UBERBLOCK_SHIFT)
51 
52 #define	UBERBLOCK_MAGIC		0x00bab10c		/* oo-ba-bloc!	*/
53 
54 #define	UBERBLOCK_VERSION	1ULL
55 
56 struct uberblock {
57 	uint64_t	ub_magic;	/* UBERBLOCK_MAGIC		*/
58 	uint64_t	ub_version;	/* UBERBLOCK_VERSION		*/
59 	uint64_t	ub_txg;		/* txg of last sync		*/
60 	uint64_t	ub_guid_sum;	/* sum of all vdev guids	*/
61 	uint64_t	ub_timestamp;	/* UTC time of last sync	*/
62 	blkptr_t	ub_rootbp;	/* MOS objset_phys_t		*/
63 };
64 
65 typedef struct uberblock_phys {
66 	uberblock_t	ubp_uberblock;
67 	char		ubp_pad[UBERBLOCK_SIZE - sizeof (uberblock_t) -
68 	    sizeof (zio_block_tail_t)];
69 	zio_block_tail_t ubp_zbt;
70 } uberblock_phys_t;
71 
72 #ifdef	__cplusplus
73 }
74 #endif
75 
76 #endif	/* _SYS_UBERBLOCK_IMPL_H */
77