NetBSD Problem Report #60621
From www@netbsd.org Thu Aug 20 03:36:01 2026
Return-Path: <www@netbsd.org>
Received: from mail.netbsd.org (mail.netbsd.org [199.233.217.200])
(using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)
key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256
client-signature RSA-PSS (2048 bits) client-digest SHA256)
(Client CN "mail.netbsd.org", Issuer "YR2" (not verified))
by mollari.NetBSD.org (Postfix) with ESMTPS id C65951A923B
for <gnats-bugs@gnats.NetBSD.org>; Thu, 20 Aug 2026 03:36:00 +0000 (UTC)
Message-Id: <20260820033559.5C8BC1A923C@mollari.NetBSD.org>
Date: Thu, 20 Aug 2026 03:35:59 +0000 (UTC)
From: campbell+netbsd@mumble.net
Reply-To: campbell+netbsd@mumble.net
To: gnats-bugs@NetBSD.org
Subject: panic: ufs_inactive: dirty filesystem?
X-Send-Pr-Version: www-1.0
X-From4GNATS: "campbell+netbsd@mumble.net via gnats" <gnats-admin@NetBSD.org>
>Number: 60621
>Category: kern
>Synopsis: panic: ufs_inactive: dirty filesystem?
>Confidential: no
>Severity: serious
>Priority: medium
>Responsible: hannken
>State: open
>Class: sw-bug
>Submitter-Id: net
>Arrival-Date: Thu Aug 20 03:40:00 +0000 2026
>Last-Modified: Fri Nov 27 10:10:01 +0000 2026
>Originator: Taylor R Campbell
>Release: 10.1
>Organization:
The NetBSD Foundation, Inc.
>Environment:
NetBSD bester.NetBSD.org 10.1 NetBSD 10.1 (WWUSERVER) #0: Wed Dec 18 12:03:42 UTC 2024 spz@franklin.NetBSD.org:/home/netbsd/10/amd64/obj/sys/arch/amd64/compile/WWUSERVER amd64
>Description:
Wed Aug 19 15:35:20 UTC 2026
Starting root file system check:
/dev/rraid0a: file system is journaled; not checking
[ 10.9232881] /: replaying log to disk
[ 22.7101747] ufs_inactive: unlinked ino 61 on "/" has non zero size 0 or blocks fffffffffffffec0 with allerror 0
[ 22.7201807] panic: ufs_inactive: dirty filesystem?
[ 22.7301867] cpu3: Begin traceback...
[ 22.7301867] vpanic() at netbsd:vpanic+0x183
[ 22.7301867] panic() at netbsd:panic+0x3c
[ 22.7401925] ufs_inactive() at netbsd:ufs_inactive+0x167
[ 22.7501979] VOP_INACTIVE() at netbsd:VOP_INACTIVE+0x3c
[ 22.7501979] vrelel() at netbsd:vrelel+0x154
[ 22.7602037] ffs_wapbl_replay_finish() at netbsd:ffs_wapbl_replay_finish+0x35
[ 22.7602037] ffs_wapbl_start() at netbsd:ffs_wapbl_start+0x4b
[ 22.7702094] ffs_mount() at netbsd:ffs_mount+0x553
[ 22.7702094] VFS_MOUNT() at netbsd:VFS_MOUNT+0x5a
[ 22.7802154] do_sys_mount() at netbsd:do_sys_mount+0x3ac
[ 22.7902217] sys___mount50() at netbsd:sys___mount50+0x33
[ 22.7902217] syscall() at netbsd:syscall+0x1fc
[ 22.8002275] --- syscall (number 410) ---
[ 22.8002275] netbsd:syscall+0x1fc:
[ 22.8002275] cpu3: End traceback...
>How-To-Repeat:
1. take and unlink an fss ffs fs-internal snapshot
(say that five times fast!)
2. create a couple very large files (~70GB), not sparse
3. rm the very large files
4. trip over wapbl_flush: current transaction too big to flush
(PR kern/54504: -9/-current WAPBL panic: current transaction
too big to flush, https://gnats.NetBSD.org/54504)
5. reboot
Not 100% sure the snapshot part is necessary -- perhaps keeping
any unlinked file open during sudden interruption (panic, power
loss, &c.) is enough.
The ffs wapbl replay logic seems to be unable to cope with the
resulting non-truncated unlinked file.
>Fix:
Yes, please! And a test case too.
I'm not clear on why the inode in question is being processed
by ffs_wapbl_replay_finish.
That means it is listed in a WAPBL_WC_INODES record, i.e., it
has been registered with wapbl_register_inode as a partially
allocated inode, which shouldn't be in use by anything else
yet; surely, if the inode allocation had completed, as I
suspect it had (since fssconfig(8) completed and I think --
though I'm not sure -- that the snapshot was even mounted),
then we should have passed through wapbl_unregister_inode.
But maybe there's some path that bypasses
wapbl_unregister_inode incorrectly under certain circumstances,
or somehow the complete inode allocation got committed in a
separate transaction from wapbl_unregister_inode.
>Release-Note:
>Audit-Trail:
Responsible-Changed-From-To: kern-bug-people->hannken
Responsible-Changed-By: riastradh@NetBSD.org
Responsible-Changed-When: Thu, 05 Nov 2026 08:55:29 +0000
Responsible-Changed-Why:
Can I interest you in taking a look at this? It's holding up TNF
infrastructure (particularly the src/xsrc cvs->hg->git conversion).
From: "J. Hannken-Illjes" <hannken@netbsd.org>
To: gnats-bugs@netbsd.org
Cc:
Subject: Re: kern/60621 (panic: ufs_inactive: dirty filesystem?)
Date: Sun, 15 Nov 2026 14:32:10 +0000
With this simple recipe I always get the panic "transaction too big...":
dd if=/dev/zero of=file0 bs=1m count=45k
/usr/sbin/fssconfig -c -v fss0 / /
rm file0
Using a persistent snapshot or no snapshot the "rm" succeeds.
Unfortunately on next reboot "wapbl_replay" always succeeds and the
"ufs_inactive" panic doesn't happen. I remember seeing this panic
some times with crashes while an unlinked snapshot was open.
I'm quite sure this inode 61 is such an unlinked snapshot. It was
registered with "wapbl_register_inode" when its link count became zero
while it was still open. On reboot "wapbl_replay" finds it, truncates
it to size zero and "ufs_inactive" panics. As this inode now has
size zero and block count 0xfffffffffffffec0 == -320 it looks like the
the field i_blocks was too low, missing 320 disk blocks.
Have to look deeper into wapbl if there should be a guarantee the number
of allocated blocks and the inode field i_blocks are in sync when a
transaction gets flushed.
--
J. Hannken-Illjes - hannken@netbsd.org
From: Taylor R Campbell <riastradh@NetBSD.org>
To: "J. Hannken-Illjes" <hannken@NetBSD.org>
Cc: gnats-bugs@NetBSD.org, netbsd-bugs@NetBSD.org
Subject: Re: kern/60621 (panic: ufs_inactive: dirty filesystem?)
Date: Tue, 17 Nov 2026 18:11:53 +0000
> Date: Sun, 15 Nov 2026 14:32:10 +0000
> From: "J. Hannken-Illjes" <hannken@netbsd.org>
>=20
> With this simple recipe I always get the panic "transaction too big...":
>=20
> dd if=3D/dev/zero of=3Dfile0 bs=3D1m count=3D45k
> /usr/sbin/fssconfig -c -v fss0 / /
> rm file0
Thanks! Tried simulating this with /usr/tests/fs/ffs/t_snapshot_log
by cranking down the log size after newfs with tunefs so that we can
reproduce it by rm'ing a smaller file (say 1 MiB instead of 45 GiB).
But it didn't go so well. With `tunefs -l 69632' (68*1024), the test
still passes, but with `tunefs -l 69631' (67*1024 + 1023), it crashes
with:
panic: kernel diagnostic assertion "delta !=3D size || newoff =3D=3D oldoff=
" failed: file "/home/riastradh/netbsd/current/src/sys/rump/librump/rumpvfs=
/../../../kern/vfs_wapbl.c", line 1460 size=3D64512, delta=3D64512 off=3D10=
24 newoff=3D65536 oldoff=3D0
Which is this assertion (converted locally into KASSERTMSG):
KASSERTMSG(delta !=3D size || newoff =3D=3D oldoff,
"size=3D%zu, delta=3D%zu off=3D%zu newoff=3D%zu oldoff=3D%lld",
size, delta, off, newoff, (long long)oldoff);
https://nxr.netbsd.org/xref/src/sys/kern/vfs_wapbl.c?r=3D1.117#1450
> Using a persistent snapshot or no snapshot the "rm" succeeds.
I assume you mean `Using a *non*-persistent snapshot or no snapshot'?
> Unfortunately on next reboot "wapbl_replay" always succeeds and the
> "ufs_inactive" panic doesn't happen. I remember seeing this panic
> some times with crashes while an unlinked snapshot was open.
Well, a reproducer for the `transaction too big' panic is still worth
having!
Does it help to use dump instead of fssconfig, and rm the file while
the dump is still running?
> I'm quite sure this inode 61 is such an unlinked snapshot. It was
> registered with "wapbl_register_inode" when its link count became zero
> while it was still open. On reboot "wapbl_replay" finds it, truncates
> it to size zero and "ufs_inactive" panics. As this inode now has
> size zero and block count 0xfffffffffffffec0 =3D=3D -320 it looks like the
> the field i_blocks was too low, missing 320 disk blocks.
>=20
> Have to look deeper into wapbl if there should be a guarantee the number
> of allocated blocks and the inode field i_blocks are in sync when a
> transaction gets flushed.
Presumably any
(a) changes to i_blocks, and
(b) block allocations
happen together in a single wapbl transaction delimited by
UFS_WAPBL_BEGIN/END, no? Perhaps we need to sprinkle some more
UFS_WAPBL_JLOCK_ASSERT around access to these?
I continue to think that we should invent a new type of logical log
entry for deallocating blocks and truncating an inode (or two types)
so that truncate operations require only bounded size at any given
time in the log -- and we can roll back an incomplete write on crash
if the written data haven't hit the disk (PR kern/58553: ffs: garbage
data appended after crash).
From: "J. Hannken-Illjes" <hannken@netbsd.org>
To: Taylor R Campbell <riastradh@NetBSD.org>
Cc: gnats-bugs@NetBSD.org, netbsd-bugs@NetBSD.org
Subject: Re: kern/60621 (panic: ufs_inactive: dirty filesystem?)
Date: Tue, 17 Nov 2026 18:37:54 +0000
On Tue, Nov 17, 2026 at 06:11:53PM +0000, Taylor R Campbell wrote:
> > Date: Sun, 15 Nov 2026 14:32:10 +0000
> > From: "J. Hannken-Illjes" <hannken@netbsd.org>
[snip]
> > Using a persistent snapshot or no snapshot the "rm" succeeds.
>
> I assume you mean `Using a *non*-persistent snapshot or no snapshot'?
I meant what I wrote: a persistent snapshot. As long as the snapshot
is not unlinked it will sync its data bypassing wapbl as the snapshot
activates BEFORE wapbl on mount.
--
J. Hannken-Illjes - hannken@netbsd.org
From: Taylor R Campbell <riastradh@NetBSD.org>
To: "J. Hannken-Illjes" <hannken@NetBSD.org>
Cc: gnats-bugs@NetBSD.org, netbsd-bugs@NetBSD.org
Subject: Re: kern/60621 (panic: ufs_inactive: dirty filesystem?)
Date: Tue, 17 Nov 2026 19:13:19 +0000
> Date: Tue, 17 Nov 2026 18:37:54 +0000
> From: "J. Hannken-Illjes" <hannken@netbsd.org>
>=20
> On Tue, Nov 17, 2026 at 06:11:53PM +0000, Taylor R Campbell wrote:
> > > Date: Sun, 15 Nov 2026 14:32:10 +0000
> > > From: "J. Hannken-Illjes" <hannken@netbsd.org>
> [snip]
> > > Using a persistent snapshot or no snapshot the "rm" succeeds.
> >=20
> > I assume you mean `Using a *non*-persistent snapshot or no snapshot'?
>=20
> I meant what I wrote: a persistent snapshot. As long as the snapshot
> is not unlinked it will sync its data bypassing wapbl as the snapshot
> activates BEFORE wapbl on mount.
Oh, I see -- you meant a file-system-internal snapshot that has _not_
been unlinked (as in, e.g., `fssconfig fss0 / /mysnap'), as opposed to
an fs-internal snapshot that _has_ been unlinked (as in, e.g.,
`fssconfig -x fss0 / /mysnap' or simply `fssconfig fss0 / /', which
triggers the crash). Is that right?
I was confused by the term `persistent snapshot' here because the
language in the fssconfig(8) has long used the term `persistent
snapshot' to mean any fs-internal snapshots, whether or not they have
been unlinked:
If backup resides on the snapshotted file system a persistent snapshot
will be created. This snapshot is active until backup is unlinked. P=
er-
sistent snapshots save the file system as if it had been unmounted.
https://man.netbsd.org/NetBSD-10.x-BRANCH/fssconfig.8
And in rewriting the fssconfig(8) man page (and
<https://wiki.NetBSD.org/tutorials/how_to_use_snapshots>) I made sure
not to change that terminology even though it didn't make much sense
to me -- I think `external' vs `internal' is better terminology for
the mode of operation, and `persistent' is better limited to internal
snapshots that haven't been unlinked.
So if I understand correctly, the reproducer:
- crashes with internal unlinked snapshot
- works with internal still-linked (`persistent') snapshot
- works with no snapshot
- presumably works with external snapshot, whether linked or unlinked
This suggests a (purely speculative, unconfirmed) hypothesis about the
`ufs_inactive: dirty filesystem?' panic, that the fast path of writing
to unlinked internal snapshots doesn't work with wapbl because it
allocates blocks and updates i_blocks without grouping them into a
single atomic transaction.
From: "J. Hannken-Illjes" <hannken@netbsd.org>
To: Taylor R Campbell <riastradh@NetBSD.org>
Cc: gnats-bugs@NetBSD.org, netbsd-bugs@NetBSD.org
Subject: Re: kern/60621 (panic: ufs_inactive: dirty filesystem?)
Date: Tue, 17 Nov 2026 20:58:53 +0000
On Tue, Nov 17, 2026 at 07:13:19PM +0000, Taylor R Campbell wrote:
> > Date: Tue, 17 Nov 2026 18:37:54 +0000
> > From: "J. Hannken-Illjes" <hannken@netbsd.org>
> >
> > On Tue, Nov 17, 2026 at 06:11:53PM +0000, Taylor R Campbell wrote:
> > > > Date: Sun, 15 Nov 2026 14:32:10 +0000
> > > > From: "J. Hannken-Illjes" <hannken@netbsd.org>
> > [snip]
> > > > Using a persistent snapshot or no snapshot the "rm" succeeds.
> > >
> > > I assume you mean `Using a *non*-persistent snapshot or no snapshot'?
> >
> > I meant what I wrote: a persistent snapshot. As long as the snapshot
> > is not unlinked it will sync its data bypassing wapbl as the snapshot
> > activates BEFORE wapbl on mount.
>
> Oh, I see -- you meant a file-system-internal snapshot that has _not_
> been unlinked (as in, e.g., `fssconfig fss0 / /mysnap'), as opposed to
> an fs-internal snapshot that _has_ been unlinked (as in, e.g.,
> `fssconfig -x fss0 / /mysnap' or simply `fssconfig fss0 / /', which
> triggers the crash). Is that right?
Yes.
[snip]
> So if I understand correctly, the reproducer:
>
> - crashes with internal unlinked snapshot
> - works with internal still-linked (`persistent') snapshot
> - works with no snapshot
> - presumably works with external snapshot, whether linked or unlinked
Yes.
> This suggests a (purely speculative, unconfirmed) hypothesis about the
> `ufs_inactive: dirty filesystem?' panic, that the fast path of writing
> to unlinked internal snapshots doesn't work with wapbl because it
> allocates blocks and updates i_blocks without grouping them into a
> single atomic transaction.
I suppose it is ffs_snapblkfree() claiming the freed block. The
block moves to the snapshot and its i_blocks increases. Don't know
how to group the snapshot inode update into this transaction yet.
--
J. Hannken-Illjes - hannken@netbsd.org
From: Taylor R Campbell <riastradh@NetBSD.org>
To: "J. Hannken-Illjes" <hannken@NetBSD.org>
Cc: gnats-bugs@NetBSD.org, netbsd-bugs@NetBSD.org
Subject: Re: kern/60621 (panic: ufs_inactive: dirty filesystem?)
Date: Tue, 17 Nov 2026 21:18:02 +0000
> Date: Tue, 17 Nov 2026 20:58:53 +0000
> From: "J. Hannken-Illjes" <hannken@netbsd.org>
>
> On Tue, Nov 17, 2026 at 07:13:19PM +0000, Taylor R Campbell wrote:
> > This suggests a (purely speculative, unconfirmed) hypothesis about the
> > `ufs_inactive: dirty filesystem?' panic, that the fast path of writing
> > to unlinked internal snapshots doesn't work with wapbl because it
> > allocates blocks and updates i_blocks without grouping them into a
> > single atomic transaction.
>
> I suppose it is ffs_snapblkfree() claiming the freed block. The
> block moves to the snapshot and its i_blocks increases. Don't know
> how to group the snapshot inode update into this transaction yet.
Perhaps, if that's not convenient to do, a cheap alternative would be
relax the panic so it doesn't apply to snapshots?
- if (ip->i_mode == 0 && (DIP(ip, size) != 0 || DIP(ip, blocks) != 0)) {
+ if (ip->i_mode == 0 &&
+ (DIP(ip, size) != 0 ||
+ (DIP(ip, blocks) != 0 &&
+ (ip->i_flags & (SF_SNAPSHOT|SF_SNAPINVAL)) != 0))) {
This should avoid the troublesome symptom (machine crashes
persistently on reboot, requires manual intervention of running fsck
from single-user mode to repair), without losing data (snapshot is
unlinked anyway so it's garbage to be tossed).
I say `cheap' both because:
(a) this is a small change, but also
(b) this doesn't address the underlying ickiness of
- i_blocks going negative, or
- (if my hypothesis is correct) non-atomic updates of the inode,
violating ffs invariants in spite of having wapbl atomic
transactions available.
From: "J. Hannken-Illjes" <hannken@netbsd.org>
To: Taylor R Campbell <riastradh@NetBSD.org>
Cc: gnats-bugs@NetBSD.org, netbsd-bugs@NetBSD.org
Subject: Re: kern/60621 (panic: ufs_inactive: dirty filesystem?)
Date: Wed, 18 Nov 2026 08:33:30 +0000
On Tue, Nov 17, 2026 at 09:18:02PM +0000, Taylor R Campbell wrote:
> > Date: Tue, 17 Nov 2026 20:58:53 +0000
> > From: "J. Hannken-Illjes" <hannken@netbsd.org>
> >
> > On Tue, Nov 17, 2026 at 07:13:19PM +0000, Taylor R Campbell wrote:
> > > This suggests a (purely speculative, unconfirmed) hypothesis about the
> > > `ufs_inactive: dirty filesystem?' panic, that the fast path of writing
> > > to unlinked internal snapshots doesn't work with wapbl because it
> > > allocates blocks and updates i_blocks without grouping them into a
> > > single atomic transaction.
> >
> > I suppose it is ffs_snapblkfree() claiming the freed block. The
> > block moves to the snapshot and its i_blocks increases. Don't know
> > how to group the snapshot inode update into this transaction yet.
>
> Perhaps, if that's not convenient to do, a cheap alternative would be
> relax the panic so it doesn't apply to snapshots?
>
> - if (ip->i_mode == 0 && (DIP(ip, size) != 0 || DIP(ip, blocks) != 0)) {
> + if (ip->i_mode == 0 &&
> + (DIP(ip, size) != 0 ||
> + (DIP(ip, blocks) != 0 &&
> + (ip->i_flags & (SF_SNAPSHOT|SF_SNAPINVAL)) != 0))) {
Sorry, cannot work as the snapshot flags got cleared by ffs_snapremove()
before we reach ufs_inactive(). Maybe allow negative block count if
mounted with wapbl or "fix" negative block count in ffs_snapremove() --
at least until the problem gets fixed.
--
J. Hannken-Illjes - hannken@netbsd.org
From: "J. Hannken-Illjes" <hannken@netbsd.org>
To: Taylor R Campbell <riastradh@NetBSD.org>
Cc: gnats-bugs@NetBSD.org, netbsd-bugs@NetBSD.org
Subject: Re: kern/60621 (panic: ufs_inactive: dirty filesystem?)
Date: Wed, 18 Nov 2026 15:12:42 +0000
Taylor,
sleeping another night over this problem I propose two possible fixes.
What do you think?
* To prevent the "ufs_inactive: dirty filesystem?" panic the
block allocation and inode update must be grouped into the
same transaction. This diff should fix it -- untested as I'm
unable to reproduce the panic here:
--- sys/ufs/ffs/ffs_snapshot.c Wed Nov 11 15:17:24 2026 +0100
+++ sys/ufs/ffs/ffs_snapshot.c Wed Nov 18 15:39:40 2026 +0100
@@ -1653,6 +1653,7 @@ retry:
}
DIP_ADD(ip, blocks, btodb(size));
ip->i_flag |= IN_CHANGE | IN_UPDATE;
+ UFS_WAPBL_UPDATE(vp, NULL, NULL, 0);
if (ip->i_nlink > 0 && mp->mnt_wapbl)
error = syncsnap(vp);
else
* The "wapbl_flush: current transaction too big to flush" panic
goes back to PR kern/47146 at least. It was fixed with a
reorganization of ffs_truncate() and the change to
wapbl_register_deallocation() to return EAGAIN on resource shortage.
Unfortunately th evaluation of resource shortage looks incomplete as
only "wl_dealloccnt" is checked. Replacing this check with
the "doflush" check already in wapbl_begin() but replacing "/ 2"
with "* 3 / 4" I cannot reproduce this panic anymore. I use 75% instead
of 50% so after wapbl_register_deallocation() returning EAGAIN the
next wapbl_begin() will always flush. This is the diff:
--- sys/kern/vfs_wapbl.c Wed Nov 11 15:17:24 2026 +0100
+++ sys/kern/vfs_wapbl.c Wed Nov 18 15:39:40 2026 +0100
@@ -2193,7 +2193,18 @@ wapbl_register_deallocation(struct wapbl
mutex_enter(&wl->wl_mtx);
- if (__predict_false(wl->wl_dealloccnt >= wl->wl_dealloclim)) {
+ int doflush;
+ unsigned lockcount;
+
+ lockcount = wl->wl_lock_count;
+ doflush = ((wl->wl_bufbytes + (lockcount * MAXPHYS)) >
+ wl->wl_bufbytes_max * 3 / 4) ||
+ ((wl->wl_bufcount + (lockcount * 10)) >
+ wl->wl_bufcount_max * 3 / 4) ||
+ (wapbl_transaction_len(wl) > wl->wl_circ_size * 3 / 4) ||
+ (wl->wl_dealloccnt >= (wl->wl_dealloclim * 3 / 4));
+
+ if (__predict_false(doflush)) {
if (!force) {
error = SET_ERROR(EAGAIN);
goto out;
--
J. Hannken-Illjes - hannken@netbsd.org
From: Taylor R Campbell <riastradh@NetBSD.org>
To: "J. Hannken-Illjes" <hannken@NetBSD.org>
Cc: gnats-bugs@NetBSD.org, netbsd-bugs@NetBSD.org
Subject: Re: kern/60621 (panic: ufs_inactive: dirty filesystem?)
Date: Thu, 19 Nov 2026 00:27:54 +0000
> Date: Wed, 18 Nov 2026 15:12:42 +0000
> From: "J. Hannken-Illjes" <hannken@netbsd.org>
>
> sleeping another night over this problem I propose two possible fixes.
> What do you think?
Thanks!
> * To prevent the "ufs_inactive: dirty filesystem?" panic the
> block allocation and inode update must be grouped into the
> same transaction. This diff should fix it -- untested as I'm
> unable to reproduce the panic here:
For a reproducer, I wonder whether heavy I/O concurrent with the short
script you used to provoke the other panic has the desired effect?
The host that hit this was probably in the middle of a large rsync
when it happened both times.
> --- sys/ufs/ffs/ffs_snapshot.c Wed Nov 11 15:17:24 2026 +0100
> +++ sys/ufs/ffs/ffs_snapshot.c Wed Nov 18 15:39:40 2026 +0100
> @@ -1653,6 +1653,7 @@ retry:
> }
> DIP_ADD(ip, blocks, btodb(size));
> ip->i_flag |= IN_CHANGE | IN_UPDATE;
> + UFS_WAPBL_UPDATE(vp, NULL, NULL, 0);
> if (ip->i_nlink > 0 && mp->mnt_wapbl)
> error = syncsnap(vp);
> else
This looks plausible and very low-risk, so I'm inclined to just apply
it.
I wonder if we should audit the tree for a pattern of struct inode
updates to check for missing UFS_WAPBL_UPDATE. But I guess this is
only about fusing inode updates with indirect block (de/re)assignment
in a single transaction, so perhaps there aren't many such paths to
worry about.
> * The "wapbl_flush: current transaction too big to flush" panic
> goes back to PR kern/47146 at least. It was fixed with a
> reorganization of ffs_truncate() and the change to
> wapbl_register_deallocation() to return EAGAIN on resource shortage.
> Unfortunately th evaluation of resource shortage looks incomplete as
> only "wl_dealloccnt" is checked. Replacing this check with
> the "doflush" check already in wapbl_begin() but replacing "/ 2"
> with "* 3 / 4" I cannot reproduce this panic anymore. I use 75% instead
> of 50% so after wapbl_register_deallocation() returning EAGAIN the
> next wapbl_begin() will always flush. This is the diff:
>
> --- sys/kern/vfs_wapbl.c Wed Nov 11 15:17:24 2026 +0100
> +++ sys/kern/vfs_wapbl.c Wed Nov 18 15:39:40 2026 +0100
> @@ -2193,7 +2193,18 @@ wapbl_register_deallocation(struct wapbl
>
> mutex_enter(&wl->wl_mtx);
>
> - if (__predict_false(wl->wl_dealloccnt >= wl->wl_dealloclim)) {
> + int doflush;
> + unsigned lockcount;
> +
> + lockcount = wl->wl_lock_count;
> + doflush = ((wl->wl_bufbytes + (lockcount * MAXPHYS)) >
> + wl->wl_bufbytes_max * 3 / 4) ||
> + ((wl->wl_bufcount + (lockcount * 10)) >
> + wl->wl_bufcount_max * 3 / 4) ||
> + (wapbl_transaction_len(wl) > wl->wl_circ_size * 3 / 4) ||
> + (wl->wl_dealloccnt >= (wl->wl_dealloclim * 3 / 4));
> +
> + if (__predict_false(doflush)) {
> if (!force) {
> error = SET_ERROR(EAGAIN);
> goto out;
I would believe this mitigates the problem, and have no objection to
committing it, but:
1. I'm not convinced it _fixes_ the problem and I would like to see
some clearer explanation of the bounds written down.
Surely the bounds depend on the maximum size of any transaction
issued by the file system, no? And that in turn depends both on
the logic in the file system and potentially on the content like
the shape of the indirect block tree when it is recursively
processed. But we have no mechanism to pass fs-specific bounds on
transaction size into wapbl_start or wapbl_begin.
The ffs_truncate workaround (by which I assume you mean
https://mail-index.netbsd.org/source-changes/2016/10/28/msg078723.html)
is also just that: a workaround, not a solution, which makes
truncate operations (including unlink) non-atomic by breaking them
into multiple transactions in a loop.
2. It would be nice if this flushing criterion were factored out
somewhere and not copied & pasted in two places that will get out
of sync.
3. Would like to make sure the multiplications don't overflow, by
asserting (and otherwise enforcing) bounds on wl_bufbytes_max,
wl_bufcount_max, wl_circ_size, and wl_dealloclim < SIZE_MAX/3.
From: Robert Elz <kre@munnari.OZ.AU>
To: Taylor R Campbell <riastradh@NetBSD.org>
Cc: "J. Hannken-Illjes" <hannken@NetBSD.org>, gnats-bugs@NetBSD.org,
netbsd-bugs@NetBSD.org
Subject: Re: kern/60621 (panic: ufs_inactive: dirty filesystem?)
Date: Thu, 19 Nov 2026 22:03:46 +0700
Date: Thu, 19 Nov 2026 00:27:54 +0000
From: Taylor R Campbell <riastradh@NetBSD.org>
Message-ID: <20261119002756.41C2F84EB1@mail.netbsd.org>
| 3. Would like to make sure the multiplications don't overflow, by
| asserting (and otherwise enforcing) bounds on wl_bufbytes_max,
| wl_bufcount_max, wl_circ_size, and wl_dealloclim < SIZE_MAX/3.
I'm not qualified to comment on the rest of this, but for this part,
since the 75% is just number plucked from the air, approximately where
it would be good to reach, and not something that needs to be precisely
computed, an easier way to deal with that problem is to just write them as:
wl->wl_bufbytes_max / 4 * 3
(etc). If there's any possibility that any of the values might
be < 4, leading to a 0 from the division, and so a 0 result, which
wouldn't happen with the multiplication first, it could be written as
(wl->wl_bufbytes_max | 4) / 4 * 3
The "|4" (not +3 to ensure no overflow results) would make sure there's
no possibility of a zero result from the division, without making any
real difference when wl_bufbytes_max is a more sensible big number.
It would be hide this expr in a macro though (or even a static inline func),
rather than writing it over and over again for all the different values.
kre
From: "J. Hannken-Illjes" <hannken@netbsd.org>
To: Taylor R Campbell <riastradh@NetBSD.org>
Cc: gnats-bugs@NetBSD.org, netbsd-bugs@NetBSD.org
Subject: Re: kern/60621 (panic: ufs_inactive: dirty filesystem?)
Date: Fri, 20 Nov 2026 17:40:14 +0000
On Thu, Nov 19, 2026 at 12:27:54AM +0000, Taylor R Campbell wrote:
<snip>
> > * The "wapbl_flush: current transaction too big to flush" panic
> > goes back to PR kern/47146 at least. It was fixed with a
> > reorganization of ffs_truncate() and the change to
> > wapbl_register_deallocation() to return EAGAIN on resource shortage.
> > Unfortunately th evaluation of resource shortage looks incomplete as
> > only "wl_dealloccnt" is checked. Replacing this check with
> > the "doflush" check already in wapbl_begin() but replacing "/ 2"
> > with "* 3 / 4" I cannot reproduce this panic anymore. I use 75% instead
> > of 50% so after wapbl_register_deallocation() returning EAGAIN the
> > next wapbl_begin() will always flush. This is the diff:
> >
> > --- sys/kern/vfs_wapbl.c Wed Nov 11 15:17:24 2026 +0100
> > +++ sys/kern/vfs_wapbl.c Wed Nov 18 15:39:40 2026 +0100
> > @@ -2193,7 +2193,18 @@ wapbl_register_deallocation(struct wapbl
> >
> > mutex_enter(&wl->wl_mtx);
> >
> > - if (__predict_false(wl->wl_dealloccnt >= wl->wl_dealloclim)) {
> > + int doflush;
> > + unsigned lockcount;
> > +
> > + lockcount = wl->wl_lock_count;
> > + doflush = ((wl->wl_bufbytes + (lockcount * MAXPHYS)) >
> > + wl->wl_bufbytes_max * 3 / 4) ||
> > + ((wl->wl_bufcount + (lockcount * 10)) >
> > + wl->wl_bufcount_max * 3 / 4) ||
> > + (wapbl_transaction_len(wl) > wl->wl_circ_size * 3 / 4) ||
> > + (wl->wl_dealloccnt >= (wl->wl_dealloclim * 3 / 4));
> > +
> > + if (__predict_false(doflush)) {
> > if (!force) {
> > error = SET_ERROR(EAGAIN);
> > goto out;
>
> I would believe this mitigates the problem, and have no objection to
> committing it, but:
>
> 1. I'm not convinced it _fixes_ the problem and I would like to see
> some clearer explanation of the bounds written down.
>
> Surely the bounds depend on the maximum size of any transaction
> issued by the file system, no? And that in turn depends both on
> the logic in the file system and potentially on the content like
> the shape of the indirect block tree when it is recursively
> processed. But we have no mechanism to pass fs-specific bounds on
> transaction size into wapbl_start or wapbl_begin.
>
> The ffs_truncate workaround (by which I assume you mean
> https://mail-index.netbsd.org/source-changes/2016/10/28/msg078723.html)
> is also just that: a workaround, not a solution, which makes
> truncate operations (including unlink) non-atomic by breaking them
> into multiple transactions in a loop.
Sure.
> 2. It would be nice if this flushing criterion were factored out
> somewhere and not copied & pasted in two places that will get out
> of sync.
>
> 3. Would like to make sure the multiplications don't overflow, by
> asserting (and otherwise enforcing) bounds on wl_bufbytes_max,
> wl_bufcount_max, wl_circ_size, and wl_dealloclim < SIZE_MAX/3.
Current diff is attached, if noone objects I will commit over the weekend.
--
J. Hannken-Illjes - hannken@netbsd.org
--- sys/kern/vfs_wapbl.c Fri Nov 20 09:44:45 2026 +0100
+++ sys/kern/vfs_wapbl.c Fri Nov 20 16:23:03 2026 +0100
@@ -450,6 +450,27 @@ wapbl_dkcache_init(struct wapbl *wl)
wl->wl_jwrite_flags |= B_MEDIA_DPO;
}
+static bool
+wapbl_should_flush(struct wapbl *wl, int nquarter)
+{
+ unsigned lockcount;
+
+ KASSERT(mutex_owned(&wl->wl_mtx));
+
+ /*
+ * XXX this needs to be made much more sophisticated.
+ * perhaps each wapbl_begin could reserve a specified
+ * number of buffers and bytes.
+ */
+ lockcount = wl->wl_lock_count;
+ return ((wl->wl_bufbytes + (lockcount * MAXPHYS)) >
+ wl->wl_bufbytes_max / 4 * nquarter) ||
+ ((wl->wl_bufcount + (lockcount * 10)) >
+ wl->wl_bufcount_max / 4 * nquarter) ||
+ (wapbl_transaction_len(wl) > wl->wl_circ_size / 4 * nquarter) ||
+ (wl->wl_dealloccnt >= (wl->wl_dealloclim / 4 * nquarter));
+}
+
static int
wapbl_start_flush_inodes(struct wapbl *wl, struct wapbl_replay *wr)
{
@@ -1203,24 +1224,12 @@ wapbl_circ_write(struct wapbl *wl, void
int
wapbl_begin(struct wapbl *wl, const char *file, int line)
{
- int doflush;
- unsigned lockcount;
+ bool doflush;
KDASSERT(wl);
- /*
- * XXX this needs to be made much more sophisticated.
- * perhaps each wapbl_begin could reserve a specified
- * number of buffers and bytes.
- */
mutex_enter(&wl->wl_mtx);
- lockcount = wl->wl_lock_count;
- doflush = ((wl->wl_bufbytes + (lockcount * MAXPHYS)) >
- wl->wl_bufbytes_max / 2) ||
- ((wl->wl_bufcount + (lockcount * 10)) >
- wl->wl_bufcount_max / 2) ||
- (wapbl_transaction_len(wl) > wl->wl_circ_size / 2) ||
- (wl->wl_dealloccnt >= (wl->wl_dealloclim / 2));
+ doflush = wapbl_should_flush(wl, 2);
mutex_exit(&wl->wl_mtx);
if (doflush) {
@@ -2193,7 +2202,7 @@ wapbl_register_deallocation(struct wapbl
mutex_enter(&wl->wl_mtx);
- if (__predict_false(wl->wl_dealloccnt >= wl->wl_dealloclim)) {
+ if (__predict_false(wapbl_should_flush(wl, 3))) {
if (!force) {
error = SET_ERROR(EAGAIN);
goto out;
From: Konrad Schroder <perseant@hhhh.org>
To: "J. Hannken-Illjes" <hannken@netbsd.org>,
Taylor R Campbell <riastradh@NetBSD.org>
Cc: gnats-bugs@NetBSD.org, netbsd-bugs@NetBSD.org
Subject: Re: kern/60621 (panic: ufs_inactive: dirty filesystem?)
Date: Fri, 20 Nov 2026 10:24:22 -0800
On 11/20/2026 9:40 AM, J. Hannken-Illjes wrote:
>> 1. I'm not convinced it _fixes_ the problem and I would like to see
>> some clearer explanation of the bounds written down.
In the case of FFS, the issue appears to be that cylinder group blocks
are not being included in the accounting. I recorded some analysis, a
possible patch, and a link to a small reproducing filesystem image, in
PR 54504. I'm not suggesting using my patch; for one thing, it is
FFS-centric. Just a comment as to the nature of the issue, and the
reproducer may be of some use.
Thanks,
--
Konrad Schroder
perseant@hhhh.org
From: "Juergen Hannken-Illjes" <hannken@netbsd.org>
To: gnats-bugs@gnats.NetBSD.org
Cc:
Subject: PR/60621 CVS commit: src/sys/ufs/ffs
Date: Sat, 21 Nov 2026 18:27:07 +0000
Module Name: src
Committed By: hannken
Date: Sat Nov 21 18:27:07 UTC 2026
Modified Files:
src/sys/ufs/ffs: ffs_snapshot.c
Log Message:
Add UFS_WAPBL_UPDATE() after block allocations to group the
allocation and the inode update into the same transaction.
PR kern/60621 (panic: ufs_inactive: dirty filesystem?)
To generate a diff of this commit:
cvs rdiff -u -r1.157 -r1.158 src/sys/ufs/ffs/ffs_snapshot.c
Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.
From: "Juergen Hannken-Illjes" <hannken@netbsd.org>
To: gnats-bugs@gnats.NetBSD.org
Cc:
Subject: PR/60621 CVS commit: src/sys/kern
Date: Sun, 22 Nov 2026 09:14:51 +0000
Module Name: src
Committed By: hannken
Date: Sun Nov 22 09:14:51 UTC 2026
Modified Files:
src/sys/kern: vfs_wapbl.c
Log Message:
The evaluation of resource shortage in wapbl_register_deallocation()
is incomplete as only "wl_dealloccnt" is checked. Replace this check with
the doflush check from wapbl_begin() testing for 75% instead 50% to
make sure the next wapbl_begin() will always flush.
It is still a mitigation, for a fix the file system must provide an
upper bound for every transaction to wapbl_begin().
PR kern/47146 user-triggerable crash in wapbl_register_deallocation (confi)
PR kern/60621 (panic: ufs_inactive: dirty filesystem?)
To generate a diff of this commit:
cvs rdiff -u -r1.117 -r1.118 src/sys/kern/vfs_wapbl.c
Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.
From: "Martin Husemann" <martin@netbsd.org>
To: gnats-bugs@gnats.NetBSD.org
Cc:
Subject: PR/60621 CVS commit: [netbsd-11] src/sys/ufs/ffs
Date: Fri, 27 Nov 2026 09:55:17 +0000
Module Name: src
Committed By: martin
Date: Fri Nov 27 09:55:17 UTC 2026
Modified Files:
src/sys/ufs/ffs [netbsd-11]: ffs_snapshot.c
Log Message:
Pull up following revision(s) (requested by hannken in ticket #585):
sys/ufs/ffs/ffs_snapshot.c: revision 1.158
Add UFS_WAPBL_UPDATE() after block allocations to group the
allocation and the inode update into the same transaction.
PR kern/60621 (panic: ufs_inactive: dirty filesystem?)
To generate a diff of this commit:
cvs rdiff -u -r1.155 -r1.155.8.1 src/sys/ufs/ffs/ffs_snapshot.c
Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.
From: "Martin Husemann" <martin@netbsd.org>
To: gnats-bugs@gnats.NetBSD.org
Cc:
Subject: PR/60621 CVS commit: [netbsd-10] src/sys/ufs/ffs
Date: Fri, 27 Nov 2026 09:58:10 +0000
Module Name: src
Committed By: martin
Date: Fri Nov 27 09:58:10 UTC 2026
Modified Files:
src/sys/ufs/ffs [netbsd-10]: ffs_snapshot.c
Log Message:
Pull up following revision(s) (requested by hannken in ticket #1424):
sys/ufs/ffs/ffs_snapshot.c: revision 1.158
Add UFS_WAPBL_UPDATE() after block allocations to group the
allocation and the inode update into the same transaction.
PR kern/60621 (panic: ufs_inactive: dirty filesystem?)
To generate a diff of this commit:
cvs rdiff -u -r1.154.4.1 -r1.154.4.2 src/sys/ufs/ffs/ffs_snapshot.c
Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.
From: "Martin Husemann" <martin@netbsd.org>
To: gnats-bugs@gnats.NetBSD.org
Cc:
Subject: PR/60621 CVS commit: [netbsd-11] src/sys/kern
Date: Fri, 27 Nov 2026 10:00:48 +0000
Module Name: src
Committed By: martin
Date: Fri Nov 27 10:00:48 UTC 2026
Modified Files:
src/sys/kern [netbsd-11]: vfs_wapbl.c
Log Message:
Pull up following revision(s) (requested by hannken in ticket #586):
sys/kern/vfs_wapbl.c: revision 1.118
The evaluation of resource shortage in wapbl_register_deallocation()
is incomplete as only "wl_dealloccnt" is checked. Replace this check with
the doflush check from wapbl_begin() testing for 75% instead 50% to
make sure the next wapbl_begin() will always flush.
It is still a mitigation, for a fix the file system must provide an
upper bound for every transaction to wapbl_begin().
PR kern/47146 user-triggerable crash in wapbl_register_deallocation (confi)
PR kern/60621 (panic: ufs_inactive: dirty filesystem?)
To generate a diff of this commit:
cvs rdiff -u -r1.117 -r1.117.2.1 src/sys/kern/vfs_wapbl.c
Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.
From: "Martin Husemann" <martin@netbsd.org>
To: gnats-bugs@gnats.NetBSD.org
Cc:
Subject: PR/60621 CVS commit: [netbsd-10] src/sys/kern
Date: Fri, 27 Nov 2026 10:06:17 +0000
Module Name: src
Committed By: martin
Date: Fri Nov 27 10:06:17 UTC 2026
Modified Files:
src/sys/kern [netbsd-10]: vfs_wapbl.c
Log Message:
Pull up following revision(s) (requested by hannken in ticket #1425):
sys/kern/vfs_wapbl.c: revision 1.118 (via patch)
The evaluation of resource shortage in wapbl_register_deallocation()
is incomplete as only "wl_dealloccnt" is checked. Replace this check with
the doflush check from wapbl_begin() testing for 75% instead 50% to
make sure the next wapbl_begin() will always flush.
It is still a mitigation, for a fix the file system must provide an
upper bound for every transaction to wapbl_begin().
PR kern/47146 user-triggerable crash in wapbl_register_deallocation (confi)
PR kern/60621 (panic: ufs_inactive: dirty filesystem?)
To generate a diff of this commit:
cvs rdiff -u -r1.112 -r1.112.4.1 src/sys/kern/vfs_wapbl.c
Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.
>Unformatted:
(Contact us)
$NetBSD: query-full-pr,v 1.51 2026/08/10 02:28:17 riastradh Exp $
$NetBSD: gnats_config.sh,v 1.10 2026/05/13 22:00:09 riastradh Exp $
Copyright © 1994-2026
The NetBSD Foundation, Inc. ALL RIGHTS RESERVED.