zio.h 2.5 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192
  1. /*
  2. * GRUB -- GRand Unified Bootloader
  3. * Copyright (C) 1999,2000,2001,2002,2003,2004 Free Software Foundation, Inc.
  4. *
  5. * This program is free software; you can redistribute it and/or modify
  6. * it under the terms of the GNU General Public License as published by
  7. * the Free Software Foundation; either version 2 of the License, or
  8. * (at your option) any later version.
  9. *
  10. * This program is distributed in the hope that it will be useful,
  11. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  12. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  13. * GNU General Public License for more details.
  14. *
  15. * You should have received a copy of the GNU General Public License
  16. * along with this program; if not, write to the Free Software
  17. * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
  18. */
  19. /*
  20. * Copyright (c) 2008, 2010, Oracle and/or its affiliates. All rights reserved.
  21. */
  22. #ifndef _ZIO_H
  23. #define _ZIO_H
  24. #include <zfs/spa.h>
  25. #define ZEC_MAGIC 0x210da7ab10c7a11ULL /* zio data bloc tail */
  26. typedef struct zio_eck {
  27. uint64_t zec_magic; /* for validation, endianness */
  28. zio_cksum_t zec_cksum; /* 256-bit checksum */
  29. } zio_eck_t;
  30. /*
  31. * Gang block headers are self-checksumming and contain an array
  32. * of block pointers.
  33. */
  34. #define SPA_GANGBLOCKSIZE SPA_MINBLOCKSIZE
  35. #define SPA_GBH_NBLKPTRS ((SPA_GANGBLOCKSIZE - \
  36. sizeof(zio_eck_t)) / sizeof(blkptr_t))
  37. #define SPA_GBH_FILLER ((SPA_GANGBLOCKSIZE - \
  38. sizeof(zio_eck_t) - \
  39. (SPA_GBH_NBLKPTRS * sizeof(blkptr_t))) /\
  40. sizeof(uint64_t))
  41. #define ZIO_GET_IOSIZE(zio) \
  42. (BP_IS_GANG((zio)->io_bp) ? \
  43. SPA_GANGBLOCKSIZE : BP_GET_PSIZE((zio)->io_bp))
  44. typedef struct zio_gbh {
  45. blkptr_t zg_blkptr[SPA_GBH_NBLKPTRS];
  46. uint64_t zg_filler[SPA_GBH_FILLER];
  47. zio_eck_t zg_tail;
  48. } zio_gbh_phys_t;
  49. enum zio_checksum {
  50. ZIO_CHECKSUM_INHERIT = 0,
  51. ZIO_CHECKSUM_ON,
  52. ZIO_CHECKSUM_OFF,
  53. ZIO_CHECKSUM_LABEL,
  54. ZIO_CHECKSUM_GANG_HEADER,
  55. ZIO_CHECKSUM_ZILOG,
  56. ZIO_CHECKSUM_FLETCHER_2,
  57. ZIO_CHECKSUM_FLETCHER_4,
  58. ZIO_CHECKSUM_SHA256,
  59. ZIO_CHECKSUM_ZILOG2,
  60. ZIO_CHECKSUM_FUNCTIONS
  61. };
  62. #define ZIO_CHECKSUM_ON_VALUE ZIO_CHECKSUM_FLETCHER_2
  63. #define ZIO_CHECKSUM_DEFAULT ZIO_CHECKSUM_ON
  64. enum zio_compress {
  65. ZIO_COMPRESS_INHERIT = 0,
  66. ZIO_COMPRESS_ON,
  67. ZIO_COMPRESS_OFF,
  68. ZIO_COMPRESS_LZJB,
  69. ZIO_COMPRESS_EMPTY,
  70. ZIO_COMPRESS_GZIP1,
  71. ZIO_COMPRESS_GZIP2,
  72. ZIO_COMPRESS_GZIP3,
  73. ZIO_COMPRESS_GZIP4,
  74. ZIO_COMPRESS_GZIP5,
  75. ZIO_COMPRESS_GZIP6,
  76. ZIO_COMPRESS_GZIP7,
  77. ZIO_COMPRESS_GZIP8,
  78. ZIO_COMPRESS_GZIP9,
  79. ZIO_COMPRESS_FUNCTIONS
  80. };
  81. #endif /* _ZIO_H */