xref: /openbmc/u-boot/include/zfs/zio.h (revision 17aa548c)
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 (c) 2008, 2010, Oracle and/or its affiliates. All rights reserved.
9  */
10 
11 #ifndef _ZIO_H
12 #define	_ZIO_H
13 
14 #include <zfs/spa.h>
15 
16 #define	ZEC_MAGIC	0x210da7ab10c7a11ULL	/* zio data bloc tail */
17 
18 typedef struct zio_eck {
19 	uint64_t	zec_magic;	/* for validation, endianness	*/
20 	zio_cksum_t	zec_cksum;	/* 256-bit checksum		*/
21 } zio_eck_t;
22 
23 /*
24  * Gang block headers are self-checksumming and contain an array
25  * of block pointers.
26  */
27 #define	SPA_GANGBLOCKSIZE	SPA_MINBLOCKSIZE
28 #define	SPA_GBH_NBLKPTRS	((SPA_GANGBLOCKSIZE - \
29 	sizeof(zio_eck_t)) / sizeof(blkptr_t))
30 #define	SPA_GBH_FILLER		((SPA_GANGBLOCKSIZE - \
31 	sizeof(zio_eck_t) - \
32 	(SPA_GBH_NBLKPTRS * sizeof(blkptr_t))) /\
33 	sizeof(uint64_t))
34 
35 #define	ZIO_GET_IOSIZE(zio)	\
36 	(BP_IS_GANG((zio)->io_bp) ? \
37 	SPA_GANGBLOCKSIZE : BP_GET_PSIZE((zio)->io_bp))
38 
39 typedef struct zio_gbh {
40 	blkptr_t		zg_blkptr[SPA_GBH_NBLKPTRS];
41 	uint64_t		zg_filler[SPA_GBH_FILLER];
42 	zio_eck_t		zg_tail;
43 } zio_gbh_phys_t;
44 
45 enum zio_checksum {
46 	ZIO_CHECKSUM_INHERIT = 0,
47 	ZIO_CHECKSUM_ON,
48 	ZIO_CHECKSUM_OFF,
49 	ZIO_CHECKSUM_LABEL,
50 	ZIO_CHECKSUM_GANG_HEADER,
51 	ZIO_CHECKSUM_ZILOG,
52 	ZIO_CHECKSUM_FLETCHER_2,
53 	ZIO_CHECKSUM_FLETCHER_4,
54 	ZIO_CHECKSUM_SHA256,
55 	ZIO_CHECKSUM_ZILOG2,
56 	ZIO_CHECKSUM_FUNCTIONS
57 };
58 
59 #define	ZIO_CHECKSUM_ON_VALUE	ZIO_CHECKSUM_FLETCHER_2
60 #define	ZIO_CHECKSUM_DEFAULT	ZIO_CHECKSUM_ON
61 
62 enum zio_compress {
63 	ZIO_COMPRESS_INHERIT = 0,
64 	ZIO_COMPRESS_ON,
65 	ZIO_COMPRESS_OFF,
66 	ZIO_COMPRESS_LZJB,
67 	ZIO_COMPRESS_EMPTY,
68 	ZIO_COMPRESS_GZIP1,
69 	ZIO_COMPRESS_GZIP2,
70 	ZIO_COMPRESS_GZIP3,
71 	ZIO_COMPRESS_GZIP4,
72 	ZIO_COMPRESS_GZIP5,
73 	ZIO_COMPRESS_GZIP6,
74 	ZIO_COMPRESS_GZIP7,
75 	ZIO_COMPRESS_GZIP8,
76 	ZIO_COMPRESS_GZIP9,
77 	ZIO_COMPRESS_FUNCTIONS
78 };
79 
80 #endif	/* _ZIO_H */
81