NetBSD-Bugs archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
Re: kern/60621 (panic: ufs_inactive: dirty filesystem?)
The following reply was made to PR kern/60621; it has been noted by GNATS.
From: Taylor R Campbell <riastradh%NetBSD.org@localhost>
To: "J. Hannken-Illjes" <hannken%NetBSD.org@localhost>
Cc: gnats-bugs%NetBSD.org@localhost, netbsd-bugs%NetBSD.org@localhost
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@localhost>
>
> 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.
Home |
Main Index |
Thread Index |
Old Index