mirror of
https://git.proxmox.com/git/mirror_zfs.git
synced 2024-11-17 10:01:01 +03:00
d3c2ae1c08
Authored by: George Wilson <george.wilson@delphix.com> Reviewed by: Prakash Surya <prakash.surya@delphix.com> Reviewed by: Dan Kimmel <dan.kimmel@delphix.com> Reviewed by: Matt Ahrens <mahrens@delphix.com> Reviewed by: Paul Dagnelie <pcd@delphix.com> Reviewed by: Tom Caputi <tcaputi@datto.com> Reviewed by: Brian Behlendorf <behlendorf1@llnl.gov> Ported by: David Quigley <david.quigley@intel.com> This review covers the reading and writing of compressed arc headers, sharing data between the arc_hdr_t and the arc_buf_t, and the implementation of a new dbuf cache to keep frequently access data uncompressed. I've added a new member to l1 arc hdr called b_pdata. The b_pdata always hangs off the arc_buf_hdr_t (if an L1 hdr is in use) and points to the physical block for that DVA. The physical block may or may not be compressed. If compressed arc is enabled and the block on-disk is compressed, then the b_pdata will match the block on-disk and remain compressed in memory. If the block on disk is not compressed, then neither will the b_pdata. Lastly, if compressed arc is disabled, then b_pdata will always be an uncompressed version of the on-disk block. Typically the arc will cache only the arc_buf_hdr_t and will aggressively evict any arc_buf_t's that are no longer referenced. This means that the arc will primarily have compressed blocks as the arc_buf_t's are considered overhead and are always uncompressed. When a consumer reads a block we first look to see if the arc_buf_hdr_t is cached. If the hdr is cached then we allocate a new arc_buf_t and decompress the b_pdata contents into the arc_buf_t's b_data. If the hdr already has a arc_buf_t, then we will allocate an additional arc_buf_t and bcopy the uncompressed contents from the first arc_buf_t to the new one. Writing to the compressed arc requires that we first discard the b_pdata since the physical block is about to be rewritten. The new data contents will be passed in via an arc_buf_t (uncompressed) and during the I/O pipeline stages we will copy the physical block contents to a newly allocated b_pdata. When an l2arc is inuse it will also take advantage of the b_pdata. Now the l2arc will always write the contents of b_pdata to the l2arc. This means that when compressed arc is enabled that the l2arc blocks are identical to those stored in the main data pool. This provides a significant advantage since we can leverage the bp's checksum when reading from the l2arc to determine if the contents are valid. If the compressed arc is disabled, then we must first transform the read block to look like the physical block in the main data pool before comparing the checksum and determining it's valid. OpenZFS-issue: https://www.illumos.org/issues/6950 OpenZFS-commit: https://github.com/openzfs/openzfs/commit/7fc10f0 Issue #5078
81 lines
2.5 KiB
C
81 lines
2.5 KiB
C
/*
|
|
* 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
|
|
* or http://www.opensolaris.org/os/licensing.
|
|
* 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
|
|
*/
|
|
/*
|
|
* Copyright (c) 2005, 2010, Oracle and/or its affiliates. All rights reserved.
|
|
* Copyright (c) 2014 by Delphix. All rights reserved.
|
|
*/
|
|
|
|
#ifndef _SYS_ZIO_CHECKSUM_H
|
|
#define _SYS_ZIO_CHECKSUM_H
|
|
|
|
#include <sys/zio.h>
|
|
|
|
#ifdef __cplusplus
|
|
extern "C" {
|
|
#endif
|
|
|
|
/*
|
|
* Signature for checksum functions.
|
|
*/
|
|
typedef void zio_checksum_func_t(const void *, uint64_t, zio_cksum_t *);
|
|
|
|
/*
|
|
* Information about each checksum function.
|
|
*/
|
|
typedef const struct zio_checksum_info {
|
|
zio_checksum_func_t *ci_func[2]; /* checksum function per byteorder */
|
|
int ci_correctable; /* number of correctable bits */
|
|
int ci_eck; /* uses zio embedded checksum? */
|
|
boolean_t ci_dedup; /* strong enough for dedup? */
|
|
char *ci_name; /* descriptive name */
|
|
} zio_checksum_info_t;
|
|
|
|
typedef struct zio_bad_cksum {
|
|
zio_cksum_t zbc_expected;
|
|
zio_cksum_t zbc_actual;
|
|
const char *zbc_checksum_name;
|
|
uint8_t zbc_byteswapped;
|
|
uint8_t zbc_injected;
|
|
uint8_t zbc_has_cksum; /* expected/actual valid */
|
|
} zio_bad_cksum_t;
|
|
|
|
extern zio_checksum_info_t zio_checksum_table[ZIO_CHECKSUM_FUNCTIONS];
|
|
|
|
/*
|
|
* Checksum routines.
|
|
*/
|
|
extern zio_checksum_func_t zio_checksum_SHA256;
|
|
|
|
extern int zio_checksum_equal(spa_t *, blkptr_t *, enum zio_checksum,
|
|
void *, uint64_t, uint64_t, zio_bad_cksum_t *);
|
|
extern void zio_checksum_compute(zio_t *zio, enum zio_checksum checksum,
|
|
void *data, uint64_t size);
|
|
extern int zio_checksum_error_impl(spa_t *, blkptr_t *, enum zio_checksum,
|
|
void *, uint64_t, uint64_t, zio_bad_cksum_t *);
|
|
extern int zio_checksum_error(zio_t *zio, zio_bad_cksum_t *out);
|
|
extern enum zio_checksum spa_dedup_checksum(spa_t *spa);
|
|
|
|
#ifdef __cplusplus
|
|
}
|
|
#endif
|
|
|
|
#endif /* _SYS_ZIO_CHECKSUM_H */
|