zio_checksum.c revision cde58dbc6a23d4d38db7c8866312be83221c765f
/*
* CDDL HEADER START
*
* The contents of this file are subject to the terms of the
* Common Development and Distribution License (the "License").
* You may not use this file except in compliance with the License.
*
* You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
* See the License for the specific language governing permissions
* and limitations under the License.
*
* When distributing Covered Code, include this CDDL HEADER in each
* file and include the License file at usr/src/OPENSOLARIS.LICENSE.
* If applicable, add the following below this CDDL HEADER, with the
* fields enclosed by brackets "[]" replaced with your own identifying
* information: Portions Copyright [yyyy] [name of copyright owner]
*
* CDDL HEADER END
*/
/*
*/
#include <sys/zfs_context.h>
#include <sys/zio_checksum.h>
#include <zfs_fletcher.h>
/*
* Checksum vectors.
*
* In the SPA, everything is checksummed. We support checksum vectors
* for three distinct reasons:
*
* 1. Different kinds of data need different levels of protection.
* For SPA metadata, we always want a very strong checksum.
* For user data, we let users make the trade-off between speed
* and checksum strength.
*
* 2. Cryptographic hash and MAC algorithms are an area of active research.
* It is likely that in future hash functions will be at least as strong
* as current best-of-breed, and may be substantially faster as well.
* We want the ability to take advantage of these new hashes as soon as
* they become available.
*
* 3. If someone develops hardware that can compute a strong hash quickly,
* we want the ability to take advantage of that hardware.
*
* Of course, we don't want a checksum upgrade to invalidate existing
* data, so we store the checksum *function* in eight bits of the bp.
* This gives us room for up to 256 different checksum functions.
*
* When writing a block, we always checksum it with the latest-and-greatest
* checksum function of the appropriate strength. When reading a block,
* we compare the expected checksum against the actual checksum, which we
* compute via the checksum function specified by BP_GET_CHECKSUM(bp).
*/
/*ARGSUSED*/
static void
{
ZIO_SET_CHECKSUM(zcp, 0, 0, 0, 0);
}
};
enum zio_checksum
{
if (child == ZIO_CHECKSUM_INHERIT)
return (parent);
if (child == ZIO_CHECKSUM_ON)
return (ZIO_CHECKSUM_ON_VALUE);
return (child);
}
enum zio_checksum
enum zio_checksum parent)
{
if (child == ZIO_CHECKSUM_INHERIT)
return (parent);
if (child == ZIO_CHECKSUM_ON)
return (spa_dedup_checksum(spa));
return (child);
}
/*
* Set the external verifier for a gang block based on <vdev, offset, txg>,
* a tuple which is guaranteed to be unique for the life of the pool.
*/
static void
{
}
/*
* Set the external verifier for a label block based on its offset.
* The vdev is implicit, and the txg is unknowable at pool open time --
* hence the logic in vdev_uberblock_load() to find the most recent copy.
*/
static void
{
}
/*
* Generate the checksum.
*/
void
{
if (checksum == ZIO_CHECKSUM_ZILOG2) {
uint64_t);
} else {
}
if (checksum == ZIO_CHECKSUM_GANG_HEADER)
else if (checksum == ZIO_CHECKSUM_LABEL)
else
} else {
}
}
int
{
int byteswap;
int error;
return (EINVAL);
if (checksum == ZIO_CHECKSUM_ZILOG2) {
else
return (ECKSUM);
return (ECKSUM);
} else {
}
if (checksum == ZIO_CHECKSUM_GANG_HEADER)
else if (checksum == ZIO_CHECKSUM_LABEL)
else
if (byteswap)
if (byteswap)
sizeof (zio_cksum_t));
} else {
}
info->zbc_injected = 0;
return (ECKSUM);
return (error);
}
return (0);
}