ZTS: restore the tunables that tests change
These tests change a tunable and then never set it back, or set it to a
value that is not its default, so the tests after them run with a
different value:
- zfs_send_006_pos: zfs_override_estimate_recordsize was left at 8192
(default 0).
- zpool_scrub_print_repairing: zfs_scan_vdev_limit was set to 4 MB
(default 16 MB).
- import_rewind_config_changed, import_rewind_device_replaced: the
zpool_import cleanup set zfs_txg_history to 0 (default 100).
- tst.memory_limit: zfs_lua_max_memlimit was never restored.
- async_destroy_001_pos: zfs_async_block_max_blocks was set to 100000
(default unlimited).
- zfs_clone_livelist_condense_races: zfs_livelist_condense_zthr_cancel
and _sync_cancel were never reset, and a failed destroy skipped
resetting the other tunables. Destroying a clone that is still
condensing increments the counters, so they are reset again after the
[11 lines not shown]
[AllocToken] Propagate !alloc_token through inlined malloc_span wrappers (#244314)
#198535 propagates the !alloc_token of a call to an inlined allocation
wrapper to the allocation call whose result the wrapper returns, so a
type known at the wrapper's call site (e.g. from a sizeof in the size
argument) applies to the underlying allocation. It only follows
pointer-typed return values, so for a malloc_span wrapper such as
```c++
__attribute__((always_inline, malloc_span))
inline sized_ptr_t AllocateBytes(size_t n) { return __size_returning_new(n); }
sized_ptr_t s = AllocateBytes(n * sizeof(char));
```
the call site's pointer-free type was dropped and __size_returning_new
kept the fallback token. This lets size-returning wrappers shared by
several types be typed at each call site rather than inside the wrapper.
Follow the returned value as a whole, of any type, through casts, phis
[5 lines not shown]
ZTS: restore the ARC size limits that tests lower
The l2arc_dwpd_*, l2arc_multidev_* and fadvise_willneed_limit tests
lower zfs_arc_max and zfs_arc_min, and their cleanup writes back the
saved value, usually 0. Writing 0 does not change the ARC's limits, so
the rest of the run had a 400 MB ARC. New libtest helpers
save_arc_limits and restore_arc_limits save the ARC's actual limits and
restore them before the tunables.
The l2arc tests also set zfs_arc_max before they lower zfs_arc_min. On
a host whose ARC minimum is above 400 MB, such as a FreeBSD machine
with 32 GB of memory, FreeBSD rejects that maximum and the tests fail;
Linux ignores it, with a warning, until the minimum comes down. A
third helper, set_arc_limits, sets the maximum first, after lowering the
minimum out of its way if needed. The tests and restore_arc_limits use
it, and restore_arc_limits writes back only the tunables that changed,
so it can also restore a minimum equal to the maximum.
Reviewed-by: Brian Behlendorf <behlendorf1 at llnl.gov>
[3 lines not shown]
[CIR] Implement lowering of vectors of _BitInt (#244412)
Sema allows vectors of _BitInt(N) as long as N is a power-of-two. This
change adds a power-of-two check for _BitInt elements in vector types
and implements lowering of such vectors to LLVM.
This change eliminated most of the unsupported cases in
`unsupported-initializer-types.cir` and
`unsupported-type-conversions.cir` so those tests are being deleted. The
test cases from those files that are still relevant were moved into
`unlowered-address-spaces.cir`.
Assisted-by: Cursor / claude-opus-5.5
rtsock: drop a notification whose sockaddr does not fit
rtsock_msg_mbuf() bounces every sockaddr through a struct
sockaddr_storage on the stack, and only a KASSERT checks that it
fits. Without INVARIANTS, a larger sockaddr overflows the stack.
The callers pass only sockaddrs that the kernel built or checked, so
one that does not fit is a bug in the caller.
Also check at run time, as f3be7df50f0 did for rtsock_msg_buffer():
free the mbuf and return NULL, which every caller already handles
like a failed allocation.
Log the drop at LOG_DEBUG, as rt_xaddrs() does for an oversized
sockaddr from userland. The message is compiled in but off by
default. Setting net.route.debug.rtsock_debug_level to 7 shows which
message and sockaddr were dropped.
Reviewed by: lytboris
[4 lines not shown]
Check objset MACs directly
When an objset block is smaller than the pool's objset_phys_t size,
dmu_objset_open_impl() copies it into a larger anonymous ARC buffer.
The copy isn't marked unauthenticated, so dmu_objset_own() and
non-raw sends accept it without checking its MACs, and the next write
computes new MACs over it. Encrypted objsets written by older illumos
ZFS are 2 KiB, so they take this path on pools with project quotas
enabled.
Have dmu_objset_authenticate() check the MACs of os_phys itself
rather than rely on the ARC's mark. The zero padding of a copy doesn't
change the MACs. A new objset has no MACs to check, so it starts out
authenticated.
Reviewed by: George Wilson <gwilson at zfsmail.com>
Reviewed-by: Brian Behlendorf <behlendorf1 at llnl.gov>
Signed-off-by: Matthew Ahrens <matt at mahrens.org>
Co-Authored-By: Claude Opus 5.5 <noreply at anthropic.com>
Closes #19884
[lld/mac,lld/win] Call llvm::sys::fs::current_path() less (#247661)
Summary: This makes linking Chromium Framework ~30 ms faster on
unix systems in the common case, and ~0.2s faster on macOS in
a very uncommon case. If chrome.dll is linked without /pdbsourcepath
(in practice, it's always linked with that flag), it makes linking
chrome.dll faster by ~1.4s on unix systems in the common case,
and ~11 s (!) (19.45s -> 8.63s) on macOS in a very uncommon case.
Details:
Unix/Path.inc implements current_path() by checking if
stat($PWD) and stat(".") refer to the same inode. If they do, it
returns $PWD. Else, it returns getcwd().
lld-link and ld64.lld by default make all debug info paths absolute
relative to the cwd. They did this by calling sys::fs::make_absolute()
with just the relative path for each object file. make_absolute()
internally calls current_path().
[26 lines not shown]
Check objset MACs in one place
dmu_objset_own() and non-raw sends each check the MACs of an
encrypted objset by looking at the ARC header of os_phys_buf, without
a lock, while the sync thread may be writing the objset and replacing
that header.
Move the check into dmu_objset_authenticate(). Mark the objset as
being written from before os_phys_buf is released until the write is
done, and have the check wait for a write in progress. Record in the
objset that its MACs have been checked, so that later callers skip
the check and don't wait. A raw receive changes the MACs, so it marks
them unchecked again.
Reviewed by: George Wilson <gwilson at zfsmail.com>
Reviewed-by: Brian Behlendorf <behlendorf1 at llnl.gov>
Signed-off-by: Matthew Ahrens <matt at mahrens.org>
Co-Authored-By: Claude Opus 5.5 <noreply at anthropic.com>
Closes #19884
ZTS: make zfs-tests.sh -t NAME select the test of that name
zfs-tests.sh -t NAME, given a name rather than a path, runs the first
path under the test suite whose name starts with NAME, in directory
order. Many tests share that prefix with something that is not the
test: a helper program (bin/mmap_ftruncate once installed, or
cmd/mmap_ftruncate.c in a source tree; likewise mmap_read_truncate,
mmap_eof_extend, mount_null_source, send_doall, file_append), a
directory named after the test (zfs_rewrite, zfs_load-key), a data
file (a channel program's .zcp or .out), an object file, or another
test (tst.clone_neg for tst.clone). Which path comes first depends on
the file system. A directory or a data file makes test-runner reject
the runfile, so nothing runs; an installed helper is an executable
file, so test-runner runs it instead of the test.
Search only tests/, and for a file named NAME.ksh or NAME first, so
that the tests that are programs (hkdf_test, many_fds, page_alignment,
tmpfile_*) are still found, and skip .libs, where libtool keeps a
second copy of such a program in a build tree. Only when no file has
[10 lines not shown]
[RISCV][CFI] Preserve CFI instructions around CM_POP and RET (#246963)
Emit CFI restore directives and update the CFA offset after CM_POP,
except when followed by RET. Update the POPRET fusion pass to match
CM_POP and RET across debug instructions. Remove CFI directives between
foldable CM_POP and RET. Update affected tests accordingly.
Follow up #245548
ZTS: run cleanup when a test fails
These tests skip some of their cleanup when they fail, so a failure
leaves state behind for the tests after it:
- zpool_iostat_interval_all, zpool_iostat_interval_some, slog_014_pos:
register the cleanup function, which they never did.
- inherit_001_pos: register default_cleanup_noexit, which was only
called at the start of each configuration.
- delegate verify_fs_receive, verify_fs_receive_append: remove the
stream files when the test fails, too.
- tmpfile_002_pos: remove the link when zpool freeze or export fails,
so that tmpfile_003_pos does not find it.
- removal tests: stop the random writer when the test fails, before
the pool is destroyed.
Reviewed-by: Brian Behlendorf <behlendorf1 at llnl.gov>
Reviewed-by: Alan Somers <asomers at gmail.com>
Signed-off-by: Matthew Ahrens <matt at mahrens.org>
Co-authored-by: Claude Opus 5.5 <noreply at anthropic.com>
Closes #20081
DAG: Express atomic extload and truncstore legality more like non-atomic
Make legalization of ATOMIC_LOAD behave more like LOAD, and
ATOMIC_STORE more like STORE. Previously atomic legality was decided
by the value type alone. Extending atomic loads now use the atomic
load extension actions, queried with a new getAtomicLoadExtAction
instead of an Atomic flag on getLoadAction. This removes a lot of
noise from the common case without introducing an unsafe default
argument. Truncating atomic stores check the truncating store actions
shared with non-atomic stores since there's no practical usecase for
distinguishing them.
An expanded sign or zero extending atomic load becomes an
any-extending atomic load plus an in-register extend, and an expanded
truncating atomic store of a legal memory type becomes a truncate and
a non-truncating atomic store. Atomic extload support differs from
non-atomic extloads on some targets. All extending atomic loads
default to Expand, unlike load.
Co-authored-by: Claude Opus 5.5 <noreply at anthropic.com>
docs: Add some best practices documentation for codegen tests (#244482)
Document common review feedback.
Co-authored-by: Claude Opus 5.5 <noreply at anthropic.com>
[dsymutil] Don't write past a DIE for a relocation that does not fit (#247778)
applyValidRelocs() asserts that a relocation fits in the DIE it
patches, then writes it regardless. A relocation map which does not
describe the DWARF of its dSYM holds relocations running past their
DIE, and one larger than 8 bytes also overflows the buffer its value
is built in.
Reject a relocation running past the range it is looked up in, with a
warning. getRelocations() does so for every lookup: such a relocation
is not applied, does not keep its DIE, and is not saved to the output
relocation map. The asserts in applyValidRelocs() now hold.
The check needs exact ranges. In both linkers,
getVariableRelocAdjustment() passed a range starting at the length of
the block, which precedes the expression. Two tests had their
relocations on that length, where only such a range found them. Move
them to the operand.
[4 lines not shown]
RuntimeLibcalls: Add attributes to ObjC runtime calls
Mark the ObjC runtime functions nounwind, and mark the argument of
the functions whose intrinsics mark their argument returned.
Co-authored-by: Claude Opus 5.5 <noreply at anthropic.com>
RuntimeLibcalls: Add attributes to operator new and delete
Annotate operator new and delete implementation variants. The nothrow
variants are nounwind. No library registers these yet so they don't
appear in the DeclareRuntimeLibcalls tests.
Co-authored-by: Claude Opus 5.5 <noreply at anthropic.com>
linux: reuse stored names for normalized lookups
Resolve normalization-equivalent names to the stored dentry so that
removing or renaming one spelling cannot leave another cached spelling
accessible. Keep case sensitivity unchanged and discard negative
dentries that could hide a newly created equivalent name.
Warm both spellings in the native mixed-case deletion test.
Remove the Linux expected-failure entries for the four normalization
tests which now pass.
Assisted-by: OpenAI Codex
Reviewed-by: Brian Behlendorf <behlendorf1 at llnl.gov>
Signed-off-by: ooonea <35407790+ooonea at users.noreply.github.com>
Closes #13980
Closes #19726
Revert "[Clang][Sema] Accept weak reference after declaration" (#247827)
Reverts llvm/llvm-project#228809 . There was reported breakage building
OpenZFS.
I'd prefer to take our time to get this right.
[X86] canonicalizeShuffleWithOp - generalize VZEXT_MOVL folding to any op with known zero in the upper bits (#247832)
Generalised from the VTRUNC handling that was added to #245048 - we can
use value tracking to confirm that the upper bits are already zero,
which means the VZEXT_MOVL will be free if moved through the logic op.
libzfs: FreeBSD: retry an unmount a mount update holds busy
FreeBSD's dounmount() returns EBUSY while the mount has MNT_UPDATE
set, that is while any nmount(MNT_UPDATE) on it is in progress.
mountd(8) applies export changes that way, and libzfs signals mountd
in zfs_unmount() (zfs_commit_shares() after zfs_unshare()) right
before calling unmount(2). So 'zfs unmount', 'zfs set canmount=off',
'zfs destroy' or 'zpool export' of a dataset with sharenfs=on could
fail with "pool or dataset is busy" when mountd's update of that file
system (from this or an earlier share change) overlapped the unmount.
This is the inheritance/inherit_001_pos failure on the FreeBSD CI
runners. FreeBSD 14 calls VFS_MOUNT() (a ZFS remount) for each export
update as well, which makes the window wider there.
Retry unmount(2) on EBUSY with a short backoff (10 ms doubling, about
1.3 s in all). A file system that is really busy still fails with
EBUSY, only later.
This makes zfs_unmount_remount_busy pass.
[5 lines not shown]
ZTS: zfs unmount of a file system busy for a moment
On FreeBSD, unmount(2) returns EBUSY while another thread is inside
nmount(MNT_UPDATE) on the same mount. mountd(8) does exactly that
whenever libzfs commits an NFS share change: it pushes the new export
list into the kernel with nmount(MNT_UPDATE). 'zfs unmount' of a
dataset with sharenfs=on signals mountd right before its own
unmount(2), so it races mountd's update of that very file system.
This is the "cannot unmount ...: pool or dataset is busy" failure of
'zfs set canmount=off' in inheritance/inherit_001_pos on the FreeBSD
CI runners.
zfs_unmount_remount_busy (FreeBSD only, about 3 s):
- a file system held busy by a process, released only once
'zfs unmount' has had EBUSY and waits to try again, must unmount;
without a retry this fails every time, independent of timing;
- 50 unmount/mount cycles while a background loop updates the mount
(mount -u), as mountd does, must all succeed;
- a file system that stays in use must still refuse with "busy",
[6 lines not shown]