zfs/module
Rob Norris 531af601a1 dnode_is_dirty: use dn_dirty_txg to check dirtiness
dn_dirty_ctx is always set to the highest txg that has ever dirtied the
dnode. It is set in dbuf_dirty() when a data or metadnode dbuf is
dirtied, and never cleared.

[analysis of bug #15526 and fix #15571 below, for future readers]

The previous dirty check was:

    for (int i = 0; i < TXG_SIZE; i++) {
        if (multilist_link_active(&dn->dn_dirty_link[i])
            [dnode is dirty]

However, this check is not "is the dnode dirty?" but rather, "is the
dnode on a list?".

There is a gap in dmu_objset_sync_dnodes() where the dnode is moved from
os_dirty_dnodes to os_synced_dnodes, before dnode_sync() is called to
write out the dirty dbufs. So, there is a moment when the dnode is not
on a list, and so the check fails.

It doesn't matter that the dirty check takes dn_mtx, because that lock
isn't used for dn_dirty_link. The os_dirty_dnodes sublist lock is held
in dmu_objset_sync_dnodes(), but trying to take that would mean possibly
waiting until everything on that sublist has been synced.

The correct fix has to check something that positively asserts the dnode
is dirty, rather than an implementation detail. dn_dirty_txg (via
DNODE_IS_DIRTY()) is that - its a normal bit of dnode state, under the
dn_mtx lock, and unambiguously indicates whether or not there's changes
pending.

Sponsored-by: Klara, Inc.
Sponsored-by: Wasabi Technology, Inc.
Signed-off-by: Rob Norris <rob.norris@klarasystems.com>
2023-12-01 08:48:27 +11:00
..
avl Suppress Clang Static Analyzer false positive in the AVL tree code. 2023-03-08 13:51:21 -08:00
icp module/icp/asm-arm/sha2: fix compiling on armv5/6 2023-11-28 13:26:12 -08:00
lua Add loongarch64 support 2023-04-25 16:05:45 -07:00
nvpair nvpair: Constify string functions 2023-03-14 15:25:50 -07:00
os ZIL: Assert record sizes in different places 2023-11-28 13:35:14 -08:00
unicode Illumos #15286: do_composition() needs sign awareness 2023-01-05 11:16:21 -08:00
zcommon RAID-Z expansion feature 2023-11-08 10:19:41 -08:00
zfs dnode_is_dirty: use dn_dirty_txg to check dirtiness 2023-12-01 08:48:27 +11:00
zstd Resolve WS-2021-0184 vulnerability in zstd 2023-02-02 15:12:51 -08:00
.gitignore FreeBSD: Ignore symlink to i386 includes 2022-08-02 16:34:23 -07:00
Kbuild.in Workaround UBSAN errors for variable arrays 2023-11-12 16:26:07 -08:00
Makefile.bsd Finally drop long disabled vdev cache. 2023-06-09 12:40:55 -07:00
Makefile.in check-zstd-symbols: also ignore __pfx_ symbols 2023-09-18 09:08:41 -07:00