equal
deleted
inserted
replaced
18 * |
18 * |
19 * CDDL HEADER END |
19 * CDDL HEADER END |
20 */ |
20 */ |
21 /* |
21 /* |
22 * Copyright (c) 2005, 2010, Oracle and/or its affiliates. All rights reserved. |
22 * Copyright (c) 2005, 2010, Oracle and/or its affiliates. All rights reserved. |
|
23 * Copyright (c) 2013 by Delphix. All rights reserved. |
23 */ |
24 */ |
24 |
25 |
25 #include <sys/zfs_context.h> |
26 #include <sys/zfs_context.h> |
26 #include <sys/spa.h> |
27 #include <sys/spa.h> |
27 #include <sys/zio.h> |
28 #include <sys/zio.h> |
199 void *data = zio->io_data; |
200 void *data = zio->io_data; |
200 zio_checksum_info_t *ci = &zio_checksum_table[checksum]; |
201 zio_checksum_info_t *ci = &zio_checksum_table[checksum]; |
201 zio_cksum_t actual_cksum, expected_cksum, verifier; |
202 zio_cksum_t actual_cksum, expected_cksum, verifier; |
202 |
203 |
203 if (checksum >= ZIO_CHECKSUM_FUNCTIONS || ci->ci_func[0] == NULL) |
204 if (checksum >= ZIO_CHECKSUM_FUNCTIONS || ci->ci_func[0] == NULL) |
204 return (EINVAL); |
205 return (SET_ERROR(EINVAL)); |
205 |
206 |
206 if (ci->ci_eck) { |
207 if (ci->ci_eck) { |
207 zio_eck_t *eck; |
208 zio_eck_t *eck; |
208 |
209 |
209 if (checksum == ZIO_CHECKSUM_ZILOG2) { |
210 if (checksum == ZIO_CHECKSUM_ZILOG2) { |
214 if (eck->zec_magic == ZEC_MAGIC) |
215 if (eck->zec_magic == ZEC_MAGIC) |
215 nused = zilc->zc_nused; |
216 nused = zilc->zc_nused; |
216 else if (eck->zec_magic == BSWAP_64(ZEC_MAGIC)) |
217 else if (eck->zec_magic == BSWAP_64(ZEC_MAGIC)) |
217 nused = BSWAP_64(zilc->zc_nused); |
218 nused = BSWAP_64(zilc->zc_nused); |
218 else |
219 else |
219 return (ECKSUM); |
220 return (SET_ERROR(ECKSUM)); |
220 |
221 |
221 if (nused > size) |
222 if (nused > size) |
222 return (ECKSUM); |
223 return (SET_ERROR(ECKSUM)); |
223 |
224 |
224 size = P2ROUNDUP_TYPED(nused, ZIL_MIN_BLKSZ, uint64_t); |
225 size = P2ROUNDUP_TYPED(nused, ZIL_MIN_BLKSZ, uint64_t); |
225 } else { |
226 } else { |
226 eck = (zio_eck_t *)((char *)data + size) - 1; |
227 eck = (zio_eck_t *)((char *)data + size) - 1; |
227 } |
228 } |
259 info->zbc_byteswapped = byteswap; |
260 info->zbc_byteswapped = byteswap; |
260 info->zbc_injected = 0; |
261 info->zbc_injected = 0; |
261 info->zbc_has_cksum = 1; |
262 info->zbc_has_cksum = 1; |
262 |
263 |
263 if (!ZIO_CHECKSUM_EQUAL(actual_cksum, expected_cksum)) |
264 if (!ZIO_CHECKSUM_EQUAL(actual_cksum, expected_cksum)) |
264 return (ECKSUM); |
265 return (SET_ERROR(ECKSUM)); |
265 |
266 |
266 if (zio_injection_enabled && !zio->io_error && |
267 if (zio_injection_enabled && !zio->io_error && |
267 (error = zio_handle_fault_injection(zio, ECKSUM)) != 0) { |
268 (error = zio_handle_fault_injection(zio, ECKSUM)) != 0) { |
268 |
269 |
269 info->zbc_injected = 1; |
270 info->zbc_injected = 1; |