FreeBSD/src 4a97b40 — sys/netpfil/pf if_pfsync.c, tests/sys/netpfil/pf Makefile pfsync_upd_c.py

pfsync: don't apply a stale dst peer from a state update

pfsync_upd_tcp() checks each peer of an incoming update separately.  A
peer whose window is behind the local copy is skipped and counted as
stale, otherwise it is copied into the state.  pfsync_in_upd() and
pfsync_in_upd_c() then copied the dst peer again whenever fewer than two
peers were stale.  When only the dst peer was stale, that second copy
moved the local dst window backwards.

This is the common case for a bulk transfer, where the receiver's
window barely moves and the sender's advances quickly.  Once dst.seqlo
regresses by more than MAXACKWINDOW, pf_tcp_track_full() drops every
packet of the connection as PFRES_BADSTATE.  Dropped packets never
update the state, so the connection stays wedged until the application
times out.  The only trace is the state-mismatch counter.

Remove the extra copy.  Both branches that compute sync already copy dst
when it is acceptable.  Allocate dst scrub memory before the peers are
compared, so an accepted update still finds it.

    [9 lines not shown]
DeltaFile
+73-0tests/sys/netpfil/pf/pfsync.sh
+71-0tests/sys/netpfil/pf/pfsync_upd_c.py
+2-4sys/netpfil/pf/if_pfsync.c
+2-0tests/sys/netpfil/pf/Makefile
+148-44 files

FreeBSD/src 2c2007f — sys/dev/md md.c

md: Read the preloaded image length as size_t

hint.md.N.len was read as an int, so on 64-bit platforms ram disks of
4 GiB or more were truncated, or skipped at exact multiples of 4 GiB.

Reported by:    llm-postcr
Reviewed by:    imp
Approved by:    imp
Fixes:          15925062e1ba ("biosboot: Detect memory disks from PXE")
Sponsored by:   Netflix
Differential Revision:  https://ron-dev.freebsd.org/FreeBSD/src/pulls/104
DeltaFile
+2-2sys/dev/md/md.c
+2-21 files

FreeBSD/src c01bb33 — sys/netgraph ng_ether.c, sys/netinet igmp.c ip_mroute.c

mbuf: unshare headers again where m_pullup() did it implicitly

Since the inline m_pullup() returns a contiguous mbuf untouched, callers using
"!M_WRITABLE(m) || m_len < len" kept writing into a shared cluster.
Forwarded multicast fragments left with a corrupted IP header.
Use m_copyup(), which always allocates a new header mbuf, at those sites.

Reviewed by:    glebius, pouria
Approved by:    pouria
Fixes:          671babc79497 ("mbuf: make m_pullup() an inline over most expected case")
Sponsored by:   Netflix
Differential Revision:  https://ron-dev.freebsd.org/FreeBSD/src/pulls/109
DeltaFile
+3-3sys/netinet6/ip6_mroute.c
+3-3sys/netinet/ip_mroute.c
+2-2sys/netinet/igmp.c
+2-2sys/netgraph/ng_ether.c
+1-1sys/netinet6/ip6_output.c
+11-115 files

FreeBSD/src d1470ac — contrib/llvm-project/clang/lib/Basic/Targets PPC.h, contrib/llvm-project/llvm/lib/Target/PowerPC PPCTargetMachine.cpp

