1*4d3c95f5SJorgen Lundman /* 2*4d3c95f5SJorgen Lundman * GRUB -- GRand Unified Bootloader 3*4d3c95f5SJorgen Lundman * Copyright (C) 1999,2000,2001,2002,2003,2004 Free Software Foundation, Inc. 4*4d3c95f5SJorgen Lundman * 5*4d3c95f5SJorgen Lundman * This program is free software; you can redistribute it and/or modify 6*4d3c95f5SJorgen Lundman * it under the terms of the GNU General Public License as published by 7*4d3c95f5SJorgen Lundman * the Free Software Foundation; either version 2 of the License, or 8*4d3c95f5SJorgen Lundman * (at your option) any later version. 9*4d3c95f5SJorgen Lundman * 10*4d3c95f5SJorgen Lundman * This program is distributed in the hope that it will be useful, 11*4d3c95f5SJorgen Lundman * but WITHOUT ANY WARRANTY; without even the implied warranty of 12*4d3c95f5SJorgen Lundman * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13*4d3c95f5SJorgen Lundman * GNU General Public License for more details. 14*4d3c95f5SJorgen Lundman * 15*4d3c95f5SJorgen Lundman * You should have received a copy of the GNU General Public License 16*4d3c95f5SJorgen Lundman * along with this program; if not, write to the Free Software 17*4d3c95f5SJorgen Lundman * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. 18*4d3c95f5SJorgen Lundman */ 19*4d3c95f5SJorgen Lundman /* 20*4d3c95f5SJorgen Lundman * Copyright 2007 Sun Microsystems, Inc. All rights reserved. 21*4d3c95f5SJorgen Lundman * Use is subject to license terms. 22*4d3c95f5SJorgen Lundman */ 23*4d3c95f5SJorgen Lundman 24*4d3c95f5SJorgen Lundman #ifndef _SYS_UBERBLOCK_IMPL_H 25*4d3c95f5SJorgen Lundman #define _SYS_UBERBLOCK_IMPL_H 26*4d3c95f5SJorgen Lundman 27*4d3c95f5SJorgen Lundman #define UBMAX(a, b) ((a) > (b) ? (a) : (b)) 28*4d3c95f5SJorgen Lundman 29*4d3c95f5SJorgen Lundman /* 30*4d3c95f5SJorgen Lundman * The uberblock version is incremented whenever an incompatible on-disk 31*4d3c95f5SJorgen Lundman * format change is made to the SPA, DMU, or ZAP. 32*4d3c95f5SJorgen Lundman * 33*4d3c95f5SJorgen Lundman * Note: the first two fields should never be moved. When a storage pool 34*4d3c95f5SJorgen Lundman * is opened, the uberblock must be read off the disk before the version 35*4d3c95f5SJorgen Lundman * can be checked. If the ub_version field is moved, we may not detect 36*4d3c95f5SJorgen Lundman * version mismatch. If the ub_magic field is moved, applications that 37*4d3c95f5SJorgen Lundman * expect the magic number in the first word won't work. 38*4d3c95f5SJorgen Lundman */ 39*4d3c95f5SJorgen Lundman #define UBERBLOCK_MAGIC 0x00bab10c /* oo-ba-bloc! */ 40*4d3c95f5SJorgen Lundman #define UBERBLOCK_SHIFT 10 /* up to 1K */ 41*4d3c95f5SJorgen Lundman 42*4d3c95f5SJorgen Lundman typedef struct uberblock { 43*4d3c95f5SJorgen Lundman uint64_t ub_magic; /* UBERBLOCK_MAGIC */ 44*4d3c95f5SJorgen Lundman uint64_t ub_version; /* ZFS_VERSION */ 45*4d3c95f5SJorgen Lundman uint64_t ub_txg; /* txg of last sync */ 46*4d3c95f5SJorgen Lundman uint64_t ub_guid_sum; /* sum of all vdev guids */ 47*4d3c95f5SJorgen Lundman uint64_t ub_timestamp; /* UTC time of last sync */ 48*4d3c95f5SJorgen Lundman blkptr_t ub_rootbp; /* MOS objset_phys_t */ 49*4d3c95f5SJorgen Lundman } uberblock_t; 50*4d3c95f5SJorgen Lundman 51*4d3c95f5SJorgen Lundman #define VDEV_UBERBLOCK_SHIFT(as) UBMAX(as, UBERBLOCK_SHIFT) 52*4d3c95f5SJorgen Lundman #define UBERBLOCK_SIZE(as) (1ULL << VDEV_UBERBLOCK_SHIFT(as)) 53*4d3c95f5SJorgen Lundman 54*4d3c95f5SJorgen Lundman /* Number of uberblocks that can fit in the ring at a given ashift */ 55*4d3c95f5SJorgen Lundman #define UBERBLOCK_COUNT(as) (VDEV_UBERBLOCK_RING >> VDEV_UBERBLOCK_SHIFT(as)) 56*4d3c95f5SJorgen Lundman 57*4d3c95f5SJorgen Lundman #endif /* _SYS_UBERBLOCK_IMPL_H */ 58