Bug 288345 - poudriere run, hanging umounts, system fails to reboot due to hanging processes
Summary: poudriere run, hanging umounts, system fails to reboot due to hanging processes
Status: Closed FIXED
Alias: None
Product: Base System
Classification: Unclassified
Component: kern (show other bugs)
Version: 14.3-RELEASE
Hardware: amd64 Any
: --- Affects Only Me
Assignee: Mark Johnston
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2025-07-20 08:00 UTC by Kurt Jaeger
Modified: 2026-05-06 20:14 UTC (History)
10 users (show)

See Also:


Attachments
debugging patch (337 bytes, patch)
2026-03-02 09:46 UTC, Mark Johnston
no flags Details | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Kurt Jaeger freebsd_committer freebsd_triage 2025-07-20 08:00:15 UTC
14.3p1, running poudriere, fails to umount after build, hangs hard:

umount: unmount of /pou/data/.m/143-default/21/usr/ports failed: Device busy
umount: unmount of /pou/data/.m/143-default/21/usr/local failed: Device busy
umount: unmount of /pou/data/.m/143-default/21/dev failed: Device busy
umount: unmount of /pou/data/.m/143-default/21/.p failed: Device busy

Reboot will probably hang as well (the last time I tried, it did).

What kind of diagnostic can be done ?

