The Design and Implementation of the FreeBSD Operating System, Second Edition
Now available: The Design and Implementation of the FreeBSD Operating System (Second Edition)


[ source navigation ] [ diff markup ] [ identifier search ] [ freetext search ] [ file search ] [ list types ] [ track identifier ]

FreeBSD/Linux Kernel Cross Reference
sys/contrib/openzfs/include/sys/zio_checksum.h

Version: -  FREEBSD  -  FREEBSD-13-STABLE  -  FREEBSD-13-0  -  FREEBSD-12-STABLE  -  FREEBSD-12-0  -  FREEBSD-11-STABLE  -  FREEBSD-11-0  -  FREEBSD-10-STABLE  -  FREEBSD-10-0  -  FREEBSD-9-STABLE  -  FREEBSD-9-0  -  FREEBSD-8-STABLE  -  FREEBSD-8-0  -  FREEBSD-7-STABLE  -  FREEBSD-7-0  -  FREEBSD-6-STABLE  -  FREEBSD-6-0  -  FREEBSD-5-STABLE  -  FREEBSD-5-0  -  FREEBSD-4-STABLE  -  FREEBSD-3-STABLE  -  FREEBSD22  -  l41  -  OPENBSD  -  linux-2.6  -  MK84  -  PLAN9  -  xnu-8792 
SearchContext: -  none  -  3  -  10 

    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
    9  * or https://opensource.org/licenses/CDDL-1.0.
   10  * See the License for the specific language governing permissions
   11  * and limitations under the License.
   12  *
   13  * When distributing Covered Code, include this CDDL HEADER in each
   14  * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
   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) 2014, 2016 by Delphix. All rights reserved.
   24  * Copyright (c) 2013 Saso Kiselkov, All rights reserved.
   25  * Copyright (c) 2021 Tino Reichardt <milky-zfs@mcmilk.de>
   26  */
   27 
   28 #ifndef _SYS_ZIO_CHECKSUM_H
   29 #define _SYS_ZIO_CHECKSUM_H extern __attribute__((visibility("default")))
   30 
   31 #include <sys/zio.h>
   32 #include <zfeature_common.h>
   33 #include <zfs_fletcher.h>
   34 
   35 #ifdef  __cplusplus
   36 extern "C" {
   37 #endif
   38 
   39 struct abd;
   40 
   41 /*
   42  * Signature for checksum functions.
   43  */
   44 typedef void zio_checksum_t(struct abd *abd, uint64_t size,
   45     const void *ctx_template, zio_cksum_t *zcp);
   46 typedef void *zio_checksum_tmpl_init_t(const zio_cksum_salt_t *salt);
   47 typedef void zio_checksum_tmpl_free_t(void *ctx_template);
   48 
   49 typedef enum zio_checksum_flags {
   50         /* Strong enough for metadata? */
   51         ZCHECKSUM_FLAG_METADATA = (1 << 1),
   52         /* ZIO embedded checksum */
   53         ZCHECKSUM_FLAG_EMBEDDED = (1 << 2),
   54         /* Strong enough for dedup (without verification)? */
   55         ZCHECKSUM_FLAG_DEDUP = (1 << 3),
   56         /* Uses salt value */
   57         ZCHECKSUM_FLAG_SALTED = (1 << 4),
   58         /* Strong enough for nopwrite? */
   59         ZCHECKSUM_FLAG_NOPWRITE = (1 << 5)
   60 } zio_checksum_flags_t;
   61 
   62 typedef enum {
   63         ZIO_CHECKSUM_NATIVE,
   64         ZIO_CHECKSUM_BYTESWAP
   65 } zio_byteorder_t;
   66 
   67 typedef struct zio_abd_checksum_data {
   68         zio_byteorder_t         acd_byteorder;
   69         fletcher_4_ctx_t        *acd_ctx;
   70         zio_cksum_t             *acd_zcp;
   71         void                    *acd_private;
   72 } zio_abd_checksum_data_t;
   73 
   74 typedef void zio_abd_checksum_init_t(zio_abd_checksum_data_t *);
   75 typedef void zio_abd_checksum_fini_t(zio_abd_checksum_data_t *);
   76 typedef int zio_abd_checksum_iter_t(void *, size_t, void *);
   77 
   78 typedef const struct zio_abd_checksum_func {
   79         zio_abd_checksum_init_t *acf_init;
   80         zio_abd_checksum_fini_t *acf_fini;
   81         zio_abd_checksum_iter_t *acf_iter;
   82 } zio_abd_checksum_func_t;
   83 
   84 /*
   85  * Information about each checksum function.
   86  */
   87 typedef const struct zio_checksum_info {
   88         /* checksum function for each byteorder */
   89         zio_checksum_t                  *ci_func[2];
   90         zio_checksum_tmpl_init_t        *ci_tmpl_init;
   91         zio_checksum_tmpl_free_t        *ci_tmpl_free;
   92         zio_checksum_flags_t            ci_flags;
   93         const char                      *ci_name;       /* descriptive name */
   94 } zio_checksum_info_t;
   95 
   96 typedef struct zio_bad_cksum {
   97         zio_cksum_t             zbc_expected;
   98         zio_cksum_t             zbc_actual;
   99         const char              *zbc_checksum_name;
  100         uint8_t                 zbc_byteswapped;
  101         uint8_t                 zbc_injected;
  102         uint8_t                 zbc_has_cksum;  /* expected/actual valid */
  103 } zio_bad_cksum_t;
  104 
  105 _SYS_ZIO_CHECKSUM_H zio_checksum_info_t
  106     zio_checksum_table[ZIO_CHECKSUM_FUNCTIONS];
  107 
  108 /*
  109  * Checksum routines.
  110  */
  111 
  112 /* SHA2 */
  113 extern zio_checksum_t abd_checksum_SHA256;
  114 extern zio_checksum_t abd_checksum_SHA512_native;
  115 extern zio_checksum_t abd_checksum_SHA512_byteswap;
  116 
  117 /* Skein */
  118 extern zio_checksum_t abd_checksum_skein_native;
  119 extern zio_checksum_t abd_checksum_skein_byteswap;
  120 extern zio_checksum_tmpl_init_t abd_checksum_skein_tmpl_init;
  121 extern zio_checksum_tmpl_free_t abd_checksum_skein_tmpl_free;
  122 
  123 /* Edon-R */
  124 extern zio_checksum_t abd_checksum_edonr_native;
  125 extern zio_checksum_t abd_checksum_edonr_byteswap;
  126 extern zio_checksum_tmpl_init_t abd_checksum_edonr_tmpl_init;
  127 extern zio_checksum_tmpl_free_t abd_checksum_edonr_tmpl_free;
  128 
  129 /* BLAKE3 */
  130 extern zio_checksum_t abd_checksum_blake3_native;
  131 extern zio_checksum_t abd_checksum_blake3_byteswap;
  132 extern zio_checksum_tmpl_init_t abd_checksum_blake3_tmpl_init;
  133 extern zio_checksum_tmpl_free_t abd_checksum_blake3_tmpl_free;
  134 
  135 /* Fletcher 4 */
  136 _SYS_ZIO_CHECKSUM_H zio_abd_checksum_func_t fletcher_4_abd_ops;
  137 extern zio_checksum_t abd_fletcher_4_native;
  138 extern zio_checksum_t abd_fletcher_4_byteswap;
  139 
  140 extern int zio_checksum_equal(spa_t *, blkptr_t *, enum zio_checksum,
  141     void *, uint64_t, uint64_t, zio_bad_cksum_t *);
  142 extern void zio_checksum_compute(zio_t *, enum zio_checksum,
  143     struct abd *, uint64_t);
  144 extern int zio_checksum_error_impl(spa_t *, const blkptr_t *, enum zio_checksum,
  145     struct abd *, uint64_t, uint64_t, zio_bad_cksum_t *);
  146 extern int zio_checksum_error(zio_t *zio, zio_bad_cksum_t *out);
  147 extern enum zio_checksum spa_dedup_checksum(spa_t *spa);
  148 extern void zio_checksum_templates_free(spa_t *spa);
  149 extern spa_feature_t zio_checksum_to_feature(enum zio_checksum cksum);
  150 
  151 #ifdef  __cplusplus
  152 }
  153 #endif
  154 
  155 #endif  /* _SYS_ZIO_CHECKSUM_H */

Cache object: fcc48679dd44290d2ee6759314d7fcf5


[ source navigation ] [ diff markup ] [ identifier search ] [ freetext search ] [ file search ] [ list types ] [ track identifier ]


This page is part of the FreeBSD/Linux Linux Kernel Cross-Reference, and was automatically generated using a modified version of the LXR engine.