Notable upstream pull request merges:
  #13725 Fix BLAKE3 tuneable and module loading on Linux and FreeBSD
  #13756 FreeBSD: Organize sysctls
  #13773 FreeBSD: add kqfilter support for zvol cdev
  #13781 Importing from cachefile can trip assertion
  #13794 Apply arc_shrink_shift to ARC above arc_c_min
  #13798 Improve too large physical ashift handling
  #13799 Revert "Avoid panic with recordsize > 128k, raw sending and
         no large_blocks"
  #13802 Add zfs.sync.snapshot_rename
  #13831 zfs_enter rework
  #13855 zfs recv hangs if max recordsize is less than received
         recordsize

Obtained from:	OpenZFS
OpenZFS commit:	c629f0bf62
This commit is contained in:
Martin Matuska 2022-09-21 14:17:13 +02:00
commit c7046f76c2
177 changed files with 3906 additions and 2018 deletions

View File

@ -10,7 +10,6 @@ SRCS=\
uu_ident.c \
uu_list.c \
uu_misc.c \
uu_pname.c \
uu_string.c
WARNS?= 2

View File

@ -119,7 +119,6 @@ KERNEL_C = \
sha256.c \
skein_zfs.c \
spa.c \
spa_boot.c \
spa_checkpoint.c \
spa_config.c \
spa_errlog.c \

View File

