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