Browse Source

zfs: merge openzfs/zfs@deb121309

Notable upstream pull request merges:
  #12918 Introduce BLAKE3 checksums as an OpenZFS feature
  #13553 Reduce ZIO io_lock contention on sorted scrub
  #13537 Improve sorted scan memory accounting
  #13540 AVL: Remove obsolete branching optimizations
  #13563 FreeBSD: Improve crypto_dispatch() handling

Obtained from:	OpenZFS
OpenZFS commit:	deb1213098
main
Martin Matuska 2 weeks ago
parent
commit
1f1e2261e3
  1. 29
      cddl/lib/libicp/Makefile
  2. 29
      cddl/lib/libicp_rescue/Makefile
  3. 2
      cddl/lib/libzpool/Makefile
  4. 1
      sys/contrib/openzfs/AUTHORS
  5. 6
      sys/contrib/openzfs/cmd/zfs/zfs_iter.c
  6. 68
      sys/contrib/openzfs/cmd/zfs/zfs_main.c
  7. 4
      sys/contrib/openzfs/cmd/zpool/zpool_main.c
  8. 89
      sys/contrib/openzfs/cmd/ztest.c
  9. 2
      sys/contrib/openzfs/config/always-arch.m4
  10. 3
      sys/contrib/openzfs/config/kernel-add-disk.m4
  11. 32
      sys/contrib/openzfs/config/kernel-blk-queue.m4
  12. 23
      sys/contrib/openzfs/config/kernel-user-ns-inum.m4
  13. 2
      sys/contrib/openzfs/config/kernel.m4
  14. 3
      sys/contrib/openzfs/contrib/dracut/90zfs/module-setup.sh.in
  15. 1
      sys/contrib/openzfs/contrib/pyzfs/libzfs_core/_constants.py
  16. 3
      sys/contrib/openzfs/etc/Makefile.am
  17. 12
      sys/contrib/openzfs/etc/systemd/system/zfs-trim-monthly@.timer.in
  18. 12
      sys/contrib/openzfs/etc/systemd/system/zfs-trim-weekly@.timer.in
  19. 15
      sys/contrib/openzfs/etc/systemd/system/zfs-trim@.service.in
  20. 2
      sys/contrib/openzfs/include/Makefile.am
  21. 10
      sys/contrib/openzfs/include/libzfs.h
  22. 2
      sys/contrib/openzfs/include/os/freebsd/spl/sys/ccompile.h
  23. 111
      sys/contrib/openzfs/include/os/linux/kernel/linux/blkdev_compat.h
  24. 34
      sys/contrib/openzfs/include/os/linux/kernel/linux/simd_powerpc.h
  25. 16
      sys/contrib/openzfs/include/os/linux/kernel/linux/vfs_compat.h
  26. 39
      sys/contrib/openzfs/include/os/linux/spl/sys/uio.h
  27. 31
      sys/contrib/openzfs/include/os/linux/spl/sys/zone.h
  28. 5
      sys/contrib/openzfs/include/os/linux/zfs/sys/zfs_context_os.h
  29. 125
      sys/contrib/openzfs/include/sys/blake3.h
  30. 6
      sys/contrib/openzfs/include/sys/fs/zfs.h
  31. 48
      sys/contrib/openzfs/include/sys/zfs_chksum.h
  32. 3
      sys/contrib/openzfs/include/sys/zfs_ioctl.h
  33. 1
      sys/contrib/openzfs/include/sys/zio.h
  34. 12
      sys/contrib/openzfs/include/sys/zio_checksum.h
  35. 1
      sys/contrib/openzfs/include/zfeature_common.h
  36. 25
      sys/contrib/openzfs/lib/libicp/Makefile.am
  37. 18
      sys/contrib/openzfs/lib/libspl/include/sys/simd.h
  38. 2
      sys/contrib/openzfs/lib/libspl/include/sys/types.h
  39. 12
      sys/contrib/openzfs/lib/libspl/include/zone.h
  40. 32
      sys/contrib/openzfs/lib/libspl/os/linux/zone.c
  41. 2
      sys/contrib/openzfs/lib/libuutil/libuutil.abi
  42. 18
      sys/contrib/openzfs/lib/libzfs/libzfs.abi
  43. 10
      sys/contrib/openzfs/lib/libzfs/libzfs_crypto.c
  44. 64
      sys/contrib/openzfs/lib/libzfs/libzfs_dataset.c
  45. 2
      sys/contrib/openzfs/lib/libzfs/libzfs_diff.c
  46. 4
      sys/contrib/openzfs/lib/libzfs/libzfs_impl.h
  47. 299
      sys/contrib/openzfs/lib/libzfs/libzfs_pool.c
  48. 36
      sys/contrib/openzfs/lib/libzfs/libzfs_sendrecv.c
  49. 12
      sys/contrib/openzfs/lib/libzfs/libzfs_util.c
  50. 2
      sys/contrib/openzfs/lib/libzfs/os/freebsd/libzfs_compat.c
  51. 2
      sys/contrib/openzfs/lib/libzfs/os/linux/libzfs_pool_os.c
  52. 71
      sys/contrib/openzfs/lib/libzfs/os/linux/libzfs_util_os.c
  53. 2
      sys/contrib/openzfs/lib/libzfs_core/libzfs_core.abi
  54. 2
      sys/contrib/openzfs/lib/libzpool/Makefile.am
  55. 2
      sys/contrib/openzfs/man/Makefile.am
  56. 69
      sys/contrib/openzfs/man/man4/zfs.4
  57. 10
      sys/contrib/openzfs/man/man7/zfsprops.7
  58. 8
      sys/contrib/openzfs/man/man7/zpool-features.7
  59. 1
      sys/contrib/openzfs/man/man8/zfs-unzone.8
  60. 116
      sys/contrib/openzfs/man/man8/zfs-zone.8
  61. 21
      sys/contrib/openzfs/man/man8/zpool-trim.8
  62. 38
      sys/contrib/openzfs/module/Kbuild.in
  63. 34
      sys/contrib/openzfs/module/Makefile.bsd
  64. 24
      sys/contrib/openzfs/module/avl/avl.c
  65. 732
      sys/contrib/openzfs/module/icp/algs/blake3/blake3.c
  66. 202
      sys/contrib/openzfs/module/icp/algs/blake3/blake3_generic.c
  67. 284
      sys/contrib/openzfs/module/icp/algs/blake3/blake3_impl.c
  68. 213
      sys/contrib/openzfs/module/icp/algs/blake3/blake3_impl.h
  69. 248
      sys/contrib/openzfs/module/icp/algs/blake3/blake3_x86-64.c
  70. 2450
      sys/contrib/openzfs/module/icp/asm-aarch64/blake3/b3_aarch64_sse2.S
  71. 2463
      sys/contrib/openzfs/module/icp/asm-aarch64/blake3/b3_aarch64_sse41.S
  72. 2823
      sys/contrib/openzfs/module/icp/asm-ppc64/blake3/b3_ppc64le_sse2.S
  73. 3064
      sys/contrib/openzfs/module/icp/asm-ppc64/blake3/b3_ppc64le_sse41.S
  74. 1845
      sys/contrib/openzfs/module/icp/asm-x86_64/blake3/blake3_avx2.S
  75. 2618
      sys/contrib/openzfs/module/icp/asm-x86_64/blake3/blake3_avx512.S
  76. 2323
      sys/contrib/openzfs/module/icp/asm-x86_64/blake3/blake3_sse2.S
  77. 2058
      sys/contrib/openzfs/module/icp/asm-x86_64/blake3/blake3_sse41.S
  78. 41
      sys/contrib/openzfs/module/os/freebsd/zfs/crypto_os.c
  79. 6
      sys/contrib/openzfs/module/os/linux/spl/spl-generic.c
  80. 424
      sys/contrib/openzfs/module/os/linux/spl/spl-zone.c
  81. 2
      sys/contrib/openzfs/module/os/linux/zfs/policy.c
  82. 47
      sys/contrib/openzfs/module/os/linux/zfs/zfs_ioctl_os.c
  83. 154
      sys/contrib/openzfs/module/os/linux/zfs/zfs_uio.c
  84. 20
      sys/contrib/openzfs/module/os/linux/zfs/zfs_vfsops.c
  85. 17
      sys/contrib/openzfs/module/os/linux/zfs/zpl_ctldir.c
  86. 1
      sys/contrib/openzfs/module/os/linux/zfs/zpl_super.c
  87. 5
      sys/contrib/openzfs/module/os/linux/zfs/zpl_xattr.c
  88. 632
      sys/contrib/openzfs/module/os/linux/zfs/zvol_os.c
  89. 31
      sys/contrib/openzfs/module/zcommon/zfeature_common.c
  90. 8
      sys/contrib/openzfs/module/zcommon/zfs_prop.c
  91. 117
      sys/contrib/openzfs/module/zfs/blake3_zfs.c
  92. 10
      sys/contrib/openzfs/module/zfs/dsl_prop.c
  93. 26
      sys/contrib/openzfs/module/zfs/dsl_scan.c
  94. 3
      sys/contrib/openzfs/module/zfs/spa_misc.c
  95. 6
      sys/contrib/openzfs/module/zfs/vdev.c
  96. 2
      sys/contrib/openzfs/module/zfs/zcp_synctask.c
  97. 323
      sys/contrib/openzfs/module/zfs/zfs_chksum.c
  98. 14
      sys/contrib/openzfs/module/zfs/zfs_ioctl.c
  99. 6
      sys/contrib/openzfs/module/zfs/zio_checksum.c
  100. 10
      sys/contrib/openzfs/tests/runfiles/common.run
  101. Some files were not shown because too many files have changed in this diff Show More