@ -8,6 +8,13 @@
* Hack for aarch64... There's no way to tell it omit the SIMD
* versions, so we fake it here.
*/
#ifndef isspace
static __inline int isspace(int c)
{
return c == ' ' || (c >= 0x9 && c <= 0xd);
}
#endif
#include "blake3_impl.c"
static inline boolean_t blake3_is_not_supported(void)
@ -15,13 +22,13 @@ static inline boolean_t blake3_is_not_supported(void)
return (B_FALSE);
}
const blake3_impl_ops_t blake3_sse2_impl = {
const blake3_ops_t blake3_sse2_impl = {
.is_supported = blake3_is_not_supported,
.degree = 4,
.name = "fakesse2"
};
const blake3_impl_ops_t blake3_sse41_impl = {
const blake3_ops_t blake3_sse41_impl = {
.is_supported = blake3_is_not_supported,
.degree = 4,
.name = "fakesse41"

View File

@ -200,6 +200,7 @@ contrib/openzfs/module/os/freebsd/zfs/abd_os.c optional zfs compile-with "${ZFS
contrib/openzfs/module/os/freebsd/zfs/arc_os.c optional zfs compile-with "${ZFS_C}"
contrib/openzfs/module/os/freebsd/zfs/crypto_os.c optional zfs compile-with "${ZFS_C}"
contrib/openzfs/module/os/freebsd/zfs/dmu_os.c optional zfs compile-with "${ZFS_C}"
contrib/openzfs/module/os/freebsd/zfs/event_os.c optional zfs compile-with "${ZFS_C}"
contrib/openzfs/module/os/freebsd/zfs/hkdf.c optional zfs compile-with "${ZFS_C}"
contrib/openzfs/module/os/freebsd/zfs/kmod_core.c optional zfs compile-with "${ZFS_C}"
contrib/openzfs/module/os/freebsd/zfs/spa_os.c optional zfs compile-with "${ZFS_C}"
@ -306,7 +307,6 @@ contrib/openzfs/module/zfs/sa.c optional zfs compile-with "${ZFS_C}"
contrib/openzfs/module/zfs/sha256.c optional zfs compile-with "${ZFS_C}"
contrib/openzfs/module/zfs/skein_zfs.c optional zfs compile-with "${ZFS_C}"
contrib/openzfs/module/zfs/spa.c optional zfs compile-with "${ZFS_C}"
contrib/openzfs/module/zfs/spa_boot.c optional zfs compile-with "${ZFS_C}"
contrib/openzfs/module/zfs/spa_checkpoint.c optional zfs compile-with "${ZFS_C}"
contrib/openzfs/module/zfs/spa_config.c optional zfs compile-with "${ZFS_C}"
contrib/openzfs/module/zfs/spa_errlog.c optional zfs compile-with "${ZFS_C}"

View File

@ -28,7 +28,7 @@ jobs:
./autogen.sh
- name: Configure
run: |
./configure --enable-debug --enable-debuginfo --enable-asan --enable-ubsan --with-config=dist
./configure --enable-debug --enable-debuginfo --enable-asan --enable-ubsan
- name: Make
run: |
make -j$(nproc) --no-print-directory --silent pkg-utils pkg-kmod

View File

@ -24,7 +24,7 @@ jobs:
./autogen.sh
- name: Configure
run: |
./configure --enable-debug --enable-debuginfo --enable-asan --enable-ubsan --with-config=dist
./configure --enable-debug --enable-debuginfo --enable-asan --enable-ubsan
- name: Make
run: |
make -j$(nproc) --no-print-directory --silent pkg-utils pkg-kmod

View File

@ -23,7 +23,7 @@ jobs:
./autogen.sh
- name: Configure
run: |
./configure --enable-debug --enable-debuginfo --enable-asan --enable-ubsan --with-config=dist
./configure --enable-debug --enable-debuginfo --enable-asan --enable-ubsan
- name: Make
run: |
make -j$(nproc) --no-print-directory --silent pkg-utils pkg-kmod

View File

@ -100,12 +100,13 @@ endif
if USING_PYTHON
bin_SCRIPTS += arc_summary arcstat dbufstat
CLEANFILES += arc_summary arcstat dbufstat
dist_noinst_DATA += %D%/arc_summary %D%/arcstat.in %D%/dbufstat.in
bin_SCRIPTS += arc_summary arcstat dbufstat zilstat
CLEANFILES += arc_summary arcstat dbufstat zilstat
dist_noinst_DATA += %D%/arc_summary %D%/arcstat.in %D%/dbufstat.in %D%/zilstat.in
$(call SUBST,arcstat,%D%/)
$(call SUBST,dbufstat,%D%/)
$(call SUBST,zilstat,%D%/)
arc_summary: %D%/arc_summary
$(AM_V_at)cp $< $@
endif

View File

@ -121,7 +121,7 @@ extern int zfs_vdev_async_read_max_active;
extern boolean_t spa_load_verify_dryrun;
extern boolean_t spa_mode_readable_spacemaps;
extern int zfs_reconstruct_indirect_combinations_max;
extern int zfs_btree_verify_intensity;
extern uint_t zfs_btree_verify_intensity;
static const char cmdname[] = "zdb";
uint8_t dump_opt[256];
@ -4737,6 +4737,8 @@ zdb_copy_object(objset_t *os, uint64_t srcobj, char *destfile)
}
int fd = open(destfile, O_WRONLY | O_CREAT | O_TRUNC, 0644);
if (fd == -1)
return (errno);
/*
* We cap the size at 1 mebibyte here to prevent
* allocation failures and nigh-infinite printing if the
@ -4746,6 +4748,7 @@ zdb_copy_object(objset_t *os, uint64_t srcobj, char *destfile)
offset = 0;
char *buf = kmem_alloc(oursize, KM_NOSLEEP);
if (buf == NULL) {
(void) close(fd);
return (ENOMEM);
}
@ -4755,6 +4758,7 @@ zdb_copy_object(objset_t *os, uint64_t srcobj, char *destfile)
if (err != 0) {
(void) printf("got error %u from dmu_read\n", err);
kmem_free(buf, oursize);
(void) close(fd);
return (err);
}
if (dump_opt['v'] > 3) {
@ -6415,7 +6419,7 @@ deleted_livelists_dump_mos(spa_t *spa)
static int
dump_block_stats(spa_t *spa)
{
zdb_cb_t zcb = {{{{0}}}};
zdb_cb_t *zcb;
zdb_blkstats_t *zb, *tzb;
uint64_t norm_alloc, norm_space, total_alloc, total_found;
int flags = TRAVERSE_PRE | TRAVERSE_PREFETCH_METADATA |
@ -6424,6 +6428,8 @@ dump_block_stats(spa_t *spa)
int e, c, err;
bp_embedded_type_t i;
zcb = umem_zalloc(sizeof (zdb_cb_t), UMEM_NOFAIL);
(void) printf("\nTraversing all blocks %s%s%s%s%s...\n\n",
(dump_opt['c'] || !dump_opt['L']) ? "to verify " : "",
(dump_opt['c'] == 1) ? "metadata " : "",
@ -6443,39 +6449,39 @@ dump_block_stats(spa_t *spa)
* pool claiming each block we discover, but we skip opening any space
* maps.
*/
zdb_leak_init(spa, &zcb);
zdb_leak_init(spa, zcb);
/*
* If there's a deferred-free bplist, process that first.
*/
(void) bpobj_iterate_nofree(&spa->spa_deferred_bpobj,
bpobj_count_block_cb, &zcb, NULL);
bpobj_count_block_cb, zcb, NULL);
if (spa_version(spa) >= SPA_VERSION_DEADLISTS) {
(void) bpobj_iterate_nofree(&spa->spa_dsl_pool->dp_free_bpobj,
bpobj_count_block_cb, &zcb, NULL);
bpobj_count_block_cb, zcb, NULL);
}
zdb_claim_removing(spa, &zcb);
zdb_claim_removing(spa, zcb);
if (spa_feature_is_active(spa, SPA_FEATURE_ASYNC_DESTROY)) {
VERIFY3U(0, ==, bptree_iterate(spa->spa_meta_objset,
spa->spa_dsl_pool->dp_bptree_obj, B_FALSE, count_block_cb,
&zcb, NULL));
zcb, NULL));
}
deleted_livelists_count_blocks(spa, &zcb);
deleted_livelists_count_blocks(spa, zcb);
if (dump_opt['c'] > 1)
flags |= TRAVERSE_PREFETCH_DATA;
zcb.zcb_totalasize = metaslab_class_get_alloc(spa_normal_class(spa));
zcb.zcb_totalasize += metaslab_class_get_alloc(spa_special_class(spa));
zcb.zcb_totalasize += metaslab_class_get_alloc(spa_dedup_class(spa));
zcb.zcb_totalasize +=
zcb->zcb_totalasize = metaslab_class_get_alloc(spa_normal_class(spa));
zcb->zcb_totalasize += metaslab_class_get_alloc(spa_special_class(spa));
zcb->zcb_totalasize += metaslab_class_get_alloc(spa_dedup_class(spa));
zcb->zcb_totalasize +=
metaslab_class_get_alloc(spa_embedded_log_class(spa));
zcb.zcb_start = zcb.zcb_lastprint = gethrtime();
err = traverse_pool(spa, 0, flags, zdb_blkptr_cb, &zcb);
zcb->zcb_start = zcb->zcb_lastprint = gethrtime();
err = traverse_pool(spa, 0, flags, zdb_blkptr_cb, zcb);
/*
* If we've traversed the data blocks then we need to wait for those
@ -6496,15 +6502,15 @@ dump_block_stats(spa_t *spa)
* Done after zio_wait() since zcb_haderrors is modified in
* zdb_blkptr_done()
*/
zcb.zcb_haderrors |= err;
zcb->zcb_haderrors |= err;
if (zcb.zcb_haderrors) {
if (zcb->zcb_haderrors) {
(void) printf("\nError counts:\n\n");
(void) printf("\t%5s %s\n", "errno", "count");
for (e = 0; e < 256; e++) {
if (zcb.zcb_errors[e] != 0) {
if (zcb->zcb_errors[e] != 0) {
(void) printf("\t%5d %llu\n",
e, (u_longlong_t)zcb.zcb_errors[e]);
e, (u_longlong_t)zcb->zcb_errors[e]);
}
}
}
@ -6512,9 +6518,9 @@ dump_block_stats(spa_t *spa)
/*
* Report any leaked segments.
*/
leaks |= zdb_leak_fini(spa, &zcb);
leaks |= zdb_leak_fini(spa, zcb);
tzb = &zcb.zcb_type[ZB_TOTAL][ZDB_OT_TOTAL];
tzb = &zcb->zcb_type[ZB_TOTAL][ZDB_OT_TOTAL];
norm_alloc = metaslab_class_get_alloc(spa_normal_class(spa));
norm_space = metaslab_class_get_space(spa_normal_class(spa));
@ -6525,8 +6531,8 @@ dump_block_stats(spa_t *spa)
metaslab_class_get_alloc(spa_special_class(spa)) +
metaslab_class_get_alloc(spa_dedup_class(spa)) +
get_unflushed_alloc_space(spa);
total_found = tzb->zb_asize - zcb.zcb_dedup_asize +
zcb.zcb_removing_size + zcb.zcb_checkpoint_size;
total_found = tzb->zb_asize - zcb->zcb_dedup_asize +
zcb->zcb_removing_size + zcb->zcb_checkpoint_size;
if (total_found == total_alloc && !dump_opt['L']) {
(void) printf("\n\tNo leaks (block sum matches space"
@ -6541,8 +6547,10 @@ dump_block_stats(spa_t *spa)
leaks = B_TRUE;
}
if (tzb->zb_count == 0)
if (tzb->zb_count == 0) {
umem_free(zcb, sizeof (zdb_cb_t));
return (2);
}
(void) printf("\n");
(void) printf("\t%-16s %14llu\n", "bp count:",
@ -6561,9 +6569,9 @@ dump_block_stats(spa_t *spa)
(u_longlong_t)(tzb->zb_asize / tzb->zb_count),
(double)tzb->zb_lsize / tzb->zb_asize);
(void) printf("\t%-16s %14llu ref>1: %6llu deduplication: %6.2f\n",
"bp deduped:", (u_longlong_t)zcb.zcb_dedup_asize,
(u_longlong_t)zcb.zcb_dedup_blocks,
(double)zcb.zcb_dedup_asize / tzb->zb_asize + 1.0);
"bp deduped:", (u_longlong_t)zcb->zcb_dedup_asize,
(u_longlong_t)zcb->zcb_dedup_blocks,
(double)zcb->zcb_dedup_asize / tzb->zb_asize + 1.0);
(void) printf("\t%-16s %14llu used: %5.2f%%\n", "Normal class:",
(u_longlong_t)norm_alloc, 100.0 * norm_alloc / norm_space);
@ -6601,19 +6609,19 @@ dump_block_stats(spa_t *spa)
}
for (i = 0; i < NUM_BP_EMBEDDED_TYPES; i++) {
if (zcb.zcb_embedded_blocks[i] == 0)
if (zcb->zcb_embedded_blocks[i] == 0)
continue;
(void) printf("\n");
(void) printf("\tadditional, non-pointer bps of type %u: "
"%10llu\n",
i, (u_longlong_t)zcb.zcb_embedded_blocks[i]);
i, (u_longlong_t)zcb->zcb_embedded_blocks[i]);
if (dump_opt['b'] >= 3) {
(void) printf("\t number of (compressed) bytes: "
"number of bps\n");
dump_histogram(zcb.zcb_embedded_histogram[i],
sizeof (zcb.zcb_embedded_histogram[i]) /
sizeof (zcb.zcb_embedded_histogram[i][0]), 0);
dump_histogram(zcb->zcb_embedded_histogram[i],
sizeof (zcb->zcb_embedded_histogram[i]) /
sizeof (zcb->zcb_embedded_histogram[i][0]), 0);
}
}
@ -6673,7 +6681,7 @@ dump_block_stats(spa_t *spa)
else
typename = zdb_ot_extname[t - DMU_OT_NUMTYPES];
if (zcb.zcb_type[ZB_TOTAL][t].zb_asize == 0) {
if (zcb->zcb_type[ZB_TOTAL][t].zb_asize == 0) {
(void) printf("%6s\t%5s\t%5s\t%5s"
"\t%5s\t%5s\t%6s\t%s\n",
"-",
@ -6689,7 +6697,7 @@ dump_block_stats(spa_t *spa)
for (l = ZB_TOTAL - 1; l >= -1; l--) {
level = (l == -1 ? ZB_TOTAL : l);
zb = &zcb.zcb_type[level][t];
zb = &zcb->zcb_type[level][t];
if (zb->zb_asize == 0)
continue;
@ -6698,7 +6706,7 @@ dump_block_stats(spa_t *spa)
continue;
if (level == 0 && zb->zb_asize ==
zcb.zcb_type[ZB_TOTAL][t].zb_asize)
zcb->zcb_type[ZB_TOTAL][t].zb_asize)
continue;
zdb_nicenum(zb->zb_count, csize,
@ -6742,18 +6750,23 @@ dump_block_stats(spa_t *spa)
/* Output a table summarizing block sizes in the pool */
if (dump_opt['b'] >= 2) {
dump_size_histograms(&zcb);
dump_size_histograms(zcb);
}
}
(void) printf("\n");
if (leaks)
if (leaks) {
umem_free(zcb, sizeof (zdb_cb_t));
return (2);
}
if (zcb.zcb_haderrors)
if (zcb->zcb_haderrors) {
umem_free(zcb, sizeof (zdb_cb_t));
return (3);
}
umem_free(zcb, sizeof (zdb_cb_t));
return (0);
}

View File

@ -372,7 +372,7 @@ zed_log_fault(nvlist_t *nvl, const char *uuid, const char *code)
if (code != NULL)
zed_log_msg(LOG_INFO, "\t%s: %s", FM_SUSPECT_DIAG_CODE, code);
if (nvlist_lookup_uint8(nvl, FM_FAULT_CERTAINTY, &byte) == 0)
zed_log_msg(LOG_INFO, "\t%s: %llu", FM_FAULT_CERTAINTY, byte);
zed_log_msg(LOG_INFO, "\t%s: %hhu", FM_FAULT_CERTAINTY, byte);
if (nvlist_lookup_nvlist(nvl, FM_FAULT_RESOURCE, &rsrc) == 0) {
if (nvlist_lookup_string(rsrc, FM_FMRI_SCHEME, &strval) == 0)
zed_log_msg(LOG_INFO, "\t%s: %s", FM_FMRI_SCHEME,

View File

@ -364,7 +364,7 @@ zfs_process_add(zpool_handle_t *zhp, nvlist_t *vdev, boolean_t labeled)
(vs->vs_state != VDEV_STATE_FAULTED) &&
(vs->vs_state != VDEV_STATE_CANT_OPEN)) {
zed_log_msg(LOG_INFO, " not autoreplacing since disk isn't in "
"a bad state (currently %d)", vs->vs_state);
"a bad state (currently %llu)", vs->vs_state);
return;
}
@ -894,14 +894,90 @@ zfs_deliver_check(nvlist_t *nvl)
return (0);
}
/*
* Given a path to a vdev, lookup the vdev's physical size from its
* config nvlist.
*
* Returns the vdev's physical size in bytes on success, 0 on error.
*/
static uint64_t
vdev_size_from_config(zpool_handle_t *zhp, const char *vdev_path)
{
nvlist_t *nvl = NULL;
boolean_t avail_spare, l2cache, log;
vdev_stat_t *vs = NULL;
uint_t c;
nvl = zpool_find_vdev(zhp, vdev_path, &avail_spare, &l2cache, &log);
if (!nvl)
return (0);
verify(nvlist_lookup_uint64_array(nvl, ZPOOL_CONFIG_VDEV_STATS,
(uint64_t **)&vs, &c) == 0);
if (!vs) {
zed_log_msg(LOG_INFO, "%s: no nvlist for '%s'", __func__,
vdev_path);
return (0);
}
return (vs->vs_pspace);
}
/*
* Given a path to a vdev, lookup if the vdev is a "whole disk" in the
* config nvlist. "whole disk" means that ZFS was passed a whole disk
* at pool creation time, which it partitioned up and has full control over.
* Thus a partition with wholedisk=1 set tells us that zfs created the
* partition at creation time. A partition without whole disk set would have
* been created by externally (like with fdisk) and passed to ZFS.
*
* Returns the whole disk value (either 0 or 1).
*/
static uint64_t
vdev_whole_disk_from_config(zpool_handle_t *zhp, const char *vdev_path)
{
nvlist_t *nvl = NULL;
boolean_t avail_spare, l2cache, log;
uint64_t wholedisk;
nvl = zpool_find_vdev(zhp, vdev_path, &avail_spare, &l2cache, &log);
if (!nvl)
return (0);
verify(nvlist_lookup_uint64(nvl, ZPOOL_CONFIG_WHOLE_DISK,
&wholedisk) == 0);
return (wholedisk);
}
/*
* If the device size grew more than 1% then return true.
*/
#define DEVICE_GREW(oldsize, newsize) \
((newsize > oldsize) && \
((newsize / (newsize - oldsize)) <= 100))
static int
zfsdle_vdev_online(zpool_handle_t *zhp, void *data)
{
char *devname = data;
boolean_t avail_spare, l2cache;
nvlist_t *udev_nvl = data;
nvlist_t *tgt;
int error;
char *tmp_devname, devname[MAXPATHLEN] = "";
uint64_t guid;
if (nvlist_lookup_uint64(udev_nvl, ZFS_EV_VDEV_GUID, &guid) == 0) {
sprintf(devname, "%llu", (u_longlong_t)guid);
} else if (nvlist_lookup_string(udev_nvl, DEV_PHYS_PATH,
&tmp_devname) == 0) {
strlcpy(devname, tmp_devname, MAXPATHLEN);
zfs_append_partition(devname, MAXPATHLEN);
} else {
zed_log_msg(LOG_INFO, "%s: no guid or physpath", __func__);
}
zed_log_msg(LOG_INFO, "zfsdle_vdev_online: searching for '%s' in '%s'",
devname, zpool_get_name(zhp));
@ -953,12 +1029,75 @@ zfsdle_vdev_online(zpool_handle_t *zhp, void *data)
vdev_state_t newstate;
if (zpool_get_state(zhp) != POOL_STATE_UNAVAIL) {
error = zpool_vdev_online(zhp, fullpath, 0,
&newstate);
zed_log_msg(LOG_INFO, "zfsdle_vdev_online: "
"setting device '%s' to ONLINE state "
"in pool '%s': %d", fullpath,
zpool_get_name(zhp), error);
/*
* If this disk size has not changed, then
* there's no need to do an autoexpand. To
* check we look at the disk's size in its
* config, and compare it to the disk size
* that udev is reporting.
*/
uint64_t udev_size = 0, conf_size = 0,
wholedisk = 0, udev_parent_size = 0;
/*
* Get the size of our disk that udev is
* reporting.
*/
if (nvlist_lookup_uint64(udev_nvl, DEV_SIZE,
&udev_size) != 0) {
udev_size = 0;
}
/*
* Get the size of our disk's parent device
* from udev (where sda1's parent is sda).
*/
if (nvlist_lookup_uint64(udev_nvl,
DEV_PARENT_SIZE, &udev_parent_size) != 0) {
udev_parent_size = 0;
}
conf_size = vdev_size_from_config(zhp,
fullpath);
wholedisk = vdev_whole_disk_from_config(zhp,
fullpath);
/*
* Only attempt an autoexpand if the vdev size
* changed. There are two different cases
* to consider.
*
* 1. wholedisk=1
* If you do a 'zpool create' on a whole disk
* (like /dev/sda), then zfs will create
* partitions on the disk (like /dev/sda1). In
* that case, wholedisk=1 will be set in the
* partition's nvlist config. So zed will need
* to see if your parent device (/dev/sda)
* expanded in size, and if so, then attempt
* the autoexpand.
*
* 2. wholedisk=0
* If you do a 'zpool create' on an existing
* partition, or a device that doesn't allow
* partitions, then wholedisk=0, and you will
* simply need to check if the device itself
* expanded in size.
*/
if (DEVICE_GREW(conf_size, udev_size) ||
(wholedisk && DEVICE_GREW(conf_size,
udev_parent_size))) {
error = zpool_vdev_online(zhp, fullpath,
0, &newstate);
zed_log_msg(LOG_INFO,
"%s: autoexpanding '%s' from %llu"
" to %llu bytes in pool '%s': %d",
__func__, fullpath, conf_size,
MAX(udev_size, udev_parent_size),
zpool_get_name(zhp), error);
}
}
}
zpool_close(zhp);
@ -989,7 +1128,7 @@ zfs_deliver_dle(nvlist_t *nvl)
zed_log_msg(LOG_INFO, "zfs_deliver_dle: no guid or physpath");
}
if (zpool_iter(g_zfshdl, zfsdle_vdev_online, name) != 1) {
if (zpool_iter(g_zfshdl, zfsdle_vdev_online, nvl) != 1) {
zed_log_msg(LOG_INFO, "zfs_deliver_dle: device '%s' not "
"found", name);
return (1);

View File

@ -657,7 +657,7 @@ zed_conf_read_state(struct zed_conf *zcp, uint64_t *eidp, int64_t etime[])
} else if (n != len) {
errno = EIO;
zed_log_msg(LOG_WARNING,
"Failed to read state file \"%s\": Read %d of %d bytes",
"Failed to read state file \"%s\": Read %zd of %zd bytes",
zcp->state_file, n, len);
return (-1);
}
@ -706,7 +706,7 @@ zed_conf_write_state(struct zed_conf *zcp, uint64_t eid, int64_t etime[])
if (n != len) {
errno = EIO;
zed_log_msg(LOG_WARNING,
"Failed to write state file \"%s\": Wrote %d of %d bytes",
"Failed to write state file \"%s\": Wrote %zd of %zd bytes",
zcp->state_file, n, len);
return (-1);
}

View File

@ -49,7 +49,7 @@ struct udev_monitor *g_mon;
#define DEV_BYID_PATH "/dev/disk/by-id/"
/* 64MB is minimum usable disk for ZFS */
#define MINIMUM_SECTORS 131072
#define MINIMUM_SECTORS 131072ULL
/*
@ -78,6 +78,8 @@ zed_udev_event(const char *class, const char *subclass, nvlist_t *nvl)
zed_log_msg(LOG_INFO, "\t%s: %s", DEV_PHYS_PATH, strval);
if (nvlist_lookup_uint64(nvl, DEV_SIZE, &numval) == 0)
zed_log_msg(LOG_INFO, "\t%s: %llu", DEV_SIZE, numval);
if (nvlist_lookup_uint64(nvl, DEV_PARENT_SIZE, &numval) == 0)
zed_log_msg(LOG_INFO, "\t%s: %llu", DEV_PARENT_SIZE, numval);
if (nvlist_lookup_uint64(nvl, ZFS_EV_POOL_GUID, &numval) == 0)
zed_log_msg(LOG_INFO, "\t%s: %llu", ZFS_EV_POOL_GUID, numval);
if (nvlist_lookup_uint64(nvl, ZFS_EV_VDEV_GUID, &numval) == 0)
@ -130,6 +132,20 @@ dev_event_nvlist(struct udev_device *dev)
numval *= strtoull(value, NULL, 10);
(void) nvlist_add_uint64(nvl, DEV_SIZE, numval);
/*
* If the device has a parent, then get the parent block
* device's size as well. For example, /dev/sda1's parent
* is /dev/sda.
*/
struct udev_device *parent_dev = udev_device_get_parent(dev);
if ((value = udev_device_get_sysattr_value(parent_dev, "size"))
!= NULL) {
uint64_t numval = DEV_BSIZE;
numval *= strtoull(value, NULL, 10);
(void) nvlist_add_uint64(nvl, DEV_PARENT_SIZE, numval);
}
}
/*

View File

@ -263,7 +263,7 @@ _reap_children(void *arg)
zed_log_msg(LOG_INFO,
"Finished \"%s\" eid=%llu pid=%d "
"time=%llu.%06us status=0x%X",
node.name, node.eid,
node.name, node.eid, pid,
(unsigned long long) usage.ru_utime.tv_sec,
(unsigned int) usage.ru_utime.tv_usec,
(unsigned int) status);

View File

@ -7093,6 +7093,9 @@ share_mount(int op, int argc, char **argv)
share_mount_state.sm_total = cb.cb_used;
pthread_mutex_init(&share_mount_state.sm_lock, NULL);
/* For a 'zfs share -a' operation start with a clean slate. */
zfs_truncate_shares(NULL);
/*
* libshare isn't mt-safe, so only do the operation in parallel
* if we're mounting. Additionally, the key-loading option must

View File

@ -0,0 +1,467 @@
#!/usr/bin/env @PYTHON_SHEBANG@
#
# Print out statistics for all zil stats. This information is
# available through the zil kstat.
#
# CDDL HEADER START
#
# The contents of this file are subject to the terms of the
# Common Development and Distribution License, Version 1.0 only
# (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 https://opensource.org/licenses/CDDL-1.0.
# 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]
#
# This script must remain compatible with Python 3.6+.
#
import sys
import subprocess
import time
import copy
import os
import re
import signal
from collections import defaultdict
import argparse
from argparse import RawTextHelpFormatter
cols = {
# hdr: [size, scale, kstat name]
"time": [8, -1, "time"],
"pool": [12, -1, "pool"],
"ds": [12, -1, "dataset_name"],
"obj": [12, -1, "objset"],
"zcc": [10, 1000, "zil_commit_count"],
"zcwc": [10, 1000, "zil_commit_writer_count"],
"ziic": [10, 1000, "zil_itx_indirect_count"],
"zic": [10, 1000, "zil_itx_count"],
"ziib": [10, 1024, "zil_itx_indirect_bytes"],
"zicc": [10, 1000, "zil_itx_copied_count"],
"zicb": [10, 1024, "zil_itx_copied_bytes"],
"zinc": [10, 1000, "zil_itx_needcopy_count"],
"zinb": [10, 1024, "zil_itx_needcopy_bytes"],
"zimnc": [10, 1000, "zil_itx_metaslab_normal_count"],
"zimnb": [10, 1024, "zil_itx_metaslab_normal_bytes"],
"zimsc": [10, 1000, "zil_itx_metaslab_slog_count"],
"zimsb": [10, 1024, "zil_itx_metaslab_slog_bytes"],
}
hdr = ["time", "pool", "ds", "obj", "zcc", "zcwc", "ziic", "zic", "ziib", \
"zicc", "zicb", "zinc", "zinb", "zimnc", "zimnb", "zimsc", "zimsb"]
ghdr = ["time", "zcc", "zcwc", "ziic", "zic", "ziib", "zicc", "zicb",
"zinc", "zinb", "zimnc", "zimnb", "zimsc", "zimsb"]
cmd = ("Usage: zilstat [-hgdv] [-i interval] [-p pool_name]")
curr = {}
diff = {}
kstat = {}
ds_pairs = {}
pool_name = None
dataset_name = None
interval = 0
sep = " "
gFlag = True
dsFlag = False
def prettynum(sz, scale, num=0):
suffix = [' ', 'K', 'M', 'G', 'T', 'P', 'E', 'Z']
index = 0
save = 0
if scale == -1:
return "%*s" % (sz, num)
# Rounding error, return 0
elif 0 < num < 1:
num = 0
while num > scale and index < 5:
save = num
num = num / scale
index += 1
if index == 0:
return "%*d" % (sz, num)
if (save / scale) < 10:
return "%*.1f%s" % (sz - 1, num, suffix[index])
else:
return "%*d%s" % (sz - 1, num, suffix[index])
def print_header():
global hdr
global sep
for col in hdr:
new_col = col
if interval > 0 and col not in ['time', 'pool', 'ds', 'obj']:
new_col += "/s"
sys.stdout.write("%*s%s" % (cols[col][0], new_col, sep))
sys.stdout.write("\n")
def print_values(v):
global hdr
global sep
for col in hdr:
val = v[cols[col][2]]
if col not in ['time', 'pool', 'ds', 'obj'] and interval > 0:
val = v[cols[col][2]] // interval
sys.stdout.write("%s%s" % (
prettynum(cols[col][0], cols[col][1], val), sep))
sys.stdout.write("\n")
def print_dict(d):
for pool in d:
for objset in d[pool]:
print_values(d[pool][objset])
def detailed_usage():
sys.stderr.write("%s\n" % cmd)
sys.stderr.write("Field definitions are as follows:\n")
for key in cols:
sys.stderr.write("%11s : %s\n" % (key, cols[key][2]))
sys.stderr.write("\n")
sys.exit(0)
def init():
global pool_name
global dataset_name
global interval
global hdr
global curr
global gFlag
global sep
curr = dict()
parser = argparse.ArgumentParser(description='Program to print zilstats',
add_help=True,
formatter_class=RawTextHelpFormatter,
epilog="\nUsage Examples\n"\
"Note: Global zilstats is shown by default,"\
" if none of a|p|d option is not provided\n"\
"\tzilstat -a\n"\
'\tzilstat -v\n'\
'\tzilstat -p tank\n'\
'\tzilstat -d tank/d1,tank/d2,tank/zv1\n'\
'\tzilstat -i 1\n'\
'\tzilstat -s \"***\"\n'\
'\tzilstat -f zcwc,zimnb,zimsb\n')
parser.add_argument(
"-v", "--verbose",
action="store_true",
help="List field headers and definitions"
)
pool_grp = parser.add_mutually_exclusive_group()
pool_grp.add_argument(
"-a", "--all",
action="store_true",
dest="all",
help="Print all dataset stats"
)
pool_grp.add_argument(
"-p", "--pool",
type=str,
help="Print stats for all datasets of a speicfied pool"
)
pool_grp.add_argument(
"-d", "--dataset",
type=str,
help="Print given dataset(s) (Comma separated)"
)
parser.add_argument(
"-f", "--columns",
type=str,
help="Specify specific fields to print (see -v)"
)
parser.add_argument(
"-s", "--separator",
type=str,
help="Override default field separator with custom "
"character or string"
)
parser.add_argument(
"-i", "--interval",
type=int,
dest="interval",
help="Print stats between specified interval"
" (in seconds)"
)
parsed_args = parser.parse_args()
if parsed_args.verbose:
detailed_usage()
if parsed_args.all:
gFlag = False
if parsed_args.interval:
interval = parsed_args.interval
if parsed_args.pool:
pool_name = parsed_args.pool
gFlag = False
if parsed_args.dataset:
dataset_name = parsed_args.dataset
gFlag = False
if parsed_args.separator:
sep = parsed_args.separator
if gFlag:
hdr = ghdr
if parsed_args.columns:
hdr = parsed_args.columns.split(",")
invalid = []
for ele in hdr:
if gFlag and ele not in ghdr:
invalid.append(ele)
elif ele not in cols:
invalid.append(ele)
if len(invalid) > 0:
sys.stderr.write("Invalid column definition! -- %s\n" % invalid)
sys.exit(1)
if pool_name and dataset_name:
print ("Error: Can not filter both dataset and pool")
sys.exit(1)
def FileCheck(fname):
try:
return (open(fname))
except IOError:
print ("Unable to open zilstat proc file: " + fname)
sys.exit(1)
if sys.platform.startswith('freebsd'):
# Requires py-sysctl on FreeBSD
import sysctl
def kstat_update(pool = None, objid = None):
global kstat
kstat = {}
if not pool:
file = "kstat.zfs.misc.zil"
k = [ctl for ctl in sysctl.filter(file) \
if ctl.type != sysctl.CTLTYPE_NODE]
kstat_process_str(k, file, "GLOBAL", len(file + "."))
elif objid:
file = "kstat.zfs." + pool + ".dataset.objset-" + objid
k = [ctl for ctl in sysctl.filter(file) if ctl.type \
!= sysctl.CTLTYPE_NODE]
kstat_process_str(k, file, objid, len(file + "."))
else:
file = "kstat.zfs." + pool + ".dataset"
zil_start = len(file + ".")
obj_start = len("kstat.zfs." + pool + ".")
k = [ctl for ctl in sysctl.filter(file)
if ctl.type != sysctl.CTLTYPE_NODE]
for s in k:
if not s or (s.name.find("zil") == -1 and \
s.name.find("dataset_name") == -1):
continue
name, value = s.name, s.value
objid = re.findall(r'0x[0-9A-F]+', \
name[obj_start:], re.I)[0]
if objid not in kstat:
kstat[objid] = dict()
zil_start = len(file + ".objset-" + \
objid + ".")
kstat[objid][name[zil_start:]] = value \
if (name.find("dataset_name")) \
else int(value)
def kstat_process_str(k, file, objset = "GLOBAL", zil_start = 0):
global kstat
if not k:
print("Unable to process kstat for: " + file)
sys.exit(1)
kstat[objset] = dict()
for s in k:
if not s or (s.name.find("zil") == -1 and \
s.name.find("dataset_name") == -1):
continue
name, value = s.name, s.value
kstat[objset][name[zil_start:]] = value \
if (name.find("dataset_name")) else int(value)
elif sys.platform.startswith('linux'):
def kstat_update(pool = None, objid = None):
global kstat
kstat = {}
if not pool:
k = [line.strip() for line in \
FileCheck("/proc/spl/kstat/zfs/zil")]
kstat_process_str(k, "/proc/spl/kstat/zfs/zil")
elif objid:
file = "/proc/spl/kstat/zfs/" + pool + "/objset-" + objid
k = [line.strip() for line in FileCheck(file)]
kstat_process_str(k, file, objid)
else:
if not os.path.exists(f"/proc/spl/kstat/zfs/{pool}"):
print("Pool \"" + pool + "\" does not exist, Exitting")
sys.exit(1)
objsets = os.listdir(f'/proc/spl/kstat/zfs/{pool}')
for objid in objsets:
if objid.find("objset-") == -1:
continue
file = "/proc/spl/kstat/zfs/" + pool + "/" + objid
k = [line.strip() for line in FileCheck(file)]
kstat_process_str(k, file, objid.replace("objset-", ""))
def kstat_process_str(k, file, objset = "GLOBAL", zil_start = 0):
global kstat
if not k:
print("Unable to process kstat for: " + file)
sys.exit(1)
kstat[objset] = dict()
for s in k:
if not s or (s.find("zil") == -1 and \
s.find("dataset_name") == -1):
continue
name, unused, value = s.split()
kstat[objset][name] = value \
if (name == "dataset_name") else int(value)
def zil_process_kstat():
global curr, pool_name, dataset_name, dsFlag, ds_pairs
curr.clear()
if gFlag == True:
kstat_update()
zil_build_dict()
else:
if pool_name:
kstat_update(pool_name)
zil_build_dict(pool_name)
elif dataset_name:
if dsFlag == False:
dsFlag = True
datasets = dataset_name.split(',')
ds_pairs = defaultdict(list)
for ds in datasets:
try:
objid = subprocess.check_output(['zfs',
'list', '-Hpo', 'objsetid', ds], \
stderr=subprocess.DEVNULL) \
.decode('utf-8').strip()
except subprocess.CalledProcessError as e:
print("Command: \"zfs list -Hpo objset "\
+ str(ds) + "\" failed with error code:"\
+ str(e.returncode))
print("Please make sure that dataset \""\
+ str(ds) + "\" exists")
sys.exit(1)
if not objid:
continue
ds_pairs[ds.split('/')[0]]. \
append(hex(int(objid)))
for pool, objids in ds_pairs.items():
for objid in objids:
kstat_update(pool, objid)
zil_build_dict(pool)
else:
try:
pools = subprocess.check_output(['zpool', 'list', '-Hpo',\
'name']).decode('utf-8').split()
except subprocess.CalledProcessError as e:
print("Command: \"zpool list -Hpo name\" failed with error"\
"code: " + str(e.returncode))
sys.exit(1)
for pool in pools:
kstat_update(pool)
zil_build_dict(pool)
def calculate_diff():
global curr, diff
prev = copy.deepcopy(curr)
zil_process_kstat()
diff = copy.deepcopy(curr)
for pool in curr:
for objset in curr[pool]:
for col in hdr:
if col not in ['time', 'pool', 'ds', 'obj']:
key = cols[col][2]
# If prev is NULL, this is the
# first time we are here
if not prev:
diff[pool][objset][key] = 0
else:
diff[pool][objset][key] \
= curr[pool][objset][key] \
- prev[pool][objset][key]
def zil_build_dict(pool = "GLOBAL"):
global kstat
for objset in kstat:
for key in kstat[objset]:
val = kstat[objset][key]
if pool not in curr:
curr[pool] = dict()
if objset not in curr[pool]:
curr[pool][objset] = dict()
curr[pool][objset][key] = val
curr[pool][objset]["pool"] = pool
curr[pool][objset]["objset"] = objset
curr[pool][objset]["time"] = time.strftime("%H:%M:%S", \
time.localtime())
def sign_handler_epipe(sig, frame):
print("Caught EPIPE signal: " + str(frame))
print("Exitting...")
sys.exit(0)
def main():
global interval
global curr
hprint = False
init()
signal.signal(signal.SIGINT, signal.SIG_DFL)
signal.signal(signal.SIGPIPE, sign_handler_epipe)
if interval > 0:
while True:
calculate_diff()
if not diff:
print ("Error: No stats to show")
sys.exit(0)
if hprint == False:
print_header()
hprint = True
print_dict(diff)
time.sleep(interval)
else:
zil_process_kstat()
if not curr:
print ("Error: No stats to show")
sys.exit(0)
print_header()
print_dict(curr)
if __name__ == '__main__':
main()

View File

@ -5466,8 +5466,8 @@ get_namewidth_iostat(zpool_handle_t *zhp, void *data)
* get_namewidth() returns the maximum width of any name in that column
* for any pool/vdev/device line that will be output.
*/
width = get_namewidth(zhp, cb->cb_namewidth, cb->cb_vdevs.cb_name_flags,
cb->cb_verbose);
width = get_namewidth(zhp, cb->cb_namewidth,
cb->cb_vdevs.cb_name_flags | VDEV_NAME_TYPE_ID, cb->cb_verbose);
/*
* The width we are calculating is the width of the header and also the
@ -6298,8 +6298,8 @@ get_namewidth_list(zpool_handle_t *zhp, void *data)
list_cbdata_t *cb = data;
int width;
width = get_namewidth(zhp, cb->cb_namewidth, cb->cb_name_flags,
cb->cb_verbose);
width = get_namewidth(zhp, cb->cb_namewidth,
cb->cb_name_flags | VDEV_NAME_TYPE_ID, cb->cb_verbose);
if (width < 9)
width = 9;

View File

@ -6413,7 +6413,7 @@ ztest_blake3(ztest_ds_t *zd, uint64_t id)
void *res2 = &zc_res2;
/* BLAKE3_KEY_LEN = 32 */
VERIFY0(blake3_set_impl_name("generic"));
VERIFY0(blake3_impl_setname("generic"));
templ = abd_checksum_blake3_tmpl_init(&salt);
Blake3_InitKeyed(&ctx, salt_ptr);
Blake3_Update(&ctx, buf, size);
@ -6422,7 +6422,7 @@ ztest_blake3(ztest_ds_t *zd, uint64_t id)
ZIO_CHECKSUM_BSWAP(&zc_ref2);
abd_checksum_blake3_tmpl_free(templ);
VERIFY0(blake3_set_impl_name("cycle"));
VERIFY0(blake3_impl_setname("cycle"));
while (run_count-- > 0) {
/* Test current implementation */
@ -7966,6 +7966,7 @@ exec_child(char *cmd, char *libpath, boolean_t ignorekill, int *statusp)
VERIFY3S(-1, !=,
asprintf(&newlp, "%s:%s", libpath, curlp));
VERIFY0(setenv("LD_LIBRARY_PATH", newlp, 1));
free(newlp);
}
}
(void) execl(cmd, cmd, (char *)NULL);

View File