host: HPE DL380 Gen10
2x Intel Xeon-Platinum 8168
2.7GHz-3.7GHz/24-core/205W Processor
Comment 1 Kurt Jaeger freebsd_committer freebsd_triage 2025-07-20 10:34:07 UTC
(In reply to Kurt Jaeger from comment #0)
I created a ktrace:
   
ktrace -f /tmp/ktr3 df
kdump -f /tmp/ktr3 > df-ktrace

see:
https://people.freebsd.org/~pi/logs/hang/df-ktrace

It looks like the last sign of life are some calls to getfsstat() ?

 23969 df       RET   close 0
 23969 df       CALL  munmap(0x2c36300f000,0xcf44)
 23969 df       RET   munmap 0
 23969 df       CALL  ioctl(0x1,TIOCGETA,0x2c35fccf394)
 23969 df       RET   ioctl 0
 23969 df       CALL  getfsstat(0,0,MNT_NOWAIT)
 23969 df       RET   getfsstat 68/0x44
 23969 df       CALL  getfsstat(0xf7dddc4a580,0x4dd40,MNT_NOWAIT)
 23969 df       RET   getfsstat 67/0x43
 23969 df       CALL  getfsstat(0xf7dddc4a580,0x4dd40,MNT_WAIT)
Comment 2 Kurt Jaeger freebsd_committer freebsd_triage 2025-07-20 10:43:54 UTC
(In reply to Kurt Jaeger from comment #1)
  ktrace -f /tmp/ktr4 mount > mount-stdout
  kdump -f /tmp/ktr4 > mount-ktrace2

show that almost the same getfsstat() is made, but it leads to no hang:

 24159 mount    CALL  getfsstat(0,0,MNT_NOWAIT)
 24159 mount    RET   getfsstat 68/0x44
 24159 mount    CALL  getfsstat(0x3ae24724a840,0x4dd40,MNT_NOWAIT)
 24159 mount    RET   getfsstat 67/0x43
 24159 mount    CALL  fstat(0x1,0x1337f26aa7d0)
 24159 mount    STRU  struct stat {dev=3136594270542703103, ino=24217, mode=0100664, nlink=1, uid=0, gid=0, rdev=0, atime=1753005689.619056000, mtime=1753005689.619056000, ctime=1753005689.619056000, birthtime=1753005689.619056000, size=0, blksize=131072, blocks=1, flags=0x800 }
 24159 mount    RET   fstat 0
Comment 3 Kurt Jaeger freebsd_committer freebsd_triage 2025-07-20 12:48:36 UTC
Note: this box ran many builds before without that effect.
Comment 4 Mark Johnston freebsd_committer freebsd_triage 2025-07-25 16:25:30 UTC
Can you share fstat output?  That should reveal what is holding a file open on the mountpoint.

What exactly is hanging?  The original comment just shows output from umount failing.  Does umount -f work?
Comment 5 Kurt Jaeger freebsd_committer freebsd_triage 2025-07-27 20:06:19 UTC
(In reply to Mark Johnston from comment #4)
Sorry, we had to power-cycle to be able to use the host. I'll use fstat
the next time this happens.

umount -f hang as well.
Comment 6 Mark Johnston freebsd_committer freebsd_triage 2025-07-28 13:08:22 UTC
(In reply to Kurt Jaeger from comment #5)
Also important would be output from "procstat -kka".
Comment 7 Kurt Jaeger freebsd_committer freebsd_triage 2025-07-28 13:19:46 UTC
(In reply to Mark Johnston from comment #6)
Ok, will collect both infos.
Comment 8 Kurt Jaeger freebsd_committer freebsd_triage 2025-08-18 16:19:50 UTC
(In reply to Kurt Jaeger from comment #7)
2 more hanging incidents yesterday and today.

https://people.freebsd.org/~pi/logs/20250817/
and
https://people.freebsd.org/~pi/logs/20250818/
Comment 9 Mark Johnston freebsd_committer freebsd_triage 2025-08-18 16:36:45 UTC
In both cases we are getting stuck removing a tmpfs mount:

umount              -                   mi_switch+0xbd _sleep+0x1f3 vfs_write_suspend+0xe2 vfs_write_suspend_umnt+0x1c tmpfs_unmount+0x23 dounmount+0x789 kern_unmount+0x2f5 amd64_syscall+0x117 fast_syscall_common+0xf8

and there is an ld thread blocked on a vnode lock:

ld                  -                   mi_switch+0xbd sleeplk+0x10a lockmgr_xlock_hard+0x398 _vn_lock+0x47 tmpfs_alloc_vp+0x2f3 tmpfs_alloc_file+0x20c tmpfs_create+0x2b VOP_CREATE_APV+0x25 vn_open_cred+0x3dd openatfp+0x262 sys_open+0x28 amd64_syscall+0x117 fast_syscall_common+0xf8

So we allocated a new tmpfs node and a vnode to go with it, but something else has the vnode locked.

When this deadlock arises again, it'd be good to get a kernel dump so we can see who's holding the lock.  I can't see any obvious candidates in the procstat output, e.g., the vnlru thread is idle.  If you have a dumpdev configured, it should be enough to just panic the system with `sysctl debug.kdb.panic=1` after the deadlock happens.
Comment 10 Sebastian Oswald 2025-08-25 20:18:33 UTC
I've also seen this on some occasions (~5 or 6 times) on both of my buildhosts since upgrading to 14.3-RELEASE.

I just tried to build angie-* ports for i386 to try and reproduce the recent failures for angie-module-auth-spnego and the poudriere build job went completely catatonic, so I aborted via ^C and got a bunch of umount failed/device busy errors:

[00:23:10] Cleaning up
umount: unmount of /usr/local/poudriere/data/.m/FreeBSD_14_i386-latest-servers/04/wrkdirs failed: Device busy
umount: unmount of /usr/local/poudriere/data/.m/FreeBSD_14_i386-latest-servers/05/wrkdirs failed: Device busy
umount: unmount of /usr/local/poudriere/data/.m/FreeBSD_14_i386-latest-servers/03/wrkdirs failed: Device busy
umount: unmount of /usr/local/poudriere/data/.m/FreeBSD_14_i386-latest-servers/07/wrkdirs failed: Device busy
umount: unmount of /usr/local/poudriere/data/.m/FreeBSD_14_i386-latest-servers/06/wrkdirs failed: Device busy
umount: unmount of /usr/local/poudriere/data/.m/FreeBSD_14_i386-latest-servers/01/wrkdirs failed: Device busy
umount: unmount of /usr/local/poudriere/data/.m/FreeBSD_14_i386-latest-servers/08/wrkdirs failed: Device busy
umount: unmount of /usr/local/poudriere/data/.m/FreeBSD_14_i386-latest-servers/12/wrkdirs failed: Device busy
umount: unmount of /usr/local/poudriere/data/.m/FreeBSD_14_i386-latest-servers/08/root/.ccache failed: Device busy
umount: unmount of /usr/local/poudriere/data/.m/FreeBSD_14_i386-latest-servers/08/dev failed: Device busy
umount: unmount of /usr/local/poudriere/data/.m/FreeBSD_14_i386-latest-servers/08/.p failed: Device busy
umount: unmount of /usr/local/poudriere/data/.m/FreeBSD_14_i386-latest-servers/16/wrkdirs failed: Device busy
umount: unmount of /usr/local/poudriere/data/.m/FreeBSD_14_i386-latest-servers/19/wrkdirs failed: Device busy
umount: unmount of /usr/local/poudriere/data/.m/FreeBSD_14_i386-latest-servers/19/root/.ccache failed: Device busy
umount: unmount of /usr/local/poudriere/data/.m/FreeBSD_14_i386-latest-servers/19/dev failed: Device busy
umount: unmount of /usr/local/poudriere/data/.m/FreeBSD_14_i386-latest-servers/19/.p failed: Device busy
umount: unmount of /usr/local/poudriere/data/.m/FreeBSD_14_i386-latest-servers/20/wrkdirs failed: Device busy
umount: unmount of /usr/local/poudriere/data/.m/FreeBSD_14_i386-latest-servers/21/wrkdirs failed: Device busy
umount: unmount of /usr/local/poudriere/data/.m/FreeBSD_14_i386-latest-servers/09/wrkdirs failed: Device busy
umount: unmount of /usr/local/poudriere/data/.m/FreeBSD_14_i386-latest-servers/21/root/.ccache failed: Device busy
umount: unmount of /usr/local/poudriere/data/.m/FreeBSD_14_i386-latest-servers/21/.p failed: Device busy
umount: unmount of /usr/local/poudriere/data/.m/FreeBSD_14_i386-latest-servers/18/wrkdirs failed: Device busy
umount: unmount of /usr/local/poudriere/data/.m/FreeBSD_14_i386-latest-servers/18/root/.ccache failed: Device busy
umount: unmount of /usr/local/poudriere/data/.m/FreeBSD_14_i386-latest-servers/18/dev failed: Device busy
umount: unmount of /usr/local/poudriere/data/.m/FreeBSD_14_i386-latest-servers/18/.p failed: Device busy
umount: unmount of /usr/local/poudriere/data/.m/FreeBSD_14_i386-latest-servers/17/wrkdirs failed: Device busy
umount: unmount of /usr/local/poudriere/data/.m/FreeBSD_14_i386-latest-servers/10/wrkdirs failed: Device busy
umount: unmount of /usr/local/poudriere/data/.m/FreeBSD_14_i386-latest-servers/17/root/.ccache failed: Device busy
umount: unmount of /usr/local/poudriere/data/.m/FreeBSD_14_i386-latest-servers/17/.p failed: Device busy


output of fstat | grep poudriere at termbin: https://termbin.com/u0dr

output of procstat -kka at termbin: https://termbin.com/dsmg

(this particular build host is my home server and running a bunch of other jails, so the procstat output might be rather crowded with unrelated stuff...)

Unfortunately, it seems I don't have large enough swap configured on this host to handle a full 'savecore' (256GB RAM vs 64G SWAP), at least triggering a panic didn't gave me a 'vmcore.0' dumpfile at /var/crash...


Please let me know if there is there any other information I can provide.

Thanks,
Sebastian
Comment 11 Mark Johnston freebsd_committer freebsd_triage 2025-08-25 20:24:00 UTC
(In reply to Sebastian Oswald from comment #10)
The pastes you sent seem to be truncated.  It'd be better to attach them directly here if possible.

> Unfortunately, it seems I don't have large enough swap configured on this host to handle a full 'savecore' (256GB RAM vs 64G SWAP), at least triggering a panic didn't gave me a 'vmcore.0' dumpfile at /var/crash...

You might try adding dumpon_flags=-Z to rc.conf to enable crash dump compression next time, that will reduce the space requirements for a kernel dump.
Comment 12 Craig Leres freebsd_committer freebsd_triage 2025-08-28 17:10:49 UTC
I had another one today. I got on the ipmi console and there were a bunch of messages like this:

    swap_pager: out of swap space
    swp_pager_getswapspace(2): failed

I tried to create a crash dump but my "partition is tool small". (I now have dumpon_flags=-Z).

I do have a LOT of swap:

    zinc 3 # swapinfo
    Device          1K-blocks     Used    Avail Capacity
    /dev/mirror/gm0p2  33554428        0 33554428     0%

And a decent amount of cores and ram:

    zinc 7 # sysctl hw.ncpu
    hw.ncpu: 48
    zinc 9 # egrep ^real /var/run/dmesg.boot 
    real memory  = 206158430208 (196608 MB)

This machine was spec'ed to be a build server.

What can I capture next time this happens?
Comment 13 Craig Leres freebsd_committer freebsd_triage 2025-09-04 19:52:25 UTC
I had another hang today. I tried to force a panic; the system was unreachable for ~10 minutes and booted without a crash dump... I was able to get the list of D processes:

64116  1  S+        0:00.00 fgrep D
49043  2  IJ        0:00.04 /usr/bin/make -C /usr/ports/devel/qt6-base -k -DNOC
49064  2  DJ        0:00.01 /bin/rm -f -r /wrkdirs/usr/ports/devel/qt6-base/wor
70858  2  DJ        0:00.28 /usr/bin/tar -xf /portdistfiles/KDE/Qt/6.9.2/qtbase
Comment 14 Craig Leres freebsd_committer freebsd_triage 2025-10-10 17:57:42 UTC
I'm still seeing about one hang a week (5 of them since Sept 4th). This morning's poudriere finished building but three jails were stuck in "clean_pool". I tried debug.kdb.panic and watched it dump "3002 out of 195197 MB" but when the system booted it said "No core dumps found." I guess next time I should try running savecore on the running system?

I never saw this behavior with 14.2
Comment 15 Craig Leres freebsd_committer freebsd_triage 2025-10-24 16:33:34 UTC
I had another hang overnight. I tried "savecore -L" in a window I had open but it just hung.

Next time I'll try a hardware reset -> single user -> "savecore -vLZ"
Comment 16 Craig Leres freebsd_committer freebsd_triage 2025-10-25 17:53:08 UTC
Wow, two hangs two days. I see now "savecore -vLZ" is wrong, what I need to do is (if possible) "sysctl debug.kdb.panic=1", THEN -> single user -> "mount -u /" -> "savecore -vZ"
Comment 17 Sebastian Oswald 2025-11-13 10:59:55 UTC
This week I had another 4 (!) poudriere bulk jobs hanging indefinitiely and was unable to terminate them and couldn't reboot without a power cycle via ipmi...

For the last occurence, I could determine the approximate moment when all builds went catatonic and that time pretty much lined up with these cronjobs:

0   22  *   *   *   /usr/local/sbin/zfsnap snapshot -a 3w -r nvme_pool/poudriere/data
0   22  *   *   *   /usr/local/sbin/zfsnap snapshot -a 4w -r nvme_pool/poudriere/jails
0   22  *   *   *   /usr/local/sbin/zfsnap snapshot -a 4w -r nvme_pool/poudriere/ports
0   22  *   *   *   /usr/local/sbin/zfsnap snapshot -a 3m -r nvme_pool/poudriere/poudriere.d

These were present as long as this system existed and always worked. I suspect it's the first one causing issues, as it's always the data/.m mounts that go titsup.
The fact that the snapshot itself seems to trigger all builds to go catatonic and make the data/.m mounts defunct definitely reeks of some regression with one of the latest zfs updates (of which there are way too many nowadays IMHO...), so poudriere most likely isn't at fault here.
Comment 18 Craig Leres freebsd_committer freebsd_triage 2025-12-10 18:24:06 UTC
I've had many more hangs but today was the first time I was able to get on the (ipmi) console and try to get a crash dump. So far I'm still unsuccessful.

I was getting usage messages if I added -Z to savecore so I left it out. I tried this:

    # savecore -kv
    unable to open bounds file, using 0
    checking for kernel dump on device /dev/mirror/gm0p2
    mediasize = 34359737856 bytes
    sectorsize = 512 bytes
    magic mismatch on last dump header on /dev/mirror/gm0p2
    savecore 43 - - no dumps found

"dumpon -l" showed /dev/null but savecore was still able to locate mirror/gm0p2 as the dump device (which is what I see when the system is booted multiuser).

I also see that when the system is running, I've configured /var/crash as a zfs partition but it's not mounted when /etc/rc.d/savecore runs. I guess having dedicated zfs crash partition isn't really possible.

Is something initializing swap when I boot into single user after "sysctl debug.kdb.panic=1"?

This is a pretty annoying bug that I only see on this one system and I'm not sure what to try next time it occurs.
Comment 19 Craig Leres freebsd_committer freebsd_triage 2025-12-11 18:17:03 UTC
Today was my third hang in a week, second day in a row. I had several windows on the box and tried to do a live savecore; that got into D-wait pretty quickly. Soon almost anything I did would hang (including the sysctl panic).

Is there a problem with the way I have swap configured on this box that is preventing savecore from working? This server runs zfs on six nvme drives.

zinc 7 % dumpon -l
mirror/gm0p2
zinc 8 % gpart show
=>       40  937703008  nda0  GPT  (447G)
         40       1024     1  freebsd-boot  (512K)
       1064        984        - free -  (492K)
       2048   67108864     2  freebsd-swap  (32G)
   67110912  870590464     3  freebsd-zfs  (415G)
  937701376       1672        - free -  (836K)

=>       40  937703008  nda1  GPT  (447G)
         40       1024     1  freebsd-boot  (512K)
       1064        984        - free -  (492K)
       2048   67108864     2  freebsd-swap  (32G)
   67110912  870590464     3  freebsd-zfs  (415G)
  937701376       1672        - free -  (836K)

=>       40  937703008  nda2  GPT  (447G)
         40       1024     1  freebsd-boot  (512K)
       1064        984        - free -  (492K)
       2048   67108864     2  freebsd-swap  (32G)
   67110912  870590464     3  freebsd-zfs  (415G)
  937701376       1672        - free -  (836K)

=>       40  937703008  nda3  GPT  (447G)
         40       1024     1  freebsd-boot  (512K)
       1064        984        - free -  (492K)
       2048   67108864     2  freebsd-swap  (32G)
   67110912  870590464     3  freebsd-zfs  (415G)
  937701376       1672        - free -  (836K)

=>       40  937703008  nda4  GPT  (447G)
         40       1024     1  freebsd-boot  (512K)
       1064        984        - free -  (492K)
       2048   67108864     2  freebsd-swap  (32G)
   67110912  870590464     3  freebsd-zfs  (415G)
  937701376       1672        - free -  (836K)

=>       40  937703008  nda5  GPT  (447G)
         40       1024     1  freebsd-boot  (512K)
       1064        984        - free -  (492K)
       2048   67108864     2  freebsd-swap  (32G)
   67110912  870590464     3  freebsd-zfs  (415G)
  937701376       1672        - free -  (836K)

zinc 9 % gmirror list
Geom name: gm0p2
State: COMPLETE
Components: 6
Balance: load
Slice: 4096
Flags: NONE
GenID: 0
SyncID: 2
ID: 859694810
Type: AUTOMATIC
Providers:
1. Name: mirror/gm0p2
   Mediasize: 34359737856 (32G)
   Sectorsize: 512
   Mode: r1w1e0
Consumers:
1. Name: nda0p2
   Mediasize: 34359738368 (32G)
   Sectorsize: 512
   Stripesize: 0
   Stripeoffset: 1048576
   Mode: r1w1e1
   State: ACTIVE
   Priority: 0
   Flags: (null)
   GenID: 0
   SyncID: 2
   ID: 2317411985
2. Name: nda1p2
   Mediasize: 34359738368 (32G)
   Sectorsize: 512
   Stripesize: 0
   Stripeoffset: 1048576
   Mode: r1w1e1
   State: ACTIVE
   Priority: 1
   Flags: (null)
   GenID: 0
   SyncID: 2
   ID: 1611450630
3. Name: nda2p2
   Mediasize: 34359738368 (32G)
   Sectorsize: 512
   Stripesize: 0
   Stripeoffset: 1048576
   Mode: r1w1e1
   State: ACTIVE
   Priority: 2
   Flags: (null)
   GenID: 0
   SyncID: 2
   ID: 2208673777
4. Name: nda3p2
   Mediasize: 34359738368 (32G)
   Sectorsize: 512
   Stripesize: 0
   Stripeoffset: 1048576
   Mode: r1w1e1
   State: ACTIVE
   Priority: 3
   Flags: (null)
   GenID: 0
   SyncID: 2
   ID: 807113585
5. Name: nda4p2
   Mediasize: 34359738368 (32G)
   Sectorsize: 512
   Stripesize: 0
   Stripeoffset: 1048576
   Mode: r1w1e1
   State: ACTIVE
   Priority: 4
   Flags: (null)
   GenID: 0
   SyncID: 2
   ID: 3628942691
6. Name: nda5p2
   Mediasize: 34359738368 (32G)
   Sectorsize: 512
   Stripesize: 0
   Stripeoffset: 1048576
   Mode: r1w1e1
   State: ACTIVE
   Priority: 5
   Flags: (null)
   GenID: 0
   SyncID: 2
   ID: 4233446169

zinc 13 % zpool status
  pool: tank
 state: ONLINE
  scan: scrub repaired 0B in 00:04:54 with 0 errors on Wed Dec 10 20:04:54 2025
config:

        NAME        STATE     READ WRITE CKSUM
        tank        ONLINE       0     0     0
          mirror-0  ONLINE       0     0     0
            nda0p3  ONLINE       0     0     0
            nda1p3  ONLINE       0     0     0
          mirror-1  ONLINE       0     0     0
            nda2p3  ONLINE       0     0     0
            nda3p3  ONLINE       0     0     0
          mirror-2  ONLINE       0     0     0
            nda4p3  ONLINE       0     0     0
            nda5p3  ONLINE       0     0     0

errors: No known data errors
zinc 14 % zpool list
NAME   SIZE  ALLOC   FREE  CKPOINT  EXPANDSZ   FRAG    CAP  DEDUP    HEALTH  ALTROOT
tank  1.21T  1000G   236G        -         -    64%    80%  1.00x    ONLINE  -
Comment 20 Craig Leres freebsd_committer freebsd_triage 2025-12-13 18:14:39 UTC
Third hang in three days. Today any commands in the windows I had open immediately hung.

Has this regression been seen in 15 or 16?
Comment 21 Kurt Jaeger freebsd_committer freebsd_triage 2025-12-13 18:59:53 UTC
(In reply to Craig Leres from comment #20)
I'm now running my builds on a recent CURRENT (16-something) and on a 15.0 box, and I did no longer observe hanging builds.
Comment 22 Craig Leres freebsd_committer freebsd_triage 2025-12-23 18:53:19 UTC
(In reply to Craig Leres from comment #19)
> Is there a problem with the way I have swap configured on this 
> box that is preventing savecore from working? This server runs
> zfs on six nvme drives.

Survey says YES!

    https://forums.freebsd.org/threads/cant-get-crash-dump.72304/

(As pointed out in this thread, the gmirror man page says dump to a gmirror is tricky!)

So I think what I need to do is break up the mirror change swap/dump to use just one of the six drives until I can get a crash dump, then recreate the mirror.
Comment 23 Craig Leres freebsd_committer freebsd_triage 2025-12-23 21:49:31 UTC
(In reply to Craig Leres from comment #22)
gmirror(8) talks about creating a rc.d script that runs before "savecore" but in fact all you have to do is change the balance to prefer:

    gmirror configure -b prefer swap

or just create the mirror with that balance to start with:

    gmirror label -b prefer -v swap \
        /dev/nda0p2 \
        /dev/nda1p2 \
        /dev/nda2p2 \
        /dev/nda3p2 \
        /dev/nda4p2 \
        /dev/nda5p2 

I predict I'll have a viable crash dump for this issue within the next four weeks.
Comment 24 Craig Leres freebsd_committer freebsd_triage 2025-12-27 18:58:48 UTC
Ok, here's a (compressed) crash dump:

     https://ee.lbl.gov/.bsd-dec25/

I'll try to keep it around at least the end of January, 2026.

Let me know if anything important is missing. I've included a copy of the custom kernel/modules (/usr/lib/debug/boot/kernel.LBL).
Comment 25 Craig Leres freebsd_committer freebsd_triage 2025-12-29 21:45:44 UTC
(In reply to Craig Leres from comment #24)
I had an unusual hang today; a non-jail zombie!

[...]
53784  -  S         0:00.09 /usr/local/sbin/httpd -DNOHTTPACCEPT
66251  -  IW        0:00.00 sh: poudriere[14release-current-patched][47]: build
70941  -  Z         0:00.09 <defunct>
73241  -  I         0:05.55 sh: poudriere[14release-current-patched]: pkg_cache
 3851 u0  Is+       0:00.00 /usr/libexec/getty 3wire ttyu0
[...]

I put a copy here:

    https://ee.lbl.gov/.bsd-dec29/

I'll try to keep it around at least the end of January, 2026.
Comment 26 Craig Leres freebsd_committer freebsd_triage 2025-12-31 18:38:49 UTC
(In reply to Craig Leres from comment #25)
vmcore.4.zst is a new D wait crash dump, the 2nd D wait hang in four days.

I consolidated the previous urls and all the dumps (and kernel files) are now here:

    https://ee.lbl.gov/.bsd-AzEfh3/

(The old urls still work.)

My current plan is to remove these on Feb 1.

60757  -  DJ       0:00.00 /bin/rm -f -r /wrkdirs/usr/ports/devel/binutils/work
75275  -  DJ       0:03.84 /usr/bin/tar -xf /portdistfiles/binutils-with-gold-2
Comment 27 Craig Leres freebsd_committer freebsd_triage 2026-01-23 18:10:45 UTC
A fresh crash dump (vmcore.5.zst) now available:

    https://ee.lbl.gov/.bsd-AzEfh3/

My current plan is to keep these around until 14.4 is released.
Comment 28 Mark Johnston freebsd_committer freebsd_triage 2026-01-24 14:09:58 UTC
(In reply to Craig Leres from comment #27)
Could you please also provide the kernel and modules themselves?  i.e., /boot/kernel/* in addition to the /usr/lib/debug/boot/kernel/* that's already there.
Comment 29 Craig Leres freebsd_committer freebsd_triage 2026-01-24 18:03:29 UTC
(In reply to Mark Johnston from comment #28)
I put that in kernel.LBL0 (I didn't want to confuse things by renaming kernel.LBL to kernel-debug or whatnot).
Comment 30 Mark Johnston freebsd_committer freebsd_triage 2026-01-25 22:56:23 UTC
I can see that the syncer thread is holding a vnode lock, but it's currently idle.  So there's some lock leak related to VFS_SYNC, but after staring at the 14.3 sources for quite a while I can't see what might be going wrong.

(In reply to Craig Leres from comment #27)
Is it at all possible to test and reproduce the hang with a GENERIC-DEBUG kernel?
Comment 31 Craig Leres freebsd_committer freebsd_triage 2026-01-25 23:15:35 UTC
(In reply to Mark Johnston from comment #30)
I built/installed a GENERIC-DEBUG on my build server. I created a new place to keep the kernel and crash dumps:

      https://ee.lbl.gov/.bsd-C6sfr/

I'll update this PR when I get a new crash dump which should take less than four weeks (if it's gonna crash).
Comment 32 Craig Leres freebsd_committer freebsd_triage 2026-01-28 18:12:56 UTC
Yesterday I upgraded to 14.3-RELEASE-p8 and rebuilt and rebooted the GENERIC-DEBUG kernel I had been running on my build server for the last few days.

My build server has a cron job to poudriere build ~1400 package starting at midnight. I've been using a nagios plugin that runs via nrpe to detect persistent processes with DJ flags shown by ps. At 00:49 today the test flagged a problem. Somehow it resolved six minutes later. Another problem was reported at 1:22am, it cleared up eight minutes later. I checked syslog and the only thing I see see is:

    Jan 28 00:04:34 zinc.ee.lbl.gov kernel: : witness_lock_list_get: witness exhausted

which doesn't really match the first window. Is this at all interesting?

I think these are the things missing from GENERIC-DEBUG that were in my standard custom kernel config:

    device        pps
    options       PPS_SYNC
    options       P1003_1B_MQUEUE
    device        disc
    device        pf
    device        pflog
    options       KDB_UNATTENDED
    options       DEVICE_POLLING
    options       DCONS_POLL_HZ=1000

Is it worth adding these to kernel I'm running here? I doubt making disc and pf part of the kernel instead of using loadable drivers is a problem. And I don't think the pps options are problematic, this isn't one of my systems running ntp with a gps. Is it possible the deadlock is due to device polling? 

(Or were the DJ state processes just transients and I'm reading too much into seeing them briefly exist?)
Comment 33 Mark Johnston freebsd_committer freebsd_triage 2026-01-29 16:06:35 UTC
(In reply to Craig Leres from comment #32)
> Is this at all interesting?

Not really, it just means that the subsystem which detects lock order violations ran out of preallocated space.

> Is it possible the deadlock is due to device polling? 

I don't think so.  The vmcore I looked at from you pretty clearly showed that the idle syncer thread owned a vnode lock, which shouldn't happen.
Comment 34 Craig Leres freebsd_committer freebsd_triage 2026-01-30 19:02:38 UTC
(In reply to Craig Leres from comment #32)
I saw another case of D wait processes for ~10 minutes, twice today. The timing was similar to last time: the build started at midnight, the first D wait happened 48 minutes in, resolved after 10 minutes. The second D wait was at 1:15 and lasted for 9 minutes. I don't see anything interesting in the logs.

I strongly suspect if I had been running the non DEBUG kernel these would have been system hangs. Looking at DEADLKRES I don't see any printf's that would indicate that a deadlock was resolved (only panics). Is it possible DEADLKRES is silently preventing the problematic D wait from happening?
Comment 35 Craig Leres freebsd_committer freebsd_triage 2026-02-01 00:35:03 UTC
(In reply to Craig Leres from comment #34)
Another pair of short duration D wait processes today.
Comment 36 Mark Johnston freebsd_committer freebsd_triage 2026-02-02 14:10:56 UTC
Is there any way to grab the output of "procstat -kka" while these temporary hangs are occurring?
Comment 37 Craig Leres freebsd_committer freebsd_triage 2026-02-02 17:59:53 UTC
Yes. I wrote a cron job yesterday that tries to capture a live dump during the window, I just modified it to capture procstat output every minute that dwait processes are detected.
Comment 38 Ed Maste freebsd_committer freebsd_triage 2026-02-12 21:51:15 UTC
(In reply to Craig Leres from comment #34)

DEADLKRES is a bit of a misnomer, it doesn't really "resolve" deadlocks. It detects (potential) deadlocks, and reports them by panicking. The goal is that (a) the system restarts and returns to being usabe, and (b) a core file is available to facilitate debugging.
Comment 39 Craig Leres freebsd_committer freebsd_triage 2026-02-12 22:27:48 UTC
(In reply to Ed Maste from comment #38)
I'd be completely happen with a panic because it would most likely lead to a fix. But given no failures in two weeks I'm not optimistic about getting a crash dump with the GENERIC-DEBUG kernel.

When 14.4 is released I'm inclined to run my normal custom kernel config on the build server and see if I the issue manifests without the DEBUG checks.
Comment 40 Craig Leres freebsd_committer freebsd_triage 2026-02-17 19:47:03 UTC
(In reply to Craig Leres from comment #37)
Overnight I captured a handful of "procstat -kka" (stored in date+time .txt files) and a livedump:

    https://ee.lbl.gov/.bsd-C6sfr/

(The cron job should have fired yesterday but there was a bug in the first version of my script...)
Comment 41 Craig Leres freebsd_committer freebsd_triage 2026-02-18 19:32:10 UTC
(In reply to Craig Leres from comment #40)
The GENERIC-DEBUG finally produced a panic/crashdump. About 15 minutes into the scheduled poudriere bulk build this morning it panic'ed. The ipmi console showed:

    panic: not reclaimed nullfs vnode

and a kgdb prompt. It clearly had saved the crash dump. Naively I entered "continue" and was relegated to waiting for it to save the crash dump again... Then I entered "reset" and the system rebooted, and saved the crash dump which is now here:

    https://ee.lbl.gov/.bsd-C6sfr/

I think it's interesting that D state problems most commonly occur during the first ~30 minutes of the build. I know the package build rate is high at first as many quick-to-build ports are built. I'm guessing a test script that repeatedly creates and deletes zfs partitions in the way that poudriere does would trigger this bug.
Comment 42 Mark Johnston freebsd_committer freebsd_triage 2026-02-22 18:53:54 UTC
(In reply to Craig Leres from comment #41)
Now we're getting somewhere... we panicked in nullfs_unlink_lowervp() because a nullfs vnode with usecount == 0 is not doomed:

#4  0xffffffff80b16b23 in panic (fmt=<unavailable>) at ../../../kern/kern_shutdown.c:891
#5  0xffffffff834a00a1 in nullfs_unlink_lowervp (mp=<unavailable>, lowervp=<unavailable>) at /usr/src/sys/fs/nullfs/null_vfsops.c:464
#6  0xffffffff80c161a9 in vfs_notify_upper (vp=vp@entry=0xfffff8132cfc2540, event=event@entry=VFS_NOTIFY_UPPER_UNLINK) at ../../../kern/vfs_subr.c:4282
#7  0xffffffff80c177df in vop_remove_pre (ap=ap@entry=0xfffffe0431a83d68) at ../../../kern/vfs_subr.c:6174
#8  0xffffffff8110d643 in VOP_REMOVE_APV (vop=0xffffffff8251de50, vop@entry=<error reading variable: value is not available>, a=0xfffffe0431a83d68, a@entry=<error reading variable: value is not available>) at vnode_if.c:1528
#9  0xffffffff834a01bd in null_bypass (ap=0xfffffe0431a83d68) at /usr/src/sys/fs/nullfs/null_vnops.c:293
#10 0xffffffff834a081f in null_remove (ap=<optimized out>) at /usr/src/sys/fs/nullfs/null_vnops.c:642
#11 0xffffffff8110d65a in VOP_REMOVE_APV (vop=0xffffffff834a3528 <sysctl___debug_nullfs_bug_bypass+80>, a=a@entry=0xfffffe0431a83d68) at vnode_if.c:1534
#12 0xffffffff80c24110 in VOP_REMOVE (dvp=<unavailable>, vp=0xfffff82ab594c1c0, cnp=0xfffffe0431a83d20) at ./vnode_if.h:789
#13 kern_funlinkat (td=0xfffff804d4347000, dfd=dfd@entry=-100, path=0x2cac0741ee00 <error: Cannot access memory at address 0x2cac0741ee00>, fd=fd@entry=-200, pathseg=pathseg@entry=UIO_USERSPACE, flag=flag@entry=0, oldinum=0) at ../../../kern/vfs_syscalls.c:1999
#14 0xffffffff80c23c98 in sys_unlink (td=<unavailable>, uap=<optimized out>) at ../../../kern/vfs_syscalls.c:1880
#15 0xffffffff81046cfa in syscallenter (td=0xfffff804d4347000) at ../../../amd64/amd64/../../kern/subr_syscall.c:193
#16 amd64_syscall (td=0xfffff804d4347000, traced=0) at ../../../amd64/amd64/trap.c:1241
#17 <signal handler called>
(kgdb) frame 5
#5  0xffffffff834a00a1 in nullfs_unlink_lowervp (mp=<unavailable>, lowervp=<unavailable>) at /usr/src/sys/fs/nullfs/null_vfsops.c:464
464             if (vp->v_usecount == 0) {
(kgdb) p vp
$1 = (struct vnode *) 0xfffff81fba553540
(kgdb) p &vp->v_lock
$2 = (struct lock *) 0xfffff81fba5535b0
(kgdb) p vp->v_vnlock
$3 = (struct lock *) 0xfffff8132cfc25b0
(kgdb) p/x vp->v_irflag
$4 = 0x0

Indeed, it's not doomed and the vnode lock pointer hasn't been reset yet.

Meanwhile, another thread is trying to reclaim the vnode but is blocked on the vnode lock:

#3  <signal handler called>                                                                                                                                    
#4  lock_delay (la=la@entry=0xfffffe0685061970) at ../../../kern/subr_lock.c:124                                                                       
#5  0xffffffff80ae26fe in lockmgr_xlock_adaptive (lda=<optimized out>, lk=<optimized out>, xp=<optimized out>) at ../../../kern/kern_lock.c:761
#6  lockmgr_xlock_hard (lk=0xfffff8132cfc25b0, flags=540672, ilk=0x0, file=<optimized out>, line=778, lwa=0x0) at ../../../kern/kern_lock.c:852                                                                                                                                                                               
#7  0xffffffff834a0d38 in VOP_LOCK1 (vp=0xfffff8132cfc2540, flags=524288, line=778, file=<optimized out>) at ./vnode_if.h:1118
#8  null_lock (ap=0xfffffe0685061a78) at /usr/src/sys/fs/nullfs/null_vnops.c:778                     
#9  0xffffffff80c2c9b3 in VOP_LOCK1 (vp=0xfffff81fba553540, flags=524544, file=0xffffffff811fd760 "../../../kern/vfs_subr.c", line=3556) at ./vnode_if.h:1118  
#10 _vn_lock (vp=vp@entry=0xfffff81fba553540, flags=flags@entry=524544, file=0xffffffff834a2410 "/usr/src/sys/fs/nullfs/null_vnops.c", line=61, line@entry=3556) at ../../../kern/vfs_vnops.c:1857
#11 0xffffffff80c143b9 in vput_final (vp=0xfffff81fba553540, func=func@entry=VRELE) at ../../../kern/vfs_subr.c:3556                                                                                                                                                                                                          
#12 0xffffffff80c13b93 in vrele (vp=0xfffffe0685061970, vp@entry=0xfffff81fba553540) at ../../../kern/vfs_subr.c:3631                                          
#13 0xffffffff834a0a07 in null_rename (ap=0xfffffe0685061be0) at /usr/src/sys/fs/nullfs/null_vnops.c:711            
#14 0xffffffff8110d93a in VOP_RENAME_APV (vop=0xffffffff834a3528 <sysctl___debug_nullfs_bug_bypass+80>, a=a@entry=0xfffffe0685061be0) at vnode_if.c:1672       
#15 0xffffffff80c280ef in VOP_RENAME (fdvp=0x3d, fvp=<optimized out>, tdvp=<optimized out>, tvp=0xffffffff834a2410, fcnp=<optimized out>, tcnp=<optimized out>) at ./vnode_if.h:850
#16 kern_renameat (td=0xfffff801b2d7d740, oldfd=-100, old=0x71139f752c0 <error: Cannot access memory at address 0x71139f752c0>, newfd=-100, new=0x71139e1da00 <error: Cannot access memory at address 0x71139e1da00>, pathseg=UIO_USERSPACE) at ../../../kern/vfs_syscalls.c:3776
#17 0xffffffff81046cfa in syscallenter (td=0xfffff801b2d7d740) at ../../../amd64/amd64/../../kern/subr_syscall.c:193
#18 amd64_syscall (td=0xfffff801b2d7d740, traced=0) at ../../../amd64/amd64/trap.c:1241

That vnode in vput_final() is the very same vnode that triggered the panic.  Something is trying to rename a file via the nullfs mount, while the first thread is trying to unlink the backing file directly.

The second thread has decremented the nullfs vnode's usecount to 0 but is still blocked on the vnode lock, so hasn't reclaimed the vnode yet.  The first thread assumes that usecount == 0 implies that it has reclaimed the vnode, but this is not true.  Then, because it thinks the nullfs and lower vnode locks have been split, nullfs_unlink_lowervp() unlocks the nullfs vnode, but that's definitely wrong.
Comment 43 Mark Johnston freebsd_committer freebsd_triage 2026-02-22 19:08:05 UTC
https://reviews.freebsd.org/D55446 will fix this I think.  It should apply to 14.x as well.
Comment 44 Craig Leres freebsd_committer freebsd_triage 2026-02-22 19:30:41 UTC
(In reply to Mark Johnston from comment #43)
I applied the differential, am running the resulting GENERIC-DEBUG kernel on my build server, and started a build of ~1000 packages for local 14.4 testing.

Thanks for giving this some attention.
Comment 45 Mark Johnston freebsd_committer freebsd_triage 2026-02-24 15:34:16 UTC
(In reply to Craig Leres from comment #44)
Have you seen any further problems?  It's certainly possible that there's more than one bug here.  If not, though, I will go ahead and commit the change so that it gets a chance to end up in 14.4.
Comment 46 Craig Leres freebsd_committer freebsd_triage 2026-02-24 17:11:19 UTC
(In reply to Mark Johnston from comment #45)
I still see d-wait processes but they don't stick around long, I suspect they are to be expected when the load average is > 300. The change is certainly not causing any problems I can see.

I think it took me too long to produce a usable crash dump to be confident the patch fixes the bug. But I'll continue testing with a GENERIC-DEBUG after 14.4 is released and if nothing turns up in say two months I think we'll be good.
Comment 47 commit-hook freebsd_committer freebsd_triage 2026-02-25 17:10:31 UTC
A commit in branch main references this bug:

URL: https://cgit.FreeBSD.org/src/commit/?id=8b64d46fab87af3ae062901312187f3a04ad2d67

commit 8b64d46fab87af3ae062901312187f3a04ad2d67
Author:     Mark Johnston <markj@FreeBSD.org>
AuthorDate: 2026-02-25 15:31:30 +0000
Commit:     Mark Johnston <markj@FreeBSD.org>
CommitDate: 2026-02-25 15:31:30 +0000

    nullfs: Fix handling of doomed vnodes in nullfs_unlink_lowervp()

    nullfs_unlink_lowervp() is called with the lower vnode locked, so the
    nullfs vnode is locked too.  The following can occur:
    1. the vunref() call decrements the usecount 2->1,
    2. a different thread calls vrele() on the vnode, decrements the
       usecount 0->1, then blocks on the vnode lock,
    3. the first thread tests vp->v_usecount == 0 and observes that it is
       true,
    4. the first thread incorrectly unlocks the lower vnode.

    Fix this by testing VN_IS_DOOMED directly.  Since
    nullfs_unlink_lowervp() holds the vnode lock, the value of the
    VIRF_DOOMED flag is stable.

    Thanks to leres@ for patiently helping to track this down.

    PR:             288345
    MFC after:      1 week
    Reviewed by:    kib
    Differential Revision:  https://reviews.freebsd.org/D55446

 sys/fs/nullfs/null_vfsops.c | 14 ++++----------
 1 file changed, 4 insertions(+), 10 deletions(-)
Comment 48 Mark Johnston freebsd_committer freebsd_triage 2026-02-25 17:11:51 UTC
(In reply to Craig Leres from comment #46)
Makes sense.  You might try testing a plain GENERIC kernel instead, since I believe that tends to trigger the problem more readily?
Comment 49 Craig Leres freebsd_committer freebsd_triage 2026-02-25 18:28:04 UTC
(In reply to Mark Johnston from comment #48)
Good point about trigger frequency; my custom kernel is basically GENERIC plus PPS_SYNC and DEVICE_POLLING so I'll switch back to that. And given that the fix is  74c7ff1a0e940 from current and that 15.0 and newer don't appear to suffer from it (see comment #21)in all likelihood it is fixed.

It's probably safe to close this PR (it can always be reopened). And I'll clean up the files I uploaded to ee.lbl.gov.

I appreciate the timely attention to this bug.
Comment 50 commit-hook freebsd_committer freebsd_triage 2026-02-26 02:59:18 UTC
A commit in branch stable/14 references this bug:

URL: https://cgit.FreeBSD.org/src/commit/?id=6ed373227680b016b4cfa5af1b802ef23a121513

commit 6ed373227680b016b4cfa5af1b802ef23a121513
Author:     Mark Johnston <markj@FreeBSD.org>
AuthorDate: 2026-02-25 15:31:30 +0000
Commit:     Mark Johnston <markj@FreeBSD.org>
CommitDate: 2026-02-26 02:54:34 +0000

    nullfs: Fix handling of doomed vnodes in nullfs_unlink_lowervp()

    nullfs_unlink_lowervp() is called with the lower vnode locked, so the
    nullfs vnode is locked too.  The following can occur:
    1. the vunref() call decrements the usecount 2->1,
    2. a different thread calls vrele() on the vnode, decrements the
       usecount 0->1, then blocks on the vnode lock,
    3. the first thread tests vp->v_usecount == 0 and observes that it is
       true,
    4. the first thread incorrectly unlocks the lower vnode.

    Fix this by testing VN_IS_DOOMED directly.  Since
    nullfs_unlink_lowervp() holds the vnode lock, the value of the
    VIRF_DOOMED flag is stable.

    Thanks to leres@ for patiently helping to track this down.

    PR:             288345
    MFC after:      1 week
    Reviewed by:    kib
    Differential Revision:  https://reviews.freebsd.org/D55446

    (cherry picked from commit 8b64d46fab87af3ae062901312187f3a04ad2d67)

 sys/fs/nullfs/null_vfsops.c | 14 ++++----------
 1 file changed, 4 insertions(+), 10 deletions(-)
Comment 51 commit-hook freebsd_committer freebsd_triage 2026-02-26 03:21:34 UTC
A commit in branch releng/14.4 references this bug:

URL: https://cgit.FreeBSD.org/src/commit/?id=49684d7d93d318391c4a2b33b74f5cc3fba61143

commit 49684d7d93d318391c4a2b33b74f5cc3fba61143
Author:     Mark Johnston <markj@FreeBSD.org>
AuthorDate: 2026-02-25 15:31:30 +0000
Commit:     Colin Percival <cperciva@FreeBSD.org>
CommitDate: 2026-02-26 03:12:43 +0000

    nullfs: Fix handling of doomed vnodes in nullfs_unlink_lowervp()

    nullfs_unlink_lowervp() is called with the lower vnode locked, so the
    nullfs vnode is locked too.  The following can occur:
    1. the vunref() call decrements the usecount 2->1,
    2. a different thread calls vrele() on the vnode, decrements the
       usecount 0->1, then blocks on the vnode lock,
    3. the first thread tests vp->v_usecount == 0 and observes that it is
       true,
    4. the first thread incorrectly unlocks the lower vnode.

    Fix this by testing VN_IS_DOOMED directly.  Since
    nullfs_unlink_lowervp() holds the vnode lock, the value of the
    VIRF_DOOMED flag is stable.

    Thanks to leres@ for patiently helping to track this down.

    PR:             288345
    MFC after:      1 week
    Reviewed by:    kib
    Differential Revision:  https://reviews.freebsd.org/D55446

    (cherry picked from commit 8b64d46fab87af3ae062901312187f3a04ad2d67)
    (cherry picked from commit 6ed373227680b016b4cfa5af1b802ef23a121513)

 sys/fs/nullfs/null_vfsops.c | 14 ++++----------
 1 file changed, 4 insertions(+), 10 deletions(-)
Comment 52 Craig Leres freebsd_committer freebsd_triage 2026-02-27 15:01:30 UTC
(In reply to Craig Leres from comment #49)
Grrr... It looks like there is more than one bug. A single process, created 8 minutes into the poudriere run, got stuck on dwait:

    zinc 63 # ps wwu81115
    USER   PID %CPU %MEM   VSZ RSS TT  STAT STARTED    TIME COMMAND
    root 81115  0.0  0.0 21176  72  -  DJ   00:08   0:00.01 /usr/bin/tar -xf /portdistfiles/YAML-Tiny-1.76.tar.gz --no-same-owner --no-same-permissions (bsdtar)

This hang is different than what I saw before 8b64d46fab87, only one process is stuck and poudriere has been able to build > 1000 packages since the hang -- poudriere lists the stuck build with status "extract/timeout".

I used sysctl debug.kdb.panic=1 to create a crash dump and put it and other relevant files (including procstat -kka output) here:

    https://ee.lbl.gov/.bsd-AzEfh3/
Comment 53 Mark Johnston freebsd_committer freebsd_triage 2026-03-02 09:46:24 UTC
Created attachment 268473 [details]
debugging patch

Could you please try applying the attached patch, and test again with a non-debug kernel as you did in the latest hang?  It will trigger a panic if a certain invariant fails.  It seems that enabling invariants-checking more broadly causes the race to go away, I'm hopeful that the check added in the patch is sufficient.
Comment 54 Mark Johnston freebsd_committer freebsd_triage 2026-03-02 09:47:53 UTC
(In reply to Craig Leres from comment #52)
This is another instance of the syncer thread mysteriously owning a free vnode lock while idle.  The patch I uploaded in the previous comment adds a panic() which will hopefully make it possible to see how this is happening.
Comment 55 Craig Leres freebsd_committer freebsd_triage 2026-03-02 17:49:00 UTC
(In reply to Mark Johnston from comment #53)
That's running now. I had to make the change by hand because the ASSERT_VOP_UNLOCKED line before the comment block was missing in my 14.3 source.
Comment 56 Craig Leres freebsd_committer freebsd_triage 2026-03-07 07:39:58 UTC
(In reply to Craig Leres from comment #55)
FYI, I updated my build server to 14.4-RELEASE this evening; it's running my custom kernel and the patch from this PR was applied.
Comment 57 commit-hook freebsd_committer freebsd_triage 2026-03-31 15:59:38 UTC
A commit in branch stable/15 references this bug:

URL: https://cgit.FreeBSD.org/src/commit/?id=d86a85e9b5ecc59754616edcd915e7d9eae9bab1

commit d86a85e9b5ecc59754616edcd915e7d9eae9bab1
Author:     Mark Johnston <markj@FreeBSD.org>
AuthorDate: 2026-02-25 15:31:30 +0000
Commit:     Mark Johnston <markj@FreeBSD.org>
CommitDate: 2026-03-31 15:57:29 +0000

    nullfs: Fix handling of doomed vnodes in nullfs_unlink_lowervp()

    nullfs_unlink_lowervp() is called with the lower vnode locked, so the
    nullfs vnode is locked too.  The following can occur:
    1. the vunref() call decrements the usecount 2->1,
    2. a different thread calls vrele() on the vnode, decrements the
       usecount 0->1, then blocks on the vnode lock,
    3. the first thread tests vp->v_usecount == 0 and observes that it is
       true,
    4. the first thread incorrectly unlocks the lower vnode.

    Fix this by testing VN_IS_DOOMED directly.  Since
    nullfs_unlink_lowervp() holds the vnode lock, the value of the
    VIRF_DOOMED flag is stable.

    Thanks to leres@ for patiently helping to track this down.

    PR:             288345
    MFC after:      1 week
    Reviewed by:    kib
    Differential Revision:  https://reviews.freebsd.org/D55446

    (cherry picked from commit 8b64d46fab87af3ae062901312187f3a04ad2d67)

 sys/fs/nullfs/null_vfsops.c | 14 ++++----------
 1 file changed, 4 insertions(+), 10 deletions(-)
Comment 58 Mark Johnston freebsd_committer freebsd_triage 2026-05-06 17:56:54 UTC
Craig, have you seen any further hangs?  IIRC you saw one even with the patch applied, but has the frequency decreased or has something else changed?
Comment 59 Craig Leres freebsd_committer freebsd_triage 2026-05-06 18:01:41 UTC
(In reply to Mark Johnston from comment #58)
I only saw that one hang.

I plan on upgrading this system from 14.4 to 15.1 once released. I'll try and keep the vfs_subr.c patch.

It's probably safe to close this PR (I can always re-open if I see another hang/crash).
Comment 60 Mark Johnston freebsd_committer freebsd_triage 2026-05-06 18:53:53 UTC
(In reply to Craig Leres from comment #59)
Hmm, ok.  Is there some chance the system was accidentally running an unpatched kernel?

I'll close this for now in any case.
Comment 61 Craig Leres freebsd_committer freebsd_triage 2026-05-06 19:39:24 UTC
(In reply to Mark Johnston from comment #60)
I see the patch in my vfs_subr.c source and also the object references lockstatus()

zinc 277 % nm -po /sys/amd64/compile/LBL/vfs_subr.o | fgrep lockstatus
/sys/amd64/compile/LBL/vfs_subr.o:                 U lockstatus
Comment 62 Mark Johnston freebsd_committer freebsd_triage 2026-05-06 19:46:44 UTC
(In reply to Craig Leres from comment #61)
Sorry, I meant the nullfs patch which purports to fix a race condition that matches the symptoms you see.
Comment 63 Craig Leres freebsd_committer freebsd_triage 2026-05-06 19:56:13 UTC
(In reply to Mark Johnston from comment #62)
It is my understanding that https://cgit.freebsd.org/src/commit/?id=6ed373227680b016b4cfa5af1b802ef23a121513 was included in 14.4. Certainly I see the changes in my src tree.
Comment 64 Mark Johnston freebsd_committer freebsd_triage 2026-05-06 19:58:49 UTC
(In reply to Craig Leres from comment #63)
Yes, but reading the comments starting from #52 suggest to me that the last hang occurred before you upgraded to 14.4.
Comment 65 Craig Leres freebsd_committer freebsd_triage 2026-05-06 20:14:13 UTC
(In reply to Mark Johnston from comment #64)
I was running 14.3 when I saw the hangs. Eventually you had me switch to the GENERIC-DEBUG config and that eventually produce a crash. In response you created D55446 which I applied locally (still with GENERIC-DEBUG). Things were quiet for awhile so I switched back to my custom kernel (basically GENERIC plus PPS_SYNC and DEVICE_POLLING).

I had one hang after that. I was able to force a crash dump and your response was 268473 which I kept when I upgraded to 14.4.

Things have been quiet since, so yes, no issues since upgrading to 14.4