29
cddl/lib/libicp/Makefile

@ -16,9 +16,23 @@ ASM_SOURCES_AS = \
asm-x86_64/modes/aesni-gcm-x86_64.S \
asm-x86_64/modes/ghash-x86_64.S \
asm-x86_64/sha2/sha256_impl.S \
asm-x86_64/sha2/sha512_impl.S
asm-x86_64/sha2/sha512_impl.S \
asm-x86_64/blake3/blake3_avx2.S \
asm-x86_64/blake3/blake3_avx512.S \
asm-x86_64/blake3/blake3_sse2.S \
asm-x86_64/blake3/blake3_sse41.S
CFLAGS+= -D__amd64 -D_SYS_STACK_H -UHAVE_AES
.elif ${MACHINE_ARCH} == "aarch64"
ASM_SOURCES_C =
ASM_SOURCES_AS = \
asm-aarch64/blake3/b3_aarch64_sse2.S \
asm-aarch64/blake3/b3_aarch64_sse41.S
.elif ${MACHINE_ARCH} == "powerpc64"
ASM_SOURCES_C =
ASM_SOURCES_AS = \
asm-ppc64/blake3/b3_ppc64le_sse2.S \
asm-ppc64/blake3/b3_ppc64le_sse41.S
.else
ASM_SOURCES_C =
ASM_SOURCES_AS =
@ -35,6 +49,10 @@ KERNEL_C = \
algs/aes/aes_impl_x86-64.c \
algs/aes/aes_impl.c \
algs/aes/aes_modes.c \
algs/blake3/blake3.c \
algs/blake3/blake3_generic.c \
algs/blake3/blake3_impl.c \
algs/blake3/blake3_x86-64.c \
algs/edonr/edonr.c \
algs/modes/modes.c \
algs/modes/cbc.c \
@ -88,5 +106,14 @@ CFLAGS.aesni-gcm-x86_64.S+= -DLOCORE
CFLAGS.ghash-x86_64.S+= -DLOCORE
CFLAGS.sha256_impl.S+= -DLOCORE
CFLAGS.sha512_impl.S+= -DLOCORE
CFLAGS.blake3_avx2.S = -DLOCORE
CFLAGS.blake3_avx512.S = -DLOCORE
CFLAGS.blake3_sse2.S = -DLOCORE
CFLAGS.blake3_sse41.S = -DLOCORE
CFLAGS.b3_aarch64_sse2.S = -DLOCORE
CFLAGS.b3_aarch64_sse41.S = -DLOCORE
CFLAGS.b3_ppc64le_sse2.S = -DLOCORE
CFLAGS.b3_ppc64le_sse41.S = -DLOCORE
.include <bsd.lib.mk>

29
cddl/lib/libicp_rescue/Makefile