@ -0,0 +1,23 @@
dnl #
dnl # Linux 4.19 API
dnl #
AC_DEFUN([ZFS_AC_KERNEL_SRC_FADVISE], [
ZFS_LINUX_TEST_SRC([file_fadvise], [
#include <linux/fs.h>
static const struct file_operations
fops __attribute__ ((unused)) = {
.fadvise = NULL,
};
],[])
])
AC_DEFUN([ZFS_AC_KERNEL_FADVISE], [
AC_MSG_CHECKING([whether fops->fadvise() exists])
ZFS_LINUX_TEST_RESULT([file_fadvise], [
AC_MSG_RESULT(yes)
AC_DEFINE(HAVE_FILE_FADVISE, 1, [fops->fadvise() exists])
],[
AC_MSG_RESULT(no)
])
])

View File

@ -0,0 +1,27 @@
dnl #
dnl # 5.3 API change
dnl # The generic_fadvise() function is present since 4.19 kernel
dnl # but it was not exported until Linux 5.3.
dnl #
AC_DEFUN([ZFS_AC_KERNEL_SRC_GENERIC_FADVISE], [
ZFS_LINUX_TEST_SRC([generic_fadvise], [
#include <linux/fs.h>
], [
struct file *fp __attribute__ ((unused)) = NULL;
loff_t offset __attribute__ ((unused)) = 0;
loff_t len __attribute__ ((unused)) = 0;
int advise __attribute__ ((unused)) = 0;
generic_fadvise(fp, offset, len, advise);
])
])
AC_DEFUN([ZFS_AC_KERNEL_GENERIC_FADVISE], [
AC_MSG_CHECKING([whether generic_fadvise() is available])
ZFS_LINUX_TEST_RESULT_SYMBOL([generic_fadvise],
[generic_fadvise], [mm/fadvise.c], [
AC_MSG_RESULT(yes)
AC_DEFINE(HAVE_GENERIC_FADVISE, 1, [yes])
],[
AC_MSG_RESULT(no)
])
])

View File

@ -100,6 +100,19 @@ AC_DEFUN([ZFS_AC_KERNEL_SRC_XATTR_HANDLER_GET], [
.get = get,
};
],[])
ZFS_LINUX_TEST_SRC([xattr_handler_get_dentry_inode_flags], [
#include <linux/xattr.h>
int get(const struct xattr_handler *handler,
struct dentry *dentry, struct inode *inode,
const char *name, void *buffer,
size_t size, int flags) { return 0; }
static const struct xattr_handler
xops __attribute__ ((unused)) = {
.get = get,
};
],[])
])
AC_DEFUN([ZFS_AC_KERNEL_XATTR_HANDLER_GET], [
@ -142,7 +155,21 @@ AC_DEFUN([ZFS_AC_KERNEL_XATTR_HANDLER_GET], [
AC_DEFINE(HAVE_XATTR_GET_DENTRY, 1,
[xattr_handler->get() wants dentry])
],[
ZFS_LINUX_TEST_ERROR([xattr get()])
dnl #
dnl # Android API change,
dnl # The xattr_handler->get() callback was
dnl # changed to take dentry, inode and flags.
dnl #
AC_MSG_RESULT(no)
AC_MSG_CHECKING(
[whether xattr_handler->get() wants dentry and inode and flags])
ZFS_LINUX_TEST_RESULT([xattr_handler_get_dentry_inode_flags], [
AC_MSG_RESULT(yes)
AC_DEFINE(HAVE_XATTR_GET_DENTRY_INODE_FLAGS, 1,
[xattr_handler->get() wants dentry and inode and flags])
],[
ZFS_LINUX_TEST_ERROR([xattr get()])
])
])
])
])

View File

