Commit graph

292446 commits

Author SHA1 Message Date
Ed Maste e6b88237c6 p9fs: use M_WAITOK where appropriate
device_attach routines are allowed to sleep, and this routine already
has other M_WAITOK allocations.

Reported by:	markj
Reviewed by:	markj
Fixes: 1efd69f933 ("p9fs: move NULL check immediately after alloc...")
Sponsored by:	The FreeBSD Foundation
Differential Revision: https://reviews.freebsd.org/D45721
2024-06-24 22:02:13 -04:00
Warner Losh 6176883697 sys.netinet6.divert.ipdivert_ip6_output_remote_success fails
Disable it. It's been failing with the useful
1 != 0 (1 != 0)
for weeks if not months now.

PR: 279975
Sponsored by:		Netflix
2024-06-24 15:11:05 -06:00
Warner Losh 677b28750a sys/cdefs.h: Note gcc supports many __has_* macros
The __has_* macros are no longer clang-speicifc. gcc 5 introduced
__has_include, gcc 9 introduce __has_attribute, gcc 10 introduced
__has_builtin. So all of these are supported by all the versrions of gcc
we support as a project (we have gcc 10 and newer ports, but no older
ones), so just refer to them as supported by gcc. The exact version
doesn't matter so much these days (we provide a fallback for older
compilers still, should anybody still be using them), so don't mention
them in the comments (but here in the commit message they are
discoverable).

gcc 14 adds __has_feature and __has_extension, so note that since it
will be relevant for many years.

