zio_checksum.c (219089) | zio_checksum.c (249195) |
---|---|
1/* 2 * CDDL HEADER START 3 * 4 * The contents of this file are subject to the terms of the 5 * Common Development and Distribution License (the "License"). 6 * You may not use this file except in compliance with the License. 7 * 8 * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE --- 6 unchanged lines hidden (view full) --- 15 * If applicable, add the following below this CDDL HEADER, with the 16 * fields enclosed by brackets "[]" replaced with your own identifying 17 * information: Portions Copyright [yyyy] [name of copyright owner] 18 * 19 * CDDL HEADER END 20 */ 21/* 22 * Copyright (c) 2005, 2010, Oracle and/or its affiliates. All rights reserved. | 1/* 2 * CDDL HEADER START 3 * 4 * The contents of this file are subject to the terms of the 5 * Common Development and Distribution License (the "License"). 6 * You may not use this file except in compliance with the License. 7 * 8 * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE --- 6 unchanged lines hidden (view full) --- 15 * If applicable, add the following below this CDDL HEADER, with the 16 * fields enclosed by brackets "[]" replaced with your own identifying 17 * information: Portions Copyright [yyyy] [name of copyright owner] 18 * 19 * CDDL HEADER END 20 */ 21/* 22 * Copyright (c) 2005, 2010, Oracle and/or its affiliates. All rights reserved. |
23 * Copyright (c) 2013 by Delphix. All rights reserved. |
|
23 */ 24 25#include <sys/zfs_context.h> 26#include <sys/spa.h> 27#include <sys/zio.h> 28#include <sys/zio_checksum.h> 29#include <sys/zil.h> 30#include <zfs_fletcher.h> --- 165 unchanged lines hidden (view full) --- 196 uint64_t size = (bp == NULL ? zio->io_size : 197 (BP_IS_GANG(bp) ? SPA_GANGBLOCKSIZE : BP_GET_PSIZE(bp))); 198 uint64_t offset = zio->io_offset; 199 void *data = zio->io_data; 200 zio_checksum_info_t *ci = &zio_checksum_table[checksum]; 201 zio_cksum_t actual_cksum, expected_cksum, verifier; 202 203 if (checksum >= ZIO_CHECKSUM_FUNCTIONS || ci->ci_func[0] == NULL) | 24 */ 25 26#include <sys/zfs_context.h> 27#include <sys/spa.h> 28#include <sys/zio.h> 29#include <sys/zio_checksum.h> 30#include <sys/zil.h> 31#include <zfs_fletcher.h> --- 165 unchanged lines hidden (view full) --- 197 uint64_t size = (bp == NULL ? zio->io_size : 198 (BP_IS_GANG(bp) ? SPA_GANGBLOCKSIZE : BP_GET_PSIZE(bp))); 199 uint64_t offset = zio->io_offset; 200 void *data = zio->io_data; 201 zio_checksum_info_t *ci = &zio_checksum_table[checksum]; 202 zio_cksum_t actual_cksum, expected_cksum, verifier; 203 204 if (checksum >= ZIO_CHECKSUM_FUNCTIONS || ci->ci_func[0] == NULL) |
204 return (EINVAL); | 205 return (SET_ERROR(EINVAL)); |
205 206 if (ci->ci_eck) { 207 zio_eck_t *eck; 208 209 if (checksum == ZIO_CHECKSUM_ZILOG2) { 210 zil_chain_t *zilc = data; 211 uint64_t nused; 212 213 eck = &zilc->zc_eck; 214 if (eck->zec_magic == ZEC_MAGIC) 215 nused = zilc->zc_nused; 216 else if (eck->zec_magic == BSWAP_64(ZEC_MAGIC)) 217 nused = BSWAP_64(zilc->zc_nused); 218 else | 206 207 if (ci->ci_eck) { 208 zio_eck_t *eck; 209 210 if (checksum == ZIO_CHECKSUM_ZILOG2) { 211 zil_chain_t *zilc = data; 212 uint64_t nused; 213 214 eck = &zilc->zc_eck; 215 if (eck->zec_magic == ZEC_MAGIC) 216 nused = zilc->zc_nused; 217 else if (eck->zec_magic == BSWAP_64(ZEC_MAGIC)) 218 nused = BSWAP_64(zilc->zc_nused); 219 else |
219 return (ECKSUM); | 220 return (SET_ERROR(ECKSUM)); |
220 221 if (nused > size) | 221 222 if (nused > size) |
222 return (ECKSUM); | 223 return (SET_ERROR(ECKSUM)); |
223 224 size = P2ROUNDUP_TYPED(nused, ZIL_MIN_BLKSZ, uint64_t); 225 } else { 226 eck = (zio_eck_t *)((char *)data + size) - 1; 227 } 228 229 if (checksum == ZIO_CHECKSUM_GANG_HEADER) 230 zio_checksum_gang_verifier(&verifier, bp); --- 25 unchanged lines hidden (view full) --- 256 info->zbc_expected = expected_cksum; 257 info->zbc_actual = actual_cksum; 258 info->zbc_checksum_name = ci->ci_name; 259 info->zbc_byteswapped = byteswap; 260 info->zbc_injected = 0; 261 info->zbc_has_cksum = 1; 262 263 if (!ZIO_CHECKSUM_EQUAL(actual_cksum, expected_cksum)) | 224 225 size = P2ROUNDUP_TYPED(nused, ZIL_MIN_BLKSZ, uint64_t); 226 } else { 227 eck = (zio_eck_t *)((char *)data + size) - 1; 228 } 229 230 if (checksum == ZIO_CHECKSUM_GANG_HEADER) 231 zio_checksum_gang_verifier(&verifier, bp); --- 25 unchanged lines hidden (view full) --- 257 info->zbc_expected = expected_cksum; 258 info->zbc_actual = actual_cksum; 259 info->zbc_checksum_name = ci->ci_name; 260 info->zbc_byteswapped = byteswap; 261 info->zbc_injected = 0; 262 info->zbc_has_cksum = 1; 263 264 if (!ZIO_CHECKSUM_EQUAL(actual_cksum, expected_cksum)) |
264 return (ECKSUM); | 265 return (SET_ERROR(ECKSUM)); |
265 266 if (zio_injection_enabled && !zio->io_error && 267 (error = zio_handle_fault_injection(zio, ECKSUM)) != 0) { 268 269 info->zbc_injected = 1; 270 return (error); 271 } 272 273 return (0); 274} | 266 267 if (zio_injection_enabled && !zio->io_error && 268 (error = zio_handle_fault_injection(zio, ECKSUM)) != 0) { 269 270 info->zbc_injected = 1; 271 return (error); 272 } 273 274 return (0); 275} |