@ -15,9 +15,23 @@ ASM_SOURCES_AS = \
asm-x86_64/modes/gcm_pclmulqdq.S \
asm-x86_64/modes/aesni-gcm-x86_64.S \
asm-x86_64/sha2/sha256_impl.S \
asm-x86_64/sha2/sha512_impl.S
asm-x86_64/sha2/sha512_impl.S \
asm-x86_64/blake3/blake3_avx2.S \
asm-x86_64/blake3/blake3_avx512.S \
asm-x86_64/blake3/blake3_sse2.S \
asm-x86_64/blake3/blake3_sse41.S
CFLAGS+= -D__amd64 -D_SYS_STACK_H
.elif ${MACHINE_ARCH} == "aarch64"
ASM_SOURCES_C =
ASM_SOURCES_AS = \
asm-aarch64/blake3/b3_aarch64_sse2.S \
asm-aarch64/blake3/b3_aarch64_sse41.S
.elif ${MACHINE_ARCH} == "powerpc64"
ASM_SOURCES_C =
ASM_SOURCES_AS = \
asm-ppc64/blake3/b3_ppc64le_sse2.S \
asm-ppc64/blake3/b3_ppc64le_sse41.S
.else
ASM_SOURCES_C =
ASM_SOURCES_AS =
@ -34,6 +48,10 @@ KERNEL_C = \
algs/aes/aes_impl_x86-64.c \
algs/aes/aes_impl.c \
algs/aes/aes_modes.c \
algs/blake3/blake3.c \
algs/blake3/blake3_generic.c \
algs/blake3/blake3_impl.c \
algs/blake3/blake3_x86-64.c \
algs/edonr/edonr.c \
algs/modes/modes.c \
algs/modes/cbc.c \
@ -81,5 +99,14 @@ CFLAGS.ghash-x86_64.S+= -DLOCORE
CFLAGS.sha256_impl.S+= -DLOCORE
CFLAGS.sha512_impl.S+= -DLOCORE
CFLAGS.gcm.c+= -UCAN_USE_GCM_ASM
CFLAGS.blake3_avx2.S = -DLOCORE
CFLAGS.blake3_avx512.S = -DLOCORE
CFLAGS.blake3_sse2.S = -DLOCORE
CFLAGS.blake3_sse41.S = -DLOCORE
CFLAGS.b3_aarch64_sse2.S = -DLOCORE
CFLAGS.b3_aarch64_sse41.S = -DLOCORE
CFLAGS.b3_ppc64le_sse2.S = -DLOCORE
CFLAGS.b3_ppc64le_sse41.S = -DLOCORE
.include <bsd.lib.mk>

2
cddl/lib/libzpool/Makefile

@ -56,6 +56,7 @@ KERNEL_C = \
aggsum.c \
arc.c \
arc_os.c \
blake3_zfs.c \
blkptr.c \
bplist.c \
bpobj.c \
@ -169,6 +170,7 @@ KERNEL_C = \
zcp_synctask.c \
zfeature.c \
zfs_byteswap.c \
zfs_chksum.c \
zfs_debug.c \
zfs_fm.c \
zfs_fuid.c \

1
sys/contrib/openzfs/AUTHORS

@ -285,6 +285,7 @@ CONTRIBUTORS:
Tim Connors <tconnors@rather.puzzling.org>
Tim Crawford <tcrawford@datto.com>
Tim Haley <Tim.Haley@Sun.COM>
Tino Reichardt <milky-zfs@mcmilk.de>
Tobin Harding <me@tobin.cc>
Tom Caputi <tcaputi@datto.com>
Tom Matthews <tom@axiom-partners.com>

6
sys/contrib/openzfs/cmd/zfs/zfs_iter.c

