uberblock_impl.h 1.6 KB

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