Tom Rini | 83d290c | 2018-05-06 17:58:06 -0400 | [diff] [blame] | 1 | /* SPDX-License-Identifier: GPL-2.0+ */ |
Jorgen Lundman | 4d3c95f | 2012-07-19 20:48:25 +0000 | [diff] [blame] | 2 | /* |
| 3 | * GRUB -- GRand Unified Bootloader |
| 4 | * Copyright (C) 1999,2000,2001,2002,2003,2004 Free Software Foundation, Inc. |
Jorgen Lundman | 4d3c95f | 2012-07-19 20:48:25 +0000 | [diff] [blame] | 5 | */ |
| 6 | /* |
| 7 | * Copyright (c) 2008, 2010, Oracle and/or its affiliates. All rights reserved. |
| 8 | */ |
| 9 | |
| 10 | #ifndef _ZIO_H |
| 11 | #define _ZIO_H |
| 12 | |
| 13 | #include <zfs/spa.h> |
| 14 | |
| 15 | #define ZEC_MAGIC 0x210da7ab10c7a11ULL /* zio data bloc tail */ |
| 16 | |
| 17 | typedef struct zio_eck { |
| 18 | uint64_t zec_magic; /* for validation, endianness */ |
| 19 | zio_cksum_t zec_cksum; /* 256-bit checksum */ |
| 20 | } zio_eck_t; |
| 21 | |
| 22 | /* |
| 23 | * Gang block headers are self-checksumming and contain an array |
| 24 | * of block pointers. |
| 25 | */ |
| 26 | #define SPA_GANGBLOCKSIZE SPA_MINBLOCKSIZE |
| 27 | #define SPA_GBH_NBLKPTRS ((SPA_GANGBLOCKSIZE - \ |
| 28 | sizeof(zio_eck_t)) / sizeof(blkptr_t)) |
| 29 | #define SPA_GBH_FILLER ((SPA_GANGBLOCKSIZE - \ |
| 30 | sizeof(zio_eck_t) - \ |
| 31 | (SPA_GBH_NBLKPTRS * sizeof(blkptr_t))) /\ |
| 32 | sizeof(uint64_t)) |
| 33 | |
| 34 | #define ZIO_GET_IOSIZE(zio) \ |
| 35 | (BP_IS_GANG((zio)->io_bp) ? \ |
| 36 | SPA_GANGBLOCKSIZE : BP_GET_PSIZE((zio)->io_bp)) |
| 37 | |
| 38 | typedef struct zio_gbh { |
| 39 | blkptr_t zg_blkptr[SPA_GBH_NBLKPTRS]; |
| 40 | uint64_t zg_filler[SPA_GBH_FILLER]; |
| 41 | zio_eck_t zg_tail; |
| 42 | } zio_gbh_phys_t; |
| 43 | |
| 44 | enum zio_checksum { |
| 45 | ZIO_CHECKSUM_INHERIT = 0, |
| 46 | ZIO_CHECKSUM_ON, |
| 47 | ZIO_CHECKSUM_OFF, |
| 48 | ZIO_CHECKSUM_LABEL, |
| 49 | ZIO_CHECKSUM_GANG_HEADER, |
| 50 | ZIO_CHECKSUM_ZILOG, |
| 51 | ZIO_CHECKSUM_FLETCHER_2, |
| 52 | ZIO_CHECKSUM_FLETCHER_4, |
| 53 | ZIO_CHECKSUM_SHA256, |
| 54 | ZIO_CHECKSUM_ZILOG2, |
| 55 | ZIO_CHECKSUM_FUNCTIONS |
| 56 | }; |
| 57 | |
| 58 | #define ZIO_CHECKSUM_ON_VALUE ZIO_CHECKSUM_FLETCHER_2 |
| 59 | #define ZIO_CHECKSUM_DEFAULT ZIO_CHECKSUM_ON |
| 60 | |
| 61 | enum zio_compress { |
| 62 | ZIO_COMPRESS_INHERIT = 0, |
| 63 | ZIO_COMPRESS_ON, |
| 64 | ZIO_COMPRESS_OFF, |
| 65 | ZIO_COMPRESS_LZJB, |
| 66 | ZIO_COMPRESS_EMPTY, |
| 67 | ZIO_COMPRESS_GZIP1, |
| 68 | ZIO_COMPRESS_GZIP2, |
| 69 | ZIO_COMPRESS_GZIP3, |
| 70 | ZIO_COMPRESS_GZIP4, |
| 71 | ZIO_COMPRESS_GZIP5, |
| 72 | ZIO_COMPRESS_GZIP6, |
| 73 | ZIO_COMPRESS_GZIP7, |
| 74 | ZIO_COMPRESS_GZIP8, |
| 75 | ZIO_COMPRESS_GZIP9, |
| 76 | ZIO_COMPRESS_FUNCTIONS |
| 77 | }; |
| 78 | |
| 79 | #endif /* _ZIO_H */ |