metaslab: expose df_alloc_threshold and df_free_pct on Linux
Expose metaslab_df_alloc_threshold and metaslab_df_free_pct as module
parameters on Linux, matching their existing FreeBSD sysctls.
Reviewed-by: Alexander Motin <alexander.motin at TrueNAS.com>
Reviewed-by: Brian Behlendorf <behlendorf1 at llnl.gov>
Signed-off-by: Christos Longros <chris.longros at gmail.com>
Closes #18632
ZTS: relax zpool_import_parallel_pos.ksh timing
Occasionally in the CI this test will fail because the parallel import
took longer than half of the serial time (but still less than the full
serial time). Increase the cutoff to 3/4 of the serial time to preserve
the intent yet try and avoid these false positive failures.
Reviewed-by: Chris Longros <chris.longros at gmail.com>
Signed-off-by: Brian Behlendorf <behlendorf1 at llnl.gov>
Closes #18634
Fix uninitialized variable warning in zil_parse()
This resolves the following possible uninitialized variable warning
when building with --enable-code-coverage and gcc 8.5.0.
module/zfs/zil.c: In function ‘zil_parse’:
module/zfs/zil.c:549:47: warning: ‘end’ may be used uninitialized
in this function [-Wmaybe-uninitialized]
Reviewed-by: Alexander Motin <alexander.motin at TrueNAS.com>
Signed-off-by: Brian Behlendorf <behlendorf1 at llnl.gov>
Closes #18633
unit/zap: zap_value_search
Two separate tests, one for basic operation and one for the "value mask"
feature.
Sponsored-by: TrueNAS
Reviewed-by: Alexander Motin <alexander.motin at TrueNAS.com>
Reviewed-by: Brian Behlendorf <behlendorf1 at llnl.gov>
Signed-off-by: Rob Norris <rob.norris at truenas.com>
Closes #18630
unit: rand helpers
Sponsored-by: TrueNAS
Reviewed-by: Alexander Motin <alexander.motin at TrueNAS.com>
Reviewed-by: Brian Behlendorf <behlendorf1 at llnl.gov>
Signed-off-by: Rob Norris <rob.norris at truenas.com>
Closes #18630
zap: add zap_value_search_by_dnode()
This operates entirely on a cursor, so the two entry points just
instantiate a new cursor and then pass it into the worker.
Sponsored-by: TrueNAS
Reviewed-by: Alexander Motin <alexander.motin at TrueNAS.com>
Reviewed-by: Brian Behlendorf <behlendorf1 at llnl.gov>
Signed-off-by: Rob Norris <rob.norris at truenas.com>
Closes #18630
unit/zap: zap_*_int and zap_*_int_key
Sponsored-by: TrueNAS
Reviewed-by: Alexander Motin <alexander.motin at TrueNAS.com>
Reviewed-by: Brian Behlendorf <behlendorf1 at llnl.gov>
Signed-off-by: Rob Norris <rob.norris at truenas.com>
Closes #18630
zap: add _by_dnode() variants for int and int_key functions
These functions are far too simple to make wrapping worthwhile, so
instead we just lift the important shared bit - the value->string
conversion - into a small macro, and use it in all of them.
Sponsored-by: TrueNAS
Reviewed-by: Alexander Motin <alexander.motin at TrueNAS.com>
Reviewed-by: Brian Behlendorf <behlendorf1 at llnl.gov>
Signed-off-by: Rob Norris <rob.norris at truenas.com>
Closes #18630
unit/zap: zap_increment
Sponsored-by: TrueNAS
Reviewed-by: Alexander Motin <alexander.motin at TrueNAS.com>
Reviewed-by: Brian Behlendorf <behlendorf1 at llnl.gov>
Signed-off-by: Rob Norris <rob.norris at truenas.com>
Closes #18630
zap: add zap_increment_by_dnode()
Make consistent with the standard pattern, with zap_increment() becoming
a simple wrapper around zap_increment_by_dnode().
This has a small, likely unnoticeable, behaviour change. The previous
version didn't use the _by_dnode() functions, so the ZAP, dnode and dbuf
could theoretically be evicted between calls. With the dnode held across
the calls, this won't happen anymore. This is almost certainly a good
thing.
Sponsored-by: TrueNAS
Reviewed-by: Alexander Motin <alexander.motin at TrueNAS.com>
Reviewed-by: Brian Behlendorf <behlendorf1 at llnl.gov>
Signed-off-by: Rob Norris <rob.norris at truenas.com>
Closes #18630
zap: remove zap_join() functions
These work, but are limited in their focus (single uint64_t key). The
last use anywhere was removed in d4a72f2386 (~2017). Better to remove
them rather than bother to uplift them to the new _by_dnode() structure.
They're simple to recreate if we ever do need them again.
Sponsored-by: TrueNAS
Reviewed-by: Alexander Motin <alexander.motin at TrueNAS.com>
Reviewed-by: Brian Behlendorf <behlendorf1 at llnl.gov>
Signed-off-by: Rob Norris <rob.norris at truenas.com>
Closes #18630
zap: remove zap_increment_int()
This is a strange function that can't possibly work sensibly with
zap_add_int()/zap_remove_int()/zap_lookup_int(), as it allows the key
and value to diverge, which is not how these functions appear to work.
It would make more sense if it were called zap_increment_int_key(), as
that family can have divergent key and value. But it doesn't.
Fortunately, nothing uses it. There was a function named
zap_increment_int() in Sun ZFS, that was renamed to zap_increment()
early in ZoL's lifetime, and is unrelated.
So, remove it, and fix up some very old comments referring to it.
Sponsored-by: TrueNAS
Reviewed-by: Alexander Motin <alexander.motin at TrueNAS.com>
Reviewed-by: Brian Behlendorf <behlendorf1 at llnl.gov>
Signed-off-by: Rob Norris <rob.norris at truenas.com>
Closes #18630
Add additional verification of size fields and strings (#18623)
- Check for size fields that convert to smaller integers.
- Explicitly terminate bootenv string.
- Initialize variables that could be returned in an error case.
Reviewed-by: Brian Behlendorf <behlendorf1 at llnl.gov>
Reviewed-by: Chris Longros <chris.longros at gmail.com>
Reviewed-by: Alexander Motin <alexander.motin at TrueNAS.com>
Signed-off-by: Tony Hutter <hutter2 at llnl.gov>
Closes #18623
CI: Add alternative URLs for CentOS stream
Fallback to trying the "CentOS Strean Composes" repo for the qcow2
images if the regular URLs fail. The Composes repo contains the daily
autobuilt Stream images.
Reviewed-by: Brian Behlendorf <behlendorf1 at llnl.gov>
Signed-off-by: Tony Hutter <hutter2 at llnl.gov>
Closes #18628
CI: Increase default RCU stall timeout on Linux
When CONFIG_RCU_CPU_STALL_TIMEOUT is configured an RCU stall which
exceeds the default timeout will trigger an NMI and panic the VM.
Given the heavily virtualized nature of the CI environment we want
to make sure to only trigger this due to a real deadlock and not
due to over-subscription of the systems resources. This timeout
normally defaults to 20-30 seconds and this change increases it
to 120 seconds.
Reviewed-by: Tony Hutter <hutter2 at llnl.gov>
Signed-off-by: Brian Behlendorf <behlendorf1 at llnl.gov>
Closes #18624
CI: Update CodeQL actions to v4
CodeQL Action v3 has been deprecated and will be retired
December 2026. Update codeql.yml to use CodeQL Action v4
and update the runner to ubuntu-24.04.
Signed-off-by: Brian Behlendorf <behlendorf1 at llnl.gov>
Closes #18629
CI: Re-enable CodeQL workflows on push
This workflow was disabled 'on push' recently in commit 1916c2c5
to reduce redundant CI runs. However, this check is fairly quick
and we want it run regularly against the branches. Enable it.
Reviewed-by: Tony Hutter <hutter2 at llnl.gov>
Signed-off-by: Brian Behlendorf <behlendorf1 at llnl.gov>
Closes #18627
Remove /etc/sudoers.d/zfs
The smartctl exception in /etc/sudoers.d/zfs doesn't cover devices
like NVMe or symlinked devices. Just get rid of it rather than
keep maintaining it.
Reviewed-by: Brian Behlendorf <behlendorf1 at llnl.gov>
Reviewed-by: Alexander Motin <alexander.motin at TrueNAS.com>
Signed-off-by: Tony Hutter <hutter2 at llnl.gov>
Closes #18626
zpool/zfs: accept --help and -? after a subcommand
Print the short usage instead of "invalid option".
Reviewed-by: Brian Behlendorf <behlendorf1 at llnl.gov>
Signed-off-by: Christos Longros <chris.longros at gmail.com>
Closes #18541
Parallelize metaslab_sync_done() calls
Some of our random write benchmarks on a fragmented pool show that
single-threaded portion of sync process (txg_sync_thread) can use
up to 45% of CPU time. Most of it is consumed by metaslab_sync()
and metaslab_sync_done(), during which time the pool is not doing
anything else.
While metaslab_sync() is not trivial to parallelize due to having
single spacemap log, metaslab_sync_done() is doing only per-metaslab
accounting and they can run in parallel. Even better, we can run
them while waiting for vdev label update and cache flush I/Os.
With this patch on my test system similar test randomly writing 12
100GB files with 4KB blocks shows IOPS increase from 176K to 220K.
Reviewed-by: Tony Hutter <hutter2 at llnl.gov>
Reviewed-by: Brian Behlendorf <behlendorf1 at llnl.gov>
Signed-off-by: Alexander Motin <alexander.motin at TrueNAS.com>
Closes #18622
unit: update docs for new coverage report options
Sponsored-by: TrueNAS
Reviewed-by: Brian Behlendorf <behlendorf1 at llnl.gov>
Signed-off-by: Rob Norris <rob.norris at truenas.com>
Closes #18619
unit: support text & HTML targets; improve coverage rules
The main change is switching `unit-coverage` to run
scripts/coverage_report.pl, to get nice coverage summary output on the
commandline. The previous behaviour moves to `unit-coverage-html`.
Calls to lcov and genhtml are now silencing more warnings, and the
output file now gets branch coverage as well.
This should be compatible with both lcov 1.x and 2.x. It takes advantage
of the fact that 1.x is far more forgiving of both options it doesn't
understand, and of various kinds of "inconsistency" in the input data.
The rest is both simplifying and improving the rules. We keep the
coverage output around now, but still rebuild it if the binary changes.
The `clean` target now removes the coverage output too. And we use the
target name more often for building path names, as its far less noisy.
Sponsored-by: TrueNAS
[3 lines not shown]
coverage_report: produce nice text reports from lcov/geninfo tracefiles
Sponsored-by: TrueNAS
Reviewed-by: Brian Behlendorf <behlendorf1 at llnl.gov>
Signed-off-by: Rob Norris <rob.norris at truenas.com>
Closes #18619
pam: use open fd instead of path
Instead of performing multiple operations on the path name in
zfs_key_config_modify_session_counter() open the file once and
perform the fchown, fchmod, and openat on the open file handle.
Reviewed-by: Tony Hutter <hutter2 at llnl.gov>
Signed-off-by: Brian Behlendorf <behlendorf1 at llnl.gov>
Closes #18618
ZTS: fix mktemp usage on FreeBSD
On FreeBSD -t takes a required prefix argument. Use
"mktemp -d $TEST_BASE_DIR/..." instead.
Reviewed-by: Tony Hutter <hutter2 at llnl.gov>
Reviewed-by: Brian Behlendorf <behlendorf1 at llnl.gov>
Signed-off-by: Christos Longros <chris.longros at gmail.com>
Closes #18621
Extend dataset zfs_ioc_set_prop() secpolicy
When zc->zc_cookie is set this indicates to zfs_ioc_set_prop() that
these are received properties and ZPROP_HAS_RECVD will be set on the
dataset. This is only done as part of a `zfs receive` so additionally
apply the zfs_secpolicy_recv() policy. Individual property checks
continue to be handled by zfs_check_settable().
Reviewed-by: Tony Hutter <hutter2 at llnl.gov>
Reviewed-by: Alexander Motin <alexander.motin at TrueNAS.com>
Signed-off-by: Brian Behlendorf <behlendorf1 at llnl.gov>
Closes #18617
Fix uninitialized variable warning in vdev_prop_get()
Update vdev_prop_get_objid() to set objid on error as the comment
in vdev_prop_get() describes.
"objid is set to 0 when absent and the few cases that call
zap_lookup directly guard against this below."
This resolves the following possible uninitialized variable warning.
module/zfs/vdev.c: In function ‘vdev_prop_get’:
module/zfs/vdev.c:6913:12: error: ‘objid’ may be used uninitialized
in this function [-Werror=maybe-uninitialized]
Reviewed-by: Alexander Motin <alexander.motin at TrueNAS.com>
Reviewed-by: Tony Hutter <hutter2 at llnl.gov>
Signed-off-by: Brian Behlendorf <behlendorf1 at llnl.gov>
Closes #18616
sharenfs: Check for invalid characters
Check for invalid characters in sharenfs/sharesmb dataset props.
Reviewed-by: Brian Behlendorf <behlendorf1 at llnl.gov>
Signed-off-by: Tony Hutter <hutter2 at llnl.gov>
Closes #18613
Fix the integer type in zfs_ioc_userspace_many()
Fix the mismatched type in zfs_ioc_userspace_many() and limit the
number of entries returned to 1000. When a size larger than this
is requested the response is truncated, zfs_userspace() already
correctly handles short responses. Historically, zfs_userspace()
has requested 100 entries at a time, this cap allows for 10x larger
batch sizes if needed in the future.
Reported-by: Yuxiang Yang, Yizhou Zhao, Ao Wang, Xuewei Feng, Qi Li,
Reported-by: and Ke Xu from Tsinghua University using GLM-5.1 from Z.ai
Reviewed-by: Alexander Motin <alexander.motin at TrueNAS.com>
Reviewed-by: Tony Hutter <hutter2 at llnl.gov>
Signed-off-by: Brian Behlendorf <behlendorf1 at llnl.gov>
Closes #18615
When reading a vdev label skip libzfs_core_init()
There's no need to call libzfs_core_init() when `zdb -l` is used to
read a vdev label.
Reviewed-by: Brian Behlendorf <behlendorf1 at llnl.gov>
Signed-off-by: tiehexue <tiehexue at hotmail.com>
Closes #18606