@ -42,6 +42,8 @@ AC_DEFUN([ZFS_AC_KERNEL_TEST_SRC], [
ZFS_AC_KERNEL_SRC_ACCESS_OK_TYPE
ZFS_AC_KERNEL_SRC_PDE_DATA
ZFS_AC_KERNEL_SRC_FALLOCATE
ZFS_AC_KERNEL_SRC_FADVISE
ZFS_AC_KERNEL_SRC_GENERIC_FADVISE
ZFS_AC_KERNEL_SRC_2ARGS_ZLIB_DEFLATE_WORKSPACESIZE
ZFS_AC_KERNEL_SRC_RWSEM
ZFS_AC_KERNEL_SRC_SCHED
@ -161,6 +163,8 @@ AC_DEFUN([ZFS_AC_KERNEL_TEST_RESULT], [
ZFS_AC_KERNEL_OBJTOOL
ZFS_AC_KERNEL_PDE_DATA
ZFS_AC_KERNEL_FALLOCATE
ZFS_AC_KERNEL_FADVISE
ZFS_AC_KERNEL_GENERIC_FADVISE
ZFS_AC_KERNEL_2ARGS_ZLIB_DEFLATE_WORKSPACESIZE
ZFS_AC_KERNEL_RWSEM
ZFS_AC_KERNEL_SCHED

View File

@ -0,0 +1,422 @@
/*
* Coverity Scan model
* https://scan.coverity.com/models
*
* This is a modeling file for Coverity Scan.
* Modeling helps to avoid false positives.
*
* - Modeling doesn't need full structs and typedefs. Rudimentary structs
* and similar types are sufficient.
* - An uninitialized local pointer is not an error. It signifies that the
* variable could be either NULL or have some data.
*
* Coverity Scan doesn't pick up modifications automatically. The model file
* must be uploaded by an admin in the analysis settings.
*
* Some of this initially cribbed from:
*
* https://github.com/kees/coverity-linux/blob/trunk/model.c
*
* The below model was based on the original model by Brian Behlendorf for the
* original zfsonlinux/zfs repository. Some inspiration was taken from
* kees/coverity-linux, specifically involving memory copies.
*/
#include <stdarg.h>
#define UMEM_DEFAULT 0x0000 /* normal -- may fail */
#define UMEM_NOFAIL 0x0100 /* Never fails */
#define NULL (0)
int condition0, condition1;
void
abort()
{
__coverity_panic__();
}
void
exit(int status)
{
(void) status;
__coverity_panic__();
}
void
_exit(int status)
{
(void) status;
__coverity_panic__();
}
void
zed_log_die(const char *fmt, ...)
{
__coverity_format_string_sink__(fmt);
__coverity_panic__();
}
void
panic(const char *fmt, ...)
{
__coverity_format_string_sink__(fmt);
__coverity_panic__();
}
void
vpanic(const char *fmt, va_list adx)
{
(void) adx;
__coverity_format_string_sink__(fmt);
__coverity_panic__();
}
void
uu_panic(const char *format, ...)
{
__coverity_format_string_sink__(format);
__coverity_panic__();
}
int
libspl_assertf(const char *file, const char *func, int line,
const char *format, ...)
{
__coverity_format_string_sink__(format);
__coverity_panic__();
}
int
ddi_copyin(const void *from, void *to, size_t len, int flags)
{
__coverity_tainted_data_argument__(from);
__coverity_tainted_data_argument__(to);
__coverity_writeall__(to);
}
void *
memset(void *dst, int c, size_t len)
{
__coverity_writeall__(dst);
return (dst);
}
void *
memmove(void *dst, void *src, size_t len)
{
__coverity_writeall__(dst);
return (dst);
}
void *
memcpy(void *dst, void *src, size_t len)
{
__coverity_writeall__(dst);
return (dst);
}
void *
umem_alloc_aligned(size_t size, size_t align, int kmflags)
{
(void) align;
if (UMEM_NOFAIL & kmflags == UMEM_NOFAIL)
return (__coverity_alloc__(size));
else if (condition0)
return (__coverity_alloc__(size));
else
return (NULL);
}
void *
umem_alloc(size_t size, int kmflags)
{
if (UMEM_NOFAIL & kmflags == UMEM_NOFAIL)
return (__coverity_alloc__(size));
else if (condition0)
return (__coverity_alloc__(size));
else
return (NULL);
}
void *
umem_zalloc(size_t size, int kmflags)
{
if (UMEM_NOFAIL & kmflags == UMEM_NOFAIL)
return (__coverity_alloc__(size));
else if (condition0)
return (__coverity_alloc__(size));
else
return (NULL);
}
void
umem_free(void *buf, size_t size)
{
(void) size;
__coverity_free__(buf);
}
void *
spl_kmem_alloc(size_t sz, int fl, const char *func, int line)
{
(void) func;
(void) line;
if (condition1)
__coverity_sleep__();
if (fl == 0) {
return (__coverity_alloc__(sz));
} else if (condition0)
return (__coverity_alloc__(sz));
else
return (NULL);
}
void *
spl_kmem_zalloc(size_t sz, int fl, const char *func, int line)
{
(void) func;
(void) line;
if (condition1)
__coverity_sleep__();
if (fl == 0) {
return (__coverity_alloc__(sz));
} else if (condition0)
return (__coverity_alloc__(sz));
else
return (NULL);
}
void
spl_kmem_free(const void *ptr, size_t sz)
{
(void) sz;
__coverity_free__(ptr);
}
typedef struct {} spl_kmem_cache_t;
void *
spl_kmem_cache_alloc(spl_kmem_cache_t *skc, int flags)
{
(void) skc;
if (condition1)
__coverity_sleep__();
if (flags == 0) {
return (__coverity_alloc_nosize__());
} else if (condition0)
return (__coverity_alloc_nosize__());
else
return (NULL);
}
void
spl_kmem_cache_free(spl_kmem_cache_t *skc, void *obj)
{
(void) skc;
__coverity_free__(obj);
}
void
malloc(size_t size)
{
__coverity_alloc__(size);
}
void
free(void *buf)
{
__coverity_free__(buf);
}
int
spl_panic(const char *file, const char *func, int line, const char *fmt, ...)
{
__coverity_format_string_sink__(fmt);
__coverity_panic__();
}
int
sched_yield(void)
{
__coverity_sleep__();
}
typedef struct {} kmutex_t;
typedef struct {} krwlock_t;
typedef int krw_t;
/*
* Coverty reportedly does not support macros, so this only works for
* userspace.
*/
void
mutex_enter(kmutex_t *mp)
{
if (condition0)
__coverity_sleep__();
__coverity_exclusive_lock_acquire__(mp);
}
int
mutex_tryenter(kmutex_t *mp)
{
if (condition0) {
__coverity_exclusive_lock_acquire__(mp);
return (1);
}
return (0);
}
void
mutex_exit(kmutex_t *mp)
{
__coverity_exclusive_lock_release__(mp);
}
void
rw_enter(krwlock_t *rwlp, krw_t rw)
{
(void) rw;
if (condition0)
__coverity_sleep__();
__coverity_recursive_lock_acquire__(rwlp);
}
void
rw_exit(krwlock_t *rwlp)
{
__coverity_recursive_lock_release__(rwlp);
}
int
rw_tryenter(krwlock_t *rwlp, krw_t rw)
{
if (condition0) {
__coverity_recursive_lock_acquire__(rwlp);
return (1);
}
return (0);
}
/* Thus, we fallback to the Linux kernel locks */
struct {} mutex;
struct {} rw_semaphore;
void
mutex_lock(struct mutex *lock)
{
if (condition0) {
__coverity_sleep__();
}
__coverity_exclusive_lock_acquire__(lock);
}
void
mutex_unlock(struct mutex *lock)
{
__coverity_exclusive_lock_release__(lock);
}
void
down_read(struct rw_semaphore *sem)
{
if (condition0) {
__coverity_sleep__();
}
__coverity_recursive_lock_acquire__(sem);
}
void
down_write(struct rw_semaphore *sem)
{
if (condition0) {
__coverity_sleep__();
}
__coverity_recursive_lock_acquire__(sem);
}
int
down_read_trylock(struct rw_semaphore *sem)
{
if (condition0) {
__coverity_recursive_lock_acquire__(sem);
return (1);
}
return (0);
}
int
down_write_trylock(struct rw_semaphore *sem)
{
if (condition0) {
__coverity_recursive_lock_acquire__(sem);
return (1);
}
return (0);
}
void
up_read(struct rw_semaphore *sem)
{
__coverity_recursive_lock_release__(sem);
}
void
up_write(struct rw_semaphore *sem)
{
__coverity_recursive_lock_release__(sem);
}
int
__cond_resched(void)
{
if (condition0) {
__coverity_sleep__();
}
}
/*
* An endian-independent filesystem must support doing byte swaps on data. We
* attempt to suppress taint warnings, which are false positives for us.
*/
void
byteswap_uint64_array(void *vbuf, size_t size)
{
__coverity_tainted_data_sanitize__(vbuf);
}
void
byteswap_uint32_array(void *vbuf, size_t size)
{
__coverity_tainted_data_sanitize__(vbuf);
}
void
byteswap_uint16_array(void *vbuf, size_t size)
{
__coverity_tainted_data_sanitize__(vbuf);
}

View File

@ -531,7 +531,6 @@ zfs_key_config_get_dataset(zfs_key_config_t *config)
if (zhp == NULL) {
pam_syslog(NULL, LOG_ERR, "dataset %s not found",
config->homes_prefix);
zfs_close(zhp);
return (NULL);
}
@ -543,6 +542,10 @@ zfs_key_config_get_dataset(zfs_key_config_t *config)
return (dsname);
}
if (config->homes_prefix == NULL) {
return (NULL);
}
size_t len = ZFS_MAX_DATASET_NAME_LEN;
size_t total_len = strlen(config->homes_prefix) + 1
+ strlen(config->username);

View File

@ -1,7 +1,7 @@
[Unit]
Description=ZFS file system shares
Documentation=man:zfs(8)
After=nfs-server.service nfs-kernel-server.service
Before=nfs-server.service nfs-kernel-server.service
After=smb.service
Before=rpc-statd-notify.service
Wants=zfs-mount.service

View File

@ -76,7 +76,6 @@ COMMON_H = \
sys/sa_impl.h \
sys/skein.h \
sys/spa.h \
sys/spa_boot.h \
sys/spa_checkpoint.h \
sys/spa_checksum.h \
sys/spa_impl.h \

View File

@ -56,13 +56,6 @@ extern "C" {
#define UU_ERROR_SYSTEM 99 /* underlying system error */
#define UU_ERROR_UNKNOWN 100 /* error status not known */
/*
* Standard program exit codes.
*/
#define UU_EXIT_OK (*(uu_exit_ok()))
#define UU_EXIT_FATAL (*(uu_exit_fatal()))
#define UU_EXIT_USAGE (*(uu_exit_usage()))
/*
* Exit status profiles.
*/
@ -75,32 +68,6 @@ extern "C" {
uint32_t uu_error(void);
const char *uu_strerror(uint32_t);
/*
* Program notification functions.
*/
extern void uu_alt_exit(int);
extern const char *uu_setpname(char *);
extern const char *uu_getpname(void);
extern void uu_warn(const char *, ...)
__attribute__((format(printf, 1, 2)));
extern void uu_vwarn(const char *, va_list)
__attribute__((format(printf, 1, 0)));
extern __attribute__((noreturn)) void uu_die(const char *, ...)
__attribute__((format(printf, 1, 2)));
extern __attribute__((noreturn)) void uu_vdie(const char *, va_list)
__attribute__((format(printf, 1, 0)));
extern __attribute__((noreturn)) void uu_xdie(int, const char *, ...)
__attribute__((format(printf, 2, 3)));
extern __attribute__((noreturn)) void uu_vxdie(int, const char *, va_list)
__attribute__((format(printf, 2, 0)));
/*
* Exit status functions (not to be used directly)
*/
extern int *uu_exit_ok(void);
extern int *uu_exit_fatal(void);
extern int *uu_exit_usage(void);
/*
* Identifier test flags and function.
*/

View File

@ -21,7 +21,7 @@
/*
* Copyright (c) 2005, 2010, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2011, 2020 by Delphix. All rights reserved.
* Copyright (c) 2011, 2022 by Delphix. All rights reserved.
* Copyright Joyent, Inc.
* Copyright (c) 2013 Steven Hartland. All rights reserved.
* Copyright (c) 2016, Intel Corporation.
@ -151,6 +151,7 @@ typedef enum zfs_error {
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_CKSUM, /* insufficient replicas */
EZFS_UNKNOWN
} zfs_error_t;
@ -895,6 +896,7 @@ _LIBZFS_H int zfs_unshare(zfs_handle_t *zhp, const char *mountpoint,
_LIBZFS_H int zfs_unshareall(zfs_handle_t *zhp,
const enum sa_protocol *proto);
_LIBZFS_H void zfs_commit_shares(const enum sa_protocol *proto);
_LIBZFS_H void zfs_truncate_shares(const enum sa_protocol *proto);
_LIBZFS_H int zfs_nicestrtonum(libzfs_handle_t *, const char *, uint64_t *);

View File

@ -21,7 +21,6 @@ noinst_HEADERS = \
%D%/spl/sys/dirent.h \
%D%/spl/sys/disp.h \
%D%/spl/sys/dkio.h \
%D%/spl/sys/extdirent.h \
%D%/spl/sys/fcntl.h \
%D%/spl/sys/file.h \
%D%/spl/sys/freebsd_rwlock.h \
@ -50,6 +49,7 @@ noinst_HEADERS = \
%D%/spl/sys/sid.h \
%D%/spl/sys/sig.h \
%D%/spl/sys/simd.h \
%D%/spl/sys/simd_powerpc.h \
%D%/spl/sys/simd_x86.h \
%D%/spl/sys/spl_condvar.h \
%D%/spl/sys/string.h \

View File

@ -83,7 +83,6 @@
#define __printf(a, b) __printflike(a, b)
#define barrier() __asm__ __volatile__("": : :"memory")
#define smp_rmb() rmb()
#define ___PASTE(a, b) a##b
#define __PASTE(a, b) ___PASTE(a, b)

View File

@ -57,7 +57,9 @@ extern uint64_t atomic_cas_64(volatile uint64_t *target, uint64_t cmp,
uint64_t newval);
#endif
#define membar_producer atomic_thread_fence_rel
#define membar_consumer() atomic_thread_fence_acq()
#define membar_producer() atomic_thread_fence_rel()
#define membar_sync() atomic_thread_fence_seq_cst()
static __inline uint32_t
atomic_add_32_nv(volatile uint32_t *target, int32_t delta)

View File

@ -31,6 +31,8 @@
#include <sys/proc.h>
#define KPREEMPT_SYNC (-1)
#define kpreempt(x) kern_yield(PRI_USER)
#endif /* _OPENSOLARIS_SYS_DISP_H_ */

View File

@ -1,71 +0,0 @@
/*
* 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 https://opensource.org/licenses/CDDL-1.0.
* 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 2007 Sun Microsystems, Inc. All rights reserved.
* Use is subject to license terms.
*/
#ifndef _SYS_EXTDIRENT_H
#define _SYS_EXTDIRENT_H
#ifdef __cplusplus
extern "C" {
#endif
#include <sys/types.h>
#include <sys/dirent.h>
/*
* Extended file-system independent directory entry. This style of
* dirent provides additional informational flag bits for each
* directory entry. This dirent will be returned instead of the
* standard dirent if a VOP_READDIR() requests dirent flags via
* V_RDDIR_ENTFLAGS, and if the file system supports the flags.
*/
typedef struct edirent {
ino64_t ed_ino; /* "inode number" of entry */
off64_t ed_off; /* offset of disk directory entry */
uint32_t ed_eflags; /* per-entry flags */
unsigned short ed_reclen; /* length of this record */
char ed_name[1]; /* name of file */
} edirent_t;
#define EDIRENT_RECLEN(namelen) \
((offsetof(edirent_t, ed_name[0]) + 1 + (namelen) + 7) & ~ 7)
#define EDIRENT_NAMELEN(reclen) \
((reclen) - (offsetof(edirent_t, ed_name[0])))
/*
* Extended entry flags
* Extended entries include a bitfield of extra information
* regarding that entry.
*/
#define ED_CASE_CONFLICT 0x10 /* Disconsidering case, entry is not unique */
/*
* Extended flags accessor function
*/
#define ED_CASE_CONFLICTS(x) ((x)->ed_eflags & ED_CASE_CONFLICT)
#ifdef __cplusplus
}
#endif
#endif /* _SYS_EXTDIRENT_H */

View File

@ -31,10 +31,6 @@
#include <sys/sysctl.h>
#define EXPORT_SYMBOL(x)
#define module_param(a, b, c)
#define MODULE_PARM_DESC(a, b)
#define ZMOD_RW CTLFLAG_RWTUN
#define ZMOD_RD CTLFLAG_RDTUN
@ -47,7 +43,7 @@
#define ZFS_MODULE_PARAM_CALL_IMPL(parent, name, perm, args, desc) \
SYSCTL_DECL(parent); \
SYSCTL_PROC(parent, OID_AUTO, name, perm | args, desc)
SYSCTL_PROC(parent, OID_AUTO, name, CTLFLAG_MPSAFE | perm | args, desc)
#define ZFS_MODULE_PARAM_CALL( \
scope_prefix, name_prefix, name, func, _, perm, desc) \
@ -59,15 +55,21 @@
#define param_set_arc_long_args(var) \
CTLTYPE_ULONG, &var, 0, param_set_arc_long, "LU"
#define param_set_arc_min_args(var) \
CTLTYPE_ULONG, &var, 0, param_set_arc_min, "LU"
#define param_set_arc_max_args(var) \
CTLTYPE_ULONG, &var, 0, param_set_arc_max, "LU"
#define param_set_arc_int_args(var) \
CTLTYPE_INT, &var, 0, param_set_arc_int, "I"
#define param_set_arc_min_args(var) \
CTLTYPE_ULONG, NULL, 0, param_set_arc_min, "LU"
#define param_set_arc_max_args(var) \
CTLTYPE_ULONG, NULL, 0, param_set_arc_max, "LU"
#define param_set_arc_free_target_args(var) \
CTLTYPE_UINT, NULL, 0, param_set_arc_free_target, "IU"
#define param_set_arc_no_grow_shift_args(var) \
CTLTYPE_INT, NULL, 0, param_set_arc_no_grow_shift, "I"
#define param_set_deadman_failmode_args(var) \
CTLTYPE_STRING, NULL, 0, param_set_deadman_failmode, "A"
@ -78,20 +80,23 @@
CTLTYPE_ULONG, NULL, 0, param_set_deadman_ziotime, "LU"
#define param_set_multihost_interval_args(var) \
CTLTYPE_ULONG, &var, 0, param_set_multihost_interval, "LU"
CTLTYPE_ULONG, NULL, 0, param_set_multihost_interval, "LU"
#define param_set_slop_shift_args(var) \
CTLTYPE_INT, &var, 0, param_set_slop_shift, "I"
CTLTYPE_INT, NULL, 0, param_set_slop_shift, "I"
#define param_set_min_auto_ashift_args(var) \
CTLTYPE_U64, &var, 0, param_set_min_auto_ashift, "QU"
CTLTYPE_U64, NULL, 0, param_set_min_auto_ashift, "QU"
#define param_set_max_auto_ashift_args(var) \
CTLTYPE_U64, &var, 0, param_set_max_auto_ashift, "QU"
CTLTYPE_U64, NULL, 0, param_set_max_auto_ashift, "QU"
#define fletcher_4_param_set_args(var) \
CTLTYPE_STRING, NULL, 0, fletcher_4_param, "A"
#define blake3_param_set_args(var) \
CTLTYPE_STRING, NULL, 0, blake3_param, "A"
#include <sys/kernel.h>
#define module_init(fn) \
static void \

View File

@ -26,13 +26,16 @@
* $FreeBSD$
*/
#ifndef _FREEBSD_SIMD_H
#define _FREEBSD_SIMD_H
#if defined(__amd64__) || defined(__i386__)
#include <sys/simd_x86.h>
#else
#elif defined(__powerpc__)
#include <sys/simd_powerpc.h>
#else
#define kfpu_allowed() 0
#define kfpu_initialize(tsk) do {} while (0)
#define kfpu_begin() do {} while (0)
@ -40,4 +43,5 @@
#define kfpu_init() (0)
#define kfpu_fini() do {} while (0)
#endif
#endif

View File

@ -0,0 +1,90 @@
/*
* 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 https://opensource.org/licenses/CDDL-1.0.
* 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) 2022 Tino Reichardt <milky-zfs@mcmilk.de>
*/
/*
* USER API:
*
* Kernel fpu methods:
* kfpu_allowed()
* kfpu_begin()
* kfpu_end()
* kfpu_init()
* kfpu_fini()
*
* SIMD support:
*
* Following functions should be called to determine whether CPU feature
* is supported. All functions are usable in kernel and user space.
* If a SIMD algorithm is using more than one instruction set
* all relevant feature test functions should be called.
*
* Supported features:
* zfs_altivec_available()
* zfs_vsx_available()
* zfs_isa207_available()
*/
#ifndef _FREEBSD_SIMD_POWERPC_H
#define _FREEBSD_SIMD_POWERPC_H
#include <sys/types.h>
#include <sys/cdefs.h>
#include <machine/pcb.h>
#include <powerpc/cpu.h>
#define kfpu_allowed() 1
#define kfpu_initialize(tsk) do {} while (0)
#define kfpu_begin() do {} while (0)
#define kfpu_end() do {} while (0)
#define kfpu_init() (0)
#define kfpu_fini() do {} while (0)
/*
* Check if Altivec is available
*/
static inline boolean_t
zfs_altivec_available(void)
{
return ((cpu_features & PPC_FEATURE_HAS_ALTIVEC) != 0);
}
/*
* Check if VSX is available
*/
static inline boolean_t
zfs_vsx_available(void)
{
return ((cpu_features & PPC_FEATURE_HAS_VSX) != 0);
}
/*
* Check if POWER ISA 2.07 is available (SHA2)
*/
static inline boolean_t
zfs_isa207_available(void)
{
return ((cpu_features2 & PPC_FEATURE2_ARCH_2_07) != 0);
}

View File

@ -77,7 +77,7 @@ __simd_state_enabled(const uint64_t state)
boolean_t has_osxsave;
uint64_t xcr0;
has_osxsave = !!(cpu_feature2 & CPUID2_OSXSAVE);
has_osxsave = (cpu_feature2 & CPUID2_OSXSAVE) != 0;
if (!has_osxsave)
return (B_FALSE);
@ -99,7 +99,7 @@ __simd_state_enabled(const uint64_t state)
static inline boolean_t
zfs_sse_available(void)
{
return (!!(cpu_feature & CPUID_SSE));
return ((cpu_feature & CPUID_SSE) != 0);
}
/*
@ -108,7 +108,7 @@ zfs_sse_available(void)
static inline boolean_t
zfs_sse2_available(void)
{
return (!!(cpu_feature & CPUID_SSE2));
return ((cpu_feature & CPUID_SSE2) != 0);
}
/*
@ -117,7 +117,7 @@ zfs_sse2_available(void)
static inline boolean_t
zfs_sse3_available(void)
{
return (!!(cpu_feature2 & CPUID2_SSE3));
return ((cpu_feature2 & CPUID2_SSE3) != 0);
}
/*
@ -126,7 +126,7 @@ zfs_sse3_available(void)
static inline boolean_t
zfs_ssse3_available(void)
{
return (!!(cpu_feature2 & CPUID2_SSSE3));
return ((cpu_feature2 & CPUID2_SSSE3) != 0);
}
/*
@ -135,7 +135,7 @@ zfs_ssse3_available(void)
static inline boolean_t
zfs_sse4_1_available(void)
{
return (!!(cpu_feature2 & CPUID2_SSE41));
return ((cpu_feature2 & CPUID2_SSE41) != 0);
}
/*
@ -144,7 +144,7 @@ zfs_sse4_1_available(void)
static inline boolean_t
zfs_sse4_2_available(void)
{
return (!!(cpu_feature2 & CPUID2_SSE42));
return ((cpu_feature2 & CPUID2_SSE42) != 0);
}
/*
@ -155,7 +155,7 @@ zfs_avx_available(void)
{
boolean_t has_avx;
has_avx = !!(cpu_feature2 & CPUID2_AVX);
has_avx = (cpu_feature2 & CPUID2_AVX) != 0;
return (has_avx && __ymm_enabled());
}
@ -168,7 +168,7 @@ zfs_avx2_available(void)
{
boolean_t has_avx2;
has_avx2 = !!(cpu_stdext_feature & CPUID_STDEXT_AVX2);
has_avx2 = (cpu_stdext_feature & CPUID_STDEXT_AVX2) != 0;
return (has_avx2 && __ymm_enabled());
}
@ -196,7 +196,7 @@ zfs_avx512f_available(void)
{
boolean_t has_avx512;
has_avx512 = !!(cpu_stdext_feature & CPUID_STDEXT_AVX512F);
has_avx512 = (cpu_stdext_feature & CPUID_STDEXT_AVX512F) != 0;
return (has_avx512 && __zmm_enabled());
}
@ -207,8 +207,8 @@ zfs_avx512cd_available(void)
{
boolean_t has_avx512;
has_avx512 = !!(cpu_stdext_feature & CPUID_STDEXT_AVX512F) &&
!!(cpu_stdext_feature & CPUID_STDEXT_AVX512CD);
has_avx512 = (cpu_stdext_feature & CPUID_STDEXT_AVX512F) != 0 &&
(cpu_stdext_feature & CPUID_STDEXT_AVX512CD) != 0;
return (has_avx512 && __zmm_enabled());
}
@ -219,8 +219,8 @@ zfs_avx512er_available(void)
{
boolean_t has_avx512;
has_avx512 = !!(cpu_stdext_feature & CPUID_STDEXT_AVX512F) &&
!!(cpu_stdext_feature & CPUID_STDEXT_AVX512CD);
has_avx512 = (cpu_stdext_feature & CPUID_STDEXT_AVX512F) != 0 &&
(cpu_stdext_feature & CPUID_STDEXT_AVX512CD) != 0;
return (has_avx512 && __zmm_enabled());
}
@ -231,8 +231,8 @@ zfs_avx512pf_available(void)
{
boolean_t has_avx512;
has_avx512 = !!(cpu_stdext_feature & CPUID_STDEXT_AVX512F) &&
!!(cpu_stdext_feature & CPUID_STDEXT_AVX512PF);
has_avx512 = (cpu_stdext_feature & CPUID_STDEXT_AVX512F) != 0 &&
(cpu_stdext_feature & CPUID_STDEXT_AVX512PF) != 0;
return (has_avx512 && __zmm_enabled());
}
@ -243,7 +243,7 @@ zfs_avx512bw_available(void)
{
boolean_t has_avx512 = B_FALSE;
has_avx512 = !!(cpu_stdext_feature & CPUID_STDEXT_AVX512BW);
has_avx512 = (cpu_stdext_feature & CPUID_STDEXT_AVX512BW) != 0;
return (has_avx512 && __zmm_enabled());
}
@ -254,8 +254,8 @@ zfs_avx512dq_available(void)
{
boolean_t has_avx512;
has_avx512 = !!(cpu_stdext_feature & CPUID_STDEXT_AVX512F) &&
!!(cpu_stdext_feature & CPUID_STDEXT_AVX512DQ);
has_avx512 = (cpu_stdext_feature & CPUID_STDEXT_AVX512F) != 0 &&
(cpu_stdext_feature & CPUID_STDEXT_AVX512DQ) != 0;
return (has_avx512 && __zmm_enabled());
}
@ -266,8 +266,8 @@ zfs_avx512vl_available(void)
{
boolean_t has_avx512;
has_avx512 = !!(cpu_stdext_feature & CPUID_STDEXT_AVX512F) &&
!!(cpu_stdext_feature & CPUID_STDEXT_AVX512VL);
has_avx512 = (cpu_stdext_feature & CPUID_STDEXT_AVX512F) != 0 &&
(cpu_stdext_feature & CPUID_STDEXT_AVX512VL) != 0;
return (has_avx512 && __zmm_enabled());
}
@ -278,8 +278,8 @@ zfs_avx512ifma_available(void)
{
boolean_t has_avx512;
has_avx512 = !!(cpu_stdext_feature & CPUID_STDEXT_AVX512F) &&
!!(cpu_stdext_feature & CPUID_STDEXT_AVX512IFMA);
has_avx512 = (cpu_stdext_feature & CPUID_STDEXT_AVX512F) != 0 &&
(cpu_stdext_feature & CPUID_STDEXT_AVX512IFMA) != 0;
return (has_avx512 && __zmm_enabled());
}
@ -290,8 +290,8 @@ zfs_avx512vbmi_available(void)
{
boolean_t has_avx512;
has_avx512 = !!(cpu_stdext_feature & CPUID_STDEXT_AVX512F) &&
!!(cpu_stdext_feature & CPUID_STDEXT_BMI1);
has_avx512 = (cpu_stdext_feature & CPUID_STDEXT_AVX512F) != 0 &&
(cpu_stdext_feature & CPUID_STDEXT_BMI1) != 0;
return (has_avx512 && __zmm_enabled());
}

View File

@ -33,6 +33,4 @@
#define usleep_range(wakeup, wakeupepsilon) \
pause_sbt("usleep_range", ustosbt(wakeup), \
ustosbt(wakeupepsilon - wakeup), 0)
#define schedule() pause("schedule", 1)
#endif

View File

@ -117,9 +117,5 @@ typedef uint64_t vfs_feature_t;
#define VFSFT_ZEROCOPY_SUPPORTED 0x100000200
/* Support loaning /returning cache buffer */
#define vfs_set_feature(vfsp, feature) do { } while (0)
#define vfs_clear_feature(vfsp, feature) do { } while (0)
#define vfs_has_feature(vfsp, feature) (0)
#include <sys/mount.h>
#endif /* _OPENSOLARIS_SYS_VFS_H_ */

View File

@ -44,8 +44,6 @@
#define IS_DEVVP(vp) \
((vp)->v_type == VCHR || (vp)->v_type == VBLK || (vp)->v_type == VFIFO)
#define V_XATTRDIR 0x0000 /* attribute unnamed directory */
#define AV_SCANSTAMP_SZ 32 /* length of anti-virus scanstamp */
/*
@ -193,11 +191,6 @@
#define MODEMASK 07777 /* mode bits plus permission bits */
#define PERMMASK 00777 /* permission bits */
/*
* VOP_ACCESS flags
*/
#define V_ACE_MASK 0x1 /* mask represents NFSv4 ACE permissions */
/*
* Flags for vnode operations.
*/
@ -234,12 +227,6 @@ struct taskq;
#define CREATE_XATTR_DIR 0x04 /* Create extended attr dir */
#define LOOKUP_HAVE_SYSATTR_DIR 0x08 /* Already created virtual GFS dir */
/*
* Flags for VOP_READDIR
*/
#define V_RDDIR_ENTFLAGS 0x01 /* request dirent flags */
#define V_RDDIR_ACCFILTER 0x02 /* filter out inaccessible dirents */
/*
* Public vnode manipulation functions.
*/

View File

@ -0,0 +1,34 @@
/*
* SPDX-License-Identifier: BSD-2-Clause-FreeBSD
*
* Copyright (c) 2022 Martin Matuska
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
*
* THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
* ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
* OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
*/
#ifndef _SYS_ARC_OS_H
#define _SYS_ARC_OS_H
int param_set_arc_free_target(SYSCTL_HANDLER_ARGS);
int param_set_arc_no_grow_shift(SYSCTL_HANDLER_ARGS);
#endif

View File

@ -0,0 +1,37 @@
/*
* SPDX-License-Identifier: BSD-2-Clause-FreeBSD
*
* Copyright (c) 2022 Rob Wing
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
*
* THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
* ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
* OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
*/
#ifndef _ZFS_FREEBSD_EVENT_H
#define _ZFS_FREEBSD_EVENT_H
#ifdef _KERNEL
void knlist_init_sx(struct knlist *knl, struct sx *lock);
#endif /* !_KERNEL */
#endif /* !_ZFS_FREEBSD_EVENT_H */

View File

@ -45,8 +45,6 @@
#define HAVE_LARGE_STACKS 1
#endif
#define cond_resched() kern_yield(PRI_USER)
#define taskq_create_sysdc(a, b, d, e, p, dc, f) \
((void) sizeof (dc), taskq_create(a, b, maxclsyspri, d, e, f))

View File

@ -128,9 +128,6 @@ struct zfsvfs {
#define ZFS_TEARDOWN_DESTROY(zfsvfs) \
rms_destroy(&(zfsvfs)->z_teardown_lock)
#define ZFS_TEARDOWN_TRY_ENTER_READ(zfsvfs) \
rms_try_rlock(&(zfsvfs)->z_teardown_lock)
#define ZFS_TEARDOWN_ENTER_READ(zfsvfs, tag) \
rms_rlock(&(zfsvfs)->z_teardown_lock);
@ -161,9 +158,6 @@ struct zfsvfs {
#define ZFS_TEARDOWN_DESTROY(zfsvfs) \
rrm_destroy(&(zfsvfs)->z_teardown_lock)
#define ZFS_TEARDOWN_TRY_ENTER_READ(zfsvfs) \
rw_tryenter(&(zfsvfs)->z_teardown_lock, RW_READER)
#define ZFS_TEARDOWN_ENTER_READ(zfsvfs, tag) \
rrm_enter_read(&(zfsvfs)->z_teardown_lock, tag);

View File

@ -121,29 +121,24 @@ typedef struct zfs_soft_state {
#define zn_rlimit_fsize(zp, uio) \
vn_rlimit_fsize(ZTOV(zp), GET_UIO_STRUCT(uio), zfs_uio_td(uio))
#define ZFS_ENTER_ERROR(zfsvfs, error) do { \
ZFS_TEARDOWN_ENTER_READ((zfsvfs), FTAG); \
if (__predict_false((zfsvfs)->z_unmounted)) { \
ZFS_TEARDOWN_EXIT_READ(zfsvfs, FTAG); \
return (error); \
} \
} while (0)
/* Called on entry to each ZFS vnode and vfs operation */
#define ZFS_ENTER(zfsvfs) ZFS_ENTER_ERROR(zfsvfs, EIO)
static inline int
zfs_enter(zfsvfs_t *zfsvfs, const char *tag)
{
ZFS_TEARDOWN_ENTER_READ(zfsvfs, tag);
if (__predict_false((zfsvfs)->z_unmounted)) {
ZFS_TEARDOWN_EXIT_READ(zfsvfs, tag);
return (SET_ERROR(EIO));
}
return (0);
}
/* Must be called before exiting the vop */
#define ZFS_EXIT(zfsvfs) ZFS_TEARDOWN_EXIT_READ(zfsvfs, FTAG)
#define ZFS_VERIFY_ZP_ERROR(zp, error) do { \
if (__predict_false((zp)->z_sa_hdl == NULL)) { \
ZFS_EXIT((zp)->z_zfsvfs); \
return (error); \
} \
} while (0)
/* Verifies the znode is valid */
#define ZFS_VERIFY_ZP(zp) ZFS_VERIFY_ZP_ERROR(zp, EIO)
static inline void
zfs_exit(zfsvfs_t *zfsvfs, const char *tag)
{
ZFS_TEARDOWN_EXIT_READ(zfsvfs, tag);
}
/*
* Macros for dealing with dmu_buf_hold

View File

@ -21,6 +21,7 @@
/*
* Copyright (C) 2019 Romain Dolbeau
* <romain.dolbeau@european-processor-initiative.eu>
* Copyright (C) 2022 Tino Reichardt <milky-zfs@mcmilk.de>
*/
/*
@ -41,7 +42,9 @@
* all relevant feature test functions should be called.
*
* Supported features:
* zfs_altivec_available()
* zfs_altivec_available()
* zfs_vsx_available()
* zfs_isa207_available()
*/
#ifndef _LINUX_SIMD_POWERPC_H
@ -57,73 +60,65 @@
#include <sys/types.h>
#include <linux/version.h>
#if LINUX_VERSION_CODE >= KERNEL_VERSION(4, 7, 0)
#include <asm/cpufeature.h>
#else
#include <asm/cputable.h>
#endif
#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(); \
enable_kernel_spe(); \
}
#define kfpu_end() \
{ \
disable_kernel_spe(); \
disable_kernel_vsx(); \
disable_kernel_altivec(); \
preempt_enable(); \
}
#else
/* 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
*/
static inline boolean_t
zfs_altivec_available(void)
{
boolean_t res;
/* suggested by macallan at netbsd dot org */
#if defined(__powerpc64__)
u64 msr;
#else
u32 msr;
#endif
kfpu_begin();
__asm volatile("mfmsr %0" : "=r"(msr));
/*
* 64 bits -> need to check bit 38
* Power ISA Version 3.0B
* p944
* 32 bits -> Need to check bit 6
* AltiVec Technology Programming Environments Manual
* p49 (2-9)
* They are the same, as ppc counts 'backward' ...
*/
res = (msr & 0x2000000) != 0;
kfpu_end();
return (res);
return (cpu_has_feature(CPU_FTR_ALTIVEC));
}
/*
* Check if VSX is available
*/
static inline boolean_t
zfs_vsx_available(void)
{
return (cpu_has_feature(CPU_FTR_VSX));
}
/*
* Check if POWER ISA 2.07 is available (SHA2)
*/
static inline boolean_t
zfs_isa207_available(void)
{
return (cpu_has_feature(CPU_FTR_ARCH_207S));
}
#endif /* defined(__powerpc) */
#endif /* _LINUX_SIMD_POWERPC_H */

View File

@ -115,6 +115,20 @@ fn(struct dentry *dentry, const char *name, void *buffer, size_t size, \
{ \
return (__ ## fn(dentry->d_inode, name, buffer, size)); \
}
/*
* Android API change,
* The xattr_handler->get() callback was changed to take a dentry and inode
* and flags, because the dentry might not be attached to an inode yet.
*/
#elif defined(HAVE_XATTR_GET_DENTRY_INODE_FLAGS)
#define ZPL_XATTR_GET_WRAPPER(fn) \
static int \
fn(const struct xattr_handler *handler, struct dentry *dentry, \
struct inode *inode, const char *name, void *buffer, \
size_t size, int flags) \
{ \
return (__ ## fn(inode, name, buffer, size)); \
}
#else
#error "Unsupported kernel"
#endif

View File

@ -26,7 +26,9 @@
#include <linux/preempt.h>
#define kpreempt(unused) schedule()
#define KPREEMPT_SYNC (-1)
#define kpreempt(unused) cond_resched()
#define kpreempt_disable() preempt_disable()
#define kpreempt_enable() preempt_enable()

View File

@ -44,7 +44,10 @@
#define zfs_totalhigh_pages totalhigh_pages
#endif
#define membar_consumer() smp_rmb()
#define membar_producer() smp_wmb()
#define membar_sync() smp_mb()
#define physmem zfs_totalram_pages
#define xcopyin(from, to, size) copy_from_user(to, from, size)

View File

@ -143,9 +143,6 @@ struct zfsvfs {
#define ZFS_TEARDOWN_DESTROY(zfsvfs) \
rrm_destroy(&(zfsvfs)->z_teardown_lock)
#define ZFS_TEARDOWN_TRY_ENTER_READ(zfsvfs) \
rw_tryenter(&(zfsvfs)->z_teardown_lock, RW_READER)
#define ZFS_TEARDOWN_ENTER_READ(zfsvfs, tag) \
rrm_enter_read(&(zfsvfs)->z_teardown_lock, tag);

View File

@ -84,39 +84,41 @@ extern "C" {
#define zrele(zp) iput(ZTOI((zp)))
/* Called on entry to each ZFS inode and vfs operation. */
#define ZFS_ENTER_ERROR(zfsvfs, error) \
do { \
ZFS_TEARDOWN_ENTER_READ(zfsvfs, FTAG); \
if (unlikely((zfsvfs)->z_unmounted)) { \
ZFS_TEARDOWN_EXIT_READ(zfsvfs, FTAG); \
return (error); \
} \
} while (0)
#define ZFS_ENTER(zfsvfs) ZFS_ENTER_ERROR(zfsvfs, EIO)
#define ZPL_ENTER(zfsvfs) ZFS_ENTER_ERROR(zfsvfs, -EIO)
static inline int
zfs_enter(zfsvfs_t *zfsvfs, const char *tag)
{
ZFS_TEARDOWN_ENTER_READ(zfsvfs, tag);
if (unlikely(zfsvfs->z_unmounted)) {
ZFS_TEARDOWN_EXIT_READ(zfsvfs, tag);
return (SET_ERROR(EIO));
}
return (0);
}
/* Must be called before exiting the operation. */
#define ZFS_EXIT(zfsvfs) \
do { \
zfs_exit_fs(zfsvfs); \
ZFS_TEARDOWN_EXIT_READ(zfsvfs, FTAG); \
} while (0)
static inline void
zfs_exit(zfsvfs_t *zfsvfs, const char *tag)
{
zfs_exit_fs(zfsvfs);
ZFS_TEARDOWN_EXIT_READ(zfsvfs, tag);
}
#define ZPL_EXIT(zfsvfs) \
do { \
rrm_exit(&(zfsvfs)->z_teardown_lock, FTAG); \
} while (0)
static inline int
zpl_enter(zfsvfs_t *zfsvfs, const char *tag)
{
return (-zfs_enter(zfsvfs, tag));
}
/* Verifies the znode is valid. */
#define ZFS_VERIFY_ZP_ERROR(zp, error) \
do { \
if (unlikely((zp)->z_sa_hdl == NULL)) { \
ZFS_EXIT(ZTOZSB(zp)); \
return (error); \
} \
} while (0)
#define ZFS_VERIFY_ZP(zp) ZFS_VERIFY_ZP_ERROR(zp, EIO)
#define ZPL_VERIFY_ZP(zp) ZFS_VERIFY_ZP_ERROR(zp, -EIO)
static inline void
zpl_exit(zfsvfs_t *zfsvfs, const char *tag)
{
ZFS_TEARDOWN_EXIT_READ(zfsvfs, tag);
}
/* zfs_verify_zp and zfs_enter_verify_zp are defined in zfs_znode.h */
#define zpl_verify_zp(zp) (-zfs_verify_zp(zp))
#define zpl_enter_verify_zp(zfsvfs, zp, tag) \
(-zfs_enter_verify_zp(zfsvfs, zp, tag))
/*
* Macros for dealing with dmu_buf_hold

View File

@ -72,7 +72,7 @@ typedef struct {
*/
uint8_t cv_stack[(BLAKE3_MAX_DEPTH + 1) * BLAKE3_OUT_LEN];
/* const blake3_impl_ops_t *ops */
/* const blake3_ops_t *ops */
const void *ops;
} BLAKE3_CTX;
@ -97,26 +97,23 @@ 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);
/* get count of supported implementations */
extern uint32_t blake3_impl_getcnt(void);
/* return id of selected implementation */
extern int blake3_get_impl_id(void);
/* get id of selected implementation */
extern uint32_t blake3_impl_getid(void);
/* return name of selected implementation */
extern const char *blake3_get_impl_name(void);
/* get name of selected implementation */
extern const char *blake3_impl_getname(void);
/* setup id as fastest implementation */
extern void blake3_set_impl_fastest(uint32_t id);
extern void blake3_impl_set_fastest(uint32_t id);
/* set implementation by id */
extern void blake3_set_impl_id(uint32_t id);
extern void blake3_impl_setid(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);
extern int blake3_impl_setname(const char *name);
#ifdef __cplusplus
}

View File

@ -30,22 +30,22 @@ typedef struct bqueue {
kmutex_t bq_lock;
kcondvar_t bq_add_cv;
kcondvar_t bq_pop_cv;
uint64_t bq_size;
uint64_t bq_maxsize;
uint64_t bq_fill_fraction;
size_t bq_size;
size_t bq_maxsize;
uint_t bq_fill_fraction;
size_t bq_node_offset;
} bqueue_t;
typedef struct bqueue_node {
list_node_t bqn_node;
uint64_t bqn_size;
size_t bqn_size;
} bqueue_node_t;
int bqueue_init(bqueue_t *, uint64_t, uint64_t, size_t);
int bqueue_init(bqueue_t *, uint_t, size_t, size_t);
void bqueue_destroy(bqueue_t *);
void bqueue_enqueue(bqueue_t *, void *, uint64_t);
void bqueue_enqueue_flush(bqueue_t *, void *, uint64_t);
void bqueue_enqueue(bqueue_t *, void *, size_t);
void bqueue_enqueue_flush(bqueue_t *, void *, size_t);
void *bqueue_dequeue(bqueue_t *);
boolean_t bqueue_empty(bqueue_t *);

View File

@ -136,7 +136,7 @@ typedef enum dmu_object_byteswap {
#endif
#define DMU_OT_IS_METADATA(ot) (((ot) & DMU_OT_NEWTYPE) ? \
((ot) & DMU_OT_METADATA) : \
(((ot) & DMU_OT_METADATA) != 0) : \
DMU_OT_IS_METADATA_IMPL(ot))
#define DMU_OT_IS_DDT(ot) \
@ -147,7 +147,7 @@ typedef enum dmu_object_byteswap {
((ot) == DMU_OT_PLAIN_FILE_CONTENTS || (ot) == DMU_OT_UINT64_OTHER)
#define DMU_OT_IS_ENCRYPTED(ot) (((ot) & DMU_OT_NEWTYPE) ? \
((ot) & DMU_OT_ENCRYPTED) : \
(((ot) & DMU_OT_ENCRYPTED) != 0) : \
DMU_OT_IS_ENCRYPTED_IMPL(ot))
/*

View File

@ -301,6 +301,14 @@ typedef struct dsl_dataset_snapshot_arg {
proc_t *ddsa_proc;
} dsl_dataset_snapshot_arg_t;
typedef struct dsl_dataset_rename_snapshot_arg {
const char *ddrsa_fsname;
const char *ddrsa_oldsnapname;
const char *ddrsa_newsnapname;
boolean_t ddrsa_recursive;
dmu_tx_t *ddrsa_tx;
} dsl_dataset_rename_snapshot_arg_t;
/*
* The max length of a temporary tag prefix is the number of hex digits
* required to express UINT64_MAX plus one for the hyphen.
@ -375,7 +383,6 @@ boolean_t dsl_dataset_modified_since_snap(dsl_dataset_t *ds,
void dsl_dataset_sync(dsl_dataset_t *ds, zio_t *zio, dmu_tx_t *tx);
void dsl_dataset_sync_done(dsl_dataset_t *ds, dmu_tx_t *tx);
void dsl_dataset_feature_set_activation(const blkptr_t *bp, dsl_dataset_t *ds);
void dsl_dataset_block_born(dsl_dataset_t *ds, const blkptr_t *bp,
dmu_tx_t *tx);
int dsl_dataset_block_kill(dsl_dataset_t *ds, const blkptr_t *bp,
@ -474,6 +481,9 @@ void dsl_dataset_rollback_sync(void *arg, dmu_tx_t *tx);
int dsl_dataset_rollback(const char *fsname, const char *tosnap, void *owner,
nvlist_t *result);
int dsl_dataset_rename_snapshot_check(void *arg, dmu_tx_t *tx);
void dsl_dataset_rename_snapshot_sync(void *arg, dmu_tx_t *tx);
uint64_t dsl_dataset_get_remap_deadlist_object(dsl_dataset_t *ds);
void dsl_dataset_create_remap_deadlist(dsl_dataset_t *ds, dmu_tx_t *tx);
boolean_t dsl_dataset_remap_deadlist_exists(dsl_dataset_t *ds);

View File

@ -52,6 +52,7 @@ struct zthr;
#define DD_FIELD_SNAPSHOT_COUNT "com.joyent:snapshot_count"
#define DD_FIELD_CRYPTO_KEY_OBJ "com.datto:crypto_key_obj"
#define DD_FIELD_LIVELIST "com.delphix:livelist"
#define DD_FIELD_SNAPSHOTS_CHANGED "com.ixsystems:snapshots_changed"
typedef enum dd_used {
DD_USED_HEAD,

View File

@ -1758,9 +1758,9 @@ typedef enum {
* against the cost of COWing a giant block to modify one byte, and the
* large latency of reading or writing a large block.
*
* Note that although blocks up to 16MB are supported, the recordsize
* property can not be set larger than zfs_max_recordsize (default 1MB).
* See the comment near zfs_max_recordsize in dsl_dataset.c for details.
* The recordsize property can not be set larger than zfs_max_recordsize
* (default 16MB on 64-bit and 1MB on 32-bit). See the comment near
* zfs_max_recordsize in dsl_dataset.c for details.
*
* Note that although the LSIZE field of the blkptr_t can store sizes up
* to 32MB, the dnode's dn_datablkszsec can only store sizes up to

View File

@ -1,42 +0,0 @@
/*
* 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 https://opensource.org/licenses/CDDL-1.0.
* 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 2009 Sun Microsystems, Inc. All rights reserved.
* Use is subject to license terms.
*/
#ifndef _SYS_SPA_BOOT_H
#define _SYS_SPA_BOOT_H
#include <sys/nvpair.h>
#ifdef __cplusplus
extern "C" {
#endif
extern char *spa_get_bootprop(char *prop);
extern void spa_free_bootprop(char *prop);
#ifdef __cplusplus
}
#endif
#endif /* _SYS_SPA_BOOT_H */

View File

@ -244,6 +244,9 @@ extern "C" {
#define DEV_PATH "path"
#define DEV_IS_PART "is_slice"
#define DEV_SIZE "dev_size"
/* Size of the whole parent block device (if dev is a partition) */
#define DEV_PARENT_SIZE "dev_parent_size"
#endif /* __linux__ */
#define EV_V1 1

View File

@ -641,6 +641,7 @@ extern int vdev_obsolete_counts_are_precise(vdev_t *vd, boolean_t *are_precise);
*/
int vdev_checkpoint_sm_object(vdev_t *vd, uint64_t *sm_obj);
void vdev_metaslab_group_create(vdev_t *vd);
uint64_t vdev_best_ashift(uint64_t logical, uint64_t a, uint64_t b);
/*
* Vdev ashift optimization tunables

View File

@ -321,7 +321,7 @@ vdev_raidz_exp2(const uint8_t a, const unsigned exp)
* Galois Field operations.
*
* gf_exp2 - computes 2 raised to the given power
* gf_exp2 - computes 4 raised to the given power
* gf_exp4 - computes 4 raised to the given power
* gf_mul - multiplication
* gf_div - division
* gf_inv - multiplicative inverse

View File

@ -219,7 +219,6 @@ typedef pthread_t kthread_t;
#define TS_JOINABLE 0x00000004
#define curthread ((void *)(uintptr_t)pthread_self())
#define kpreempt(x) yield()
#define getcomm() "unknown"
#define thread_create_named(name, stk, stksize, func, arg, len, \
@ -248,9 +247,11 @@ extern kthread_t *zk_thread_create(void (*func)(void *), void *arg,
#define issig(why) (FALSE)
#define ISSIG(thr, why) (FALSE)
#define KPREEMPT_SYNC (-1)
#define kpreempt(x) sched_yield()
#define kpreempt_disable() ((void)0)
#define kpreempt_enable() ((void)0)
#define cond_resched() sched_yield()
/*
* Mutexes

View File

@ -218,6 +218,29 @@ typedef struct znode {
ZNODE_OS_FIELDS;
} znode_t;
/* Verifies the znode is valid. */
static inline int
zfs_verify_zp(znode_t *zp)
{
if (unlikely(zp->z_sa_hdl == NULL))
return (SET_ERROR(EIO));
return (0);
}
/* zfs_enter and zfs_verify_zp together */
static inline int
zfs_enter_verify_zp(zfsvfs_t *zfsvfs, znode_t *zp, const char *tag)
{
int error;
if ((error = zfs_enter(zfsvfs, tag)) != 0)
return (error);
if ((error = zfs_verify_zp(zp)) != 0) {
zfs_exit(zfsvfs, tag);
return (error);
}
return (0);
}
typedef struct znode_hold {
uint64_t zh_obj; /* object id */
kmutex_t zh_lock; /* lock serializing object access */

View File

@ -22,7 +22,7 @@
/*
* Copyright (c) 2002, 2010, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2011 Gunnar Beutner
* Copyright (c) 2018, 2020 by Delphix. All rights reserved.
* Copyright (c) 2018, 2022 by Delphix. All rights reserved.
*/
#include <stdio.h>
@ -96,6 +96,16 @@ sa_commit_shares(enum sa_protocol protocol)
fstypes[protocol]->commit_shares();
}
void
sa_truncate_shares(enum sa_protocol protocol)
{
/* CSTYLED */
VALIDATE_PROTOCOL(protocol, );
if (fstypes[protocol]->truncate_shares != NULL)
fstypes[protocol]->truncate_shares();
}
int
sa_validate_shareopts(const char *options, enum sa_protocol protocol)
{

View File

@ -22,7 +22,7 @@
/*
* Copyright (c) 2002, 2010, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2011 Gunnar Beutner
* Copyright (c) 2019, 2020 by Delphix. All rights reserved.
* Copyright (c) 2019, 2022 by Delphix. All rights reserved.
*/
#ifndef _LIBSPL_LIBSHARE_IMPL_H
#define _LIBSPL_LIBSHARE_IMPL_H
@ -39,6 +39,7 @@ typedef struct {
boolean_t (*const is_shared)(sa_share_impl_t share);
int (*const validate_shareopts)(const char *shareopts);
int (*const commit_shares)(void);
void (*const truncate_shares)(void);
} sa_fstype_t;
extern const sa_fstype_t libshare_nfs_type, libshare_smb_type;

View File

@ -28,6 +28,7 @@
#include <stdio.h>
#include <errno.h>
#include <libshare.h>
#include <unistd.h>
#include "nfs.h"
@ -281,6 +282,17 @@ nfs_toggle_share(const char *lockfile, const char *exports,
return (error);
}
void
nfs_reset_shares(const char *lockfile, const char *exports)
{
int nfs_lock_fd = -1;
if (nfs_exports_lock(lockfile, &nfs_lock_fd) == 0) {
(void) ! truncate(exports, 0);
nfs_exports_unlock(lockfile, &nfs_lock_fd);
}
}
static boolean_t
nfs_is_shared_cb(void *userdata, char *line, boolean_t found_mountpoint)
{

View File

@ -22,6 +22,7 @@
/*
* Copyright (c) 2002, 2010, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2011 Gunnar Beutner
* Copyright (c) 2022 by Delphix. All rights reserved.
*/
#include "libshare_impl.h"
@ -33,3 +34,4 @@ boolean_t nfs_is_shared_impl(const char *exports, sa_share_impl_t impl_share);
int nfs_toggle_share(const char *lockfile, const char *exports,
const char *expdir, sa_share_impl_t impl_share,
int(*cbk)(sa_share_impl_t impl_share, FILE *tmpfile));
void nfs_reset_shares(const char *lockfile, const char *exports);

View File

@ -23,7 +23,7 @@
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
*
* Copyright (c) 2020 by Delphix. All rights reserved.
* Copyright (c) 2020, 2022 by Delphix. All rights reserved.
*/
#include <sys/cdefs.h>
@ -195,6 +195,12 @@ nfs_commit_shares(void)
return (SA_OK);
}
static void
nfs_truncate_shares(void)
{
nfs_reset_shares(ZFS_EXPORTS_LOCK, ZFS_EXPORTS_FILE);
}
const sa_fstype_t libshare_nfs_type = {
.enable_share = nfs_enable_share,
.disable_share = nfs_disable_share,
@ -202,4 +208,5 @@ const sa_fstype_t libshare_nfs_type = {
.validate_shareopts = nfs_validate_shareopts,
.commit_shares = nfs_commit_shares,
.truncate_shares = nfs_truncate_shares,
};

View File

@ -23,7 +23,7 @@
* Copyright (c) 2002, 2010, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2011 Gunnar Beutner
* Copyright (c) 2012 Cyril Plisko. All rights reserved.
* Copyright (c) 2019, 2020 by Delphix. All rights reserved.
* Copyright (c) 2019, 2022 by Delphix. All rights reserved.
*/
#include <dirent.h>
@ -449,7 +449,7 @@ static int
nfs_disable_share(sa_share_impl_t impl_share)
{
if (!nfs_available())
return (SA_SYSTEM_ERR);
return (SA_OK);
return (nfs_toggle_share(
ZFS_EXPORTS_LOCK, ZFS_EXPORTS_FILE, ZFS_EXPORTS_DIR, impl_share,
@ -495,6 +495,12 @@ nfs_commit_shares(void)
return (libzfs_run_process(argv[0], argv, 0));
}
static void
nfs_truncate_shares(void)
{
nfs_reset_shares(ZFS_EXPORTS_LOCK, ZFS_EXPORTS_FILE);
}
const sa_fstype_t libshare_nfs_type = {
.enable_share = nfs_enable_share,
.disable_share = nfs_disable_share,
@ -502,6 +508,7 @@ const sa_fstype_t libshare_nfs_type = {
.validate_shareopts = nfs_validate_shareopts,
.commit_shares = nfs_commit_shares,
.truncate_shares = nfs_truncate_shares,
};
static boolean_t

View File

@ -381,6 +381,12 @@ membar_exit(void)
__atomic_thread_fence(__ATOMIC_SEQ_CST);
}
void
membar_sync(void)
{
__atomic_thread_fence(__ATOMIC_SEQ_CST);
}
void
membar_producer(void)
{

View File

@ -313,6 +313,13 @@ extern void membar_enter(void);
*/
extern void membar_exit(void);
/*
* Make all stores and loads emitted prior to the the barrier complete before
* crossing it, while also making sure stores and loads emitted after the
* barrier only start being executed after crossing it.
*/
extern void membar_sync(void);
/*
* Arrange that all stores issued before this point in the code reach
* global visibility before any stores that follow; useful in producer

View File

@ -22,7 +22,7 @@
/*
* Copyright 2008 Sun Microsystems, Inc. All rights reserved.
* Use is subject to license terms.
* Copyright (c) 2019, 2020 by Delphix. All rights reserved.
* Copyright (c) 2019, 2022 by Delphix. All rights reserved.
*/
#ifndef _LIBSPL_LIBSHARE_H
#define _LIBSPL_LIBSHARE_H extern __attribute__((visibility("default")))
@ -88,6 +88,7 @@ _LIBSPL_LIBSHARE_H int sa_enable_share(const char *, const char *, const char *,
_LIBSPL_LIBSHARE_H int sa_disable_share(const char *, enum sa_protocol);
_LIBSPL_LIBSHARE_H boolean_t sa_is_shared(const char *, enum sa_protocol);
_LIBSPL_LIBSHARE_H void sa_commit_shares(enum sa_protocol);
_LIBSPL_LIBSHARE_H void sa_truncate_shares(enum sa_protocol);
/* protocol specific interfaces */
_LIBSPL_LIBSHARE_H int sa_validate_shareopts(const char *, enum sa_protocol);

View File

@ -20,8 +20,8 @@
* CDDL HEADER END
*/
/*
* Copyright 2006 Sun Microsystems, Inc. All rights reserved.
* Use is subject to license terms.
* Copyright (c) 2006 Sun Microsystems, Inc. All rights reserved.
* Copyright (c) 2022 Tino Reichardt <milky-zfs@mcmilk.de>
*/
#ifndef _LIBSPL_SYS_SIMD_H
@ -452,63 +452,60 @@ zfs_avx512vbmi_available(void)
#elif defined(__powerpc__)
/* including <sys/auxv.h> clashes with AT_UID and others */
extern unsigned long getauxval(unsigned long type);
#if defined(__FreeBSD__)
#define AT_HWCAP 25 /* CPU feature flags. */
#define AT_HWCAP2 26 /* CPU feature flags 2. */
extern int elf_aux_info(int aux, void *buf, int buflen);
static unsigned long getauxval(unsigned long key)
{
unsigned long val = 0UL;
if (elf_aux_info((int)key, &val, sizeof (val)) != 0)
return (0UL);
return (val);
}
#elif defined(__linux__)
#define AT_HWCAP 16 /* CPU feature flags. */
#define AT_HWCAP2 26 /* CPU feature flags 2. */
#endif
#define kfpu_allowed() 1
#define kfpu_initialize(tsk) do {} while (0)
#define kfpu_begin() do {} while (0)
#define kfpu_end() do {} while (0)
/*
* Check if AltiVec instruction set is available
* No easy way beyond 'altivec works' :-(
*/
#include <signal.h>
#include <setjmp.h>
#if defined(__ALTIVEC__) && !defined(__FreeBSD__)
static jmp_buf env;
static void sigillhandler(int x)
{
(void) x;
longjmp(env, 1);
}
#endif
#define PPC_FEATURE_HAS_ALTIVEC 0x10000000
static inline boolean_t
zfs_altivec_available(void)
{
boolean_t has_altivec = B_FALSE;
#if defined(__ALTIVEC__) && !defined(__FreeBSD__)
sighandler_t savesig;
savesig = signal(SIGILL, sigillhandler);
if (setjmp(env)) {
signal(SIGILL, savesig);
has_altivec = B_FALSE;
} else {
__asm__ __volatile__("vor 0,0,0\n" : : : "v0");
signal(SIGILL, savesig);
has_altivec = B_TRUE;
}
#endif
return (has_altivec);
unsigned long hwcap = getauxval(AT_HWCAP);
return (hwcap & PPC_FEATURE_HAS_ALTIVEC);
}
#define PPC_FEATURE_HAS_VSX 0x00000080
static inline boolean_t
zfs_vsx_available(void)
{
boolean_t has_vsx = B_FALSE;
#if defined(__ALTIVEC__) && !defined(__FreeBSD__)
sighandler_t savesig;
savesig = signal(SIGILL, sigillhandler);
if (setjmp(env)) {
signal(SIGILL, savesig);
has_vsx = B_FALSE;
} else {
__asm__ __volatile__("xssubsp 0,0,0\n");
signal(SIGILL, savesig);
has_vsx = B_TRUE;
}
#endif
return (has_vsx);
unsigned long hwcap = getauxval(AT_HWCAP);
return (hwcap & PPC_FEATURE_HAS_VSX);
}
#define PPC_FEATURE2_ARCH_2_07 0x80000000
static inline boolean_t
zfs_isa207_available(void)
{
unsigned long hwcap = getauxval(AT_HWCAP);
unsigned long hwcap2 = getauxval(AT_HWCAP2);
return ((hwcap & PPC_FEATURE_HAS_VSX) &&
(hwcap2 & PPC_FEATURE2_ARCH_2_07));
}
#else
#define kfpu_allowed() 0

View File

@ -9,7 +9,6 @@ libuutil_la_SOURCES = \
%D%/uu_ident.c \
%D%/uu_list.c \
%D%/uu_misc.c \
%D%/uu_pname.c \
%D%/uu_string.c
libuutil_la_LIBADD = \

View File

@ -1744,79 +1744,6 @@
<return type-id='48b5725f'/>
</function-decl>
</abi-instr>
<abi-instr address-size='64' path='uu_pname.c' language='LANG_C99'>
<class-decl name='__va_list_tag' size-in-bits='192' is-struct='yes' visibility='default' id='d5027220'>
<data-member access='public' layout-offset-in-bits='0'>
<var-decl name='gp_offset' type-id='f0981eeb' visibility='default'/>
</data-member>
<data-member access='public' layout-offset-in-bits='32'>
<var-decl name='fp_offset' type-id='f0981eeb' visibility='default'/>
</data-member>
<data-member access='public' layout-offset-in-bits='64'>
<var-decl name='overflow_arg_area' type-id='eaa32e2f' visibility='default'/>
</data-member>
<data-member access='public' layout-offset-in-bits='128'>
<var-decl name='reg_save_area' type-id='eaa32e2f' visibility='default'/>
</data-member>
</class-decl>
<pointer-type-def type-id='d5027220' size-in-bits='64' id='b7f2d5e6'/>
<pointer-type-def type-id='95e97e5e' size-in-bits='64' id='7292109c'/>
<var-decl name='uu_exit_ok_value' type-id='95e97e5e' mangled-name='uu_exit_ok_value' visibility='default' elf-symbol-id='uu_exit_ok_value'/>
<var-decl name='uu_exit_fatal_value' type-id='95e97e5e' mangled-name='uu_exit_fatal_value' visibility='default' elf-symbol-id='uu_exit_fatal_value'/>
<var-decl name='uu_exit_usage_value' type-id='95e97e5e' mangled-name='uu_exit_usage_value' visibility='default' elf-symbol-id='uu_exit_usage_value'/>
<function-decl name='uu_exit_ok' mangled-name='uu_exit_ok' visibility='default' binding='global' size-in-bits='64' elf-symbol-id='uu_exit_ok'>
<return type-id='7292109c'/>
</function-decl>
<function-decl name='uu_exit_fatal' mangled-name='uu_exit_fatal' visibility='default' binding='global' size-in-bits='64' elf-symbol-id='uu_exit_fatal'>
<return type-id='7292109c'/>
</function-decl>
<function-decl name='uu_exit_usage' mangled-name='uu_exit_usage' visibility='default' binding='global' size-in-bits='64' elf-symbol-id='uu_exit_usage'>
<return type-id='7292109c'/>
</function-decl>
<function-decl name='uu_alt_exit' mangled-name='uu_alt_exit' visibility='default' binding='global' size-in-bits='64' elf-symbol-id='uu_alt_exit'>
<parameter type-id='95e97e5e' name='profile'/>
<return type-id='48b5725f'/>
</function-decl>
<function-decl name='uu_vwarn' mangled-name='uu_vwarn' visibility='default' binding='global' size-in-bits='64' elf-symbol-id='uu_vwarn'>
<parameter type-id='80f4b756' name='format'/>
<parameter type-id='b7f2d5e6' name='alist'/>
<return type-id='48b5725f'/>
</function-decl>
<function-decl name='uu_warn' mangled-name='uu_warn' visibility='default' binding='global' size-in-bits='64' elf-symbol-id='uu_warn'>
<parameter type-id='80f4b756' name='format'/>
<parameter is-variadic='yes'/>
<return type-id='48b5725f'/>
</function-decl>
<function-decl name='uu_vdie' mangled-name='uu_vdie' visibility='default' binding='global' size-in-bits='64' elf-symbol-id='uu_vdie'>
<parameter type-id='80f4b756' name='format'/>
<parameter type-id='b7f2d5e6' name='alist'/>
<return type-id='48b5725f'/>
</function-decl>
<function-decl name='uu_die' mangled-name='uu_die' visibility='default' binding='global' size-in-bits='64' elf-symbol-id='uu_die'>
<parameter type-id='80f4b756' name='format'/>
<parameter is-variadic='yes'/>
<return type-id='48b5725f'/>
</function-decl>
<function-decl name='uu_vxdie' mangled-name='uu_vxdie' visibility='default' binding='global' size-in-bits='64' elf-symbol-id='uu_vxdie'>
<parameter type-id='95e97e5e' name='status'/>
<parameter type-id='80f4b756' name='format'/>
<parameter type-id='b7f2d5e6' name='alist'/>
<return type-id='48b5725f'/>
</function-decl>
<function-decl name='uu_xdie' mangled-name='uu_xdie' visibility='default' binding='global' size-in-bits='64' elf-symbol-id='uu_xdie'>
<parameter type-id='95e97e5e' name='status'/>
<parameter type-id='80f4b756' name='format'/>
<parameter is-variadic='yes'/>
<return type-id='48b5725f'/>
</function-decl>
<function-decl name='uu_setpname' mangled-name='uu_setpname' visibility='default' binding='global' size-in-bits='64' elf-symbol-id='uu_setpname'>
<parameter type-id='26a90f95' name='arg0'/>
<return type-id='80f4b756'/>
</function-decl>
<function-decl name='uu_getpname' mangled-name='uu_getpname' visibility='default' binding='global' size-in-bits='64' elf-symbol-id='uu_getpname'>
<return type-id='80f4b756'/>
</function-decl>
</abi-instr>
<abi-instr address-size='64' path='uu_string.c' language='LANG_C99'>
<type-decl name='unnamed-enum-underlying-type-32' is-anonymous='yes' size-in-bits='32' alignment-in-bits='32' id='9cac1fee'/>
<enum-decl name='boolean_t' naming-typedef-id='c19b74c3' id='f58c8277'>

View File

@ -1,202 +0,0 @@
/*
* CDDL HEADER START
*
* The contents of this file are subject to the terms of the
* Common Development and Distribution License, Version 1.0 only
* (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 https://opensource.org/licenses/CDDL-1.0.
* 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 2005 Sun Microsystems, Inc. All rights reserved.
* Use is subject to license terms.
*/
#include "libuutil_common.h"
#include <libintl.h>
#include <limits.h>
#include <string.h>
#include <stdlib.h>
#include <stdarg.h>
#include <stdio.h>
#include <errno.h>
#include <wchar.h>
#include <unistd.h>
static const char *pname;
static __attribute__((noreturn)) void
uu_die_internal(int status, const char *format, va_list alist);
int uu_exit_ok_value = EXIT_SUCCESS;
int uu_exit_fatal_value = EXIT_FAILURE;
int uu_exit_usage_value = 2;
int *
uu_exit_ok(void)
{
return (&uu_exit_ok_value);
}
int *
uu_exit_fatal(void)
{
return (&uu_exit_fatal_value);
}
int *
uu_exit_usage(void)
{
return (&uu_exit_usage_value);
}
void
uu_alt_exit(int profile)
{
switch (profile) {
case UU_PROFILE_DEFAULT:
uu_exit_ok_value = EXIT_SUCCESS;
uu_exit_fatal_value = EXIT_FAILURE;
uu_exit_usage_value = 2;
break;
case UU_PROFILE_LAUNCHER:
uu_exit_ok_value = EXIT_SUCCESS;
uu_exit_fatal_value = 124;
uu_exit_usage_value = 125;
break;
}
}
static __attribute__((format(printf, 2, 0))) void
uu_warn_internal(int err, const char *format, va_list alist)
{
if (pname != NULL)
(void) fprintf(stderr, "%s: ", pname);
if (format != NULL)
(void) vfprintf(stderr, format, alist);
if (strrchr(format, '\n') == NULL)
(void) fprintf(stderr, ": %s\n", strerror(err));
}
void
uu_vwarn(const char *format, va_list alist)
{
uu_warn_internal(errno, format, alist);
}
void
uu_warn(const char *format, ...)
{
va_list alist;
va_start(alist, format);
uu_warn_internal(errno, format, alist);
va_end(alist);
}
static __attribute__((format(printf, 2, 0))) __attribute__((noreturn)) void
uu_die_internal(int status, const char *format, va_list alist)
{
uu_warn_internal(errno, format, alist);
#ifdef DEBUG
{
char *cp;
if (!issetugid()) {
cp = getenv("UU_DIE_ABORTS");
if (cp != NULL && *cp != '\0')
abort();
}
}
#endif
exit(status);
}
void
uu_vdie(const char *format, va_list alist)
{
uu_die_internal(UU_EXIT_FATAL, format, alist);
}
void
uu_die(const char *format, ...)
{
va_list alist;
va_start(alist, format);
uu_die_internal(UU_EXIT_FATAL, format, alist);
va_end(alist);
}
void
uu_vxdie(int status, const char *format, va_list alist)
{
uu_die_internal(status, format, alist);
}
void
uu_xdie(int status, const char *format, ...)
{
va_list alist;
va_start(alist, format);
uu_die_internal(status, format, alist);
va_end(alist);
}
const char *
uu_setpname(char *arg0)
{
/*
* Having a NULL argv[0], while uncommon, is possible. It
* makes more sense to handle this event in uu_setpname rather
* than in each of its consumers.
*/
if (arg0 == NULL) {
pname = getexecname();
if (pname == NULL)
pname = "unknown_command";
return (pname);
}
/*
* Guard against '/' at end of command invocation.
*/
for (;;) {
char *p = strrchr(arg0, '/');
if (p == NULL) {
pname = arg0;
break;
} else {
if (*(p + 1) == '\0') {
*p = '\0';
continue;
}
pname = p + 1;
break;
}
}
return (pname);
}
const char *
uu_getpname(void)
{
return (pname);
}

View File

@ -245,6 +245,7 @@
<elf-symbol name='sa_enable_share' type='func-type' binding='global-binding' visibility='default-visibility' is-defined='yes'/>
<elf-symbol name='sa_errorstr' type='func-type' binding='global-binding' visibility='default-visibility' is-defined='yes'/>
<elf-symbol name='sa_is_shared' type='func-type' binding='global-binding' visibility='default-visibility' is-defined='yes'/>
<elf-symbol name='sa_truncate_shares' type='func-type' binding='global-binding' visibility='default-visibility' is-defined='yes'/>
<elf-symbol name='sa_validate_shareopts' type='func-type' binding='global-binding' visibility='default-visibility' is-defined='yes'/>
<elf-symbol name='snapshot_namecheck' type='func-type' binding='global-binding' visibility='default-visibility' is-defined='yes'/>
<elf-symbol name='spl_pagesize' type='func-type' binding='global-binding' visibility='default-visibility' is-defined='yes'/>
@ -428,6 +429,7 @@
<elf-symbol name='zfs_strcmp_pathname' type='func-type' binding='global-binding' visibility='default-visibility' is-defined='yes'/>
<elf-symbol name='zfs_strip_partition' type='func-type' binding='global-binding' visibility='default-visibility' is-defined='yes'/>
<elf-symbol name='zfs_strip_path' type='func-type' binding='global-binding' visibility='default-visibility' is-defined='yes'/>
<elf-symbol name='zfs_truncate_shares' type='func-type' binding='global-binding' visibility='default-visibility' is-defined='yes'/>
<elf-symbol name='zfs_type_to_name' type='func-type' binding='global-binding' visibility='default-visibility' is-defined='yes'/>
<elf-symbol name='zfs_unmount' type='func-type' binding='global-binding' visibility='default-visibility' is-defined='yes'/>
<elf-symbol name='zfs_unmountall' type='func-type' binding='global-binding' visibility='default-visibility' is-defined='yes'/>
@ -758,6 +760,10 @@
<parameter type-id='9155d4b5' name='protocol'/>
<return type-id='48b5725f'/>
</function-decl>
<function-decl name='sa_truncate_shares' mangled-name='sa_truncate_shares' visibility='default' binding='global' size-in-bits='64' elf-symbol-id='sa_truncate_shares'>
<parameter type-id='9155d4b5' name='protocol'/>
<return type-id='48b5725f'/>
</function-decl>
<function-decl name='sa_validate_shareopts' mangled-name='sa_validate_shareopts' visibility='default' binding='global' size-in-bits='64' elf-symbol-id='sa_validate_shareopts'>
<parameter type-id='80f4b756' name='options'/>
<parameter type-id='9155d4b5' name='protocol'/>
@ -787,7 +793,7 @@
</data-member>
</class-decl>
<typedef-decl name='sa_share_impl_t' type-id='946a2c6b' id='a48b47d0'/>
<class-decl name='sa_fstype_t' size-in-bits='320' is-struct='yes' naming-typedef-id='639af739' visibility='default' id='944afa86'>
<class-decl name='sa_fstype_t' size-in-bits='384' is-struct='yes' naming-typedef-id='639af739' visibility='default' id='944afa86'>
<data-member access='public' layout-offset-in-bits='0'>
<var-decl name='enable_share' type-id='2f78a9c1' visibility='default'/>
</data-member>
@ -803,6 +809,9 @@
<data-member access='public' layout-offset-in-bits='256'>
<var-decl name='commit_shares' type-id='797ee7da' visibility='default'/>
</data-member>
<data-member access='public' layout-offset-in-bits='320'>
<var-decl name='truncate_shares' type-id='5d51038b' visibility='default'/>
</data-member>
</class-decl>
<typedef-decl name='sa_fstype_t' type-id='944afa86' id='639af739'/>
<qualified-type-def type-id='639af739' const='yes' id='d19dbca9'/>
@ -816,6 +825,8 @@
<qualified-type-def type-id='fa1f29ce' const='yes' id='2f78a9c1'/>
<pointer-type-def type-id='86373eb1' size-in-bits='64' id='f337456d'/>
<qualified-type-def type-id='f337456d' const='yes' id='81020bc2'/>
<pointer-type-def type-id='ee076206' size-in-bits='64' id='953b12f8'/>
<qualified-type-def type-id='953b12f8' const='yes' id='5d51038b'/>
<var-decl name='libshare_nfs_type' type-id='d19dbca9' visibility='default'/>
<function-type size-in-bits='64' id='276427e1'>
<return type-id='95e97e5e'/>
@ -832,6 +843,9 @@
<parameter type-id='a48b47d0'/>
<return type-id='c19b74c3'/>
</function-type>
<function-type size-in-bits='64' id='ee076206'>
<return type-id='48b5725f'/>
</function-type>
</abi-instr>
<abi-instr address-size='64' path='lib/libshare/os/linux/smb.c' language='LANG_C99'>
<var-decl name='libshare_smb_type' type-id='d19dbca9' visibility='default'/>
@ -2302,6 +2316,7 @@
<underlying-type type-id='9cac1fee'/>
<enumerator name='ZPROP_CONT' value='-2'/>
<enumerator name='ZPROP_INVAL' value='-1'/>
<enumerator name='ZPROP_USERPROP' value='-1'/>
<enumerator name='ZFS_PROP_TYPE' value='0'/>
<enumerator name='ZFS_PROP_CREATION' value='1'/>
<enumerator name='ZFS_PROP_USED' value='2'/>
@ -3034,6 +3049,10 @@
<parameter type-id='4567bbc9' name='proto'/>
<return type-id='48b5725f'/>
</function-decl>
<function-decl name='zfs_truncate_shares' mangled-name='zfs_truncate_shares' visibility='default' binding='global' size-in-bits='64' elf-symbol-id='zfs_truncate_shares'>
<parameter type-id='4567bbc9' name='proto'/>
<return type-id='48b5725f'/>
</function-decl>
<function-decl name='zfs_unshare' mangled-name='zfs_unshare' visibility='default' binding='global' size-in-bits='64' elf-symbol-id='zfs_unshare'>
<parameter type-id='9200a744' name='zhp'/>
<parameter type-id='80f4b756' name='mountpoint'/>
@ -3150,6 +3169,7 @@
<enum-decl name='vdev_prop_t' naming-typedef-id='5aa5c90c' id='1573bec8'>
<underlying-type type-id='9cac1fee'/>
<enumerator name='VDEV_PROP_INVAL' value='-1'/>
<enumerator name='VDEV_PROP_USERPROP' value='-1'/>
<enumerator name='VDEV_PROP_NAME' value='0'/>
<enumerator name='VDEV_PROP_CAPACITY' value='1'/>
<enumerator name='VDEV_PROP_STATE' value='2'/>
@ -3750,7 +3770,7 @@
</class-decl>
<typedef-decl name='sendflags_t' type-id='f6aa15be' id='945467e6'/>
<typedef-decl name='snapfilter_cb_t' type-id='d2a5e211' id='3d3ffb69'/>
<class-decl name='recvflags' size-in-bits='416' is-struct='yes' visibility='default' id='34a384dc'>
<class-decl name='recvflags' size-in-bits='448' is-struct='yes' visibility='default' id='34a384dc'>
<data-member access='public' layout-offset-in-bits='0'>
<var-decl name='verbose' type-id='c19b74c3' visibility='default'/>
</data-member>
@ -3790,6 +3810,9 @@
<data-member access='public' layout-offset-in-bits='384'>
<var-decl name='forceunmount' type-id='c19b74c3' visibility='default'/>
</data-member>
<data-member access='public' layout-offset-in-bits='416'>
<var-decl name='heal' type-id='c19b74c3' visibility='default'/>
</data-member>
</class-decl>
<typedef-decl name='recvflags_t' type-id='34a384dc' id='9e59d1d4'/>
<pointer-type-def type-id='f20fbd51' size-in-bits='64' id='a3681dea'/>
@ -3903,16 +3926,17 @@
<enumerator name='ZPOOL_ERRATA_ZOL_8308_ENCRYPTION' value='4'/>
</enum-decl>
<typedef-decl name='zpool_errata_t' type-id='d9abbf54' id='688c495b'/>
<pointer-type-def type-id='80f4b756' size-in-bits='64' id='7d3cd834'/>
<pointer-type-def type-id='688c495b' size-in-bits='64' id='cec6f2e4'/>
<function-decl name='zpool_get_status' mangled-name='zpool_get_status' visibility='default' binding='global' size-in-bits='64' elf-symbol-id='zpool_get_status'>
<parameter type-id='4c81de99' name='zhp'/>
<parameter type-id='9b23c9ad' name='msgid'/>
<parameter type-id='7d3cd834' name='msgid'/>
<parameter type-id='cec6f2e4' name='errata'/>
<return type-id='d3dd6294'/>
</function-decl>
<function-decl name='zpool_import_status' mangled-name='zpool_import_status' visibility='default' binding='global' size-in-bits='64' elf-symbol-id='zpool_import_status'>
<parameter type-id='5ce45b60' name='config'/>
<parameter type-id='9b23c9ad' name='msgid'/>
<parameter type-id='7d3cd834' name='msgid'/>
<parameter type-id='cec6f2e4' name='errata'/>
<return type-id='d3dd6294'/>
</function-decl>
@ -4032,8 +4056,8 @@
<return type-id='48b5725f'/>
</function-decl>
<function-decl name='libzfs_envvar_is_set' mangled-name='libzfs_envvar_is_set' visibility='default' binding='global' size-in-bits='64' elf-symbol-id='libzfs_envvar_is_set'>
<parameter type-id='26a90f95' name='envvar'/>
<return type-id='95e97e5e'/>
<parameter type-id='80f4b756' name='envvar'/>
<return type-id='c19b74c3'/>
</function-decl>
<function-decl name='libzfs_init' mangled-name='libzfs_init' visibility='default' binding='global' size-in-bits='64' elf-symbol-id='libzfs_init'>
<return type-id='b0382bb3'/>
@ -4102,15 +4126,15 @@
<return type-id='95e97e5e'/>
</function-decl>
<function-decl name='color_start' mangled-name='color_start' visibility='default' binding='global' size-in-bits='64' elf-symbol-id='color_start'>
<parameter type-id='26a90f95' name='color'/>
<parameter type-id='80f4b756' name='color'/>
<return type-id='48b5725f'/>
</function-decl>
<function-decl name='color_end' mangled-name='color_end' visibility='default' binding='global' size-in-bits='64' elf-symbol-id='color_end'>
<return type-id='48b5725f'/>
</function-decl>
<function-decl name='printf_color' mangled-name='printf_color' visibility='default' binding='global' size-in-bits='64' elf-symbol-id='printf_color'>
<parameter type-id='26a90f95' name='color'/>
<parameter type-id='26a90f95' name='format'/>
<parameter type-id='80f4b756' name='color'/>
<parameter type-id='80f4b756' name='format'/>
<parameter is-variadic='yes'/>
<return type-id='95e97e5e'/>
</function-decl>
@ -4123,7 +4147,7 @@
<abi-instr address-size='64' path='lib/libzfs/os/linux/libzfs_mount_os.c' language='LANG_C99'>
<pointer-type-def type-id='7359adad' size-in-bits='64' id='1d2c2b85'/>
<function-decl name='zfs_parse_mount_options' mangled-name='zfs_parse_mount_options' visibility='default' binding='global' size-in-bits='64' elf-symbol-id='zfs_parse_mount_options'>
<parameter type-id='26a90f95' name='mntopts'/>
<parameter type-id='80f4b756' name='mntopts'/>
<parameter type-id='1d2c2b85' name='mntflags'/>
<parameter type-id='1d2c2b85' name='zfsflags'/>
<parameter type-id='95e97e5e' name='sloppy'/>
@ -4771,8 +4795,8 @@
</function-decl>
</abi-instr>
<abi-instr address-size='64' path='module/zcommon/zfeature_common.c' language='LANG_C99'>
<array-type-def dimensions='1' type-id='83f29ca2' size-in-bits='16576' id='9d5e9e2e'>
<subrange length='37' type-id='7359adad' id='ae666bde'/>
<array-type-def dimensions='1' type-id='83f29ca2' size-in-bits='16576' id='d95b2b0b'>
<subrange length='37' type-id='7359adad' id='aa6426fb'/>
</array-type-def>
<enum-decl name='spa_feature' id='33ecb627'>
<underlying-type type-id='9cac1fee'/>
@ -4872,7 +4896,7 @@
<qualified-type-def type-id='3eee3342' const='yes' id='0c1d5bbb'/>
<pointer-type-def type-id='0c1d5bbb' size-in-bits='64' id='a3372543'/>
<pointer-type-def type-id='d6618c78' size-in-bits='64' id='a8425263'/>
<var-decl name='spa_feature_table' type-id='9d5e9e2e' mangled-name='spa_feature_table' visibility='default' elf-symbol-id='spa_feature_table'/>
<var-decl name='spa_feature_table' type-id='d95b2b0b' mangled-name='spa_feature_table' visibility='default' elf-symbol-id='spa_feature_table'/>
<var-decl name='zfeature_checks_disable' type-id='c19b74c3' mangled-name='zfeature_checks_disable' visibility='default' elf-symbol-id='zfeature_checks_disable'/>
<function-decl name='zfeature_is_valid_guid' mangled-name='zfeature_is_valid_guid' visibility='default' binding='global' size-in-bits='64' elf-symbol-id='zfeature_is_valid_guid'>
<parameter type-id='80f4b756' name='name'/>
@ -4935,7 +4959,7 @@
</function-decl>
<function-decl name='zfs_special_devs' mangled-name='zfs_special_devs' visibility='default' binding='global' size-in-bits='64' elf-symbol-id='zfs_special_devs'>
<parameter type-id='5ce45b60' name='nv'/>
<parameter type-id='26a90f95' name='type'/>
<parameter type-id='80f4b756' name='type'/>
<return type-id='c19b74c3'/>
</function-decl>
<function-decl name='zpool_get_load_policy' mangled-name='zpool_get_load_policy' visibility='default' binding='global' size-in-bits='64' elf-symbol-id='zpool_get_load_policy'>
@ -5013,7 +5037,7 @@
<typedef-decl name='zfs_deleg_note_t' type-id='729d4547' id='4613c173'/>
<class-decl name='zfs_deleg_perm_tab' size-in-bits='128' is-struct='yes' visibility='default' id='5aa05c1f'>
<data-member access='public' layout-offset-in-bits='0'>
<var-decl name='z_perm' type-id='26a90f95' visibility='default'/>
<var-decl name='z_perm' type-id='80f4b756' visibility='default'/>
</data-member>
<data-member access='public' layout-offset-in-bits='64'>
<var-decl name='z_note' type-id='4613c173' visibility='default'/>
@ -5455,7 +5479,6 @@
</data-member>
</class-decl>
<typedef-decl name='zprop_desc_t' type-id='bbff5e4b' id='ffa52b96'/>
<pointer-type-def type-id='80f4b756' size-in-bits='64' id='7d3cd834'/>
<qualified-type-def type-id='64636ce3' const='yes' id='072f7953'/>
<pointer-type-def type-id='072f7953' size-in-bits='64' id='c8bc397b'/>
<pointer-type-def type-id='ffa52b96' size-in-bits='64' id='76c8174b'/>

View File

@ -22,7 +22,7 @@
/*
* Copyright 2015 Nexenta Systems, Inc. All rights reserved.
* Copyright (c) 2005, 2010, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2014, 2021 by Delphix. All rights reserved.
* Copyright (c) 2014, 2022 by Delphix. All rights reserved.
* Copyright 2016 Igor Kozhukhov <ikozhukhov@gmail.com>
* Copyright 2017 RackTop Systems.
* Copyright (c) 2018 Datto Inc.
@ -788,6 +788,16 @@ zfs_commit_shares(const enum sa_protocol *proto)
sa_commit_shares(*p);
}
void
zfs_truncate_shares(const enum sa_protocol *proto)
{
if (proto == NULL)
proto = share_all_proto;
for (const enum sa_protocol *p = proto; *p != SA_NO_PROTOCOL; ++p)
sa_truncate_shares(*p);
}
/*
* Unshare the given filesystem.
*/

View File

@ -4684,8 +4684,8 @@ zpool_load_compat(const char *compat, boolean_t *features, char *report,
for (uint_t i = 0; i < SPA_FEATURES; i++)
features[i] = B_TRUE;
char err_badfile[1024] = "";
char err_badtoken[1024] = "";
char err_badfile[ZFS_MAXPROPLEN] = "";
char err_badtoken[ZFS_MAXPROPLEN] = "";
/*
* We ignore errors from the directory open()

View File

@ -874,11 +874,6 @@ dump_ioctl(zfs_handle_t *zhp, const char *fromsnap, uint64_t fromsnap_obj,
case EINVAL:
zfs_error_aux(hdl, "%s", strerror(errno));
return (zfs_error(hdl, EZFS_BADBACKUP, errbuf));
case ENOTSUP:
zfs_error_aux(hdl, dgettext(TEXT_DOMAIN,
"large blocks detected but large_blocks feature "
"is inactive; raw send unsupported"));
return (zfs_error(hdl, EZFS_NOTSUP, errbuf));
default:
return (zfs_standard_error(hdl, errno, errbuf));
@ -2702,11 +2697,6 @@ zfs_send_one_cb_impl(zfs_handle_t *zhp, const char *from, int fd,
case EROFS:
zfs_error_aux(hdl, "%s", strerror(errno));
return (zfs_error(hdl, EZFS_BADBACKUP, errbuf));
case ENOTSUP:
zfs_error_aux(hdl, dgettext(TEXT_DOMAIN,
"large blocks detected but large_blocks feature "
"is inactive; raw send unsupported"));
return (zfs_error(hdl, EZFS_NOTSUP, errbuf));
default:
return (zfs_standard_error(hdl, errno, errbuf));

View File

@ -170,6 +170,8 @@ libzfs_error_description(libzfs_handle_t *hdl)
return (dgettext(TEXT_DOMAIN, "I/O error"));
case EZFS_INTR:
return (dgettext(TEXT_DOMAIN, "signal received"));
case EZFS_CKSUM:
return (dgettext(TEXT_DOMAIN, "insufficient replicas"));
case EZFS_ISSPARE:
return (dgettext(TEXT_DOMAIN, "device is reserved as a hot "
"spare"));
@ -396,6 +398,10 @@ zfs_common_error(libzfs_handle_t *hdl, int error, const char *fmt,
case EINTR:
zfs_verror(hdl, EZFS_INTR, fmt, ap);
return (-1);
case ECKSUM:
zfs_verror(hdl, EZFS_CKSUM, fmt, ap);
return (-1);
}
return (0);
@ -679,7 +685,7 @@ zpool_standard_error_fmt(libzfs_handle_t *hdl, int error, const char *fmt, ...)
case ENOSPC:
case EDQUOT:
zfs_verror(hdl, EZFS_NOSPC, fmt, ap);
return (-1);
break;
case EAGAIN:
zfs_error_aux(hdl, dgettext(TEXT_DOMAIN,

View File

@ -121,7 +121,6 @@ nodist_libzpool_la_SOURCES = \
module/zfs/sha256.c \
module/zfs/skein_zfs.c \
module/zfs/spa.c \
module/zfs/spa_boot.c \
module/zfs/spa_checkpoint.c \
module/zfs/spa_config.c \
module/zfs/spa_errlog.c \

View File

@ -273,7 +273,6 @@ zfs_get_pci_slots_sys_path(const char *dev_name)
free(address2);
if (asprintf(&path, "/sys/bus/pci/slots/%s",
ep->d_name) == -1) {
free(tmp);
continue;
}
break;

View File

@ -1694,6 +1694,8 @@ zpool_find_import_cached(libpc_handle_t *hdl, importargs_t *iarg)
* caller.
*/
nvpair_t *pair = nvlist_next_nvpair(nv, NULL);
if (pair == NULL)
continue;
fnvlist_add_nvlist(pools, nvpair_name(pair),
fnvpair_value_nvlist(pair));

View File

@ -347,9 +347,12 @@ When a vdev is added, target this number of metaslabs per top-level vdev.
.It Sy zfs_vdev_default_ms_shift Ns = Ns Sy 29 Po 512 MiB Pc Pq int
Default limit for metaslab size.
.
.It Sy zfs_vdev_max_auto_ashift Ns = Ns Sy ASHIFT_MAX Po 16 Pc Pq ulong
.It Sy zfs_vdev_max_auto_ashift Ns = Ns Sy 14 Pq ulong
Maximum ashift used when optimizing for logical \[->] physical sector size on new
top-level vdevs.
May be increased up to
.Sy ASHIFT_MAX Po 16 Pc ,
but this may negatively impact pool space efficiency.
.
.It Sy zfs_vdev_min_auto_ashift Ns = Ns Sy ASHIFT_MIN Po 9 Pc Pq ulong
Minimum ashift used when creating new top-level vdevs.
@ -1159,6 +1162,20 @@ Selecting any option other than
results in vector instructions
from the respective CPU instruction set being used.
.
.It Sy zfs_blake3_impl Ns = Ns Sy fastest Pq string
Select a BLAKE3 implementation.
.Pp
Supported selectors are:
.Sy cycle , fastest , generic , sse2 , sse41 , avx2 , avx512 .
All except
.Sy cycle , fastest No and Sy generic
require instruction set extensions to be available,
and will only appear if ZFS detects that they are present at runtime.
If multiple implementations of BLAKE3 are available, the
.Sy fastest will be chosen using a micro benchmark. You can see the
benchmark results by reading this kstat file:
.Pa /proc/spl/kstat/zfs/chksum_bench .
.
.It Sy zfs_free_bpobj_enabled Ns = Ns Sy 1 Ns | Ns 0 Pq int
Enable/disable the processing of the free_bpobj object.
.
@ -1351,6 +1368,22 @@ _
.TE
.Sy \& * No Requires debug build.
.
.It Sy zfs_btree_verify_intensity Ns = Ns Sy 0 Pq uint
Enables btree verification.
The following settings are culminative:
.TS
box;
lbz r l l .
Value Description
1 Verify height.
2 Verify pointers from children to parent.
3 Verify element counts.
4 Verify element order. (expensive)
* 5 Verify unused memory is poisoned. (expensive)
.TE
.Sy \& * No Requires debug build.
.
.It Sy zfs_free_leak_on_eio Ns = Ns Sy 0 Ns | Ns 1 Pq int
If destroy encounters an
.Sy EIO

View File

@ -177,7 +177,7 @@ changed with the
.Nm zpool Cm set
command:
.Bl -tag -width Ds
.It Sy ashift Ns = Ns Sy ashift
.It Sy ashift Ns = Ns Ar ashift
Pool sector size exponent, to the power of
.Sy 2
(internally referred to as

View File

@ -424,6 +424,19 @@ To enable taking snapshots from ZCP scripts, the pool must be upgraded.
.It Ar dataset Pq string
Name of snapshot to create.
.El
.It Fn zfs.sync.rename_snapshot dataset oldsnapname newsnapname
Rename a snapshot of a filesystem or a volume.
Returns 0 if the snapshot was successfully renamed,
and a nonzero error code otherwise.
.Pp
.Bl -tag -compact -width "newbookmark (string)"
.It Ar dataset Pq string
Name of the snapshot's parent dataset.
.It Ar oldsnapname Pq string
Original name of the snapshot.
.It Ar newsnapname Pq string
New name of the snapshot.
.El
.It Fn zfs.sync.bookmark source newbookmark
Create a bookmark of an existing source snapshot or bookmark.
Returns 0 if the new bookmark was successfully created,

View File

@ -345,7 +345,6 @@ ZFS_OBJS := \
sha256.o \
skein_zfs.o \
spa.o \
spa_boot.o \
spa_checkpoint.o \
spa_config.o \
spa_errlog.o \

View File

@ -172,6 +172,7 @@ SRCS+= abd_os.c \
arc_os.c \
crypto_os.c \
dmu_os.c \
event_os.c \
hkdf.c \
kmod_core.c \
spa_os.c \
@ -270,7 +271,6 @@ SRCS+= abd.c \
sha256.c \
skein_zfs.c \
spa.c \
spa_boot.c \
spa_checkpoint.c \
spa_config.c \
spa_errlog.c \

View File

@ -129,7 +129,7 @@ static output_t make_output(const uint32_t input_cv[8],
* bytes. For that reason, chaining values in the CV stack are represented as
* bytes.
*/
static void output_chaining_value(const blake3_impl_ops_t *ops,
static void output_chaining_value(const blake3_ops_t *ops,
const output_t *ctx, uint8_t cv[32])
{
uint32_t cv_words[8];
@ -139,7 +139,7 @@ static void output_chaining_value(const blake3_impl_ops_t *ops,
store_cv_words(cv, cv_words);
}
static void output_root_bytes(const blake3_impl_ops_t *ops, const output_t *ctx,
static void output_root_bytes(const blake3_ops_t *ops, const output_t *ctx,
uint64_t seek, uint8_t *out, size_t out_len)
{
uint64_t output_block_counter = seek / 64;
@ -163,7 +163,7 @@ static void output_root_bytes(const blake3_impl_ops_t *ops, const output_t *ctx,
}
}
static void chunk_state_update(const blake3_impl_ops_t *ops,
static void chunk_state_update(const blake3_ops_t *ops,
blake3_chunk_state_t *ctx, const uint8_t *input, size_t input_len)
{
if (ctx->buf_len > 0) {
@ -230,7 +230,7 @@ static size_t left_len(size_t content_len)
* number of chunks hashed. These chunks are never the root and never empty;
* those cases use a different codepath.
*/
static size_t compress_chunks_parallel(const blake3_impl_ops_t *ops,
static size_t compress_chunks_parallel(const blake3_ops_t *ops,
const uint8_t *input, size_t input_len, const uint32_t key[8],
uint64_t chunk_counter, uint8_t flags, uint8_t *out)
{
@ -274,7 +274,7 @@ static size_t compress_chunks_parallel(const blake3_impl_ops_t *ops,
* return it as an additional output.) These parents are never the root and
* never empty; those cases use a different codepath.
*/
static size_t compress_parents_parallel(const blake3_impl_ops_t *ops,
static size_t compress_parents_parallel(const blake3_ops_t *ops,
const uint8_t *child_chaining_values, size_t num_chaining_values,
const uint32_t key[8], uint8_t flags, uint8_t *out)
{
@ -320,7 +320,7 @@ static size_t compress_parents_parallel(const blake3_impl_ops_t *ops,
* of implementing this special rule? Because we don't want to limit SIMD or
* multi-threading parallelism for that update().
*/
static size_t blake3_compress_subtree_wide(const blake3_impl_ops_t *ops,
static size_t blake3_compress_subtree_wide(const blake3_ops_t *ops,
const uint8_t *input, size_t input_len, const uint32_t key[8],
uint64_t chunk_counter, uint8_t flags, uint8_t *out)
{
@ -406,7 +406,7 @@ static size_t blake3_compress_subtree_wide(const blake3_impl_ops_t *ops,
* As with compress_subtree_wide(), this function is not used on inputs of 1
* chunk or less. That's a different codepath.
*/
static void compress_subtree_to_parent_node(const blake3_impl_ops_t *ops,
static void compress_subtree_to_parent_node(const blake3_ops_t *ops,
const uint8_t *input, size_t input_len, const uint32_t key[8],
uint64_t chunk_counter, uint8_t flags, uint8_t out[2 * BLAKE3_OUT_LEN])
{

View File

@ -192,7 +192,7 @@ static inline boolean_t blake3_is_generic_supported(void)
return (B_TRUE);
}
const blake3_impl_ops_t blake3_generic_impl = {
const blake3_ops_t blake3_generic_impl = {
.compress_in_place = blake3_compress_in_place_generic,
.compress_xof = blake3_compress_xof_generic,
.hash_many = blake3_hash_many_generic,

View File

@ -28,7 +28,7 @@
#include "blake3_impl.h"
static const blake3_impl_ops_t *const blake3_impls[] = {
static const blake3_ops_t *const blake3_impls[] = {
&blake3_generic_impl,
#if defined(__aarch64__) || \
(defined(__x86_64) && defined(HAVE_SSE2)) || \
@ -48,160 +48,199 @@ static const blake3_impl_ops_t *const blake3_impls[] = {
#endif
};
/* this pointer holds current ops for implementation */
static const blake3_impl_ops_t *blake3_selected_impl = &blake3_generic_impl;
/* special implementation selections */
/* Select BLAKE3 implementation */
#define IMPL_FASTEST (UINT32_MAX)
#define IMPL_CYCLE (UINT32_MAX-1)
#define IMPL_USER (UINT32_MAX-2)
#define IMPL_PARAM (UINT32_MAX-3)
#define IMPL_CYCLE (UINT32_MAX - 1)
#define IMPL_READ(i) (*(volatile uint32_t *) &(i))
static uint32_t icp_blake3_impl = IMPL_FASTEST;
#define IMPL_READ(i) (*(volatile uint32_t *) &(i))
#define BLAKE3_IMPL_NAME_MAX 16
/* Indicate that benchmark has been done */
static boolean_t blake3_initialized = B_FALSE;
/* id of fastest implementation */
static uint32_t blake3_fastest_id = 0;
/* Implementation that contains the fastest methods */
static blake3_ops_t blake3_fastest_impl = {
.name = "fastest"
};
/* currently used id */
static uint32_t blake3_current_id = 0;
/* Hold all supported implementations */
static const blake3_ops_t *blake3_supp_impls[ARRAY_SIZE(blake3_impls)];
static uint32_t blake3_supp_impls_cnt = 0;
/* id of module parameter (-1 == unused) */
static int blake3_param_id = -1;
/* Currently selected implementation */
static uint32_t blake3_impl_chosen = IMPL_FASTEST;
/* return number of supported implementations */
int
blake3_get_impl_count(void)
static struct blake3_impl_selector {
const char *name;
uint32_t sel;
} blake3_impl_selectors[] = {
{ "cycle", IMPL_CYCLE },
{ "fastest", IMPL_FASTEST }
};
/* check the supported implementations */
static void blake3_impl_init(void)
{
static int impls = 0;
int i;
int i, c;
if (impls)
return (impls);
/* init only once */
if (likely(blake3_initialized))
return;
for (i = 0; i < ARRAY_SIZE(blake3_impls); i++) {
if (!blake3_impls[i]->is_supported()) continue;
impls++;
/* move supported implementations into blake3_supp_impls */
for (i = 0, c = 0; i < ARRAY_SIZE(blake3_impls); i++) {
const blake3_ops_t *impl = blake3_impls[i];
if (impl->is_supported && impl->is_supported())
blake3_supp_impls[c++] = impl;
}
blake3_supp_impls_cnt = c;
return (impls);
/* first init generic impl, may be changed via set_fastest() */
memcpy(&blake3_fastest_impl, blake3_impls[0],
sizeof (blake3_fastest_impl));
blake3_initialized = B_TRUE;
}
/* return id of selected implementation */
int
blake3_get_impl_id(void)
/* get number of supported implementations */
uint32_t
blake3_impl_getcnt(void)
{
return (blake3_current_id);
blake3_impl_init();
return (blake3_supp_impls_cnt);
}
/* return name of selected implementation */
/* get id of selected implementation */
uint32_t
blake3_impl_getid(void)
{
return (IMPL_READ(blake3_impl_chosen));
}
/* get name of selected implementation */
const char *
blake3_get_impl_name(void)
blake3_impl_getname(void)
{
return (blake3_selected_impl->name);
uint32_t impl = IMPL_READ(blake3_impl_chosen);
blake3_impl_init();
switch (impl) {
case IMPL_FASTEST:
return ("fastest");
case IMPL_CYCLE:
return ("cycle");
default:
return (blake3_supp_impls[impl]->name);
}
}
/* setup id as fastest implementation */
void
blake3_set_impl_fastest(uint32_t id)
blake3_impl_set_fastest(uint32_t id)
{
blake3_fastest_id = id;
/* setup fastest impl */
memcpy(&blake3_fastest_impl, blake3_supp_impls[id],
sizeof (blake3_fastest_impl));
}
/* set implementation by id */
void
blake3_set_impl_id(uint32_t id)
blake3_impl_setid(uint32_t id)
{
int i, cid;
/* select fastest */
if (id == IMPL_FASTEST)
id = blake3_fastest_id;
/* select next or first */
if (id == IMPL_CYCLE)
id = (++blake3_current_id) % blake3_get_impl_count();
/* 0..N for the real impl */
for (i = 0, cid = 0; i < ARRAY_SIZE(blake3_impls); i++) {
if (!blake3_impls[i]->is_supported()) continue;
if (cid == id) {
blake3_current_id = cid;
blake3_selected_impl = blake3_impls[i];
return;
}
cid++;
blake3_impl_init();
switch (id) {
case IMPL_FASTEST:
atomic_swap_32(&blake3_impl_chosen, IMPL_FASTEST);
break;
case IMPL_CYCLE:
atomic_swap_32(&blake3_impl_chosen, IMPL_CYCLE);
break;
default:
ASSERT3U(id, >=, 0);
ASSERT3U(id, <, blake3_supp_impls_cnt);
atomic_swap_32(&blake3_impl_chosen, id);
break;
}
}
/* set implementation by name */
int
blake3_set_impl_name(const char *name)
blake3_impl_setname(const char *val)
{
int i, cid;
uint32_t impl = IMPL_READ(blake3_impl_chosen);
size_t val_len;
int i, err = -EINVAL;
if (strcmp(name, "fastest") == 0) {
atomic_swap_32(&icp_blake3_impl, IMPL_FASTEST);
blake3_set_impl_id(IMPL_FASTEST);
return (0);
} else if (strcmp(name, "cycle") == 0) {
atomic_swap_32(&icp_blake3_impl, IMPL_CYCLE);
blake3_set_impl_id(IMPL_CYCLE);
return (0);
}
blake3_impl_init();
val_len = strlen(val);
while ((val_len > 0) && !!isspace(val[val_len-1])) /* trim '\n' */
val_len--;
for (i = 0, cid = 0; i < ARRAY_SIZE(blake3_impls); i++) {
if (!blake3_impls[i]->is_supported()) continue;
if (strcmp(name, blake3_impls[i]->name) == 0) {
if (icp_blake3_impl == IMPL_PARAM) {
blake3_param_id = cid;
return (0);
}
blake3_selected_impl = blake3_impls[i];
blake3_current_id = cid;
return (0);
/* check mandatory implementations */
for (i = 0; i < ARRAY_SIZE(blake3_impl_selectors); i++) {
const char *name = blake3_impl_selectors[i].name;
if (val_len == strlen(name) &&
strncmp(val, name, val_len) == 0) {
impl = blake3_impl_selectors[i].sel;
err = 0;
break;
}
cid++;
}
return (-EINVAL);
}
if (err != 0 && blake3_initialized) {
/* check all supported implementations */
for (i = 0; i < blake3_supp_impls_cnt; i++) {
const char *name = blake3_supp_impls[i]->name;
/* setup implementation */
void
blake3_setup_impl(void)
{
switch (IMPL_READ(icp_blake3_impl)) {
case IMPL_PARAM:
blake3_set_impl_id(blake3_param_id);
atomic_swap_32(&icp_blake3_impl, IMPL_USER);
break;
case IMPL_FASTEST:
blake3_set_impl_id(IMPL_FASTEST);
break;
case IMPL_CYCLE:
blake3_set_impl_id(IMPL_CYCLE);
break;
default:
blake3_set_impl_id(blake3_current_id);
break;
if (val_len == strlen(name) &&
strncmp(val, name, val_len) == 0) {
impl = i;
err = 0;
break;
}
}
}
if (err == 0) {
atomic_swap_32(&blake3_impl_chosen, impl);
}
return (err);
}
/* return selected implementation */
const blake3_impl_ops_t *
const blake3_ops_t *
blake3_impl_get_ops(void)
{
/* each call to ops will cycle */
if (icp_blake3_impl == IMPL_CYCLE)
blake3_set_impl_id(IMPL_CYCLE);
const blake3_ops_t *ops = NULL;
uint32_t impl = IMPL_READ(blake3_impl_chosen);
return (blake3_selected_impl);
blake3_impl_init();
switch (impl) {
case IMPL_FASTEST:
ASSERT(blake3_initialized);
ops = &blake3_fastest_impl;
break;
case IMPL_CYCLE:
/* Cycle through supported implementations */
ASSERT(blake3_initialized);
ASSERT3U(blake3_supp_impls_cnt, >, 0);
static uint32_t cycle_count = 0;
uint32_t idx = (++cycle_count) % blake3_supp_impls_cnt;
ops = blake3_supp_impls[idx];
break;
default:
ASSERT3U(blake3_supp_impls_cnt, >, 0);
ASSERT3U(impl, <, blake3_supp_impls_cnt);
ops = blake3_supp_impls[impl];
break;
}
ASSERT3P(ops, !=, NULL);
return (ops);
}
#if defined(_KERNEL)
void **blake3_per_cpu_ctx;
void
@ -215,6 +254,9 @@ blake3_per_cpu_ctx_init(void)
blake3_per_cpu_ctx[i] = kmem_alloc(sizeof (BLAKE3_CTX),
KM_SLEEP);
}
/* init once in kernel mode */
blake3_impl_init();
}
void
@ -227,58 +269,94 @@ blake3_per_cpu_ctx_fini(void)
memset(blake3_per_cpu_ctx, 0, max_ncpus * sizeof (void *));
kmem_free(blake3_per_cpu_ctx, max_ncpus * sizeof (void *));
}
#endif
#if defined(_KERNEL) && defined(__linux__)
static int
icp_blake3_impl_set(const char *name, zfs_kernel_param_t *kp)
{
char req_name[BLAKE3_IMPL_NAME_MAX];
size_t i;
#define IMPL_FMT(impl, i) (((impl) == (i)) ? "[%s] " : "%s ")
/* sanitize input */
i = strnlen(name, BLAKE3_IMPL_NAME_MAX);
if (i == 0 || i >= BLAKE3_IMPL_NAME_MAX)
return (-EINVAL);
strlcpy(req_name, name, BLAKE3_IMPL_NAME_MAX);
while (i > 0 && isspace(req_name[i-1]))
i--;
req_name[i] = '\0';
atomic_swap_32(&icp_blake3_impl, IMPL_PARAM);
return (blake3_set_impl_name(req_name));
}
#if defined(__linux__)
static int
icp_blake3_impl_get(char *buffer, zfs_kernel_param_t *kp)
blake3_param_get(char *buffer, zfs_kernel_param_t *unused)
{
int i, cid, cnt = 0;
const uint32_t impl = IMPL_READ(blake3_impl_chosen);
char *fmt;
int cnt = 0;
/* cycling */
fmt = (icp_blake3_impl == IMPL_CYCLE) ? "[cycle] " : "cycle ";
cnt += sprintf(buffer + cnt, fmt);
fmt = IMPL_FMT(impl, IMPL_CYCLE);
cnt += sprintf(buffer + cnt, fmt, "cycle");
/* fastest one */
fmt = (icp_blake3_impl == IMPL_FASTEST) ? "[fastest] " : "fastest ";
cnt += sprintf(buffer + cnt, fmt);
/* list fastest */
fmt = IMPL_FMT(impl, IMPL_FASTEST);
cnt += sprintf(buffer + cnt, fmt, "fastest");
/* user selected */
for (i = 0, cid = 0; i < ARRAY_SIZE(blake3_impls); i++) {
if (!blake3_impls[i]->is_supported()) continue;
fmt = (icp_blake3_impl == IMPL_USER &&
cid == blake3_current_id) ? "[%s] " : "%s ";
cnt += sprintf(buffer + cnt, fmt, blake3_impls[i]->name);
cid++;
/* list all supported implementations */
for (uint32_t i = 0; i < blake3_supp_impls_cnt; ++i) {
fmt = IMPL_FMT(impl, i);
cnt += sprintf(buffer + cnt, fmt,
blake3_supp_impls[i]->name);
}
buffer[cnt] = 0;
return (cnt);
}
module_param_call(icp_blake3_impl, icp_blake3_impl_set, icp_blake3_impl_get,
NULL, 0644);
MODULE_PARM_DESC(icp_blake3_impl, "Select BLAKE3 implementation.");
static int
blake3_param_set(const char *val, zfs_kernel_param_t *unused)
{
(void) unused;
return (blake3_impl_setname(val));
}
#elif defined(__FreeBSD__)
#include <sys/sbuf.h>
static int
blake3_param(ZFS_MODULE_PARAM_ARGS)
{
int err;
if (req->newptr == NULL) {
const uint32_t impl = IMPL_READ(blake3_impl_chosen);
const int init_buflen = 64;
const char *fmt;
struct sbuf *s;
s = sbuf_new_for_sysctl(NULL, NULL, init_buflen, req);
/* cycling */
fmt = IMPL_FMT(impl, IMPL_CYCLE);
(void) sbuf_printf(s, fmt, "cycle");
/* list fastest */
fmt = IMPL_FMT(impl, IMPL_FASTEST);
(void) sbuf_printf(s, fmt, "fastest");
/* list all supported implementations */
for (uint32_t i = 0; i < blake3_supp_impls_cnt; ++i) {
fmt = IMPL_FMT(impl, i);
(void) sbuf_printf(s, fmt, blake3_supp_impls[i]->name);
}
err = sbuf_finish(s);
sbuf_delete(s);
return (err);
}
char buf[16];
err = sysctl_handle_string(oidp, buf, sizeof (buf), req);
if (err) {
return (err);
}
return (-blake3_impl_setname(buf));
}
#endif
#undef IMPL_FMT
ZFS_MODULE_VIRTUAL_PARAM_CALL(zfs, zfs_, blake3_impl,
blake3_param_set, blake3_param_get, ZMOD_RW, \
"Select BLAKE3 implementation.");
#endif

View File

@ -62,31 +62,31 @@ typedef struct blake3_impl_ops {
blake3_is_supported_f is_supported;
int degree;
const char *name;
} blake3_impl_ops_t;
} blake3_ops_t;
/* Return selected BLAKE3 implementation ops */
extern const blake3_impl_ops_t *blake3_impl_get_ops(void);
extern const blake3_ops_t *blake3_impl_get_ops(void);
extern const blake3_impl_ops_t blake3_generic_impl;
extern const blake3_ops_t blake3_generic_impl;
#if defined(__aarch64__) || \
(defined(__x86_64) && defined(HAVE_SSE2)) || \
(defined(__PPC64__) && defined(__LITTLE_ENDIAN__))
extern const blake3_impl_ops_t blake3_sse2_impl;
extern const blake3_ops_t blake3_sse2_impl;
#endif
#if defined(__aarch64__) || \
(defined(__x86_64) && defined(HAVE_SSE4_1)) || \
(defined(__PPC64__) && defined(__LITTLE_ENDIAN__))
extern const blake3_impl_ops_t blake3_sse41_impl;
extern const blake3_ops_t blake3_sse41_impl;
#endif
#if defined(__x86_64) && defined(HAVE_SSE4_1) && defined(HAVE_AVX2)
extern const blake3_impl_ops_t blake3_avx2_impl;
extern const blake3_ops_t blake3_avx2_impl;
#endif
#if defined(__x86_64) && defined(HAVE_AVX512F) && defined(HAVE_AVX512VL)
extern const blake3_impl_ops_t blake3_avx512_impl;
extern const blake3_ops_t blake3_avx512_impl;
#endif
#if defined(__x86_64)

View File

@ -75,14 +75,13 @@ static boolean_t blake3_is_sse2_supported(void)
#if defined(__x86_64)
return (kfpu_allowed() && zfs_sse2_available());
#elif defined(__PPC64__) && defined(__linux__)
/* TODO: implement vsx handler or FreeBSD */
return (kfpu_allowed() && zfs_vsx_available());
#else
return (kfpu_allowed());
#endif
}
const blake3_impl_ops_t blake3_sse2_impl = {
const blake3_ops_t blake3_sse2_impl = {
.compress_in_place = blake3_compress_in_place_sse2,
.compress_xof = blake3_compress_xof_sse2,
.hash_many = blake3_hash_many_sse2,
@ -142,14 +141,17 @@ static boolean_t blake3_is_sse41_supported(void)
#if defined(__x86_64)
return (kfpu_allowed() && zfs_sse4_1_available());
#elif defined(__PPC64__) && defined(__linux__)
<<<<<<< HEAD
/* TODO: implement vsx handler or FreeBSD */
=======
>>>>>>> c629f0bf62e351355716f9870d6c2e377584b016
return (kfpu_allowed() && zfs_vsx_available());
#else
return (kfpu_allowed());
#endif
}
const blake3_impl_ops_t blake3_sse41_impl = {
const blake3_ops_t blake3_sse41_impl = {
.compress_in_place = blake3_compress_in_place_sse41,
.compress_xof = blake3_compress_xof_sse41,
.hash_many = blake3_hash_many_sse41,
@ -181,7 +183,7 @@ static boolean_t blake3_is_avx2_supported(void)
zfs_avx2_available());
}
const blake3_impl_ops_t blake3_avx2_impl = {
const blake3_ops_t blake3_avx2_impl = {
.compress_in_place = blake3_compress_in_place_sse41,
.compress_xof = blake3_compress_xof_sse41,
.hash_many = blake3_hash_many_avx2,
@ -239,7 +241,7 @@ static boolean_t blake3_is_avx512_supported(void)
zfs_avx512vl_available());
}
const blake3_impl_ops_t blake3_avx512_impl = {
const blake3_ops_t blake3_avx512_impl = {
.compress_in_place = blake3_compress_in_place_avx512,
.compress_xof = blake3_compress_xof_avx512,
.hash_many = blake3_hash_many_avx512,

View File

@ -342,8 +342,8 @@ kcf_remove_mech_provider(const char *mech_name, kcf_provider_desc_t *prov_desc)
mech_entry->me_sw_prov = NULL;
/* free entry */
KCF_PROV_REFRELE(prov_mech->pm_prov_desc);
KCF_PROV_IREFRELE(prov_mech->pm_prov_desc);
KCF_PROV_REFRELE(prov_mech->pm_prov_desc);
kmem_free(prov_mech, sizeof (kcf_prov_mech_desc_t));
}

View File

@ -158,8 +158,8 @@ kcf_prov_tab_rem_provider(crypto_provider_id_t prov_id)
* at that time.
*/
KCF_PROV_REFRELE(prov_desc);
KCF_PROV_IREFRELE(prov_desc);
KCF_PROV_REFRELE(prov_desc);
return (CRYPTO_SUCCESS);
}

View File

@ -126,28 +126,26 @@ typedef struct kcf_provider_desc {
crypto_provider_id_t pd_prov_id;
} kcf_provider_desc_t;
/* atomic operations in linux implicitly form a memory barrier */
#define membar_exit()
/*
* If a component has a reference to a kcf_provider_desc_t,
* it REFHOLD()s. A new provider descriptor which is referenced only
* by the providers table has a reference counter of one.
*/
#define KCF_PROV_REFHOLD(desc) { \
atomic_add_32(&(desc)->pd_refcnt, 1); \
ASSERT((desc)->pd_refcnt != 0); \
#define KCF_PROV_REFHOLD(desc) { \
int newval = atomic_add_32_nv(&(desc)->pd_refcnt, 1); \
ASSERT(newval != 0); \
}
#define KCF_PROV_IREFHOLD(desc) { \
atomic_add_32(&(desc)->pd_irefcnt, 1); \
ASSERT((desc)->pd_irefcnt != 0); \
#define KCF_PROV_IREFHOLD(desc) { \
int newval = atomic_add_32_nv(&(desc)->pd_irefcnt, 1); \
ASSERT(newval != 0); \
}
#define KCF_PROV_IREFRELE(desc) { \
ASSERT((desc)->pd_irefcnt != 0); \
membar_exit(); \
if (atomic_add_32_nv(&(desc)->pd_irefcnt, -1) == 0) { \
membar_producer(); \
int newval = atomic_add_32_nv(&(desc)->pd_irefcnt, -1); \
ASSERT(newval != -1); \
if (newval == 0) { \
cv_broadcast(&(desc)->pd_remove_cv); \
} \
}
@ -155,9 +153,10 @@ typedef struct kcf_provider_desc {
#define KCF_PROV_REFHELD(desc) ((desc)->pd_refcnt >= 1)
#define KCF_PROV_REFRELE(desc) { \
ASSERT((desc)->pd_refcnt != 0); \
membar_exit(); \
if (atomic_add_32_nv(&(desc)->pd_refcnt, -1) == 0) { \
membar_producer(); \
int newval = atomic_add_32_nv(&(desc)->pd_refcnt, -1); \
ASSERT(newval != -1); \
if (newval == 0) { \
kcf_provider_zero_refcnt((desc)); \
} \
}
@ -193,9 +192,9 @@ typedef struct kcf_mech_entry {
* it REFHOLD()s. A new policy descriptor which is referenced only
* by the policy table has a reference count of one.
*/
#define KCF_POLICY_REFHOLD(desc) { \
atomic_add_32(&(desc)->pd_refcnt, 1); \
ASSERT((desc)->pd_refcnt != 0); \
#define KCF_POLICY_REFHOLD(desc) { \
int newval = atomic_add_32_nv(&(desc)->pd_refcnt, 1); \
ASSERT(newval != 0); \
}
/*
@ -203,9 +202,10 @@ typedef struct kcf_mech_entry {
* reference is released, the descriptor is freed.
*/
#define KCF_POLICY_REFRELE(desc) { \
ASSERT((desc)->pd_refcnt != 0); \
membar_exit(); \
if (atomic_add_32_nv(&(desc)->pd_refcnt, -1) == 0) \
membar_producer(); \
int newval = atomic_add_32_nv(&(desc)->pd_refcnt, -1); \
ASSERT(newval != -1); \
if (newval == 0) \
kcf_policy_free_desc(desc); \
}

View File

@ -73,9 +73,10 @@ typedef struct kcf_context {
* context structure is freed along with the global context.
*/
#define KCF_CONTEXT_REFRELE(ictx) { \
ASSERT((ictx)->kc_refcnt != 0); \
membar_exit(); \
if (atomic_add_32_nv(&(ictx)->kc_refcnt, -1) == 0) \
membar_producer(); \
int newval = atomic_add_32_nv(&(ictx)->kc_refcnt, -1); \
ASSERT(newval != -1); \
if (newval == 0) \
kcf_free_context(ictx); \
}

View File

@ -27,6 +27,7 @@
#include <sys/zio_checksum.h>
#include <sys/zfs_context.h>
#include <sys/arc.h>
#include <sys/arc_os.h>
#include <sys/zfs_refcount.h>
#include <sys/vdev.h>
#include <sys/vdev_trim.h>
@ -72,31 +73,12 @@ SYSINIT(arc_free_target_init, SI_SUB_KTHREAD_PAGE, SI_ORDER_ANY,
* We don't have a tunable for arc_free_target due to the dependency on
* pagedaemon initialisation.
*/
static int
sysctl_vfs_zfs_arc_free_target(SYSCTL_HANDLER_ARGS)
{
uint_t val;
int err;
val = zfs_arc_free_target;
err = sysctl_handle_int(oidp, &val, 0, req);
if (err != 0 || req->newptr == NULL)
return (err);
if (val < minfree)
return (EINVAL);
if (val > vm_cnt.v_page_count)
return (EINVAL);
zfs_arc_free_target = val;
return (0);
}
SYSCTL_DECL(_vfs_zfs);
SYSCTL_PROC(_vfs_zfs, OID_AUTO, arc_free_target,
CTLTYPE_UINT | CTLFLAG_MPSAFE | CTLFLAG_RW, 0, sizeof (uint_t),
sysctl_vfs_zfs_arc_free_target, "IU",
ZFS_MODULE_PARAM_CALL(zfs_arc, zfs_arc_, free_target,
param_set_arc_free_target, 0, CTLFLAG_RW,
"Desired number of free pages below which ARC triggers reclaim");
ZFS_MODULE_PARAM_CALL(zfs_arc, zfs_arc_, no_grow_shift,
param_set_arc_no_grow_shift, 0, ZMOD_RW,
"log2(fraction of ARC which must be free to allow growing)");
int64_t
arc_available_memory(void)
@ -159,6 +141,12 @@ arc_prune_task(void *arg)
int64_t nr_scan = (intptr_t)arg;
arc_reduce_target_size(ptob(nr_scan));
#ifndef __ILP32__
if (nr_scan > INT_MAX)
nr_scan = INT_MAX;
#endif
#if __FreeBSD_version >= 1300139
sx_xlock(&arc_vnlru_lock);
vnlru_free_vfsops(nr_scan, &zfs_vfsops, arc_vnlru_marker);
@ -221,7 +209,10 @@ arc_lowmem(void *arg __unused, int howto __unused)
arc_warm = B_TRUE;
arc_growtime = gethrtime() + SEC2NSEC(arc_grow_retry);
free_memory = arc_available_memory();
to_free = (arc_c >> arc_shrink_shift) - MIN(free_memory, 0);
int64_t can_free = arc_c - arc_c_min;
if (can_free <= 0)
return;
to_free = (can_free >> arc_shrink_shift) - MIN(free_memory, 0);
DTRACE_PROBE2(arc__needfree, int64_t, free_memory, int64_t, to_free);
arc_reduce_target_size(to_free);

View File

@ -0,0 +1,65 @@
/*
* SPDX-License-Identifier: BSD-2-Clause-FreeBSD
*
* Copyright (c) 2022 Rob Wing
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
*
* THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
* ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
* OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
*/
#include <sys/param.h>
#include <sys/lock.h>
#include <sys/sx.h>
#include <sys/event.h>
#include <sys/freebsd_event.h>
static void
knlist_sx_xlock(void *arg)
{
sx_xlock((struct sx *)arg);
}
static void
knlist_sx_xunlock(void *arg)
{
sx_xunlock((struct sx *)arg);
}
static void
knlist_sx_assert_lock(void *arg, int what)
{
if (what == LA_LOCKED)
sx_assert((struct sx *)arg, SX_LOCKED);
else
sx_assert((struct sx *)arg, SX_UNLOCKED);
}
void
knlist_init_sx(struct knlist *knl, struct sx *lock)
{
knlist_init(knl, lock, knlist_sx_xlock, knlist_sx_xunlock,
knlist_sx_assert_lock);
}

Some files were not shown because too many files have changed in this diff Show More