]> CyberLeo.Net >> Repos - FreeBSD/FreeBSD.git/log
FreeBSD/FreeBSD.git
8 months agopkgbase: compress packages with zstandard
Baptiste Daroussin [Thu, 26 Oct 2023 20:34:00 +0000 (22:34 +0200)]
pkgbase: compress packages with zstandard

MFC After: 3 days
Reviewed by: manu
Differential Revision: https://reviews.freebsd.org/D42375

8 months agoarm64: Use the Linux sigframe to restore registers
Andrew Turner [Wed, 25 Oct 2023 09:50:11 +0000 (10:50 +0100)]
arm64: Use the Linux sigframe to restore registers

When returning from a Linux signal use the Linux sigframe to find the
register values to restore.

Remove the FreeBSD ucontext from the stack as it's now unneeded.

Reviewed by: dchagin, emaste
Sponsored by: Arm Ltd
Differential Revision: https://reviews.freebsd.org/D42360

8 months agoUPDATING: Document branch creation
Warner Losh [Fri, 27 Oct 2023 04:14:23 +0000 (22:14 -0600)]
UPDATING: Document branch creation

Document when stable/12, stable/13 and stable/14 were created. Once we
release 14.0, I'll trim the stable/11 branchpoint through stable/12
brnachpoint. Documenting all of these will make it easier in the future.

Sponsored by: Netflix

8 months agoefibootmgr: -C isn't implemented
Warner Losh [Tue, 17 May 2022 16:47:50 +0000 (10:47 -0600)]
efibootmgr: -C isn't implemented

-C isn't implemented, so just errx out until it is. It's not listed in
the man page, but is parsed for compatibility with the Linux
efibootmgr(8) command.

Sponsored by: Netflix

8 months agoefibootmgr: support '-b bootXXXX' as an alias for '-b XXXX'
Warner Losh [Tue, 17 May 2022 16:47:03 +0000 (10:47 -0600)]
efibootmgr: support '-b bootXXXX' as an alias for '-b XXXX'

Sponsored by: Netflix

8 months agoarm: prune imx5 support from the tree
Kyle Evans [Fri, 27 Oct 2023 03:55:17 +0000 (22:55 -0500)]
arm: prune imx5 support from the tree

The IMX5 configs were removed in advance of FreeBSD 14.0 in
cdb0c2a73df ("arm: Remove IMX5 specific kernel configs").  This code
isn't built with GENERIC and doesn't actually build today as-is, so
let's remove it to avoid needless maintenance work to it that won't be
tested.  As usual, revival is welcome with a committed user and work to
maintain it with upstream DTS and, ideally, in GENERIC.

I note that vt_early_fb is now effectively orphaned as nothing else will
use it, but I haven't yet removed it since I have not done anything to
ascertain if it could be integrated easily enough for other SoC.  It is
among the files that doesn't actually build with today's clang, though.

Reviewed by: imp, manu
Differential Revision: https://reviews.freebsd.org/D41836

8 months agoarm: Introduce MK_KERNEL_BIN to control generation of kernel.bin
Warner Losh [Fri, 27 Oct 2023 03:10:36 +0000 (21:10 -0600)]
arm: Introduce MK_KERNEL_BIN to control generation of kernel.bin

It's sometimes desirable to generate kernel.bin and install it. While
the mainstream has moved on to UEFI booting on arm, some specialized
gear can't support it. For that gear, we unconditionally generate
kernel.bin. Add a knob so that WITH_KERNEL_BIN or WITHOUT_KERNEL_BIN
control its generation and installation. config files should add
'makeoptions WITH_KERNEL_BIN=t' to enable it. Since its use is
specialized, it is off by default now since the arm world has largely
moved on to UEFI.

It only affects arm and arm64 (since those are the only two that support
it).

Sponsored by: Netflix
Reviewed by: mmel
Differential Revision: https://reviews.freebsd.org/D39013

8 months agopthread_mutexattr(3), _condattr(3): reference libthr(3)
Konstantin Belousov [Mon, 23 Oct 2023 23:03:42 +0000 (02:03 +0300)]
pthread_mutexattr(3), _condattr(3): reference libthr(3)

Reviewed by: emaste
Sponsored by: The FreeBSD Foundation
MFC after: 3 days
Differential revision: https://reviews.freebsd.org/D42344

8 months agopthread_mutexattr_init(3): describe pthread_mutexattr_{set,get}pshared
Konstantin Belousov [Mon, 23 Oct 2023 22:54:54 +0000 (01:54 +0300)]
pthread_mutexattr_init(3): describe pthread_mutexattr_{set,get}pshared

PR: 274678
Reviewed by: emaste
Sponsored by: The FreeBSD Foundation
MFC after: 3 days
Differential revision: https://reviews.freebsd.org/D42344

8 months agottys: bump date
Warner Losh [Thu, 26 Oct 2023 18:37:51 +0000 (12:37 -0600)]
ttys: bump date

8 months agoauxv: make AT_BSDFLAGS unsigned
Brooks Davis [Thu, 26 Oct 2023 17:38:35 +0000 (18:38 +0100)]
auxv: make AT_BSDFLAGS unsigned

AT_BSDFLAGS shouldn't be sign extended on 64-bit systems so use a
uint32_t instead of an int.

Reviewed by: imp, kib
Differential Revision: https://reviews.freebsd.org/D42365

8 months agoprocctl.2: improve phrasing for ASLR disable
Brooks Davis [Thu, 26 Oct 2023 17:38:14 +0000 (18:38 +0100)]
procctl.2: improve phrasing for ASLR disable

Reported by: jrtc27
Reviewed by: kib
Differential Revision: https://reviews.freebsd.org/D42364

8 months agoRead prefetched buffers from L2ARC
shodanshok [Thu, 26 Oct 2023 16:40:21 +0000 (18:40 +0200)]
Read prefetched buffers from L2ARC

Prefetched buffers are currently read from L2ARC if, and only if,
l2arc_noprefetch is set to non-default value of 0. This means that
a streaming read which can be served from L2ARC will instead engage
the main pool.

For example, consider what happens when a file is sequentially read:
- application requests contiguous data, engaging the prefetcher;
- ARC buffers are initially marked as prefetched but, as the calling
application consumes data, the prefetch tag is cleared;
- these "normal" buffers become eligible for L2ARC and are copied to it;
- re-reading the same file will *not* engage L2ARC even if it contains
the required buffers;
- main pool has to suffer another sequential read load, which (due to
most NCQ-enabled HDDs preferring sequential loads) can dramatically
increase latency for uncached random reads.

In other words, current behavior is to write data to L2ARC (wearing it)
without using the very same cache when reading back the same data. This
was probably useful many years ago to preserve L2ARC read bandwidth but,
with current SSD speed/size/price, it is vastly sub-optimal.

Setting l2arc_noprefetch=1, while enabling L2ARC to serve these reads,
means that even prefetched but unused buffers will be copied into L2ARC,
further increasing wear and load for potentially not-useful data.

This patch enable prefetched buffer to be read from L2ARC even when
l2arc_noprefetch=1 (default), increasing sequential read speed and
reducing load on the main pool without polluting L2ARC with not-useful
(ie: unused) prefetched data. Moreover, it clear users confusion about
L2ARC size increasing but not serving any IO when doing sequential
reads.

Reviewed-by: Brian Behlendorf <behlendorf1@llnl.gov>
Reviewed-by: Alexander Motin <mav@FreeBSD.org>
Signed-off-by: Gionatan Danti <g.danti@assyoma.it>
Closes #15451

8 months agoAdd mutex_enter_interruptible() for interruptible sleeping IOCTLs
Thomas Bertschinger [Thu, 26 Oct 2023 16:17:40 +0000 (10:17 -0600)]
Add mutex_enter_interruptible() for interruptible sleeping IOCTLs