Sponsored by:		Netflix
2024-06-24 15:11:05 -06:00
Warner Losh 65522b64ad sys/cdefs.h: Remove old arm acle-compat.h workaround
The ACLE defines the modern ARM compiler symbols. ARM published
acle-compat.h to ease the transition to the new standard. This standard
is in all modern versions of gcc and clang, only gcc prior to 4.4 lacked
them (though our 4.2.1 back-ported them, IIRC). Since this is no longer
needed, remove the global inclusion in sys/ctypes.h. We should likely
remove arm/include/acle-compat.h as well (it's unused now in the tree),
but I'll make sure this change is the NOP I think it is before moving
ahead there. I also recall at one time some out of tree code needing
this file, though the need for it to make things right has long since
past.

Sponsored by:		Netflix
2024-06-24 15:11:05 -06:00
Kenneth D. Merry 31354813f3 Add an isp(4) tunable to default to ispfw(4) firmware.
ispfw(4) recently gained firmware for Qlogic 27XX and 28XX
FC controllers, and isp(4) now selects the newer of firmware in
flash or in ispfw(4) to load for those controllers.

This differs from the previous behavior (which remains for older
controllers), which was to always load the ispfw(4) firmware if it
is available.

This adds a loader tunable, hint.isp.N.fwload_force to default to
loading the ispfw(4) firmware, whether or not it is newer than the
firmware in flash.  This allows the user to always use the known
firmware version included with the kernel.

Note that there is an existing fwload_disable tunable that tells
the driver to always load the firmware from flash and ignore
ispfw(4).  If fwload_disable is set, fwload_force will be ignored.
So users with existing fwload_disable tunables will have the same
behavior.

If a user specifies both fwload_force and fwload_disable for the
same controller, the isp(4) driver prints a warning message,
and fwload_disable will be honored.

The user can see which firmware is active through the
dev.isp.N.fw_version* sysctl variables.

share/man/man4/isp.4:
	Document the new loader tunable.

sys/dev/isp/isp.c:
	In isp_load_risc_flash(), changet the decision logic to
	also consider ISP_CFG_FWLOAD_ONLY.  Load the flash firmware
	and get the version, so the user knows what it is, but if
	the user set fwload_force, honor that.  If the user didn't
	set fwload_force, the behavior remains to select the newer
	firmware version.

sys/dev/isp/isp_pci.c:
	Add a new fwload_force tunable.  Print out a warning if the
	user sets both fwload_disable and fwload_force.

sys/dev/isp/ispvar.h:
	Add a new ISP_CFG_FWLOAD_FORCE configuration bit.

Reviewed by:	mav
MFC after:	1 week
Sponsored by:	Spectra Logic
Differential Revision:	<https://reviews.freebsd.org/D45688>
2024-06-24 16:47:55 -04:00
Kenneth D. Merry 137b004e2b Fix the isp(4) driver with 9.x firmware.
The isp(4) driver (and ispfw(4) firmware) previously only included
firmware for Qlogic controllers up to 8Gb.  It recently gained
firmware for the 27XX and 28XX series controllers along with
improved firmware loading capabilities.

The 9.x firmware available for the 27XX and 28XX controllers in
ispfw(4) adds login state for NVMe devices in the top nibble of
the login state in the port database (isp_pdb_24xx_t in ispmbox.h).

This breaks the check at the end of isp_getpdb() to make sure the
device is in the right login state.  As a result, it breaks device
discovery for many (perhaps all?) FC devices.  In my testing with
IBM LTO-6 drives attached to a quad port 16Gb Qlogic 2714, they
don't show up when they are directly connected (and in loop mode)
or connected via a switch (and in fabric mode).

So, mask off the top bits of of the login state before checking it.
This shouldn't break anything, because all of the existing login
states defined in ispmbox.h are in the low nibble.

sys/dev/isp/ispmbox.h:
	Add a FCP login state mask define, and a NVMe login state
	shift.

sys/dev/isp/isp.c:
	In isp_getpdb(), make sure we're only looking at the FCP
	login state bits when we try to determine whether a device
	is in the right login state.

MFC after:	1 week
Sponsored by:	Spectra Logic
Reviewed by:	mav
Differential Revision:	<https://reviews.freebsd.org/D45660>
2024-06-24 16:47:55 -04:00
Jamie Gritton 63875db56b Document the zfs.mount_snapshot parameter in jail(8).
PR:		274263
Differential Revision:	https://reviews.freebsd.org/D45647
2024-06-24 13:03:45 -07:00
Jamie Gritton 9cbf1de7e3 Mark the zfs.mount_snapshot jail parameter as boolean.
PR:		274263
Differential Revision:	https://reviews.freebsd.org/D45647
2024-06-24 13:00:49 -07:00
Ed Maste 1efd69f933 p9fs: move NULL check immediately after allocation
Reported by:	Shawn Webb (HardenedBSD)
Reviewed by:	dfr
Sponsored by:	The FreeBSD Foundation
Differential Revision: https://reviews.freebsd.org/D45719
2024-06-24 15:36:11 -04:00
Ryan Libby 012e32c665 libthr: move __always_inline to canonical position
Ahead of including inline in __always_inline, move __always_inline to
where inline goes.

Reviewed by:	imp, kib, olce
Sponsored by:	Dell EMC Isilon
Differential Revision:	https://reviews.freebsd.org/D45710
2024-06-24 10:05:58 -07:00
Ryan Libby eae1767d8f vfs: move __always_inline to canonical position
Ahead of including inline in __always_inline, move __always_inline to
where inline goes.

Reviewed by:	kib, olce
Sponsored by:	Dell EMC Isilon
Differential Revision:	https://reviews.freebsd.org/D45709
2024-06-24 10:05:58 -07:00
Ryan Libby 3c84b4b35f kern: move __always_inline to canonical position
Ahead of including inline in __always_inline, move __always_inline to
where inline goes.

Reviewed by:	kib, olce
Sponsored by:	Dell EMC Isilon
Differential Revision:	https://reviews.freebsd.org/D45708
2024-06-24 10:05:58 -07:00
Val Packett daa2c99c89 p9fs: implement working putpages (fix mmap write)
Mostly copied from smbfs. This driver in its current state has the exact
same issue that prevents the generic putpages implementation from
working.

Sponsored by:		https://www.patreon.com/valpackett
Reviewed by:		dfr
Differential Revision:	https://reviews.freebsd.org/D45639
MFC after:		3 months
2024-06-24 17:11:47 +01:00
Alan Somers 6efba04df3 fusefs: fix two bugs regarding _PC_MIN_HOLE_SIZE
Background:

If a user does pathconf(_, _PC_MIN_HOLE_SIZE) on a fusefs file system,
the kernel must actually issue a FUSE_LSEEK operation in order to
determine whether the server supports it.  We cache that result, so we
only have to send FUSE_LSEEK the first time that _PC_MIN_HOLE_SIZE is
requested on any given mountpoint.

Problem 1:

Unlike fpathconf, pathconf operates on files that may not be open.  But
FUSE_LSEEK requires the file to be open.  As described in PR 278135,
FUSE_LSEEK cannot be sent for unopened files, causing _PC_MIN_HOLE_size
to wrongly report EINVAL.  We never noticed that before because the
fusefs test suite only uses fpathconf, not pathconf.  Fix this bug by
opening the file if necessary.

Problem 2:

On a completely sparse file, with no data blocks at all, FUSE_LSEEK with
SEEK_DATA would fail to ENXIO.  That's correct behavior, but
fuse_vnop_pathconf wrongly interpreted that as "FUSE_LSEEK not
supported".  Fix the interpretation.

PR:		278135
MFC after:	1 week
Sponsored by:	Axcient
Differential Revision: https://reviews.freebsd.org/D44618
2024-06-24 10:02:02 -06:00
Alan Somers a1608e8854 ctladm: add a copyright header to the port test
[skip ci]

MFC with:	9747d11d91
Reported by:	markj
Sponsored by:	Axcient
2024-06-24 09:17:27 -06:00
Mark Johnston 02cbf9ebf1 lagg: Fix a teardown race
When a lagg interface is destroyed, it destroys all of the lagg ports,
which triggers an asynchronous link state change handler.  This in turn
may generate a netlink message, a portion of which requires netlink to
invoke the SIOCGIFMEDIA ioctl of the lagg interface, which involves
scanning the list of interface media.  This list is not internally
locked, it requires the interface driver to provide some kind of
synchronization.

Shortly after the link state notification has been raised, the lagg
interface detaches itself from the network stack.  As a part of this, it
blocks in order to wait for link state handlers to drain, but before
that it destroys the interface media list.  Reverse this order of
operations so that the link state change handlers drain first, avoiding
a use-after-free that is very occasionally triggered by lagg stress
tests.  This matches other ethernet drivers in the tree.

MFC after:	2 weeks
2024-06-24 10:47:29 -04:00
Mark Johnston 66b8cac8d8 pf: Sprinkle const qualifiers in state lookup routines
State keys are trivially const in lookup routines, so annotate them as
such.  No functional change intended.

Reviewed by:	kp
MFC after:	1 week
Sponsored by:	Klara, Inc.
Sponsored by:	Modirum
Differential Revision:	https://reviews.freebsd.org/D45671
2024-06-24 10:46:55 -04:00
Mark Johnston b75d14d600 procfs.4: Fix the description of credential info in the "status" file
The 11th and 12th columns are the effective and real UIDs, respectively.
The 13th column is a group list whose first member is the effective
GID.

Reviewed by:	arrowd
MFC after:	1 week
Differential Revision:	https://reviews.freebsd.org/D45700
2024-06-24 10:46:36 -04:00
Doug Rabson 56e4622588 p9fs: fix lookup of "." for lib9p-based 9P servers
The lib9p implementation takes a strict interpretation of the Twalk RPC
call and returns an error for attempts to lookup ".".  The workaround is
to fake the lookup locally.

Reviewed by: Val Packett <val@packett.cool>
MFC after: 3 months
2024-06-24 14:40:06 +01:00
Oskar Holmlund 332f00cdba ti/am335x: Fix the device_set_descf() call in am335x_dmtimer_probe()
Fixes: 459dc61c8b ("arm: Convert drivers to use device_set_desc(f)()")

Reviewed by:    markj, imp, manu
Approved by:    markj, imp, manu (mentor)
Differential Revision:  https://reviews.freebsd.org/D45699
2024-06-24 13:57:25 +02:00
Zhenlei Huang 71f8fbf9bd ifnet: Use NET_EPOCH_WAIT() macro
This makes it easier to grep the usage.

Reviewed by:	kp
MFC after:	1 week
Differential Revision:	https://reviews.freebsd.org/D45715
2024-06-24 17:57:14 +08:00
Zhenlei Huang 08a98731dd ip_mroute: Use NET_EPOCH_WAIT() macro
This makes it easier to grep the usage.

Reviewed by:	kp
MFC after:	1 week
Differential Revision:	https://reviews.freebsd.org/D45715
2024-06-24 17:57:14 +08:00
Doug Moore 5dbf886104 x86: use order_base_2
Use order_base_2 in place of expressions involving fls.

Reviewed by:	alc, markj
Differential Revision:	https://reviews.freebsd.org/D45536
2024-06-24 02:26:23 -05:00
Doug Moore 0839258c56 ipfw: Use roundup_pow_of_two
Use roundup_pow_of_two in place of a local function that does the same thing.

Reviewed by:	alc, markj
Differential Revision:	https://reviews.freebsd.org/D45536
2024-06-24 02:24:24 -05:00
Doug Moore dc048255b3 mlx5: use roundup_pow_of_two
Use roundup_pow_of_two in place of an expression.

Reviewed by:	alc, markj
Differential Revision:	https://reviews.freebsd.org/D45536
2024-06-24 02:22:52 -05:00
Doug Moore 87177ce3aa irdma: Use round{up,down}_pow_of_two
Use roundup_pow_of_two and rounddown_pow_of_two in place of expressions.

Reviewed by:	alc, markj
Differential Revision:	https://reviews.freebsd.org/D45536
2024-06-24 02:20:49 -05:00
Doug Moore 5fc42387d7 cxgbe: use order_base_2
Use order_base_2 in place of an expression.

Reviewed by:	alc, markj
Differential Revision:	https://reviews.freebsd.org/D45536
2024-06-24 02:18:42 -05:00
Doug Moore 7bb73f7315 cxgb: use rounddown_pow_of_two
In two places, use the rounddown_pow_of_two macro in place of expressions.

Reviewed by:	alc, markj
Differential Revision:	https://reviews.freebsd.org/D45536
2024-06-24 02:17:02 -05:00
Doug Moore 4bbdabc2bd aic7xxx: use rounddown_pow_of_two
Use the roundown_pow_of_two macro in place of an expression.

Reviewed by:	alc, markj
Differential Revision:	https://reviews.freebsd.org/D45536
2024-06-24 02:14:55 -05:00
Doug Moore c8b0c33b03 log2: move log2 functions from linuxkpi to libkern
Linux has a header file that defines an ilog2 function and some simple
functions/macros that use it: roundup_pow_of_two, is_power_of_2,
rounddown_pow_of_two, and order_base_2.  This change moves three of
those simple functions (all but is_power_of_2) from linuxkpi to
libkern.  It also deletes a few implementations of these functions
that have previously been copied into code for various device drivers,
so that they can use the libkern version.  The is_power_of_2 macro was
not moved because powerof2 in param.h provides almost the same service
already (except that they disagree about whether 0 is a power of two).

Since the linux definitions of these functions were copied into
FreeBSD 11 years ago, linux has improved them, and this change
provides those improvements.  In particular, a giant table of log
values for evaluating ilog2 for constant values is no longer
necessary.

Reviewed by:	alc, markj (previous version)
Differential Revision:	https://reviews.freebsd.org/D45536
2024-06-24 02:00:31 -05:00
Doug Moore a94ed493b5 dev/mana: replace power2 function
Replace is_power_of_2(length) with power2(length).  When length != 0, as in
this case, they produce the same result.  This will allow an implementation
of is_power_of_two to be dropped.

Reviewed by:	alc, markj
Differential Revision:	https://reviews.freebsd.org/D45536
2024-06-24 01:55:01 -05:00
Ryan Libby 88478cc02a i386 kernel __storeload_barrier: quiet gcc -Warray-bounds
Use a constant input operand instead of an output operand to tell the
compiler about __OFFSETOF_MONITORBUF.  If we tell it we are writing to
*(u_int *)__OFFSETOF_MONITORBUF, it rightly complains, but we aren't.
The memory clobber already covers the necessary semantics for the
compiler.

Reviewed by:	kib
Sponsored by:	Dell EMC Isilon
Differential Revision:	https://reviews.freebsd.org/D45695
2024-06-23 18:20:47 -07:00
Ryan Libby 6095f4b04c amd64 kernel __storeload_barrier: quiet gcc -Warray-bounds
Use a constant input operand instead of an output operand to tell the
compiler about OFFSETOF_MONITORBUF.  If we tell it we are writing to
*(u_int *)OFFSETOF_MONITORBUF, it rightly complains, but we aren't.  The
memory clobber already covers the necessary semantics for the compiler.

Reviewed by:	kib
Sponsored by:	Dell EMC Isilon
Differential Revision:	https://reviews.freebsd.org/D45694
2024-06-23 16:23:14 -07:00
David E. O'Brien 5bcc33d1e0 ppoll(2) was actually added in 10.2 2024-06-23 16:13:28 -07:00
David E. O'Brien 3dd248798d procctl(2) actually appeared in 9.3 2024-06-23 16:13:28 -07:00
Rick Macklem 67284d32e5 nfsd: Make modifying vfs.nfsd.enable_locallocks safe
Commit dfaeeacc2c modified clientID handling so that it could be done
with only a mutex lock held when vfs.nfsd.enable_locallocks is 0.
This makes it unsafe to change the setting of vfs.nfsd.enable_locallocks
when nfsd threads are active.

This patch forces all nfsd threads to be blocked when the value
of vfs.nfsd.enable_locallocks is changed, so that it is done safely.

MFC after:	1 month
2024-06-23 15:47:22 -07:00
Ryan Libby fda32d5860 lock.9: describe lockmgr_{disowned,lock_flags,slock,unlock,xlock}
Describe and link the following functions in the lockgmr API:
 - lockmgr_disowned
 - lockmgr_lock_flags
 - lockmgr_slock
 - lockmgr_unlock
 - lockmgr_xlock

This is not a complete update of lock.9 but at least covers all the main
lock operations.

Reviewed by:	gbe, kib
Sponsored by:	Dell EMC Isilon
Differential Revision:	https://reviews.freebsd.org/D45689
2024-06-23 14:46:31 -07:00
Michael Tuexen 60117f9ee5 lo: update man page since SCTP checksum offloading is supported
The loopback interface supports SCTP checksum offloading in
addition to TCP and UDP.
Reviewed by:		gbe
MFC after:		1 week
Differential Revision:	https://reviews.freebsd.org/D45698
2024-06-23 13:34:50 +02:00
Gordon Bergling 16c3d7e1fa erf.3: Add a STANDARDS section
Add a STANDARDS section for the erf(3) manual page.

PR:	273413
Reviewed by:	pauamma_gundo.com
MFC after:	1 week
Differential Revision:	https://reviews.freebsd.org/D44140
2024-06-23 12:50:47 +02:00
Rick Macklem dfaeeacc2c nfsd: Allow a mutex lock for clientID handling
On Feb. 28, a problem was reported on freebsd-stable@ where a
nfsd thread processing an ExchangeID operation was blocked for
a long time by another nfsd thread performing a copy_file_range.
This occurred because the copy_file_range was taking a long time,
but also because handling a clientID requires that all other nfsd
threads be blocked via an exclusive lock, as required by ExchangeID.

This patch allows clientID handling to be done with only a mutex
held (instead of an exclusive lock that blocks all other nfsd threads)
when vfs.nfsd.enable_locallocks is 0.  For the case of
vfs.nfsd.enable_locallocks set to 1, the exclusive lock that
blocks all nfsd threads is still required.

This patch does make changing the value of vfs.nfsd.enable_locallocks
somewhat racy.  A future commit will ensure any change is done when
all nfsd threads are blocked to avoid this racyness.

MFC after:	1 month
2024-06-22 15:56:40 -07:00
Ganael LAPLANCHE 48dbc2a4f9 mailmap: Translate my personal address
Approved by:	imp
2024-06-22 08:57:56 +02:00
Doug Moore 10d8f95395 spelling: specifiy -> specify
A spelling error correction.  No functional change.

Reviewed by:	alc
Differential Revision:	https://reviews.freebsd.org/D45667
2024-06-22 00:49:40 -05:00
Warner Losh b1cd308b37 cdefs: Add missing continuation line...
TinyC has heart-burn on this construct, but gcc and clang like it just
fine.

Sponsored by:		Netflix
2024-06-21 16:51:44 -06:00
Rick Macklem a7de510685 nfsd: Fix nfsrv_cleanclient so that it can be called with a mutex
On Feb. 28, a problem was reported on freebsd-stable@ where a
nfsd thread processing an ExchangeID operation was blocked for
a long time by another nfsd thread performing a copy_file_range.
This occurred because the copy_file_range was taking a long time,
but also because handling a clientID requires that all other nfsd
threads be blocked via an exclusive lock, as required by ExchangeID.

This patch adds two arguments to nfsv4_cleanclient() so that it
can optionally be called with a mutex held.  For this patch, the
first of these arguments is "false" and, as such, there is no
change in semantics.  However, this change will allow a future
commit to modify handling of the clientID so that it can be done
with a mutex held while other nfsd threads continue to process
NFS RPCs.

MFC after:	1 month
2024-06-21 15:08:48 -07:00
Colin Percival 45846afcb7 release: Stop publishing non-FS-tagged VM images
VM, BASIC-CI, and BASIC-CLOUDWARE images are published with the
filesystem type (UFS or ZFS) in the file name.  For backwards
compatibility we have published the UFS images with no filesystem
in the filename (aka with the same file names as we used before we
supported building ZFS VM images); those are going away now.

This will not be MFCed.
2024-06-21 14:42:10 -07:00
Mark Johnston ac52fa1f1b sendfile tests: Fix an error check in tcp_socketpair()
Fixes:	c368d3f20f ("tests/sendfile: factor out tcp_socketpair()")
Differential Revision:	https://reviews.freebsd.org/D45598
2024-06-21 14:18:22 -04:00
Ganael Laplanche 681fd2bed8 pax: Terminate loop for empty directory names
Pax can sometimes loop forever. For example:

$ mkdir -p /tmp/src/foo/bar
$ rm -rf /tmp/dst ; mkdir -p /tmp/dst
$ cd /tmp/src
$ echo 'foo/bar/' | /bin/pax -r -w -d -pe "/tmp/dst"
<looping infinitely>

Here, pax(1) infinitely deletes and re-creates /tmp/dst/foo/bar/.

The problem is that chk_path() (bin/pax/file_subs.c), called from
node_creat() also creates the leaf directory when a trailing '/' appears
in the directory name to create. When the execution goes back from
chk_path() to node_creat(), the function still cannot create the leaf
directory (it has been created by chk_path()), so it unlinks it and
calls node_creat() again. The function re-creates it, and so on...

In node_creat() detect trailing slashes and not create a leaf directory,
but only intermediate ones.

PR: 277060
Reviewed by: imp
2024-06-21 10:39:09 -06:00
Warner Losh 5a969a3459 cdefs.h: Move to more regular _Thread_local define
Move to trusting C++ environment for thread local storage designation.

Noticed by:		brooks
Sponsored by:		Netflix
Differential Revision:	https://reviews.freebsd.org/D45663
2024-06-21 09:53:07 -06:00
Warner Losh 4a86b26b84 stdlib: Support compiling with tinyc by omitting compat qsort code
TinyC doesn't support the .symver assembler directive. Add a generic way
to signal this and use that not to define __sym_() macros that use
it. Only use the __sym_* macros in headers when they are defined (which
currently is only for the qsort_r compat code. Not supporting this for
tcc is fine: It's an edge case for legacy binaries / code anyway which
isn't relevant to tinyc.

Sponsored by:		Netflix
Reviewed by:		kib
Differential Revision:	https://reviews.freebsd.org/D45651
2024-06-21 09:53:07 -06:00
Baptiste Daroussin 3fdf11fe8f acpi_timer: remove leftovers from Garbage-collect ACPI-safe timer and friends
Reviewed by:	cperciva
Differential Revision:	https://reviews.freebsd.org/D45669
2024-06-21 14:06:26 +02:00