xref: /OK3568_Linux_fs/u-boot/include/zfs/uberblock_impl.h (revision 4882a59341e53eb6f0b4789bf948001014eff981)
1*4882a593Smuzhiyun /*
2*4882a593Smuzhiyun  *  GRUB  --  GRand Unified Bootloader
3*4882a593Smuzhiyun  *  Copyright (C) 1999,2000,2001,2002,2003,2004  Free Software Foundation, Inc.
4*4882a593Smuzhiyun  *
5*4882a593Smuzhiyun  * SPDX-License-Identifier:	GPL-2.0+
6*4882a593Smuzhiyun  */
7*4882a593Smuzhiyun /*
8*4882a593Smuzhiyun  * Copyright 2007 Sun Microsystems, Inc.  All rights reserved.
9*4882a593Smuzhiyun  * Use is subject to license terms.
10*4882a593Smuzhiyun  */
11*4882a593Smuzhiyun 
12*4882a593Smuzhiyun #ifndef _SYS_UBERBLOCK_IMPL_H
13*4882a593Smuzhiyun #define	_SYS_UBERBLOCK_IMPL_H
14*4882a593Smuzhiyun 
15*4882a593Smuzhiyun #define UBMAX(a, b) ((a) > (b) ? (a) : (b))
16*4882a593Smuzhiyun 
17*4882a593Smuzhiyun /*
18*4882a593Smuzhiyun  * The uberblock version is incremented whenever an incompatible on-disk
19*4882a593Smuzhiyun  * format change is made to the SPA, DMU, or ZAP.
20*4882a593Smuzhiyun  *
21*4882a593Smuzhiyun  * Note: the first two fields should never be moved.  When a storage pool
22*4882a593Smuzhiyun  * is opened, the uberblock must be read off the disk before the version
23*4882a593Smuzhiyun  * can be checked.	If the ub_version field is moved, we may not detect
24*4882a593Smuzhiyun  * version mismatch.  If the ub_magic field is moved, applications that
25*4882a593Smuzhiyun  * expect the magic number in the first word won't work.
26*4882a593Smuzhiyun  */
27*4882a593Smuzhiyun #define	UBERBLOCK_MAGIC		0x00bab10c		/* oo-ba-bloc!	*/
28*4882a593Smuzhiyun #define	UBERBLOCK_SHIFT		10			/* up to 1K	*/
29*4882a593Smuzhiyun 
30*4882a593Smuzhiyun typedef struct uberblock {
31*4882a593Smuzhiyun 	uint64_t	ub_magic;	/* UBERBLOCK_MAGIC		*/
32*4882a593Smuzhiyun 	uint64_t	ub_version;	/* ZFS_VERSION			*/
33*4882a593Smuzhiyun 	uint64_t	ub_txg;		/* txg of last sync		*/
34*4882a593Smuzhiyun 	uint64_t	ub_guid_sum;	/* sum of all vdev guids	*/
35*4882a593Smuzhiyun 	uint64_t	ub_timestamp;	/* UTC time of last sync	*/
36*4882a593Smuzhiyun 	blkptr_t	ub_rootbp;	/* MOS objset_phys_t		*/
37*4882a593Smuzhiyun } uberblock_t;
38*4882a593Smuzhiyun 
39*4882a593Smuzhiyun #define	VDEV_UBERBLOCK_SHIFT(as)	UBMAX(as, UBERBLOCK_SHIFT)
40*4882a593Smuzhiyun #define	UBERBLOCK_SIZE(as)		(1ULL << VDEV_UBERBLOCK_SHIFT(as))
41*4882a593Smuzhiyun 
42*4882a593Smuzhiyun /* Number of uberblocks that can fit in the ring at a given ashift */
43*4882a593Smuzhiyun #define UBERBLOCK_COUNT(as) (VDEV_UBERBLOCK_RING >> VDEV_UBERBLOCK_SHIFT(as))
44*4882a593Smuzhiyun 
45*4882a593Smuzhiyun #endif	/* _SYS_UBERBLOCK_IMPL_H */
46