@ -174,7 +174,7 @@ zfs_add_sort_column(zfs_sort_column_t **sc, const char *name,
zfs_sort_column_t *col;
zfs_prop_t prop;
if ((prop = zfs_name_to_prop(name)) == ZPROP_INVAL &&
if ((prop = zfs_name_to_prop(name)) == ZPROP_USERPROP &&
!zfs_prop_user(name))
return (-1);
@ -182,7 +182,7 @@ zfs_add_sort_column(zfs_sort_column_t **sc, const char *name,
col->sc_prop = prop;
col->sc_reverse = reverse;
if (prop == ZPROP_INVAL) {
if (prop == ZPROP_USERPROP) {
col->sc_user_prop = safe_malloc(strlen(name) + 1);
(void) strcpy(col->sc_user_prop, name);
}
@ -311,7 +311,7 @@ zfs_sort(const void *larg, const void *rarg, void *data)
* Otherwise, we compare 'lnum' and 'rnum'.
*/
lstr = rstr = NULL;
if (psc->sc_prop == ZPROP_INVAL) {
if (psc->sc_prop == ZPROP_USERPROP) {
nvlist_t *luser, *ruser;
nvlist_t *lval, *rval;

68
sys/contrib/openzfs/cmd/zfs/zfs_main.c

@ -127,6 +127,11 @@ static int zfs_do_jail(int argc, char **argv);
static int zfs_do_unjail(int argc, char **argv);
#endif
#ifdef __linux__
static int zfs_do_zone(int argc, char **argv);
static int zfs_do_unzone(int argc, char **argv);
#endif
/*
* Enable a reasonable set of defaults for libumem debugging on DEBUG builds.
*/
@ -184,6 +189,8 @@ typedef enum {
HELP_JAIL,
HELP_UNJAIL,
HELP_WAIT,
HELP_ZONE,
HELP_UNZONE,
} zfs_help_t;
typedef struct zfs_command {
@ -254,6 +261,11 @@ static zfs_command_t command_table[] = {
{ "jail", zfs_do_jail, HELP_JAIL },
{ "unjail", zfs_do_unjail, HELP_UNJAIL },
#endif
#ifdef __linux__
{ "zone", zfs_do_zone, HELP_ZONE },
{ "unzone", zfs_do_unzone, HELP_UNZONE },
#endif
};
#define NCOMMAND (sizeof (command_table) / sizeof (command_table[0]))
@ -415,6 +427,10 @@ get_usage(zfs_help_t idx)
return (gettext("\tunjail <jailid|jailname> <filesystem>\n"));
case HELP_WAIT:
return (gettext("\twait [-t <activity>] <filesystem>\n"));
case HELP_ZONE:
return (gettext("\tzone <nsfile> <filesystem>\n"));
case HELP_UNZONE:
return (gettext("\tunzone <nsfile> <filesystem>\n"));
default:
__builtin_unreachable();
}
@ -1901,7 +1917,7 @@ get_callback(zfs_handle_t *zhp, void *data)
pl == cbp->cb_proplist)
continue;
if (pl->pl_prop != ZPROP_INVAL) {
if (pl->pl_prop != ZPROP_USERPROP) {
if (zfs_prop_get(zhp, pl->pl_prop, buf,
sizeof (buf), &sourcetype, source,
sizeof (source),
@ -2291,7 +2307,7 @@ zfs_do_inherit(int argc, char **argv)
argc--;
argv++;
if ((prop = zfs_name_to_prop(propname)) != ZPROP_INVAL) {
if ((prop = zfs_name_to_prop(propname)) != ZPROP_USERPROP) {
if (zfs_prop_readonly(prop)) {
(void) fprintf(stderr, gettext(
"%s property is read-only\n"),
@ -3427,7 +3443,7 @@ print_header(list_cbdata_t *cb)
}
right_justify = B_FALSE;
if (pl->pl_prop != ZPROP_INVAL) {
if (pl->pl_prop != ZPROP_USERPROP) {
header = zfs_prop_column_name(pl->pl_prop);
right_justify = zfs_prop_align_right(pl->pl_prop);
} else {
@ -3478,7 +3494,7 @@ print_dataset(zfs_handle_t *zhp, list_cbdata_t *cb)
sizeof (property));
propstr = property;
right_justify = zfs_prop_align_right(pl->pl_prop);
} else if (pl->pl_prop != ZPROP_INVAL) {
} else if (pl->pl_prop != ZPROP_USERPROP) {
if (zfs_prop_get(zhp, pl->pl_prop, property,
sizeof (property), NULL, NULL, 0,
cb->cb_literal) != 0)
@ -8692,6 +8708,50 @@ main(int argc, char **argv)
return (ret);
}
/*
* zfs zone nsfile filesystem
*
* Add or delete the given dataset to/from the namespace.
*/
#ifdef __linux__
static int
zfs_do_zone_impl(int argc, char **argv, boolean_t attach)
{
zfs_handle_t *zhp;
int ret;
if (argc < 3) {
(void) fprintf(stderr, gettext("missing argument(s)\n"));
usage(B_FALSE);
}
if (argc > 3) {
(void) fprintf(stderr, gettext("too many arguments\n"));
usage(B_FALSE);
}
zhp = zfs_open(g_zfs, argv[2], ZFS_TYPE_FILESYSTEM);
if (zhp == NULL)
return (1);
ret = (zfs_userns(zhp, argv[1], attach) != 0);
zfs_close(zhp);
return (ret);
}
static int
zfs_do_zone(int argc, char **argv)
{
return (zfs_do_zone_impl(argc, argv, B_TRUE));
}
static int
zfs_do_unzone(int argc, char **argv)
{
return (zfs_do_zone_impl(argc, argv, B_FALSE));
}
#endif
#ifdef __FreeBSD__
#include <sys/jail.h>
#include <jail.h>

4
sys/contrib/openzfs/cmd/zpool/zpool_main.c

@ -5946,7 +5946,7 @@ print_header(list_cbdata_t *cb)
first = B_FALSE;
right_justify = B_FALSE;
if (pl->pl_prop != ZPROP_INVAL) {
if (pl->pl_prop != ZPROP_USERPROP) {
header = zpool_prop_column_name(pl->pl_prop);
right_justify = zpool_prop_align_right(pl->pl_prop);
} else {
@ -6004,7 +6004,7 @@ print_pool(zpool_handle_t *zhp, list_cbdata_t *cb)
}
right_justify = B_FALSE;
if (pl->pl_prop != ZPROP_INVAL) {
if (pl->pl_prop != ZPROP_USERPROP) {
if (zpool_get_prop(zhp, pl->pl_prop, property,
sizeof (property), NULL, cb->cb_literal) != 0)
propstr = "-";

89
sys/contrib/openzfs/cmd/ztest.c

@ -121,6 +121,7 @@
#include <sys/zfeature.h>
#include <sys/dsl_userhold.h>
#include <sys/abd.h>
#include <sys/blake3.h>
#include <stdio.h>
#include <stdlib.h>
#include <unistd.h>
@ -417,6 +418,7 @@ ztest_func_t ztest_device_removal;
ztest_func_t ztest_spa_checkpoint_create_discard;
ztest_func_t ztest_initialize;
ztest_func_t ztest_trim;
ztest_func_t ztest_blake3;
ztest_func_t ztest_fletcher;
ztest_func_t ztest_fletcher_incr;
ztest_func_t ztest_verify_dnode_bt;
@ -470,6 +472,7 @@ ztest_info_t ztest_info[] = {
ZTI_INIT(ztest_spa_checkpoint_create_discard, 1, &zopt_rarely),
ZTI_INIT(ztest_initialize, 1, &zopt_sometimes),
ZTI_INIT(ztest_trim, 1, &zopt_sometimes),
ZTI_INIT(ztest_blake3, 1, &zopt_rarely),
ZTI_INIT(ztest_fletcher, 1, &zopt_rarely),
ZTI_INIT(ztest_fletcher_incr, 1, &zopt_rarely),
ZTI_INIT(ztest_verify_dnode_bt, 1, &zopt_sometimes),
@ -6373,6 +6376,92 @@ ztest_reguid(ztest_ds_t *zd, uint64_t id)
VERIFY3U(load, ==, spa_load_guid(spa));
}
void
ztest_blake3(ztest_ds_t *zd, uint64_t id)
{
(void) zd, (void) id;
hrtime_t end = gethrtime() + NANOSEC;
zio_cksum_salt_t salt;
void *salt_ptr = &salt.zcs_bytes;
struct abd *abd_data, *abd_meta;
void *buf, *templ;
int i, *ptr;
uint32_t size;
BLAKE3_CTX ctx;
size = ztest_random_blocksize();
buf = umem_alloc(size, UMEM_NOFAIL);
abd_data = abd_alloc(size, B_FALSE);
abd_meta = abd_alloc(size, B_TRUE);
for (i = 0, ptr = buf; i < size / sizeof (*ptr); i++, ptr++)
*ptr = ztest_random(UINT_MAX);
memset(salt_ptr, 'A', 32);
abd_copy_from_buf_off(abd_data, buf, 0, size);
abd_copy_from_buf_off(abd_meta, buf, 0, size);
while (gethrtime() <= end) {
int run_count = 100;
zio_cksum_t zc_ref1, zc_ref2;
zio_cksum_t zc_res1, zc_res2;
void *ref1 = &zc_ref1;
void *ref2 = &zc_ref2;
void *res1 = &zc_res1;
void *res2 = &zc_res2;
/* BLAKE3_KEY_LEN = 32 */
VERIFY0(blake3_set_impl_name("generic"));
templ = abd_checksum_blake3_tmpl_init(&salt);
Blake3_InitKeyed(&ctx, salt_ptr);
Blake3_Update(&ctx, buf, size);
Blake3_Final(&ctx, ref1);
zc_ref2 = zc_ref1;
ZIO_CHECKSUM_BSWAP(&zc_ref2);
abd_checksum_blake3_tmpl_free(templ);
VERIFY0(blake3_set_impl_name("cycle"));
while (run_count-- > 0) {
/* Test current implementation */
Blake3_InitKeyed(&ctx, salt_ptr);
Blake3_Update(&ctx, buf, size);
Blake3_Final(&ctx, res1);
zc_res2 = zc_res1;
ZIO_CHECKSUM_BSWAP(&zc_res2);
VERIFY0(memcmp(ref1, res1, 32));
VERIFY0(memcmp(ref2, res2, 32));
/* Test ABD - data */
templ = abd_checksum_blake3_tmpl_init(&salt);
abd_checksum_blake3_native(abd_data, size,
templ, &zc_res1);
abd_checksum_blake3_byteswap(abd_data, size,
templ, &zc_res2);
VERIFY0(memcmp(ref1, res1, 32));
VERIFY0(memcmp(ref2, res2, 32));
/* Test ABD - metadata */
abd_checksum_blake3_native(abd_meta, size,
templ, &zc_res1);
abd_checksum_blake3_byteswap(abd_meta, size,
templ, &zc_res2);
abd_checksum_blake3_tmpl_free(templ);
VERIFY0(memcmp(ref1, res1, 32));
VERIFY0(memcmp(ref2, res2, 32));
}
}
abd_free(abd_data);
abd_free(abd_meta);
umem_free(buf, size);
}
void
ztest_fletcher(ztest_ds_t *zd, uint64_t id)
{

2
sys/contrib/openzfs/config/always-arch.m4

@ -30,6 +30,8 @@ AC_DEFUN([ZFS_AC_CONFIG_ALWAYS_ARCH], [
;;
esac
AM_CONDITIONAL([TARGET_CPU_AARCH64], test $TARGET_CPU = aarch64)
AM_CONDITIONAL([TARGET_CPU_X86_64], test $TARGET_CPU = x86_64)
AM_CONDITIONAL([TARGET_CPU_POWERPC], test $TARGET_CPU = powerpc)
AM_CONDITIONAL([TARGET_CPU_SPARC64], test $TARGET_CPU = sparc64)
])

3
sys/contrib/openzfs/config/kernel-add-disk.m4

@ -7,8 +7,7 @@ AC_DEFUN([ZFS_AC_KERNEL_SRC_ADD_DISK], [
#include <linux/blkdev.h>
], [
struct gendisk *disk = NULL;
int err = add_disk(disk);
err = err;
int error __attribute__ ((unused)) = add_disk(disk);
])
])

32
sys/contrib/openzfs/config/kernel-blk-queue.m4

@ -359,6 +359,36 @@ AC_DEFUN([ZFS_AC_KERNEL_BLK_QUEUE_MAX_SEGMENTS], [
])
])
dnl #
dnl # See if kernel supports block multi-queue and blk_status_t.
dnl # blk_status_t represents the new status codes introduced in the 4.13
dnl # kernel patch:
dnl #
dnl # block: introduce new block status code type
dnl #
dnl # We do not currently support the "old" block multi-queue interfaces from
dnl # prior kernels.
dnl #
AC_DEFUN([ZFS_AC_KERNEL_SRC_BLK_MQ], [
ZFS_LINUX_TEST_SRC([blk_mq], [
#include <linux/blk-mq.h>
], [
struct blk_mq_tag_set tag_set __attribute__ ((unused)) = {0};
(void) blk_mq_alloc_tag_set(&tag_set);
return BLK_STS_OK;
], [])
])
AC_DEFUN([ZFS_AC_KERNEL_BLK_MQ], [
AC_MSG_CHECKING([whether block multiqueue with blk_status_t is available])
ZFS_LINUX_TEST_RESULT([blk_mq], [
AC_MSG_RESULT(yes)
AC_DEFINE(HAVE_BLK_MQ, 1, [block multiqueue is available])
], [
AC_MSG_RESULT(no)
])
])
AC_DEFUN([ZFS_AC_KERNEL_SRC_BLK_QUEUE], [
ZFS_AC_KERNEL_SRC_BLK_QUEUE_PLUG
ZFS_AC_KERNEL_SRC_BLK_QUEUE_BDI
@ -370,6 +400,7 @@ AC_DEFUN([ZFS_AC_KERNEL_SRC_BLK_QUEUE], [
ZFS_AC_KERNEL_SRC_BLK_QUEUE_FLUSH
ZFS_AC_KERNEL_SRC_BLK_QUEUE_MAX_HW_SECTORS
ZFS_AC_KERNEL_SRC_BLK_QUEUE_MAX_SEGMENTS
ZFS_AC_KERNEL_SRC_BLK_MQ
])
AC_DEFUN([ZFS_AC_KERNEL_BLK_QUEUE], [
@ -383,4 +414,5 @@ AC_DEFUN([ZFS_AC_KERNEL_BLK_QUEUE], [
ZFS_AC_KERNEL_BLK_QUEUE_FLUSH
ZFS_AC_KERNEL_BLK_QUEUE_MAX_HW_SECTORS
ZFS_AC_KERNEL_BLK_QUEUE_MAX_SEGMENTS
ZFS_AC_KERNEL_BLK_MQ
])

23
sys/contrib/openzfs/config/kernel-user-ns-inum.m4

@ -0,0 +1,23 @@
dnl #
dnl # 3.18 API change
dnl # struct user_namespace inum moved from .proc_inum to .ns.inum.
dnl #
AC_DEFUN([ZFS_AC_KERNEL_SRC_USER_NS_COMMON_INUM], [
ZFS_LINUX_TEST_SRC([user_ns_common_inum], [
#include <linux/user_namespace.h>
], [
struct user_namespace uns;
uns.ns.inum = 0;
])
])
AC_DEFUN([ZFS_AC_KERNEL_USER_NS_COMMON_INUM], [
AC_MSG_CHECKING([whether user_namespace->ns.inum exists])
ZFS_LINUX_TEST_RESULT([user_ns_common_inum], [
AC_MSG_RESULT(yes)
AC_DEFINE(HAVE_USER_NS_COMMON_INUM, 1,
[user_namespace->ns.inum exists])
],[
AC_MSG_RESULT(no)
])
])

2
sys/contrib/openzfs/config/kernel.m4

@ -145,6 +145,7 @@ AC_DEFUN([ZFS_AC_KERNEL_TEST_SRC], [
ZFS_AC_KERNEL_SRC_KTHREAD
ZFS_AC_KERNEL_SRC_ZERO_PAGE
ZFS_AC_KERNEL_SRC___COPY_FROM_USER_INATOMIC
ZFS_AC_KERNEL_SRC_USER_NS_COMMON_INUM
AC_MSG_CHECKING([for available kernel interfaces])
ZFS_LINUX_TEST_COMPILE_ALL([kabi])
@ -263,6 +264,7 @@ AC_DEFUN([ZFS_AC_KERNEL_TEST_RESULT], [
ZFS_AC_KERNEL_KTHREAD
ZFS_AC_KERNEL_ZERO_PAGE
ZFS_AC_KERNEL___COPY_FROM_USER_INATOMIC
ZFS_AC_KERNEL_USER_NS_COMMON_INUM
])
dnl #

3
sys/contrib/openzfs/contrib/dracut/90zfs/module-setup.sh.in

@ -83,8 +83,7 @@ install() {
for _service in \
"zfs-import-scan.service" \
"zfs-import-cache.service" \
"zfs-load-module.service"; do
"zfs-import-cache.service"; do
inst_simple "${systemdsystemunitdir}/${_service}"
systemctl -q --root "${initdir}" add-wants zfs-import.target "${_service}"
done

1
sys/contrib/openzfs/contrib/pyzfs/libzfs_core/_constants.py

@ -100,6 +100,7 @@ zfs_errno = enum_with_offset(1024, [
'ZFS_ERR_REBUILD_IN_PROGRESS',
'ZFS_ERR_BADPROP',
'ZFS_ERR_VDEV_NOTSUP',
'ZFS_ERR_NOT_USER_NAMESPACE',
],
{}
)

3
sys/contrib/openzfs/etc/Makefile.am

@ -59,6 +59,9 @@ systemdunit_DATA = \
%D%/systemd/system/zfs-scrub-monthly@.timer \
%D%/systemd/system/zfs-scrub-weekly@.timer \
%D%/systemd/system/zfs-scrub@.service \
%D%/systemd/system/zfs-trim-monthly@.timer \
%D%/systemd/system/zfs-trim-weekly@.timer \
%D%/systemd/system/zfs-trim@.service \
%D%/systemd/system/zfs-share.service \
%D%/systemd/system/zfs-volume-wait.service \
%D%/systemd/system/zfs-volumes.target \

12
sys/contrib/openzfs/etc/systemd/system/zfs-trim-monthly@.timer.in

@ -0,0 +1,12 @@
[Unit]
Description=Monthly zpool trim timer for %i
Documentation=man:zpool-trim(8)
[Timer]
OnCalendar=monthly
Persistent=true
RandomizedDelaySec=1h
Unit=zfs-trim@%i.service
[Install]
WantedBy=timers.target

12
sys/contrib/openzfs/etc/systemd/system/zfs-trim-weekly@.timer.in

@ -0,0 +1,12 @@
[Unit]
Description=Weekly zpool trim timer for %i
Documentation=man:zpool-trim(8)
[Timer]
OnCalendar=weekly
Persistent=true
RandomizedDelaySec=1h
Unit=zfs-trim@%i.service
[Install]
WantedBy=timers.target

15
sys/contrib/openzfs/etc/systemd/system/zfs-trim@.service.in

@ -0,0 +1,15 @@
[Unit]
Description=zpool trim on %i
Documentation=man:zpool-trim(8)
Requires=zfs.target
After=zfs.target
ConditionACPower=true
ConditionPathIsDirectory=/sys/module/zfs
[Service]
EnvironmentFile=-@initconfdir@/zfs
ExecStart=/bin/sh -c '\
if @sbindir@/zpool status %i | grep -q "(trimming)"; then\
exec @sbindir@/zpool wait -t trim %i;\
else exec @sbindir@/zpool trim -w %i; fi'
ExecStop=-/bin/sh -c '@sbindir@/zpool trim -s %i 2>/dev/null || true'

2
sys/contrib/openzfs/include/Makefile.am

@ -23,6 +23,7 @@ COMMON_H = \
sys/avl.h \
sys/avl_impl.h \
sys/bitops.h \
sys/blake3.h \
sys/blkptr.h \
sys/bplist.h \
sys/bpobj.h \
@ -117,6 +118,7 @@ COMMON_H = \
sys/zfeature.h \
sys/zfs_acl.h \
sys/zfs_bootenv.h \
sys/zfs_chksum.h \
sys/zfs_context.h \
sys/zfs_debug.h \
sys/zfs_delay.h \

10
sys/contrib/openzfs/include/libzfs.h

@ -150,6 +150,7 @@ typedef enum zfs_error {
EZFS_EXPORT_IN_PROGRESS, /* currently exporting the pool */
EZFS_REBUILDING, /* resilvering (sequential reconstrution) */
EZFS_VDEV_NOTSUP, /* ops not supported for this type of vdev */
EZFS_NOT_USER_NAMESPACE, /* a file is not a user namespace */
EZFS_UNKNOWN
} zfs_error_t;
@ -979,6 +980,15 @@ _LIBZFS_H int zpool_nextboot(libzfs_handle_t *, uint64_t, uint64_t,
#endif /* __FreeBSD__ */
#ifdef __linux__
/*
* Add or delete the given filesystem to/from the given user namespace.
*/
_LIBZFS_H int zfs_userns(zfs_handle_t *zhp, const char *nspath, int attach);
#endif
#ifdef __cplusplus
}
#endif

2
sys/contrib/openzfs/include/os/freebsd/spl/sys/ccompile.h

@ -74,10 +74,12 @@ extern "C" {
#ifndef LOCORE
#ifndef HAVE_RPC_TYPES
#ifndef _KERNEL
typedef int bool_t;
typedef int enum_t;
#endif
#endif
#endif
#ifndef __cplusplus
#define __init

111
sys/contrib/openzfs/include/os/linux/kernel/linux/blkdev_compat.h

@ -34,6 +34,11 @@
#include <linux/hdreg.h>
#include <linux/major.h>
#include <linux/msdos_fs.h> /* for SECTOR_* */
#include <linux/bio.h>
#ifdef HAVE_BLK_MQ
#include <linux/blk-mq.h>
#endif
#ifndef HAVE_BLK_QUEUE_FLAG_SET
static inline void
@ -608,4 +613,110 @@ blk_generic_alloc_queue(make_request_fn make_request, int node_id)
}
#endif /* !HAVE_SUBMIT_BIO_IN_BLOCK_DEVICE_OPERATIONS */
/*
* All the io_*() helper functions below can operate on a bio, or a rq, but
* not both. The older submit_bio() codepath will pass a bio, and the
* newer blk-mq codepath will pass a rq.
*/
static inline int
io_data_dir(struct bio *bio, struct request *rq)
{
#ifdef HAVE_BLK_MQ
if (rq != NULL) {
if (op_is_write(req_op(rq))) {
return (WRITE);
} else {
return (READ);
}
}
#else
ASSERT3P(rq, ==, NULL);
#endif
return (bio_data_dir(bio));
}
static inline int
io_is_flush(struct bio *bio, struct request *rq)
{
#ifdef HAVE_BLK_MQ
if (rq != NULL)
return (req_op(rq) == REQ_OP_FLUSH);
#else
ASSERT3P(rq, ==, NULL);
#endif
return (bio_is_flush(bio));
}
static inline int
io_is_discard(struct bio *bio, struct request *rq)
{
#ifdef HAVE_BLK_MQ
if (rq != NULL)
return (req_op(rq) == REQ_OP_DISCARD);
#else
ASSERT3P(rq, ==, NULL);
#endif
return (bio_is_discard(bio));
}
static inline int
io_is_secure_erase(struct bio *bio, struct request *rq)
{
#ifdef HAVE_BLK_MQ
if (rq != NULL)
return (req_op(rq) == REQ_OP_SECURE_ERASE);
#else
ASSERT3P(rq, ==, NULL);
#endif
return (bio_is_secure_erase(bio));
}
static inline int
io_is_fua(struct bio *bio, struct request *rq)
{
#ifdef HAVE_BLK_MQ
if (rq != NULL)
return (rq->cmd_flags & REQ_FUA);
#else
ASSERT3P(rq, ==, NULL);
#endif
return (bio_is_fua(bio));
}
static inline uint64_t
io_offset(struct bio *bio, struct request *rq)
{
#ifdef HAVE_BLK_MQ
if (rq != NULL)
return (blk_rq_pos(rq) << 9);
#else
ASSERT3P(rq, ==, NULL);
#endif
return (BIO_BI_SECTOR(bio) << 9);
}
static inline uint64_t
io_size(struct bio *bio, struct request *rq)
{
#ifdef HAVE_BLK_MQ
if (rq != NULL)
return (blk_rq_bytes(rq));
#else
ASSERT3P(rq, ==, NULL);
#endif
return (BIO_BI_SIZE(bio));
}
static inline int
io_has_data(struct bio *bio, struct request *rq)
{
#ifdef HAVE_BLK_MQ
if (rq != NULL)
return (bio_has_data(rq->bio));
#else
ASSERT3P(rq, ==, NULL);
#endif
return (bio_has_data(bio));
}
#endif /* _ZFS_BLKDEV_H */

34
sys/contrib/openzfs/include/os/linux/kernel/linux/simd_powerpc.h

@ -57,25 +57,45 @@
#include <sys/types.h>
#include <linux/version.h>
#define kfpu_allowed() 1
#define kfpu_begin() \
{ \
preempt_disable(); \
enable_kernel_altivec(); \
}
#define kfpu_allowed() 1
#if LINUX_VERSION_CODE >= KERNEL_VERSION(4, 5, 0)
#define kfpu_end() \
{ \
disable_kernel_vsx(); \
disable_kernel_altivec(); \
preempt_enable(); \
}
#define kfpu_begin() \
{ \
preempt_disable(); \
enable_kernel_altivec(); \
enable_kernel_vsx(); \
}
#else
/* seems that before 4.5 no-one bothered disabling ... */
/* seems that before 4.5 no-one bothered */
#define kfpu_begin()
#define kfpu_end() preempt_enable()
#endif
#define kfpu_init() 0
#define kfpu_fini() ((void) 0)
static inline boolean_t
zfs_vsx_available(void)
{
boolean_t res;
#if defined(__powerpc64__)
u64 msr;
#else
u32 msr;
#endif
kfpu_begin();
__asm volatile("mfmsr %0" : "=r"(msr));
res = (msr & 0x800000) != 0;
kfpu_end();
return (res);
}
/*
* Check if AltiVec instruction set is available
*/

16
sys/contrib/openzfs/include/os/linux/kernel/linux/vfs_compat.h

@ -296,11 +296,7 @@ static inline struct dentry *file_dentry(const struct file *f)
static inline uid_t zfs_uid_read_impl(struct inode *ip)
{
#ifdef HAVE_SUPER_USER_NS
return (from_kuid(ip->i_sb->s_user_ns, ip->i_uid));
#else
return (from_kuid(kcred->user_ns, ip->i_uid));
#endif
}
static inline uid_t zfs_uid_read(struct inode *ip)
@ -310,11 +306,7 @@ static inline uid_t zfs_uid_read(struct inode *ip)
static inline gid_t zfs_gid_read_impl(struct inode *ip)
{
#ifdef HAVE_SUPER_USER_NS
return (from_kgid(ip->i_sb->s_user_ns, ip->i_gid));
#else
return (from_kgid(kcred->user_ns, ip->i_gid));
#endif
}
static inline gid_t zfs_gid_read(struct inode *ip)
@ -324,20 +316,12 @@ static inline gid_t zfs_gid_read(struct inode *ip)
static inline void zfs_uid_write(struct inode *ip, uid_t uid)
{
#ifdef HAVE_SUPER_USER_NS
ip->i_uid = make_kuid(ip->i_sb->s_user_ns, uid);
#else
ip->i_uid = make_kuid(kcred->user_ns, uid);
#endif
}
static inline void zfs_gid_write(struct inode *ip, gid_t gid)
{
#ifdef HAVE_SUPER_USER_NS
ip->i_gid = make_kgid(ip->i_sb->s_user_ns, gid);
#else
ip->i_gid = make_kgid(kcred->user_ns, gid);
#endif
}
/*

39
sys/contrib/openzfs/include/os/linux/spl/sys/uio.h

@ -69,9 +69,20 @@ typedef struct zfs_uio {
uint16_t uio_fmode;
uint16_t uio_extflg;
ssize_t uio_resid;
size_t uio_skip;
struct request *rq;
/*
* Used for saving rq_for_each_segment() state between calls
* to zfs_uiomove_bvec_rq().
*/
struct req_iterator iter;
struct bio_vec bv;
} zfs_uio_t;
#define zfs_uio_segflg(u) (u)->uio_segflg
#define zfs_uio_offset(u) (u)->uio_loffset
#define zfs_uio_resid(u) (u)->uio_resid
@ -116,17 +127,33 @@ zfs_uio_iovec_init(zfs_uio_t *uio, const struct iovec *iov,
}
static inline void
zfs_uio_bvec_init(zfs_uio_t *uio, struct bio *bio)
zfs_uio_bvec_init(zfs_uio_t *uio, struct bio *bio, struct request *rq)
{
uio->uio_bvec = &bio->bi_io_vec[BIO_BI_IDX(bio)];
uio->uio_iovcnt = bio->bi_vcnt - BIO_BI_IDX(bio);
uio->uio_loffset = BIO_BI_SECTOR(bio) << 9;
/* Either bio or rq will be set, but not both */
ASSERT3P(uio, !=, bio);
if (bio) {
uio->uio_iovcnt = bio->bi_vcnt - BIO_BI_IDX(bio);
uio->uio_bvec = &bio->bi_io_vec[BIO_BI_IDX(bio)];
} else {
uio->uio_bvec = NULL;
uio->uio_iovcnt = 0;
memset(&uio->iter, 0, sizeof (uio->iter));
}
uio->uio_loffset = io_offset(bio, rq);
uio->uio_segflg = UIO_BVEC;
uio->uio_fault_disable = B_FALSE;
uio->uio_fmode = 0;
uio->uio_extflg = 0;
uio->uio_resid = BIO_BI_SIZE(bio);
uio->uio_skip = BIO_BI_SKIP(bio);
uio->uio_resid = io_size(bio, rq);
if (bio) {
uio->uio_skip = BIO_BI_SKIP(bio);
} else {
uio->uio_skip = 0;
}
uio->rq = rq;
}
#if defined(HAVE_VFS_IOV_ITER)

31
sys/contrib/openzfs/include/os/linux/spl/sys/zone.h

@ -25,11 +25,34 @@
#define _SPL_ZONE_H
#include <sys/byteorder.h>
#include <sys/cred.h>
#define GLOBAL_ZONEID 0
#include <linux/cred.h>
#include <linux/user_namespace.h>
#define zone_dataset_visible(x, y) (1)
#define crgetzoneid(x) (GLOBAL_ZONEID)
#define INGLOBALZONE(z) (1)
/*
* Attach the given dataset to the given user namespace.
*/
extern int zone_dataset_attach(cred_t *, const char *, int);
/*
* Detach the given dataset from the given user namespace.
*/
extern int zone_dataset_detach(cred_t *, const char *, int);
/*
* Returns true if the named pool/dataset is visible in the current zone.
*/
extern int zone_dataset_visible(const char *dataset, int *write);
int spl_zone_init(void);
void spl_zone_fini(void);
extern unsigned int crgetzoneid(const cred_t *);
extern unsigned int global_zoneid(void);
extern boolean_t inglobalzone(proc_t *);
#define INGLOBALZONE(x) inglobalzone(x)
#define GLOBAL_ZONEID global_zoneid()
#endif /* SPL_ZONE_H */

5
sys/contrib/openzfs/include/os/linux/zfs/sys/zfs_context_os.h

@ -32,4 +32,9 @@
#define HAVE_LARGE_STACKS 1
#endif
#if defined(CONFIG_UML)
#undef setjmp
#undef longjmp
#endif
#endif

125
sys/contrib/openzfs/include/sys/blake3.h

@ -0,0 +1,125 @@
/*
* 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
*/
/*
* Based on BLAKE3 v1.3.1, https://github.com/BLAKE3-team/BLAKE3
* Copyright (c) 2019-2020 Samuel Neves and Jack O'Connor
* Copyright (c) 2021 Tino Reichardt <milky-zfs@mcmilk.de>
*/
#ifndef BLAKE3_H
#define BLAKE3_H
#ifdef _KERNEL
#include <sys/types.h>
#else
#include <stdint.h>
#include <stdlib.h>
#endif
#ifdef __cplusplus
extern "C" {
#endif
#define BLAKE3_KEY_LEN 32
#define BLAKE3_OUT_LEN 32
#define BLAKE3_MAX_DEPTH 54
#define BLAKE3_BLOCK_LEN 64
#define BLAKE3_CHUNK_LEN 1024
/*
* This struct is a private implementation detail.
* It has to be here because it's part of BLAKE3_CTX below.
*/
typedef struct {
uint32_t cv[8];
uint64_t chunk_counter;
uint8_t buf[BLAKE3_BLOCK_LEN];
uint8_t buf_len;
uint8_t blocks_compressed;
uint8_t flags;
} blake3_chunk_state_t;
typedef struct {
uint32_t key[8];
blake3_chunk_state_t chunk;
uint8_t cv_stack_len;
/*
* The stack size is MAX_DEPTH + 1 because we do lazy merging. For
* example, with 7 chunks, we have 3 entries in the stack. Adding an
* 8th chunk requires a 4th entry, rather than merging everything down
* to 1, because we don't know whether more input is coming. This is
* different from how the reference implementation does things.
*/
uint8_t cv_stack[(BLAKE3_MAX_DEPTH + 1) * BLAKE3_OUT_LEN];
/* const blake3_impl_ops_t *ops */
const void *ops;
} BLAKE3_CTX;
/* init the context for hash operation */
void Blake3_Init(BLAKE3_CTX *ctx);
/* init the context for a MAC and/or tree hash operation */
void Blake3_InitKeyed(BLAKE3_CTX *ctx, const uint8_t key[BLAKE3_KEY_LEN]);
/* process the input bytes */
void Blake3_Update(BLAKE3_CTX *ctx, const void *input, size_t input_len);
/* finalize the hash computation and output the result */
void Blake3_Final(const BLAKE3_CTX *ctx, uint8_t *out);
/* finalize the hash computation and output the result */
void Blake3_FinalSeek(const BLAKE3_CTX *ctx, uint64_t seek, uint8_t *out,
size_t out_len);
/* these are pre-allocated contexts */
extern void **blake3_per_cpu_ctx;
extern void blake3_per_cpu_ctx_init(void);
extern void blake3_per_cpu_ctx_fini(void);
/* return number of supported implementations */
extern int blake3_get_impl_count(void);
/* return id of selected implementation */
extern int blake3_get_impl_id(void);
/* return name of selected implementation */
extern const char *blake3_get_impl_name(void);
/* setup id as fastest implementation */
extern void blake3_set_impl_fastest(uint32_t id);
/* set implementation by id */
extern void blake3_set_impl_id(uint32_t id);
/* set implementation by name */
extern int blake3_set_impl_name(const char *name);
/* set startup implementation */
extern void blake3_setup_impl(void);
#ifdef __cplusplus
}
#endif
#endif /* BLAKE3_H */

6
sys/contrib/openzfs/include/sys/fs/zfs.h

@ -93,6 +93,7 @@ typedef enum dmu_objset_type {
typedef enum {
ZPROP_CONT = -2,
ZPROP_INVAL = -1,
ZPROP_USERPROP = ZPROP_INVAL,
ZFS_PROP_TYPE = 0,
ZFS_PROP_CREATION,
ZFS_PROP_USED,
@ -310,7 +311,7 @@ typedef int (*zprop_func)(int, void *);
*/
typedef enum {
VDEV_PROP_INVAL = -1,
#define VDEV_PROP_USER VDEV_PROP_INVAL
VDEV_PROP_USERPROP = VDEV_PROP_INVAL,
VDEV_PROP_NAME,
VDEV_PROP_CAPACITY,
VDEV_PROP_STATE,
@ -1450,7 +1451,9 @@ typedef enum zfs_ioc {
ZFS_IOC_EVENTS_SEEK, /* 0x83 (Linux) */
ZFS_IOC_NEXTBOOT, /* 0x84 (FreeBSD) */
ZFS_IOC_JAIL, /* 0x85 (FreeBSD) */
ZFS_IOC_USERNS_ATTACH = ZFS_IOC_JAIL, /* 0x85 (Linux) */
ZFS_IOC_UNJAIL, /* 0x86 (FreeBSD) */
ZFS_IOC_USERNS_DETACH = ZFS_IOC_UNJAIL, /* 0x86 (Linux) */
ZFS_IOC_SET_BOOTENV, /* 0x87 */
ZFS_IOC_GET_BOOTENV, /* 0x88 */
ZFS_IOC_LAST
@ -1531,6 +1534,7 @@ typedef enum {
ZFS_ERR_REBUILD_IN_PROGRESS,
ZFS_ERR_BADPROP,
ZFS_ERR_VDEV_NOTSUP,
ZFS_ERR_NOT_USER_NAMESPACE,
} zfs_errno_t;
/*

48
sys/contrib/openzfs/include/sys/zfs_chksum.h

@ -0,0 +1,48 @@
/*
* 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) 2021 Tino Reichardt <milky-zfs@mcmilk.de>
*/
#ifndef _ZFS_CHKSUM_H
#define _ZFS_CHKSUM_H
#ifdef _KERNEL
#include <sys/types.h>
#else
#include <stdint.h>
#include <stdlib.h>
#endif
#ifdef __cplusplus
extern "C" {
#endif
/* Benchmark the chksums of ZFS when the module is loading */
void chksum_init(void);
void chksum_fini(void);
#ifdef __cplusplus
}