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