Many long-running ZFS ioctls lock the spa_namespace_lock, forcing
concurrent ioctls to sleep for the mutex. Previously, the only
option is to call mutex_enter() which sleeps uninterruptibly. This
is a usability issue for sysadmins, for example, if the admin runs
`zpool status` while a slow `zpool import` is ongoing, the admin's
shell will be locked in uninterruptible sleep for a long time.

This patch resolves this admin usability issue by introducing
mutex_enter_interruptible() which sleeps interruptibly while waiting
to acquire a lock. It is implemented for both Linux and FreeBSD.

The ZFS_IOC_POOL_CONFIGS ioctl, used by `zpool status`, is changed to
use this new macro so that the command can be interrupted if it is
issued during a concurrent `zpool import` (or other long-running
operation).

Reviewed-by: Tony Hutter <hutter2@llnl.gov>
Reviewed-by: Brian Behlendorf <behlendorf1@llnl.gov>
Signed-off-by: Thomas Bertschinger <bertschinger@lanl.gov>
Closes #15360

8 months agogpart: Be less picky about GPT Tables in some cases
Warner Losh [Thu, 26 Oct 2023 16:14:54 +0000 (10:14 -0600)]
gpart: Be less picky about GPT Tables in some cases

When we're recoverying a damangae GPT, or when we're restoring a backed
up partition tables, don't enforce the 4k alignment for start/end LBAs.
This is useful for 512e/4kn drives when we're creating a new partition
table or partition. However, when we're trying to fix / restore an old
partition, we shouldn't force this alignment, since in that case it's
more important to use the partition table as is than to optimize
performance by rounding (which isn't required by the standard).

MFC After: 1 week
Sponsored by: Netflix
Differential Revision: https://reviews.freebsd.org/D42359

8 months agoarc_default_max on Linux should match FreeBSD
ednadolski-ix [Thu, 26 Oct 2023 16:13:01 +0000 (10:13 -0600)]
arc_default_max on Linux should match FreeBSD

Commits 518b487 and 23bdb07 changed the default ARC size limit on
Linux systems to 1/2 of physical memory, which has become too
strict for modern systems with large amounts of RAM. This patch
changes the default limit to match that of FreeBSD, so ZFS may
have a unified value on both platforms.

Reviewed-by: George Melikov <mail@gmelikov.ru>
Reviewed-by: Brian Behlendorf <behlendorf1@llnl.gov>
Signed-off-by: Edmund Nadolski <edmund.nadolski@ixsystems.com>
Closes #15437

8 months agottys: Document insecure flag
Warner Losh [Thu, 26 Oct 2023 16:09:16 +0000 (10:09 -0600)]
ttys: Document insecure flag

Both the secure and insecure flag is documented in init(8). the secure
flag is documented here; however, the insecure flag is not. Nor is the
nuance that a line missing the 'secure' flag is also considered
insecure. Document both here.

Sponsored by: Netflix

8 months agodevd: Restore WARNS=6
Warner Losh [Thu, 26 Oct 2023 04:35:45 +0000 (22:35 -0600)]
devd: Restore WARNS=6

We compile correctly on all platforms with clang and WARNS=6. We build
on amd64 with gcc12 and WARNS.6. Restore WARNS=6. This reverts
3741a56c310d, since that's no longer relevant.

Sponsored by: Netflix

8 months agopf: Fix packet reassembly
Kajetan Staszkiewicz [Thu, 26 Oct 2023 12:26:33 +0000 (14:26 +0200)]
pf: Fix packet reassembly

Don't drop fragmented packets when reassembly is disabled, they can be
matched by rules with "fragment" keyword. Ensure that presence of scrub
rules forces old behaviour.

Reviewed by: kp
Sponsored by: InnoGames GmbH
Differential Revision: https://reviews.freebsd.org/D42355

8 months agopf tests: Add option to send fragmented packets
Kajetan Staszkiewicz [Thu, 26 Oct 2023 09:14:14 +0000 (11:14 +0200)]
pf tests: Add option to send fragmented packets

Add option to send fragmented packets and to properly sniff them by
reassembling them by the sniffer itself.

Reviewed by: kp
Sponsored by: InnoGames GmbH
Differential Revision: https://reviews.freebsd.org/D42354

8 months agobhyve: fix arguments to ioctl(VMIO_SIOCSIFFLAGS)
Gleb Smirnoff [Thu, 26 Oct 2023 09:59:21 +0000 (02:59 -0700)]
bhyve: fix arguments to ioctl(VMIO_SIOCSIFFLAGS)

ioctl(2)'s with integer argument shall pass command argument by value,
not by pointer.  The ioctl(2) manual page is not very clear about that.
See sys/kern/sys_generic.c:sys_ioctl() near IOC_VOID.

Reviewed by: markj
Differential Revision: https://reviews.freebsd.org/D42366
Fixes: fd8b9c73a5a63a7aa438a73951d7a535b4f25d9a

8 months agoDelete snapshot after opening it when running fsck_ffs(9) in background.
Kirk McKusick [Wed, 25 Oct 2023 22:36:45 +0000 (15:36 -0700)]
Delete snapshot after opening it when running fsck_ffs(9) in background.

When fsck_ffs(8) runs in background, it creates a snapshot named
fsck_snapshot in the filesystem's .snap directory. The fsck_snapshot
file was removed when the background fsck finished. If the system
crashed or the fsck exited unexpectedly, the fsck_snapshot file
would remain. The snapshot would consume ever more space as the
filesystem changed over time until it was removed by a system
administrator or a future run of background fsck removed it to
create a new snapshot file.

This commit unlinks the .snap/fsck_snapshot file immediately after
opening it so that it will be reclaimed when fsck closes it at the
conclusion of its run. After a system crash, it will be removed as
part of the filesystem cleanup because of its zero reference count.
As only a few milliseconds pass between its creation and unlinking,
there is far less opportunity for it to be accidentally left behind.

PR:           106107
MFC-after:    1 week

8 months agoZIO: Remove READY pipeline stage from root ZIOs
Alexander Motin [Wed, 25 Oct 2023 22:22:25 +0000 (18:22 -0400)]
ZIO: Remove READY pipeline stage from root ZIOs

zio_root() has no arguments for ready callback or parent ZIO. Except
one recent case in ZIL code if root ZIOs ever have a parent it is
also a root ZIO.  It means we do not need READY pipeline stage for
them, which takes some time to process, but even more time to wait
for the children and be woken by them, and both for no good reason.

The most visible effect of this change is that it avoids one taskq
wakeup per ZIL block written, previously used to run zio_ready()
for lwb_root_zio and skipped now.

Reviewed-by: Brian Behlendorf <behlendorf1@llnl.gov>
Signed-off-by: Alexander Motin <mav@FreeBSD.org>
Sponsored by: iXsystems, Inc.
Closes #15398

8 months agoOpenSSL: regenerate asm files for 3.0.12
Ed Maste [Wed, 25 Oct 2023 17:28:47 +0000 (13:28 -0400)]
OpenSSL: regenerate asm files for 3.0.12

Fixes: ad991e4c142e ("OpenSSL: update to 3.0.12")
Sponsored by: The FreeBSD Foundation

8 months agotcp: Silence a -Wunused-function warning in tcp_ratelimit.h
Mark Johnston [Wed, 25 Oct 2023 14:03:58 +0000 (10:03 -0400)]
tcp: Silence a -Wunused-function warning in tcp_ratelimit.h

No functional change intended.

8 months agoarm64: Add a missing MRS_HWCAP_END
Andrew Turner [Wed, 25 Oct 2023 12:32:04 +0000 (13:32 +0100)]
arm64: Add a missing MRS_HWCAP_END

Add a missing end marker to stop the arm64 CPU ID code reading past
the end of an array.

Sponsored by: Arm Ltd

8 months agoUpdate ASLR stack sysctl description in security.7 and mitigations.7
Ed Maste [Tue, 24 Oct 2023 22:06:59 +0000 (18:06 -0400)]
Update ASLR stack sysctl description in security.7 and mitigations.7

In an earlier implementation the stack (gap) was randomized when the
enable sysctl was set and ASLR was also enabled (in general) for the
binary.  In the current implementation the sysctl operates
independently.

Reviewed by: kib
Sponsored by: The FreeBSD Foundation
Differential Revision: https://reviews.freebsd.org/D42357

8 months agouser stack randomization: only enable by default for 64bit processes
Konstantin Belousov [Tue, 24 Oct 2023 21:44:06 +0000 (00:44 +0300)]
user stack randomization: only enable by default for 64bit processes

All aslr knobs are disabled by default for 32bit processes, except
stack.  This results in weird stack location, typically making around 1G
of user address space hard to use.

Reviewed by: emaste
Sponsored by: The FreeBSD Foundation
MFC after: 1 week
Differential revision: https://reviews.freebsd.org/D42356

8 months agoRevert "zvol: Temporally disable blk-mq"
Tony Hutter [Mon, 23 Oct 2023 21:39:59 +0000 (14:39 -0700)]
Revert "zvol: Temporally disable blk-mq"

This reverts commit aefb6a2bd6c24597cde655e9ce69edd0a4c34357.

aefb6a2bd temporally disabled blk-mq until we could fix a fix for

Signed-off-by: Tony Hutter <hutter2@llnl.gov>
Closes #15439

8 months agozvol: Remove broken blk-mq optimization
Tony Hutter [Mon, 23 Oct 2023 21:45:06 +0000 (14:45 -0700)]
zvol: Remove broken blk-mq optimization

This fix removes a dubious optimization in zfs_uiomove_bvec_rq()
that saved the iterator contents of a rq_for_each_segment().  This
optimization allowed restoring the "saved state" from a previous
rq_for_each_segment() call on the same uio so that you wouldn't
need to iterate though each bvec on every zfs_uiomove_bvec_rq() call.
However, if the kernel is manipulating the requests/bios/bvecs under
the covers between zfs_uiomove_bvec_rq() calls, then it could result
in corruption from using the "saved state".  This optimization
results in an unbootable system after installing an OS on a zvol
with blk-mq enabled.

Reviewed-by: Brian Behlendorf <behlendorf1@llnl.gov>
Signed-off-by: Tony Hutter <hutter2@llnl.gov>
Closes #15351

8 months agoZIL: Detect single-threaded workloads
Alexander Motin [Tue, 24 Oct 2023 21:35:25 +0000 (17:35 -0400)]
ZIL: Detect single-threaded workloads

... by checking that previous block is fully written and flushed.
It allows to skip commit delays since we can give up on aggregation
in that case.  This removes zil_min_commit_timeout parameter, since
for single-threaded workloads it is not needed at all, while on very
fast devices even some multi-threaded workloads may get detected as
single-threaded and still bypass the wait.  To give multi-threaded
workloads more aggregation chances increase zfs_commit_timeout_pct
from 5 to 10%, as they should suffer less from additional latency.

Also single-threaded workloads detection allows in perspective better
prediction of the next block size.

Reviewed-by: Brian Behlendorf <behlendorf1@llnl.gov>
Reviewed-by: Prakash Surya <prakash.surya@delphix.com>
Signed-off-by: Alexander Motin <mav@FreeBSD.org>
Sponsored by: iXsystems, Inc.
Closes #15381

8 months agoABD: Be more assertive in iterators
Alexander Motin [Tue, 24 Oct 2023 21:33:58 +0000 (17:33 -0400)]
ABD: Be more assertive in iterators

Once we verified the ABDs and asserted the sizes we should never
see premature ABDs ends.  Assert that and remove extra branches
from production builds.

Reviewed-by: Brian Atkinson <batkinson@lanl.gov>
Reviewed-by: Brian Behlendorf <behlendorf1@llnl.gov>
Signed-off-by: Alexander Motin <mav@FreeBSD.org>
Sponsored by: iXsystems, Inc.
Closes #15428

8 months agoOpenSSL: update to 3.0.12
Ed Maste [Tue, 24 Oct 2023 18:55:56 +0000 (14:55 -0400)]
OpenSSL: update to 3.0.12

OpenSSL 3.0.12 addresses:

 * Fix incorrect key and IV resizing issues when calling
   EVP_EncryptInit_ex2(), EVP_DecryptInit_ex2() or EVP_CipherInit_ex2()
   with OSSL_PARAM parameters that alter the key or IV length
   ([CVE-2023-5363]).

Relnotes: Yes
Sponsored by: The FreeBSD Foundation

8 months agoAdd prefetch property
Brian Behlendorf [Tue, 24 Oct 2023 18:00:07 +0000 (11:00 -0700)]
Add prefetch property

ZFS prefetch is currently governed by the zfs_prefetch_disable
tunable. However, this is a module-wide settings - if a specific
dataset benefits from prefetch, while others have issue with it,
an optimal solution does not exists.

This commit introduce the "prefetch" tri-state property, which enable
granular control (at dataset/volume level) for prefetching.

This patch does not remove the zfs_prefetch_disable, which remains
a system-wide switch for enable/disable prefetch. However, to avoid
duplication, it would be preferable to deprecate and then remove
the module tunable.

Reviewed-by: Brian Behlendorf <behlendorf1@llnl.gov>
Reviewed-by: Alexander Motin <mav@FreeBSD.org>
Reviewed-by: Ameer Hamza <ahamza@ixsystems.com>
Signed-off-by: Gionatan Danti <g.danti@assyoma.it>
Co-authored-by: Gionatan Danti <g.danti@assyoma.it>
Closes #15237
Closes #15436

8 months agoOpenSSL: Vendor import of OpenSSL 3.0.12
Ed Maste [Tue, 24 Oct 2023 17:45:46 +0000 (13:45 -0400)]
OpenSSL: Vendor import of OpenSSL 3.0.12

 * Fix incorrect key and IV resizing issues when calling
   EVP_EncryptInit_ex2(), EVP_DecryptInit_ex2() or EVP_CipherInit_ex2()
   with OSSL_PARAM parameters that alter the key or IV length
   ([CVE-2023-5363]).

Sponsored by: The FreeBSD Foundation

8 months agopf: update pf(4) man page to list DIOCGETSTATESV2
Kristof Provost [Mon, 23 Oct 2023 15:11:15 +0000 (17:11 +0200)]
pf: update pf(4) man page to list DIOCGETSTATESV2

The nvlist based state retrieval ioctl has been replaced by an old-style
ioctl for performance reasons. Document that one.

Reported by: Michael Gmelin <grembo@freebsd.org>
MFC after: 1 week
Sponsored by: Rubicon Communications, LLC ("Netgate")
Differential Revision: https://reviews.freebsd.org/D42331

8 months agolibpfctl: fix Coverity issues
Kristof Provost [Mon, 23 Oct 2023 11:46:11 +0000 (13:46 +0200)]
libpfctl: fix Coverity issues

 - handle snl_finalize_msg() returning NULL
 - insert the correct data into the states list
 - add missing nvlist_destroy()
 - incorrect order for array bounds

Coverity: 152292915229251522923152292115227801522770152276414877851471250
Reviewed by: emaste
MFC after: 1 week
Sponsored by: Rubicon Communications, LLC ("Netgate")
Differential Revision: https://reviews.freebsd.org/D42330

8 months agolibpfctl: fix pfctl_do_ioctl()
Kristof Provost [Mon, 23 Oct 2023 11:43:52 +0000 (13:43 +0200)]
libpfctl: fix pfctl_do_ioctl()

pfctl_do_ioctl() copies the packed request data into the request buffer
and then frees it. However, it's possible for the buffer to be too small
for the reply, causing us to allocate a new buffer. We then copied from
the freed request, and freed it again.

Do not free the request buffer until we're all the way done.

PR: 274614
Reviewed by: emaste
MFC after: 1 week
Sponsored by: Rubicon Communications, LLC ("Netgate")
Differential Revision: https://reviews.freebsd.org/D42329

8 months agogssd: Add support for the new upcall required by commit 428879dc9110
Rick Macklem [Mon, 23 Oct 2023 21:41:26 +0000 (14:41 -0700)]
gssd: Add support for the new upcall required by commit 428879dc9110

Commit 428879dc9110 adds a requirement for a new upcall for the
gssd(8).  This patch adds that upcall.

Unfortunately, the old gssd.c would not build against the new
patched gssd.x.

This patch will fix the build.

MFC after: 1 month

8 months agocap_net: correct capability name from addr2name to name2addr
Mariusz Zaborski [Mon, 23 Oct 2023 21:03:51 +0000 (23:03 +0200)]
cap_net: correct capability name from addr2name to name2addr

Previously, while checking name2addr capabilities, we mistakenly used
the addr2name set. This error could cause a process to inadvertently
reset its limitations.

Reported by: Shawn Webb <shawn.webb@hardenedbsd.org>

8 months agondp: improve -c and -d handling in ndp_netlink
R. Christian McDonald [Mon, 23 Oct 2023 19:43:44 +0000 (21:43 +0200)]
ndp: improve -c and -d handling in ndp_netlink

This patch restores/fixes some of the behavior present in pre-netlink ndp(8).

 1. Deleting a local address now correctly returns EPERM (instead of
    ENOENT)
 2. ndp -c no longer dumps the entire table while complaining about
    local addresses
 3. Return exit code when deleting entry (e.g. trying ndp -d on a local
    address is an error)

Reviewed by: kp
Sponsored by: Rubicon Communications, LLC ("Netgate")
Differential Revision: https://reviews.freebsd.org/D42316

8 months ago"ARC prefetch metadata accesses:" appears twice in the output.
ofthesun9 [Mon, 23 Oct 2023 20:41:29 +0000 (22:41 +0200)]
"ARC prefetch metadata accesses:" appears twice in the output.

The first occurrence should be "ARC prefetch data accesses:"

Reviewed-by: Brian Behlendorf <behlendorf1@llnl.gov>
Reviewed-by: Alexander Motin <mav@FreeBSD.org>
Signed-off-by: ofthesun9 <olivier@ofthesun.net>
Closes #15427

8 months agonfscl/kgssapi: Fix Kerberized NFS mounts to pNFS servers
Rick Macklem [Mon, 23 Oct 2023 20:21:14 +0000 (13:21 -0700)]
nfscl/kgssapi: Fix Kerberized NFS mounts to pNFS servers

During recent testing related to the IETF NFSv4 Bakeathon, it was
discovered that Kerberized NFSv4.1/4.2 mounts to pNFS servers
(sec=krb5[ip],pnfs mount options) was broken.
The FreeBSD client was using the "service principal" for
the MDS to try and establish a rpcsec_gss credential for a DS,
which is incorrect. (A "service principal" looks like
"nfs@<fqdn-of-server>" and the <fqdn-of-server> for the DS is not
the same as the MDS for most pNFS servers.)

To fix this, the rpcsec_gss code needs to be able to do a
reverse DNS lookup of the DS's IP address.  A new kgssapi upcall
to the gssd(8) daemon is added by this patch to do the reverse DNS
along with a new rpcsec_gss function to generate the "service
principal".

A separate patch to the gssd(8) will be committed, so that this
patch will fix the problem.  Without the gssd(8) patch, the new
upcall fails and current/incorrect behaviour remains.

This bug only affects the rare case of a Kerberized (sec=krb5[ip],pnfs)
mount using pNFS.

This patch changes the internal KAPI between the kgssapi and
nfscl modules, but since I did a version bump a few days ago,
I will not do one this time.

MFC after: 1 month

8 months agokgssapi: Add a new file with a function for a future commit
Rick Macklem [Mon, 23 Oct 2023 20:17:16 +0000 (13:17 -0700)]
kgssapi: Add a new file with a function for a future commit

A future commit needs a new upcall function that can do reverse
DNS in order to generate a "service principal".
This patch adds the file.

MFC after: 1 month

8 months agodevfs(8): Remove references to /usr/share/examples/etc/devfs.conf
Jose Luis Duran [Wed, 18 Oct 2023 17:39:19 +0000 (17:39 +0000)]
devfs(8): Remove references to /usr/share/examples/etc/devfs.conf

This file does not exist, remove it from the list of files to avoid
confusion.  The example file is just /etc/devfs.conf.

Reviewed by: mhorne
Pull Request: https://github.com/freebsd/freebsd-src/pull/871

8 months agoofwdump(8): cross-reference openfirm(4)
Mitchell Horne [Wed, 20 Sep 2023 22:33:59 +0000 (22:33 +0000)]
ofwdump(8): cross-reference openfirm(4)

This utility relies on the openfirm(4) pseudo-device.

Sponsored by: The FreeBSD Foundation

8 months agosx: fixup copy pasto in previous
Mateusz Guzik [Mon, 23 Oct 2023 17:29:55 +0000 (17:29 +0000)]
sx: fixup copy pasto in previous

Spotted by: glebius
Sponsored by: Rubicon Communications, LLC ("Netgate")

8 months agosx: unset td_wantedlock around going to sleep
Mateusz Guzik [Mon, 23 Oct 2023 17:22:12 +0000 (17:22 +0000)]
sx: unset td_wantedlock around going to sleep

Otherwise it can crash in sleepq_wait_sig -> sleepq_catch_signals ->
sig_ast_checksusp -> thread_suspend_check due to a mutex acquire.

Reported by: pho
Sponsored by: Rubicon Communications, LLC ("Netgate")

8 months agopf/netlink: explicitly include sys/ucred.h to provide struct ucred definition
Konstantin Belousov [Mon, 23 Oct 2023 17:01:09 +0000 (20:01 +0300)]
pf/netlink: explicitly include sys/ucred.h to provide struct ucred definition

Also remove no longer needed standalone sys/cdefs.h include.

Reviewed by: kp
Sponsored by: NVidia Networking

8 months agoRevert "Do not persist user/group/project quota zap objects when unneeded"
Brian Behlendorf [Mon, 23 Oct 2023 16:55:36 +0000 (09:55 -0700)]
Revert "Do not persist user/group/project quota zap objects when unneeded"

This reverts commit 797f55ef12d752d2a7fb04fae5d24e019adf2a1d which
was causing a VERIFY failure when running the project quota tests.

Signed-off-by: Brian Behlendorf <behlendorf1@llnl.gov>
Closes #15438

8 months agospa: document spa_thread() and SDC feature gates
Rob N [Mon, 23 Oct 2023 15:50:55 +0000 (02:50 +1100)]
spa: document spa_thread() and SDC feature gates

spa_thread() and the "System Duty Cycle" scheduling class are from
Illumos and have not yet been adapted to Linux or FreeBSD.

HAVE_SPA_THREAD has long been explicitly undefined and used to mark
spa_thread(), but there's some related taskq code that can never be
invoked without it, which makes some already-tricky code harder to read.

HAVE_SYSDC is introduced in this commit to mark the SDC parts. SDC
requires spa_thread(), but the inverse is not true, so they are
separate.

I don't want to make the call to just remove it because I still harbour
hopes that OpenZFS could become a first-class citizen on Illumos
someday. But hopefully this will at least make the reason it exists a
bit clearer for people without long memories and/or an interest in
history.

For those that are interested in the history, the original FreeBSD port
of ZFS (before ZFS-on-Linux was adopted there) did have a spa_thread(),
but not SDC. The last version of that before it was removed can be read
here:

  https://github.com/freebsd/freebsd-src/blob/22df1ffd812f0395cdb7c0b1edae1f67b991562a/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/spa.c

Meanwhile, more information on the SDC scheduling class is here:

  https://github.com/illumos/illumos-gate/blob/master/usr/src/uts/common/disp/sysdc.c

Sponsored-by: Klara, Inc.
Sponsored-by: Wasabi Technology, Inc.
Reviewed-by: Brian Behlendorf <behlendorf1@llnl.gov>
Reviewed-by: Alexander Motin <mav@FreeBSD.org>
Signed-off-by: Rob Norris <rob.norris@klarasystems.com>
Closes #15406

8 months agopf tests: add a test for killing states by NAT address
Kristof Provost [Thu, 19 Oct 2023 13:00:43 +0000 (15:00 +0200)]
pf tests: add a test for killing states by NAT address

Sponsored by: Rubicon Communications, LLC ("Netgate")
Differential Revision: https://reviews.freebsd.org/D42313

8 months agopf: allow states to be killed by their pre-NAT address
Kristof Provost [Fri, 20 Oct 2023 05:37:46 +0000 (07:37 +0200)]
pf: allow states to be killed by their pre-NAT address

If a connection is NAT-ed we could previously only terminate it by its
ID or the post-NAT IP address. Allow users to specify they want look for
the state by its pre-NAT address. Usage: `pfctl -k nat -k <address>`.

See also: https://redmine.pfsense.org/issues/11556
Sponsored by: Rubicon Communications, LLC ("Netgate")
Differential Revision: https://reviews.freebsd.org/D42312

8 months agomakefs/zfs: Update dd_used_breakdown after writing the MOS
Mark Johnston [Mon, 23 Oct 2023 16:25:20 +0000 (12:25 -0400)]
makefs/zfs: Update dd_used_breakdown after writing the MOS

Fixes: 96092bf9108c ("makefs/zfs: Fill out dd_used_breakdown fields in DSL directories")
Sponsored by: The FreeBSD Foundation

8 months agomakefs/zfs: Add a regression test which checks the 'used*' properties
Mark Johnston [Mon, 23 Oct 2023 15:11:26 +0000 (11:11 -0400)]
makefs/zfs: Add a regression test which checks the 'used*' properties

PR: 274613
MFC after: 1 week
Sponsored by: The FreeBSD Foundation

8 months agomakefs/zfs: Fill out dd_used_breakdown fields in DSL directories
Mark Johnston [Mon, 23 Oct 2023 15:08:04 +0000 (11:08 -0400)]
makefs/zfs: Fill out dd_used_breakdown fields in DSL directories

This is required for the "used", "usedds" and "usedchild" dataset
properties to be displayed.

PR: 274613
Reported by: Mike Tancsa <mike@sentex.net>
MFC after: 1 week
Sponsored by: The FreeBSD Foundation

8 months agoboot/zfs: Add some fields to dsl_dir_phys_t
Mark Johnston [Mon, 23 Oct 2023 15:05:50 +0000 (11:05 -0400)]
boot/zfs: Add some fields to dsl_dir_phys_t

Most of the first block of pad bytes are now used for space accounting
purposes.  No functional change intended.

MFC after: 1 week
Sponsored by: The FreeBSD Foundation

8 months agopf: support basic filters for state listing
Kristof Provost [Mon, 16 Oct 2023 14:47:22 +0000 (16:47 +0200)]
pf: support basic filters for state listing

Allow users(pace) to specify a protocol, interface, address family and/
or address and mask, allowing the state listing to be pre-filtered in
the kernel.

Sponsored by: Rubicon Communications, LLC ("Netgate")
Differential Revision: https://reviews.freebsd.org/D42280

8 months agopf: convert rule addition to netlink
Kristof Provost [Sat, 14 Oct 2023 13:10:03 +0000 (15:10 +0200)]
pf: convert rule addition to netlink

The nvlist-based version will be removed in FreeBSD 16.

Sponsored by: Rubicon Communications, LLC ("Netgate")
Differential Revision: https://reviews.freebsd.org/D42279

8 months agonetlink: fix potential llentry lock leak in newneigh handler
R. Christian McDonald [Mon, 23 Oct 2023 11:23:55 +0000 (13:23 +0200)]
netlink: fix potential llentry lock leak in newneigh handler

The netlink newneigh handler has the potential to leak the lock on
llentry objects in the kernel. This patch reconciles several paths
through the newneigh handler that could result in a lock leak.

MFC after: 1 week
Reviewed by: markj, kp
Sponsored by: Rubicon Communications, LLC ("Netgate")
Differential Revision: https://reviews.freebsd.org/D42307

8 months agobsdconfig: Restore bsddialog
Alfonso S. Siciliano [Mon, 23 Oct 2023 14:11:54 +0000 (16:11 +0200)]
bsdconfig: Restore bsddialog

Readd bsddialog(1) to bsdconfig(8).

This can be considered an increment not a replacement: `$DIALOG=dialog'
restores dialog(1), no change for Xdialog(1). An exception is if an
error occurs, bsddialog(1) replaces dialog.

8 months agobsdconfig: Revert bsddialog support
Alfonso S. Siciliano [Mon, 23 Oct 2023 13:52:56 +0000 (15:52 +0200)]
bsdconfig: Revert bsddialog support

This commit reverts "bsdconfig(8): add bsddialog(1) support"
30e9abf2fc462084b752064fa814d90ad3161352 because it is not intended for
the current bsddialog 1.0 version.

8 months agoarm64: Teach bus_dma on arm64 about NUMA
Andrew Turner [Thu, 12 Oct 2023 16:01:01 +0000 (17:01 +0100)]
arm64: Teach bus_dma on arm64 about NUMA

When allocating memory we should try to allocate from the NUMA node
closest to the device to reduce cross domain memory traffic. Teach the
arm64 bus_dma code to do this.

While here use mallocarray to guard against an unlikely integer
overflow.

Reviewed by: markj
Sponsored by: Arm Ltd
Differential Revision: https://reviews.freebsd.org/D42187

8 months agoarm64: Fix long lines in vm_machdep.c
Andrew Turner [Tue, 12 Sep 2023 13:45:07 +0000 (14:45 +0100)]
arm64: Fix long lines in vm_machdep.c

Reviewed by: emaste
Sponsored by: Arm Ltd
Differential Revision: https://reviews.freebsd.org/D41828

8 months agobsdconfig: Add `network' keyword
Devin Teske [Sun, 22 Oct 2023 18:45:36 +0000 (11:45 -0700)]
bsdconfig: Add `network' keyword

Configuring a FreeBSD laptop, my fingers kept wanting to type
`bsdconfig network' and I could not figure out why this was not working.
Took me a second to realize that the shortcut was `bsdconfig networking'
for where I wanted to go.

Reviewed by: jhb
Approved by: jhb
Differential Revision: https://reviews.freebsd.org/D42242

8 months agoRevert "tests: fix ATF_TESTS_PYTEST no clean build"
Mark Johnston [Sun, 22 Oct 2023 17:13:31 +0000 (13:13 -0400)]
Revert "tests: fix ATF_TESTS_PYTEST no clean build"

This reverts commit 6120673f7566c35023921540d2d682572d1bf1ce, which
appears to break a clean buildworld.

8 months agobsd.man.mk guard against empty vars in MLINKS
Simon J. Gerraty [Sun, 22 Oct 2023 17:13:20 +0000 (10:13 -0700)]
bsd.man.mk guard against empty vars in MLINKS

share/man/man4/Makefile adds a number of
variables to MAN and MLINKS, which are only set for
certain architectures.

The empty variables wreak havoc when := is used.

Add :M*.[1-9] to MLINKS reference for STAGE_LINKS.mlinks
to avoid invalid results.

Reviewed by: stevek

8 months agothread: add td_wantedlock
Mateusz Guzik [Sun, 22 Oct 2023 15:46:39 +0000 (15:46 +0000)]
thread: add td_wantedlock

This enables obtaining lock information threads are actively waiting for
while sampling. Without the change one would only see a bunch of calls
to lock_delay(), where the stacktrace often does not reveal what the
lock might be.

Note this is not the same as lock profiling, which only produces data
for cases which wait for locks.

struct thread already has a td_lockname field, but I did not use it
because it has different semantics -- denotes when the thread is off
cpu. At the same time it could not be converted to hold a lock_object
pointer because non-curthread access would no longer be guaranteed to be
safe -- by the time it reads the pointer the lock might have been taken,
released and the object containing it freed.

Sample usage with dtrace:
rm /tmp/out.kern_stacks ; dtrace -x stackframes=100 -n 'profile-997 { @[curthread->td_wantedlock != NULL ? stringof(curthread->td_wantedlock->lo_name) : stringof("\n"), stack()] = count(); }' -o /tmp/out.kern_stacks

This also facilitates addition of lock information to traces produced by
hwpmc.

Note: spinlocks are not supported at the moment.

Sponsored by: Rubicon Communications, LLC ("Netgate")

8 months agothread: reorder td_no_sleeping to plug two 4-byte holes on LP64
Mateusz Guzik [Sun, 22 Oct 2023 15:39:25 +0000 (15:39 +0000)]
thread: reorder td_no_sleeping to plug two 4-byte holes on LP64

Sponsored by: Rubicon Communications, LLC ("Netgate")

8 months agozfs: merge openzfs/zfs@797f55ef1
Martin Matuska [Sun, 22 Oct 2023 16:25:23 +0000 (18:25 +0200)]
zfs: merge openzfs/zfs@797f55ef1

Notable upstream pull request merges:
 #14378 c0e58995e Large sync writes perform worse with slog
 #14721 797f55ef1 Do not persist user/group/project quota zap objects
                  when unneeded
 #15356 380c25f64 FreeBSD: Improve taskq wrapper
 #15390 4fbc52495 Remove lock from dsl_pool_need_dirty_delay()
 #15397 57b409856 Trust ARC_BUF_SHARED() more
 #15402 b29e98fa8 Properly pad struct tx_cpu to cache line
 #15405 ea30b5a9e Set spa_ccw_fail_time=0 when expanding a vdev
 #15416 b9384b949 FreeBSD: taskq: Remove unused declaration

Obtained from: OpenZFS
OpenZFS commit: 797f55ef12d752d2a7fb04fae5d24e019adf2a1d

8 months agoAdd expected failure for tmpfs atime test failing on FreeBSD
Ed Maste [Sat, 21 Oct 2023 15:15:14 +0000 (11:15 -0400)]
Add expected failure for tmpfs atime test failing on FreeBSD

PR: 274615
Reviewed by: ngie
Sponsored by: The FreeBSD Foundation
Differential Revision: https://reviews.freebsd.org/D42321

8 months agonfscl: Handle a Getattr failure with NFSERR_DELAY following Open
Rick Macklem [Sun, 22 Oct 2023 01:33:33 +0000 (18:33 -0700)]
nfscl: Handle a Getattr failure with NFSERR_DELAY following Open

During testing at a recent IETF NFSv4 Bakeathon, a non-FreeBSD
server was rebooted.  After the reboot, the FreeBSD client sent
an Open/Claim_previous with a Getattr after the Open in the same
compound.  The Open/Claim_previous was done to recover the Open
and a Delegation for for a file.  The Open succeeded, but the
Getattr after the Open failed with NFSERR_DELAY.  This resulted
in the FreeBSD client retrying the entire RPC over and over again,
until the server's recovery grace period ended.  Since the Open
succeeded, there was no need to retry the entire RPC.

This patch modifies the NFSv4 client side recovery Open/Claim_previous
RPC reply handling to deal with this case.  With this patch, the
Getattr reply of NFSERR_DELAY is ignored and the successful Open
reply is processed.

This bug will not normally affect users, since this non-FreeBSD
server is not widely used (it may not even have shipped to any
customers).

MFC after: 1 month

8 months agoufs quotas: fix configuring soft quota grace time
Mikel Lechner [Sat, 21 Oct 2023 06:08:38 +0000 (09:08 +0300)]
ufs quotas: fix configuring soft quota grace time

The QTF_CLOSING flag needs to be cleared earlier to allow dqget() to
work.

PR: 274552
MFC after: 1 week

8 months agobpf: Make dead_bpf_if const
Zhenlei Huang [Sat, 21 Oct 2023 04:52:27 +0000 (12:52 +0800)]
bpf: Make dead_bpf_if const

The dead_bpf_if is not subjected to be written. Make it const so that
on destructive writing to it the kernel will panic instead of silent
memory corruption.

No functional change intended.

Reviewed by: markj
MFC after: 1 week
Differential Revision: https://reviews.freebsd.org/D42189

8 months agox86: Prefer consistent naming for loader tunables
Zhenlei Huang [Tue, 17 Oct 2023 07:05:25 +0000 (15:05 +0800)]
x86: Prefer consistent naming for loader tunables

The following loader tunables do have corresponding sysctl MIBs but
with inconsistent naming. That may be historical reason. Let's prefer
consistent naming for them so that it will be easier to maintain.

 1. hw.dmar.timeout -> hw.iommu.dmar.timeout
 2. hw.lapic_eoi_suppression -> hw.apic.eoi_suppression
 3. hw.lapic_tsc_deadline -> hw.apic.timer_tsc_deadline
 4. hw.x2apic_enable -> hw.apic.x2apic_mode

Those tunables are for field debugging, no need to keep old names for
compatibility.

Reviewed by: kib
MFC after: 3 days
Differential Revision: https://reviews.freebsd.org/D42248

8 months agoamd64 pmap: Prefer consistent naming for loader tunable
Zhenlei Huang [Fri, 20 Oct 2023 07:31:44 +0000 (15:31 +0800)]
amd64 pmap: Prefer consistent naming for loader tunable

The sysctl knob 'vm.pmap.allow_2m_x_ept' is loader tunable and have
public document entry in security(7) but is fetched from kernel
environment 'hw.allow_2m_x_ept'. That is inconsistent and obscure.

As there is public security advisory FreeBSD-SA-19:25.mcepsc [1],
people may refer to it and use 'hw.allow_2m_x_ept', let's keep old
name for compatibility.

[1] https://www.freebsd.org/security/advisories/FreeBSD-SA-19:25.mcepsc.asc

Reviewed by: kib
Fixes: c08973d09c95 Workaround for Intel SKL002/SKL012S errata
MFC after: 3 days
Differential Revision: https://reviews.freebsd.org/D42311

8 months agonfscl: Use Claim_Null_FH and Claim_Deleg_Cur_FH
Rick Macklem [Fri, 20 Oct 2023 23:10:25 +0000 (16:10 -0700)]
nfscl: Use Claim_Null_FH and Claim_Deleg_Cur_FH

For NFSv4.1/4.2, there are two new options for the Open operation.
These two options use the file handle for the file instead of the
file handle for the directory plus a file name.  By doing so, the
client code is simplified (it no longer needs the "nfsv4node" structure
attached to the NFS vnode).  It also avoids problems caused by another
NFS client (or process running locally in the NFS server) doing a
rename or remove of the file name between the Lookup and Open.

Unfortunately, there was a bug (fixed recently by commit X)
in the NFS server which mis-parsed the Claim_Deleg_Cur_FH
arguments.  To allow this patch to work with the broken FreeBSD
NFSv4.1/4.2 server, NFSMNTP_BUGGYFBSDSRV is defined and is set
when a correctly formatted Claim_Deleg_Cur_FH fails with NFSERR_EXPIRED.
(This is what the old, broken NFS server does, since it erroneously
uses the Getattr arguments as a stateID.)  Once this flag is set,
the client fills in a stateID, to make the broken NFS server happy.

Tested at a recent IETF NFSv4 Bakeathon.

MFC after: 1 month

8 months agoMinor sysctl description cleanup.
Kirk McKusick [Fri, 20 Oct 2023 22:32:05 +0000 (15:32 -0700)]
Minor sysctl description cleanup.

No functional change.

Agreed-by: Mateusz Guzik
8 months agoFix a bug in fsck_ffs(8) triggered by corrupted filesystems.
Kirk McKusick [Fri, 20 Oct 2023 22:14:46 +0000 (15:14 -0700)]
Fix a bug in fsck_ffs(8) triggered by corrupted filesystems.

Add missing check for failed block read when checking information about
a snapshot file.

Reported-by: Andreas Bock
PR:           274404
MFC-after:    1 week

8 months agouart: Support EARLY_PRINTF on x86 for port-mapped COM ports
Warner Losh [Fri, 20 Oct 2023 22:07:03 +0000 (16:07 -0600)]
uart: Support EARLY_PRINTF on x86 for port-mapped COM ports

Support early printf for the ns8250 uart driver. Adding
options UART_NS8250_EARLY_PORT=0xYYY
options EARLY_PRINTF
to your kernel config will enable it. The code is rather simple minded,
so caveat emptor. This will enable printf before cninit. cninit
automatically disables this and switches to the real routine. It only
works for port-mapped COM ports, and only if you know the port's address
at compile time. It's intended for be a debugging aide, not a general
purpose thing.

Sponsored by: Netflix
Reviewed by: emaste
Differential Revision: https://reviews.freebsd.org/D42306

8 months agoacpi_pcib: Rename decoded_bus_range to get_decoded_bus_range
John Baldwin [Fri, 20 Oct 2023 21:53:49 +0000 (14:53 -0700)]
acpi_pcib: Rename decoded_bus_range to get_decoded_bus_range

While here, change the return value to bool.

Discussed by: gibbs

8 months agox86: Cosmetic cleanups to struct msi_intsrc
John Baldwin [Fri, 20 Oct 2023 21:53:05 +0000 (14:53 -0700)]
x86: Cosmetic cleanups to struct msi_intsrc

- Sort members by size.

- Change msi_msix from a u_int to a bool.

Reviewed by: kib
Differential Revision: https://reviews.freebsd.org/D42305

8 months agox86 msi: Enable/disable IDT vectors for MSI groups all at once
John Baldwin [Fri, 20 Oct 2023 21:52:38 +0000 (14:52 -0700)]
x86 msi: Enable/disable IDT vectors for MSI groups all at once

Unlike MSI-X, when a device uses multiple MSI interrupts, the entire
group of interrupts are enabled/disabled at once in the relevant PCI
config register.  Currently, the interrupt code enables the IDT vector
for each MSI interrupt when a handler is first registered.  If the PCI
device triggers an MSI interrupt which doesn't yet have a handler,
this can trigger a panic when the Xrsvd ISR executes rather than
treating it as a stray device interrupt.

To fix, enable all the IDT vectors for an MSI group when the first
interrupt handler is configured, and don't disable the IDT vectors
until the last interrupt handler for the group is torn down.

When migrating an MSI group between CPUs, enable/disable the entire
group of IDT vectors if at least one interrupt handler is configured
for the group.

Reported by: jhay
Reviewed by: kib
Differential Revision: https://reviews.freebsd.org/D42232

8 months agoDo not persist user/group/project quota zap objects when unneeded
Sam Atkinson [Fri, 20 Oct 2023 21:22:04 +0000 (17:22 -0400)]
Do not persist user/group/project quota zap objects when unneeded

In the zfs_id_over*quota functions, there is a short-circuit to skip
the zap_lookup when the quota zap does not exist. If quotas are never
used in a zpool, then the quota zap will never exist. But if
user/group/project quotas are ever used, the zap objects will be
created and will persist even if the quotas are deleted.

The quota zap_lookup in the write path can become a bottleneck for
write-heavy small I/O workloads. Before this commit, it was not
possible to remove this lookup without creating a new zpool.

Reviewed-by: Brian Behlendorf <behlendorf1@llnl.gov>
Signed-off-by: Sam Atkinson <samatk@amazon.com>
Closes #14721

8 months agocertctl: invoke with LOCALBASE set
Brooks Davis [Mon, 16 Oct 2023 22:35:40 +0000 (23:35 +0100)]
certctl: invoke with LOCALBASE set

When invoking certctl as part of installworld, set LOCALBASE in the
environment to match the build environment.  That ensures that LOCABASE
is non-empty on systems without the user.localbase sysctl and avoids
allowing a system configuration detail to leak into the build.  Users
who wish to build targeting a non-standard LOCALBASE should ensure it is
set in src.conf or similar.

Reviewed by: Mina Galić <freebsd@igalic.co>
Differential Revision: https://reviews.freebsd.org/D40530

8 months agocertctl.8: document LOCALBASE
Brooks Davis [Mon, 16 Oct 2023 22:35:34 +0000 (23:35 +0100)]
certctl.8: document LOCALBASE

Document the LOCALBASE variable and that it's set to user.localbase by
default.  Update path defaults that depend on it.

Reviewed by: bcr
Differential Revision: https://reviews.freebsd.org/D40529

8 months agoTrust ARC_BUF_SHARED() more
Alexander Motin [Fri, 20 Oct 2023 19:38:37 +0000 (15:38 -0400)]
Trust ARC_BUF_SHARED() more

In my understanding ARC_BUF_SHARED() and arc_buf_is_shared() should
return identical results, except the second also asserts it deeper.
The first is much cheaper though, saving few pointer dereferences.
Replace production arc_buf_is_shared() calls with ARC_BUF_SHARED(),
and call arc_buf_is_shared() in random assertions, while making it
even more strict.

On my tests this in half reduces arc_buf_destroy_impl() time, that
noticeably reduces hash_lock congestion under heavy dbuf eviction.

Reviewed-by: Brian Behlendorf <behlendorf1@llnl.gov>
Reviewed-by: George Wilson <george.wilson@delphix.com>
Signed-off-by: Alexander Motin <mav@FreeBSD.org>
Sponsored by: iXsystems, Inc.
Closes #15397

8 months agoRemove lock from dsl_pool_need_dirty_delay()
Alexander Motin [Fri, 20 Oct 2023 19:37:16 +0000 (15:37 -0400)]
Remove lock from dsl_pool_need_dirty_delay()

Torn reads/writes of dp_dirty_total are unlikely: on 64-bit systems
due to register size, while on 32-bit due to memory constraints.
And even if we hit some race, the code implementing the delay takes
the lock any way.

Removal of the poll-wide lock acquisition saves ~1% of CPU time on
8-thread 8KB write workload.

Reviewed-by: Brian Behlendorf <behlendorf1@llnl.gov>
Signed-off-by: Alexander Motin <mav@FreeBSD.org>
Sponsored by: iXsystems, Inc.
Closes #15390

8 months agorun-zts test procfs/pool_state failed with uncorrectable I/O failure
VaibhavB [Fri, 20 Oct 2023 18:57:39 +0000 (00:27 +0530)]
run-zts test procfs/pool_state failed with uncorrectable I/O failure

Once we trigger the zpool scrub, all zpool/zfs command gets stuck for
180 seconds. Post 180 seconds zpool/zfs commands gets start executing
however few more seconds(10s) it take to update the status. hence
sleeping for 200 seconds so that we get the correct status.

Reviewed-by: Tony Hutter <hutter2@llnl.gov>
Reviewed-by: Brian Behlendorf <behlendorf1@llnl.gov>
Signed-off-by: vaibhav.bhanawat <vaibhav.bhanawat@delphix.com>
Closes #15364

8 months agoProperly pad struct tx_cpu to cache line
Alexander Motin [Fri, 20 Oct 2023 18:54:05 +0000 (14:54 -0400)]
Properly pad struct tx_cpu to cache line

We already use ____cacheline_aligned in many places, so add one more
instead of seems arbitrary char tc_pad[8].

Reviewed-by: Brian Behlendorf <behlendorf1@llnl.gov>
Signed-off-by: Alexander Motin <mav@FreeBSD.org>
Sponsored by: iXsystems, Inc.
Closes #15402

8 months agoFix typo in tests/zfs-tests/tests/functional/cli_user/misc/misc.cfg
dennisfriedrichsen [Fri, 20 Oct 2023 18:52:13 +0000 (13:52 -0500)]
Fix typo in  tests/zfs-tests/tests/functional/cli_user/misc/misc.cfg

Reviewed-by: Rob N <robn@despairlabs.com>
Reviewed-by: Brian Behlendorf <behlendorf1@llnl.gov>
Signed-off-by: Dennis R. Friedrichsen <dennis.r.friedrichsen@gmail.com>
Closes #15417

8 months agoFreeBSD: taskq: Remove unused declaration
Olivier Certner [Fri, 20 Oct 2023 18:49:56 +0000 (20:49 +0200)]
FreeBSD: taskq: Remove unused declaration

Variable 'uma_align_cache' has not been used since commit "FreeBSD: Use
a hash table for taskqid lookups" (3933305ea).  Moreover, it is soon
going to become private to FreeBSD's UMA in 15.0-CURRENT (main),
14.0-STABLE (stable/14) and 13.2-STABLE (stable/13).  Should accessing
this information become necessary again, one will have to use the new
accessors for recent versions.

Reviewed-by: Alexander Motin <mav@FreeBSD.org>
Reviewed-by: Brian Behlendorf <behlendorf1@llnl.gov>
Signed-off-by: Olivier Certner <olce.freebsd@certner.fr>
Closes #15416

8 months agoObsoleteFiles.inc: Remove old mixer(8) tests
John Baldwin [Fri, 20 Oct 2023 18:33:11 +0000 (11:33 -0700)]
ObsoleteFiles.inc: Remove old mixer(8) tests

These were removed when the new mixer(3) library was imported.

PR: 274602
Fixes: 903873ce1560 Implement and use new mixer(3) library for FreeBSD.

8 months agotests: fix ATF_TESTS_PYTEST no clean build
Gleb Smirnoff [Fri, 20 Oct 2023 17:47:08 +0000 (10:47 -0700)]
tests: fix ATF_TESTS_PYTEST no clean build

The hack with .xtmp file was effectively making the make to
ignore changes to the sources, breaking NO_CLEAN builds.  The
hack can be actually omitted as setting SCRIPTSNAME_${_T} for
every test is sufficient to prevent renaming by bsd.prog.mk.

Reviewed by: melifaro
Differential Revision: https://reviews.freebsd.org/D42283

8 months agoSet spa_ccw_fail_time=0 when expanding a vdev.
Colin Percival [Fri, 20 Oct 2023 17:30:32 +0000 (10:30 -0700)]
Set spa_ccw_fail_time=0 when expanding a vdev.

When a vdev is to be expanded -- either via `zpool online -e` or via
the autoexpand option -- a SPA_ASYNC_CONFIG_UPDATE request is queued
to be handled via an asynchronous worker thread (spa_async_thread).
This normally happens almost immediately; but will be delayed up to
zfs_ccw_retry_interval seconds (default 5 minutes) if an attempt to
write the zpool configuration cache failed.

When FreeBSD boots ZFS-root VM images generated using `makefs -t zfs`,
the zpoolupgrade rc.d script runs `zpool upgrade`, which modifies the
pool configuration and triggers an attempt to write to the cache file.
This attempted write fails because the filesystem is still mounted
read-only at this point in the boot process, triggering a 5-minute
cooldown before SPA_ASYNC_CONFIG_UPDATE requests will be handled by
the asynchronous worker thread.

When expanding a vdev, reset the "when did a configuration cache
write last fail" value so that the SPA_ASYNC_CONFIG_UPDATE request
will be handled promptly.  A cleaner but more intrusive option would
be to use separate SPA_ASYNC_ flags for "configuration changed" and
"try writing the configuration cache again", but with FreeBSD 14.0
coming very soon I'd prefer to leave such refactoring for a later
date.

Reviewed-by: Alexander Motin <mav@FreeBSD.org>
Reviewed-by: Brian Behlendorf <behlendorf1@llnl.gov>
Signed-off-by: Colin Percival <cperciva@FreeBSD.org>
Closes #15405

8 months agoFix ZED auto-replace for VDEVs using by-id paths
Don Brady [Fri, 20 Oct 2023 16:29:02 +0000 (10:29 -0600)]
Fix ZED auto-replace for VDEVs using by-id paths

The change is simple -- restore the original code so that the VDEV
path is updated when using by-id paths.  The more challenging part
was to devise a second ZTS test, that would test auto-replace for
'by-id' and help prevent a future regression.

With that new test, we can now do an A|B test with , and without,
the fix to confirm that auto-replace for by-id paths works. The
existing auto-replace test, functional/fault/auto_replace_001_pos,
will confirm that we didn't break auto-replace for 'by-vdev' paths.

In the original functional/fault/auto_replace_001_pos test, the disk
wipe (using dd) was not effective in removing the partitioning since
the kernel was never informed of the wipe.

Added a call to wipefs(8) so that the kernel is informed and ZED will
re-partition the device.

Added a validation step that the re-partitioning occurred by
confirming  that the GPT partition UUID changes.

Sponsored-By: OpenDrives Inc.
Sponsored-By: Klara Inc.
Reviewed-by: Rob Norris <rob.norris@klarasystems.com>
Reviewed-by: Tony Hutter <hutter2@llnl.gov>
Signed-off-by: Don Brady <don.brady@klarasystems.com>
Closes #15363

8 months agoarm64: Add PAC instruction macros
Andrew Turner [Thu, 12 Oct 2023 09:48:38 +0000 (10:48 +0100)]
arm64: Add PAC instruction macros

To support Pointer Authentication (PAC) in assembly files add a pair of
macros that sign the link register. When used before storing to the
stack it will allow hardware to detect if it has changed before using
it in the return instruction.

Reviewed by: markj, emaste
Sponsored by: Arm Ltd
Differential Revision: https://reviews.freebsd.org/D42226

8 months agoarm64: Support creating a BTI & PAC note
Andrew Turner [Tue, 10 Oct 2023 13:00:59 +0000 (14:00 +0100)]
arm64: Support creating a BTI & PAC note

To detect when an object file is build with the Branch Target
Identification (BTI) and Pointer Authentication Code (PAC) extensions
there is an elf note the compiler will insert. It will only do so from
a high level language, e.g. C or C++.

To get the not in assembly add the GNU_PROPERTY_AARCH64_FEATURE_1_NOTE
macro that can be used to create it, and the
GNU_PROPERTY_AARCH64_FEATURE_1_VAL macro to insert the correct value
based on which combination of BTI and PAC are enabled.

Reviewed by: markj (earlier version), emaste
Sponsored by: Arm Ltd
Differential Revision: https://reviews.freebsd.org/D42225

8 months agotools/build: Support building with glibc 2.38
Andrew Turner [Fri, 20 Oct 2023 15:45:06 +0000 (16:45 +0100)]
tools/build: Support building with glibc 2.38

Ubuntu 23.10 uses glibc 2.38. This adds strlcpy and strlcmp so we need
to remove them from the cross build environment.

Reviewed by: jrtc27 (earlier version), arichardson
Sponsored by: Arm Ltd
Differential Revision: https://reviews.freebsd.org/D42303

8 months agosys/sys: Check for __ASSEMBLER__ in elf_common.h
Andrew Turner [Thu, 12 Oct 2023 09:45:43 +0000 (10:45 +0100)]
sys/sys: Check for __ASSEMBLER__ in elf_common.h

When preprocessing assembly files with clang or gcc the __ASSEMBLER__
macro is defined. Check for this as an alternative to LOCORE in
elf_common.h so it can be included by .S files.

Reviewed by: imp
Sponsored by: Arm Ltd
Differential Revision: https://reviews.freebsd.org/D42224