Merge commit 5472aa0c1321 from llvm git (by Piotr Kubaj):

  [PowerPC] Use the 16-byte stack and vector alignment on FreeBSD (#232336)

  FreeBSD uses the ELFv2 ABI on both byte orders, so it has the same
  16-byte stack alignment as Linux. The explicit vector alignment is a
  backend workaround that does not depend on the OS. There is no
  reason for the layouts to differ.

llvm 21 still keeps the data layout in two places, so the check is
changed in both the PowerPC backend and clang. They have to match, or
clang errors out with a data layout mismatch.

Reviewed by:    dim
MFC after:      3 days
Differential Revision:  https://reviews.freebsd.org/D61678
DeltaFile
+3-1contrib/llvm-project/llvm/lib/Target/PowerPC/PPCTargetMachine.cpp
+1-1contrib/llvm-project/clang/lib/Basic/Targets/PPC.h
+4-22 files

FreeBSD/src f9c923c — share/man/man5 freebsd-update.conf.5

freebsd.update.conf.5: No crossreferences in title

Crossreferences in titles are strongly discouraged and incompatible
with our own tooling. This is a wontfix by most of manpages ecosystem
because it is bad editorial style in the first place.

MFC after:      3 days
DeltaFile
+1-2share/man/man5/freebsd-update.conf.5
+1-21 files

FreeBSD/src 8f0e765 — share/man/man4 blackhole.4

blackhole.4: These sysctls are sysctl only

Fixes:  0c89a55a5d63a17 ("blackhole.4: Canonicalize SYNOPSIS")
MFC after:              3 days
Reported by:            llm-postcr
Differential Revision:  https://reviews.freebsd.org/D61687
DeltaFile
+0-2share/man/man4/blackhole.4
+0-21 files

FreeBSD/src 27eefcf — usr.bin/bsdiff/bspatch bspatch.1

bspatch.1: No crossreferences in titles

Crossreferences in titles are strongly discouraged and incompatible
with our own tooling. This is a wontfix by most of manpages ecosystem
because it is bad editorial style in the first place.

MFC after:      3 days
DeltaFile
+1-2usr.bin/bsdiff/bspatch/bspatch.1
+1-21 files

FreeBSD/src 3068ea3 — share/man/man4 ix.4

ix.4: Canoncialize wake sysctl

Integrate the wake sysctl in SYNOPSIS and SYSCTL VARIABLES so that
it is integrated into the search engine and visible in the canonical
sections. Also, add a blank line after the example for visual harmony.

Fixes:  c004384343be (ixgbe: Correct Wake-on-LAN configuration)
MFC after:              the above is MFCed
Reviewed by:            kbowling
Differential Revision:  https://reviews.freebsd.org/D61702
DeltaFile
+5-1share/man/man4/ix.4
+5-11 files

FreeBSD/src 000c5ec — share/man/man4 rge.4

rge.4: Polish

+ trim document description to fit on one line
+ canonicalize synopsis
+ move supported speeds to hardware with consistency with latest drivers
+ organize hardware in descending capability for marketing purposes
+ fix cursed line wrapping
+ make link to realtek.com clickable
+ first shipped in 15.2 actually
+ fix authors section line break and linter warning

Reviewed by:            adrian
MFC after:              immediately because this is shipping in 15.2
Differential Revision:  https://reviews.freebsd.org/D61704
DeltaFile
+37-43share/man/man4/rge.4
+37-431 files

FreeBSD/src 2db63f8 — contrib/elftoolchain/libdwarf dwarf.h dwarf_dump.c

MFC: libdwarf: standard DWARF 5 form names, DW_LANG_C17 and C23

7bb441c86678 added the fixed-size string and address index forms
0x25 to 0x2c as DW_FORM_ref_strx1..4 and DW_FORM_ref_addrx1..4; the
standard (DWARF 5, table 7.6) names them DW_FORM_strx1..4 and
DW_FORM_addrx1..4, with no "ref".  Rename them, keep the old spellings
as aliases since the header is installed, and update dwarf_dump.c's
form names accordingly.  Add DW_LANG_C17 (0x2c) and DW_LANG_C23 (0x3e),
which clang emits for -std=c17 and -std=c23 units.  ctfconv(1) needs
all of these; it carried them in a private header until now.

Reviewed by:    markj, emaste
Differential Revision: https://reviews.freebsd.org/D61154

(cherry picked from commit f22d65998fe15b6bed9c8c3a2eede25c706837e1)
DeltaFile
+16-16contrib/elftoolchain/libdwarf/dwarf_dump.c
+19-8contrib/elftoolchain/libdwarf/dwarf.h
+35-242 files

FreeBSD/src a0e9782 — sys/contrib/zlib gzwrite.c inflate.c

MFC: MFV: zlib 1.4

(cherry picked from commit 724bb39e83e369209d8e42a52370684b82e26350)
DeltaFile
+100-41sys/contrib/zlib/gzread.c
+73-37sys/contrib/zlib/deflate.c
+44-33sys/contrib/zlib/zlib.h
+37-37sys/contrib/zlib/gzlib.c
+43-13sys/contrib/zlib/inflate.c
+40-8sys/contrib/zlib/gzwrite.c
+337-16917 files not shown
+452-19723 files

FreeBSD/src c16da33 — contrib/kyua/utils datetime.cpp auto_array.hpp, contrib/kyua/utils/signals timer_test.cpp

contrib/kyua: update to 0.15.2

This change contains a few bugfixes to the test executor.

MFC after:      1 week
Merge commit 'dab80d5deaf7d998d587b99f7941890237960638'
DeltaFile
+0-312contrib/kyua/utils/auto_array_test.cpp
+0-227contrib/kyua/utils/auto_array.ipp
+117-0contrib/kyua/utils/datetime_test.cpp
+92-19contrib/kyua/utils/signals/timer_test.cpp
+0-102contrib/kyua/utils/auto_array.hpp
+88-0contrib/kyua/utils/datetime.cpp
+297-66014 files not shown
+442-77020 files

FreeBSD/src dab80d5 — utils datetime.cpp auto_array.hpp, utils/signals timer_test.cpp

kyua: import kyua-0.15.2

This change adds kyua kyua-0.15.2 from [upstream][1].

The kyua-0.15.2 artifact was been verified by [SHA256 checksum][3].

This version update contains a few bugfixes and some developer workflow changes.

More information about the release (from a high level) can be found in
the [release notes][4].

Updated via [`update_kyua.sh`][4] `update_kyua.sh 0.15.2 kyua-0.15.2`.

1: https://github.com/freebsd/kyua/releases/download/kyua-0.15.2/kyua-0.15.2.tar.gz
2: https://github.com/freebsd/kyua/releases/download/kyua-0.15.2/kyua-0.15.2.tar.gz.sha256
3: https://github.com/freebsd/kyua/blob/kyua-0.15.2/NEWS.md
4: https://codeberg.org/ngie/freebsd-powertools:shell/update_kyua.sh@10a04edb
DeltaFile
+0-312utils/auto_array_test.cpp
+0-227utils/auto_array.ipp
+117-0utils/datetime_test.cpp
+92-19utils/signals/timer_test.cpp
+0-102utils/auto_array.hpp
+88-0utils/datetime.cpp
+297-66020 files not shown
+480-84026 files

FreeBSD/src ad0cd01 — sys/arm64/arm64 pmap.c

arm64 pmap: Eliminate page table rewalks after demotions

pmap_demote_l1() and pmap_demote_l2_locked() return the virtual address
of the page table page that replaces the demoted superpage mapping.  In
pmap_advise(), pmap_change_props_locked(), and pmap_clear_modify() use
that address instead of rewalking the page table from the L1 or L2
entry.  Similarly, after pmap_advise() demotes an L3C superpage, compute
the virtual address of the L3 entry that it removes from the virtual
address of the current L3 entry.

Reviewed by:    kib
MFC after:      1 week
Differential Revision:  https://reviews.freebsd.org/D61599
DeltaFile
+17-13sys/arm64/arm64/pmap.c
+17-131 files

FreeBSD/src 36d9f18 — usr.bin/man man.conf.5 man.sh

man: Convert licenses to SPDX only

Reported by:    ziaee
MFC after:      3 days
Differential Revision:  https://reviews.freebsd.org/D61729
DeltaFile
+3-25usr.bin/man/manpath.1
+3-25usr.bin/man/man.1
+2-24usr.bin/man/man.sh
+2-22usr.bin/man/man.conf.5
+10-964 files

FreeBSD/src d1e14cb — share/man/man4 ipsec.4, sys/netipsec ipsec_output.c

netipsec: Set the outer IPv6 flow label from the SA

Tunnel mode encapsulation leaves the flow label of the outer IPv6 header
zero. ESP and AH have no transport ports (UDP-encapsulated ESP has them, but
the same pair for every SA), so devices that hash IPv6 headers to spread
traffic, link aggregates and ECMP routers alike, see no difference between
the security associations of two gateways and put all of their tunnels on
one path. lagg(4)'s own header hash does the same: for IPv6 its layer 4
input is the flow label.

Set the label to the low 20 bits of the SA's flow ID, the hash of its SPI
that the previous change introduced. Each SA then carries one label for its
lifetime; SPIs are unique within the SADB, so distinct SAs carry distinct
labels unless the 20-bit hashes collide. A hasher that includes the flow
label then spreads SAs over its paths while keeping the packets of each SA
on one, which avoids reordering their sequence numbers across paths. A rekey
starts a new SA and a new label. The label is set whether or not
net.inet.ipsec.sa_flowid is enabled: that sysctl governs the local transmit
queue selection, this label what the network sees. In a bundle whose tunnel

    [29 lines not shown]
DeltaFile
+281-0tests/sys/netipsec/tunnel/flowlabel.sh
+38-5sys/netipsec/ipsec_output.c
+10-1share/man/man4/ipsec.4
+1-0tests/sys/netipsec/tunnel/Makefile
+330-64 files

FreeBSD/src 3ccfcda — sys/netpfil/pf pf.c, tests/sys/netpfil/pf forward.sh

pf: Do not report a packet the outbound pass sent as dropped

For route-to on the inbound pass, pf_route() and pf_route6() run the
outbound pass on the new interface themselves and hand it the actions
of the rule.  When that pass creates a state, the state has the route-to
as well, so the outbound pass sends the packet and returns PF_PASS
without an mbuf.  Since 349360b17eab the caller turns this into PF_DROP,
and the pfil hook returns PFIL_DROPPED for a packet that was forwarded.
ip6_tryforward() then counts an input discard on the receiving
interface for every such packet.

Leave the action at PF_PASS, so that the hook returns PFIL_CONSUMED, as
it does when pf_route() or pf_route6() send the packet themselves.
Extend forward:v6_route_to_discards to rules that keep state.

Reviewed by:            kp
Fixes:                  349360b17eab ("pf: return errors from pf_route() and ...")
MFC after:              1 week
Sponsored by:           Rubicon Communications, LLC ("Netgate")
Differential Revision:  https://reviews.freebsd.org/D61674
DeltaFile
+16-14tests/sys/netpfil/pf/forward.sh
+8-4sys/netpfil/pf/pf.c
+24-182 files

FreeBSD/src 20e652b — sys/netinet6 ip6_fastfwd.c, tests/sys/netpfil/pf forward.sh

netinet6: Do not count a packet a hook consumed as discarded in ip6_tryforward()

ip6_tryforward() treats every pfil result but PFIL_PASS as a drop: it
counts a discard on the receiving interface after the inbound hooks and
on the outgoing interface after the outbound hooks.  A hook that
consumes the packet returns PFIL_CONSUMED instead: pf sends a packet a
route-to rule matches out itself, and sends a packet it reassembled on
in fragments.  Those packets were forwarded, yet netstat -s -I shows
them as discarded, in the outbound case on the interface the route
lookup chose, which route-to did not even use.  ip6_forward() and
ip_tryforward() count nothing for a consumed packet.

Return without counting when a hook consumed the packet.  The new
forward:v6_route_to_discards test checks both passes.  Its rules keep
no state: pf reports a packet it sent from the inbound hook as dropped
when its own outbound pass created a state, and that packet is still
counted.

Reviewed by:            kp, glebius, pouria

    [4 lines not shown]
DeltaFile
+66-0tests/sys/netpfil/pf/forward.sh
+19-4sys/netinet6/ip6_fastfwd.c
+85-42 files

FreeBSD/src bf8783a — sys/modules/pf Makefile, sys/netinet6 ip6_fastfwd.c

netinet6: Decrement the hop limit before the outbound hooks in ip6_tryforward()

ip6_tryforward() decrements the hop limit after the outbound pfil hooks,
whereas ip_tryforward() and ip6_forward() do it before them.  The hooks
therefore see a packet one hop older than the one that leaves, and a hook
that transmits the packet itself does not decrement it at all: pf's
route-to and reply-to on an outbound state send it on with the hop limit
it arrived with.

Decrement it right after the check, before the route lookup, as the other
two paths do.  Errors sent after that point quote the decremented value,
as they do on those paths.

pf_refragment6() hands the fragments of a forwarded packet it
reassembled to ip6_forward(), which decrements the hop limit again, so
on the slow path such a packet has always lost two hops at this router,
and with this change it would on the fast path as well.  Give the hop
back before ip6_forward(), unless ip6stealth is on, in which case
neither path decrements, or the hop limit is 255, which a scrub

    [9 lines not shown]
DeltaFile
+67-0tests/sys/netpfil/pf/forward.sh
+12-8sys/netinet6/ip6_fastfwd.c
+16-0sys/netpfil/pf/pf_norm.c
+14-0tests/sys/netpfil/pf/fragmentation_pass.sh
+1-1sys/modules/pf/Makefile
+110-95 files

FreeBSD/src fb9969c — sys/netinet6 ip6_fastfwd.c, tests/sys/netpfil/ipfw fwd.sh

netinet6: Keep a pfil-chosen next hop in ip6_tryforward()

When an inbound pfil hook chooses the next hop (ipfw fwd),
ip6_tryforward() looks up the route to it.  After the outbound hooks it
decides whether they changed the destination by comparing the packet's
destination with the address it looked up, which is that next hop.  The
two differ, so it looks up the route to the packet's destination again
and the fwd rule is lost.  ipfw always installs an outbound hook, so
every packet such a rule matches goes the wrong way while
net.inet6.ip6.redirect is 0.

Compare with the destination as it was before the outbound hooks, as
ip6_forward() does.

Reviewed by:            pouria
Fixes:                  5a1842a2 ("Add ip6_tryforward() - a run to completion ...")
MFC after:              1 week
Sponsored by:           Rubicon Communications, LLC ("Netgate")
Differential Revision:  https://reviews.freebsd.org/D61038
DeltaFile
+56-0tests/sys/netpfil/ipfw/fwd.sh
+3-1sys/netinet6/ip6_fastfwd.c
+59-12 files

FreeBSD/src b74577a — sys/net if_epair.c

if_epair: Hash the IP header, not the Ethernet header, for fanout

With RSS, epair_select_queue() hashes a packet that carries no RSS hash
with rss_soft_m2cpuid_v4() or rss_soft_m2cpuid_v6(), which read the IP
header at the start of the mbuf.  On transmit the mbuf starts with the
Ethernet header, so the hash covered the MAC addresses, the EtherType
and the first bytes of the IP header, the IPv4 total length and
identification among them.  The packets of one flow were spread over the
queues by their IP ID and delivered out of order, and the value was
stored in the mbuf as an RSS hash for the receiving side to use.

Step over the Ethernet header, and over inline 802.1Q or 802.1ad tags,
while the software hash runs.  A tag is inline when vlan(4) or a bridge
member runs without VLAN_HWTAGGING, always for 802.1ad, and for the
inner tag of stacked vlans; those frames previously went to the first
queue unhashed.  Frames with more than two tags still do.

Hash with rss_mbuf_software_hash_v4() and rss_mbuf_software_hash_v6()
and map the hash with rss_getbucket(), as the hardware hash path does,

    [10 lines not shown]
DeltaFile
+41-9sys/net/if_epair.c
+41-91 files

FreeBSD/src 09fa4e2 — sys/vm vm_object.c

Revert "vm_object: Fix synchronization with teardown in the object list loop"

This was pushed by accident.

This reverts commit 4e6e4fa8be9940e711b791073eee5bcfa77ec5d4.
DeltaFile
+7-13sys/vm/vm_object.c
+7-131 files

FreeBSD/src 4e6e4fa — sys/vm vm_object.c

vm_object: Fix synchronization with teardown in the object list loop

Checking for OBJT_DEAD is racy since pagers update the object type
without the object lock held.  Check for the flag as well, as that is
set beforehand.  Otherwise pager dealloc can race with, e.g.,
cdev_pager_get_path().

Try to minimize accesses of the object after dropping the object lock in
vm_object_list_handler().
DeltaFile
+13-7sys/vm/vm_object.c
+13-71 files

FreeBSD/src b9dca39 — sys/dev/gve gve_tx_dqo.c

gve: Fix return value in gve_tx_has_desc_room_dqo()

When the cached tx->dqo.desc_head does not show enough available
descriptor ring slots, gve_tx_has_desc_room_dqo() reloads desc_head from
tx->dqo.hw_tx_head and re-checks availability. If the refreshed
desc_head provides sufficient space, the function mistakenly returns 0
(false) instead of true, causing callers to treat a successful
descriptor head refresh as ENOBUFS, stop the TX queue, and retry or
abort packet transmission (including unloading already-mapped DMA
segments) unnecessarily.

Return true when sufficient descriptor space is available after
refreshing desc_head.

In 60s iperf benchmarks between two FreeBSD 14.4 c4-standard-192
instances, this eliminates spurious tx->stopped transitions across all
workloads:
- TCP 1-stream:  54,859 -> 13 (-99.98%)
- TCP 16-stream: 9,623,851 -> 6,324,299 (-34.3%, -3.30M spurious stops)

    [9 lines not shown]
DeltaFile
+1-1sys/dev/gve/gve_tx_dqo.c
+1-11 files

FreeBSD/src 62866fc — sys/dev/gve gve_tx_dqo.c

gve: Fix DQO TX free-list memory ordering and pending_pkt state

The DQO TX path uses lockless producer/consumer free lists
(free_pending_pkts_prd/csm and free_qpl_bufs_prd/csm) shared between
the completion and transmit taskqueues. On weakly ordered architectures
such as arm64, the current synchronization has three issues:

1. gve_free_pending_packet() updates pending_pkt state and links
   pending_pkt->next before pushing the entry onto
   free_pending_pkts_prd using a relaxed atomic_cmpset_32(), while
   gve_alloc_pending_packet() steals free_pending_pkts_prd using a
   relaxed atomic_swap_32(). Without release/acquire ordering, the
   transmit thread can observe a stale pending_pkt->next pointer after
   stealing the producer list (either orphaning freed entries or
   re-allocating entries whose completion tags are still in flight), or
   prior completion stores (such as setting state to FREE or clearing
   mbuf) can become visible after the slot is re-allocated.
2. Similarly, in QPL mode, gve_tx_alloc_qpl_buf() steals
   free_qpl_bufs_prd with a relaxed atomic_swap_32() without an acquire

    [53 lines not shown]
DeltaFile
+32-9sys/dev/gve/gve_tx_dqo.c
+32-91 files

FreeBSD/src c15a606 — sys/net/route fib_algo.c

route/fib_algo: Fix nexthop reference leak on FLM_BATCH

handle_rtable_change_cb() references the new nexthop before calling
the algorithm.  If the algorithm asks to batch the change by
returning FLM_BATCH, queue_rtable_change() references the same
nexthop again for the queued entry, while apply_rtable_changes()
only unreferences the old nexthop of each entry.

Reference new nhop once in handle_rtable_change_cb(), before
deciding whether the change is queued or passed to the algorithm,
and do not reference it again in fill_change_entry().  This also
leaves the queue reallocation as the only way for
queue_rtable_change() to fail.

Currently, dxr is the only algorithm returning FLM_BATCH.

Fixes:          6b8ef0d428c9 ("Add batched update support for the fib algo.")
MFC after:      3 days
Differential Revision:  https://reviews.freebsd.org/D61577
DeltaFile
+23-23sys/net/route/fib_algo.c
+23-231 files

FreeBSD/src 5d18a80 — sys/cam/scsi scsi_pass.c

pass(4): Don't drop the periph lock before selrecord() in passpoll()

passpoll() checked the done queue while holding the peripheral lock,
dropped the lock, and only then called selrecord().  A CCB completing
in the window between the unlock and the selrecord() call sent its
selwakeuppri() before the polling thread was on the selinfo list, so
the wakeup was lost and select(2) or poll(2) slept until another
completion arrived or the timeout expired.

Call selrecord() before dropping the lock.  This lock order is
already established: passdone() calls selwakeuppri(), which takes
the selinfo lock, while holding the peripheral lock.

kqueue is not affected, since the knlist is backed by the peripheral
mutex.

Reported by:    llm-postcr
Fixes:          a9934668aa13
MFC after:      1 week

    [4 lines not shown]
DeltaFile
+1-1sys/cam/scsi/scsi_pass.c
+1-11 files

FreeBSD/src 21b7a2f — sys/cam/scsi scsi_pass.c

pass(4): Wake select/kqueue waiters when an immediate CCB completes

In the CAMIOQUEUE ioctl, a queued CCB completes through passdone(),
which moves it to the done queue and calls selwakeuppri() and
KNOTE_LOCKED() so that a consumer blocked in select(2), poll(2) or
kevent(2) wakes up and collects the CCB with CAMIOGET.  An immediate
CCB (e.g. XPT_DEV_ADVINFO or XPT_DEV_MATCH) is instead executed
synchronously in the ioctl and moved to the done queue directly,
with no notification, so a consumer sleeping while waiting for its
completion never wakes up until some other queued I/O completes.

Send the same notification that passdone() sends.  The peripheral
lock is held at this point and backs the knlist, so KNOTE_LOCKED()
is the correct variant.

A version of this fix has been in production use at Spectra Logic
since 2024.

Co-authored-by: Dave Baukus <daveb at spectralogic.com>

    [7 lines not shown]
DeltaFile
+4-1sys/cam/scsi/scsi_pass.c
+4-11 files

FreeBSD/src 89e585b — sys/cam/scsi scsi_pass.c

pass(4): Don't drop the periph lock before selrecord() in passpoll()

passpoll() checked the done queue while holding the peripheral lock,
dropped the lock, and only then called selrecord().  A CCB completing
in the window between the unlock and the selrecord() call sent its
selwakeuppri() before the polling thread was on the selinfo list, so
the wakeup was lost and select(2) or poll(2) slept until another
completion arrived or the timeout expired.

Call selrecord() before dropping the lock.  This lock order is
already established: passdone() calls selwakeuppri(), which takes
the selinfo lock, while holding the peripheral lock.

kqueue is not affected, since the knlist is backed by the peripheral
mutex.

Reported by:    llm-postcr
Fixes:          a9934668aa13
MFC after:      1 week

    [4 lines not shown]
DeltaFile
+1-1sys/cam/scsi/scsi_pass.c
+1-11 files

FreeBSD/src a4abe5f — sys/cam/scsi scsi_pass.c

pass(4): Wake select/kqueue waiters when an immediate CCB completes

In the CAMIOQUEUE ioctl, a queued CCB completes through passdone(),
which moves it to the done queue and calls selwakeuppri() and
KNOTE_LOCKED() so that a consumer blocked in select(2), poll(2) or
kevent(2) wakes up and collects the CCB with CAMIOGET.  An immediate
CCB (e.g. XPT_DEV_ADVINFO or XPT_DEV_MATCH) is instead executed
synchronously in the ioctl and moved to the done queue directly,
with no notification, so a consumer sleeping while waiting for its
completion never wakes up until some other queued I/O completes.

Send the same notification that passdone() sends.  The peripheral
lock is held at this point and backs the knlist, so KNOTE_LOCKED()
is the correct variant.

A version of this fix has been in production use at Spectra Logic
since 2024.

Co-authored-by: Dave Baukus <daveb at spectralogic.com>

    [7 lines not shown]
DeltaFile
+4-1sys/cam/scsi/scsi_pass.c
+4-11 files