mirror_zfs/module/os/freebsd/zfs
Rob Norris 3b64a9619f FreeBSD: zfs_putpages: don't undirty pages until after write completes
In syncing mode, zfs_putpages() would put the entire range of pages onto
the ZIL, then return VM_PAGER_OK for each page to the kernel. However,
an associated zil_commit() or txg sync had not happened at this point,
so the write may not actually be on disk.

So, we rework that case to use a ZIL commit callback, and do the
post-write work of undirtying the page and signaling completion there.
We return VM_PAGER_PEND to the kernel instead so it knows that we will
take care of it.

The original version of this (238eab7dc1) copied the Linux model and did
the cleanup in a ZIL callback for both async and sync. This was a
mistake, as FreeBSD does not have a separate "busy for writeback" flag
like Linux which keeps the page usable. The full sbusy flag locks the
entire page out until the itx callback fires, which for async is after
txg sync, which could be literal seconds in the future.

For the async case, the data is already on the DMU and the in-memory
ZIL, which is sufficient for async writeback, so the old method of
logging it without a callback, undirtying the page and returning is more
than sufficient and reclaims that lost performance.

Sponsored-by: Klara, Inc.
Sponsored-by: Wasabi Technology, Inc.
Reviewed-by: Brian Behlendorf <behlendorf1@llnl.gov>
Reviewed-by: Alexander Motin <mav@FreeBSD.org>
Reviewed-by: Mark Johnston <markj@FreeBSD.org>
Signed-off-by: Rob Norris <rob.norris@klarasystems.com>
Closes #17533
2025-08-12 22:41:17 -04:00
..
abd_os.c SPDX: license tags: CDDL-1.0 2025-04-16 09:59:44 -07:00
arc_os.c SPDX: license tags: CDDL-1.0 2025-04-16 09:59:44 -07:00
crypto_os.c SPDX: license tags: BSD-2-Clause 2025-04-16 09:59:44 -07:00
dmu_os.c SPDX: license tags: BSD-2-Clause 2025-04-16 09:59:44 -07:00
event_os.c FreeBSD: remove support for FreeBSD < 13.0-RELEASE (#16372) 2024-08-05 16:56:45 -07:00
hkdf.c SPDX: license tags: CDDL-1.0 2025-04-16 09:59:44 -07:00
kmod_core.c SPDX: license tags: BSD-2-Clause 2025-04-16 09:59:44 -07:00
spa_os.c SPDX: license tags: CDDL-1.0 2025-04-16 09:59:44 -07:00
sysctl_os.c SPDX: license tags: BSD-2-Clause 2025-04-16 09:59:44 -07:00
vdev_geom.c SPDX: license tags: CDDL-1.0 2025-04-16 09:59:44 -07:00
vdev_label_os.c SPDX: license tags: CDDL-1.0 2025-04-16 09:59:44 -07:00
zfs_acl.c dmu_tx: rename dmu_tx_assign() flags from TXG_* to DMU_TX_* (#17143) 2025-04-16 09:59:45 -07:00
zfs_ctldir.c SPDX: license tags: CDDL-1.0 2025-04-16 09:59:44 -07:00
zfs_debug.c SPDX: license tags: CDDL-1.0 2025-04-16 09:59:44 -07:00
zfs_dir.c dmu_tx: rename dmu_tx_assign() flags from TXG_* to DMU_TX_* (#17143) 2025-04-16 09:59:45 -07:00
zfs_file_os.c SPDX: license tags: BSD-2-Clause 2025-04-16 09:59:44 -07:00
zfs_ioctl_compat.c SPDX: license tags: BSD-2-Clause 2025-04-16 09:59:44 -07:00
zfs_ioctl_os.c SPDX: license tags: BSD-2-Clause 2025-04-16 09:59:44 -07:00
zfs_racct.c SPDX: license tags: BSD-2-Clause 2025-04-16 09:59:44 -07:00
zfs_vfsops.c dmu_tx: rename dmu_tx_assign() flags from TXG_* to DMU_TX_* (#17143) 2025-04-16 09:59:45 -07:00
zfs_vnops_os.c FreeBSD: zfs_putpages: don't undirty pages until after write completes 2025-08-12 22:41:17 -04:00
zfs_znode_os.c Linux: sync: remove async/sync accounting 2025-08-12 17:23:39 -07:00
zio_crypt.c tunables: remove FreeBSD compat macros for Linux module params 2025-06-17 10:50:26 -07:00
zvol_os.c ZVOL: Comment platform-specific empty functions bodies on FreeBSD side 2025-06-17 10:49:40 -07:00