Print this page
Integrated Edon-R hash function.
Split |
Close |
Expand all |
Collapse all |
--- old/usr/src/grub/grub-0.97/stage2/fsys_zfs.h
+++ new/usr/src/grub/grub-0.97/stage2/fsys_zfs.h
1 1 /*
2 2 * GRUB -- GRand Unified Bootloader
3 3 * Copyright (C) 1999,2000,2001,2002,2003,2004 Free Software Foundation, Inc.
4 4 *
5 5 * This program is free software; you can redistribute it and/or modify
6 6 * it under the terms of the GNU General Public License as published by
7 7 * the Free Software Foundation; either version 2 of the License, or
8 8 * (at your option) any later version.
9 9 *
10 10 * This program is distributed in the hope that it will be useful,
11 11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 13 * GNU General Public License for more details.
14 14 *
15 15 * You should have received a copy of the GNU General Public License
16 16 * along with this program; if not, write to the Free Software
17 17 * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
18 18 */
19 19
20 20 /*
21 21 * Copyright 2010 Sun Microsystems, Inc. All rights reserved.
22 22 * Use is subject to license terms.
23 23 */
24 24
25 25 /*
26 26 * Copyright (c) 2012 by Delphix. All rights reserved.
27 27 * Copyright (c) 2013 by Saso Kiselkov. All rights reserved.
28 28 */
29 29
30 30 #ifndef _FSYS_ZFS_H
31 31 #define _FSYS_ZFS_H
32 32
33 33 #ifdef FSYS_ZFS
34 34
35 35 #ifndef FSIMAGE
36 36 typedef unsigned long long uint64_t;
37 37 typedef unsigned int uint32_t;
38 38 typedef unsigned short uint16_t;
39 39 typedef unsigned char uint8_t;
40 40 typedef unsigned char uchar_t;
41 41
42 42 #if defined(_LP64) || defined(_I32LPx)
43 43 typedef unsigned long size_t;
44 44 #else
45 45 typedef unsigned int size_t;
46 46 #endif
47 47 #else
48 48 #include "fsi_zfs.h"
49 49 #endif /* !FSIMAGE */
50 50
51 51 #include <zfs-include/zfs.h>
52 52 #include <zfs-include/dmu.h>
53 53 #include <zfs-include/spa.h>
54 54 #include <zfs-include/zio.h>
55 55 #include <zfs-include/zio_checksum.h>
56 56 #include <zfs-include/vdev_impl.h>
57 57 #include <zfs-include/zap_impl.h>
58 58 #include <zfs-include/zap_leaf.h>
59 59 #include <zfs-include/uberblock_impl.h>
60 60 #include <zfs-include/dnode.h>
61 61 #include <zfs-include/dsl_dir.h>
62 62 #include <zfs-include/zfs_acl.h>
63 63 #include <zfs-include/zfs_znode.h>
64 64 #include <zfs-include/dsl_dataset.h>
65 65 #include <zfs-include/zil.h>
66 66 #include <zfs-include/dmu_objset.h>
67 67 #include <zfs-include/sa_impl.h>
68 68
69 69 /*
70 70 * Global Memory addresses to store MOS and DNODE data
71 71 */
72 72 #define MOS ((dnode_phys_t *)\
73 73 (RAW_ADDR((mbi.mem_upper << 10) + 0x100000) - ZFS_SCRATCH_SIZE))
74 74 #define DNODE (MOS+1) /* move sizeof(dnode_phys_t) bytes */
75 75 #define ZFS_SCRATCH ((char *)(DNODE+1))
76 76
77 77 /*
78 78 * Verify dnode type.
79 79 * Can only be used in functions returning non-0 for failure.
80 80 */
81 81 #define VERIFY_DN_TYPE(dnp, type) \
82 82 if (type && (dnp)->dn_type != type) { \
83 83 return (ERR_FSYS_CORRUPT); \
84 84 }
85 85
86 86 /*
87 87 * Verify object set type.
88 88 * Can only be used in functions returning 0 for failure.
89 89 */
90 90 #define VERIFY_OS_TYPE(osp, type) \
91 91 if (type && (osp)->os_type != type) { \
92 92 errnum = ERR_FSYS_CORRUPT; \
93 93 return (0); \
94 94 }
95 95
96 96 #define ZPOOL_PROP_BOOTFS "bootfs"
97 97
98 98 /* General macros */
99 99 #define BSWAP_8(x) ((x) & 0xff)
100 100 #define BSWAP_16(x) ((BSWAP_8(x) << 8) | BSWAP_8((x) >> 8))
101 101 #define BSWAP_32(x) ((BSWAP_16(x) << 16) | BSWAP_16((x) >> 16))
102 102 #define BSWAP_64(x) ((BSWAP_32(x) << 32) | BSWAP_32((x) >> 32))
103 103 #define P2ROUNDUP(x, align) (-(-(x) & -(align)))
104 104
105 105 typedef struct uberblock uberblock_t;
106 106
107 107 /*
108 108 * Macros to get fields in a bp or DVA.
109 109 */
110 110 #define P2PHASE(x, align) ((x) & ((align) - 1))
111 111 #define DVA_OFFSET_TO_PHYS_SECTOR(offset) \
112 112 ((offset + VDEV_LABEL_START_SIZE) >> SPA_MINBLOCKSHIFT)
113 113
114 114 /*
115 115 * return x rounded down to an align boundary
116 116 * eg, P2ALIGN(1200, 1024) == 1024 (1*align)
117 117 * eg, P2ALIGN(1024, 1024) == 1024 (1*align)
118 118 * eg, P2ALIGN(0x1234, 0x100) == 0x1200 (0x12*align)
119 119 * eg, P2ALIGN(0x5600, 0x100) == 0x5600 (0x56*align)
120 120 */
121 121 #define P2ALIGN(x, align) ((x) & -(align))
122 122
123 123 /*
124 124 * For nvlist manipulation. (from nvpair.h)
125 125 */
126 126 #define NV_ENCODE_NATIVE 0
127 127 #define NV_ENCODE_XDR 1
128 128 #define HOST_ENDIAN 1 /* for x86 machine */
129 129 typedef enum {
130 130 DATA_TYPE_UNKNOWN = 0,
131 131 DATA_TYPE_BOOLEAN,
132 132 DATA_TYPE_BYTE,
133 133 DATA_TYPE_INT16,
134 134 DATA_TYPE_UINT16,
135 135 DATA_TYPE_INT32,
136 136 DATA_TYPE_UINT32,
137 137 DATA_TYPE_INT64,
138 138 DATA_TYPE_UINT64,
139 139 DATA_TYPE_STRING,
140 140 DATA_TYPE_BYTE_ARRAY,
141 141 DATA_TYPE_INT16_ARRAY,
142 142 DATA_TYPE_UINT16_ARRAY,
143 143 DATA_TYPE_INT32_ARRAY,
144 144 DATA_TYPE_UINT32_ARRAY,
145 145 DATA_TYPE_INT64_ARRAY,
146 146 DATA_TYPE_UINT64_ARRAY,
147 147 DATA_TYPE_STRING_ARRAY,
148 148 DATA_TYPE_HRTIME,
149 149 DATA_TYPE_NVLIST,
150 150 DATA_TYPE_NVLIST_ARRAY,
151 151 DATA_TYPE_BOOLEAN_VALUE,
152 152 DATA_TYPE_INT8,
153 153 DATA_TYPE_UINT8,
154 154 DATA_TYPE_BOOLEAN_ARRAY,
155 155 DATA_TYPE_INT8_ARRAY,
156 156 DATA_TYPE_UINT8_ARRAY,
157 157 DATA_TYPE_DOUBLE
158 158 } data_type_t;
159 159
160 160 /*
161 161 * Decompression Entry - lzjb
162 162 */
163 163 #ifndef NBBY
164 164 #define NBBY 8
165 165 #endif
166 166
167 167 typedef int zfs_decomp_func_t(void *s_start, void *d_start, size_t s_len,
168 168 size_t d_len);
169 169 typedef struct decomp_entry {
170 170 char *name;
171 171 zfs_decomp_func_t *decomp_func;
172 172 } decomp_entry_t;
173 173
174 174 /*
175 175 * FAT ZAP data structures
176 176 */
177 177 #define ZFS_CRC64_POLY 0xC96C5795D7870F42ULL /* ECMA-182, reflected form */
178 178 #define ZAP_HASH_IDX(hash, n) (((n) == 0) ? 0 : ((hash) >> (64 - (n))))
179 179 #define CHAIN_END 0xffff /* end of the chunk chain */
180 180
181 181 /*
182 182 * The amount of space within the chunk available for the array is:
183 183 * chunk size - space for type (1) - space for next pointer (2)
184 184 */
185 185 #define ZAP_LEAF_ARRAY_BYTES (ZAP_LEAF_CHUNKSIZE - 3)
186 186
187 187 #define ZAP_LEAF_HASH_SHIFT(bs) (bs - 5)
188 188 #define ZAP_LEAF_HASH_NUMENTRIES(bs) (1 << ZAP_LEAF_HASH_SHIFT(bs))
189 189 #define LEAF_HASH(bs, h) \
190 190 ((ZAP_LEAF_HASH_NUMENTRIES(bs)-1) & \
191 191 ((h) >> (64 - ZAP_LEAF_HASH_SHIFT(bs)-l->l_hdr.lh_prefix_len)))
192 192
193 193 /*
194 194 * The amount of space available for chunks is:
195 195 * block size shift - hash entry size (2) * number of hash
196 196 * entries - header space (2*chunksize)
197 197 */
198 198 #define ZAP_LEAF_NUMCHUNKS(bs) \
199 199 (((1<<bs) - 2*ZAP_LEAF_HASH_NUMENTRIES(bs)) / \
200 200 ZAP_LEAF_CHUNKSIZE - 2)
201 201
202 202 /*
203 203 * The chunks start immediately after the hash table. The end of the
204 204 * hash table is at l_hash + HASH_NUMENTRIES, which we simply cast to a
205 205 * chunk_t.
↓ open down ↓ |
205 lines elided |
↑ open up ↑ |
206 206 */
207 207 #define ZAP_LEAF_CHUNK(l, bs, idx) \
208 208 ((zap_leaf_chunk_t *)(l->l_hash + ZAP_LEAF_HASH_NUMENTRIES(bs)))[idx]
209 209 #define ZAP_LEAF_ENTRY(l, bs, idx) (&ZAP_LEAF_CHUNK(l, bs, idx).l_entry)
210 210
211 211 extern void fletcher_2_native(const void *, uint64_t, zio_cksum_t *);
212 212 extern void fletcher_2_byteswap(const void *, uint64_t, zio_cksum_t *);
213 213 extern void fletcher_4_native(const void *, uint64_t, zio_cksum_t *);
214 214 extern void fletcher_4_byteswap(const void *, uint64_t, zio_cksum_t *);
215 215 extern void zio_checksum_SHA256(const void *, uint64_t, zio_cksum_t *);
216 +extern void zio_checksum_EdonR512_256(const void *, uint64_t, zio_cksum_t *);
217 +extern void zio_checksum_EdonR512_256_byteswap(const void *, uint64_t,
218 + zio_cksum_t *);
216 219 extern int lzjb_decompress(void *, void *, size_t, size_t);
217 220 extern int lz4_decompress(void *, void *, size_t, size_t);
218 221
219 222 #endif /* FSYS_ZFS */
220 223
221 224 #endif /* !_FSYS_ZFS_H */
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX