zfs/lib/libspl/include/sys
Alexander Motin c0c4866f8a dmu: Allow buffer fills to fail
When ZFS overwrites a whole block, it does not bother to read the
old content from disk. It is a good optimization, but if the buffer
fill fails due to page fault or something else, the buffer ends up
corrupted, neither keeping old content, nor getting the new one.

On FreeBSD this is additionally complicated by page faults being
blocked by VFS layer, always returning EFAULT on attempt to write
from mmap()'ed but not yet cached address range.  Normally it is
not a big problem, since after original failure VFS will retry the
write after reading the required data.  The problem becomes worse
in specific case when somebody tries to write into a file its own
mmap()'ed content from the same location.  In that situation the
only copy of the data is getting corrupted on the page fault and
the following retries only fixate the status quo.  Block cloning
makes this issue easier to reproduce, since it does not read the
old data, unlike traditional file copy, that may work by chance.

This patch provides the fill status to dmu_buf_fill_done(), that
in case of error can destroy the corrupted buffer as if no write
happened.  One more complication in case of block cloning is that
if error is possible during fill, dmu_buf_will_fill() must read
the data via fall-back to dmu_buf_will_dirty().  It is required
to allow in case of error restoring the buffer to a state after
the cloning, not not before it, that would happen if we just call
dbuf_undirty().

Reviewed-by: Brian Behlendorf <behlendorf1@llnl.gov>
Reviewed-by: Rob Norris <robn@despairlabs.com>
Signed-off-by: Alexander Motin <mav@FreeBSD.org>
Sponsored by: iXsystems, Inc.
Closes #15665
2024-02-20 15:53:02 -08:00
..
dktp Replace dead opensolaris.org license link 2022-07-11 14:16:13 -07:00
acl.h Replace dead opensolaris.org license link 2022-07-11 14:16:13 -07:00
acl_impl.h Replace dead opensolaris.org license link 2022-07-11 14:16:13 -07:00
asm_linkage.h Unify Assembler files between Linux and Windows 2023-01-17 11:09:19 -08:00
callb.h Replace dead opensolaris.org license link 2022-07-11 14:16:13 -07:00
cmn_err.h spl: cmn_err_once() should be usable in brace-less if else statements 2023-03-15 11:13:25 -07:00
cred.h Replace dead opensolaris.org license link 2022-07-11 14:16:13 -07:00
debug.h Replace dead opensolaris.org license link 2022-07-11 14:16:13 -07:00
dkio.h Replace dead opensolaris.org license link 2022-07-11 14:16:13 -07:00
dklabel.h Replace dead opensolaris.org license link 2022-07-11 14:16:13 -07:00
feature_tests.h Replace dead opensolaris.org license link 2022-07-11 14:16:13 -07:00
inttypes.h Replace dead opensolaris.org license link 2022-07-11 14:16:13 -07:00
isa_defs.h Add loongarch64 support 2023-04-25 16:05:45 -07:00
kmem.h Replace dead opensolaris.org license link 2022-07-11 14:16:13 -07:00
kstat.h Replace dead opensolaris.org license link 2022-07-11 14:16:13 -07:00
list.h Replace dead opensolaris.org license link 2022-07-11 14:16:13 -07:00
list_impl.h Replace dead opensolaris.org license link 2022-07-11 14:16:13 -07:00
mhd.h Replace dead opensolaris.org license link 2022-07-11 14:16:13 -07:00
mkdev.h Replace dead opensolaris.org license link 2022-07-11 14:16:13 -07:00
policy.h Replace dead opensolaris.org license link 2022-07-11 14:16:13 -07:00
poll.h Replace dead opensolaris.org license link 2022-07-11 14:16:13 -07:00
priv.h Replace dead opensolaris.org license link 2022-07-11 14:16:13 -07:00
processor.h Replace dead opensolaris.org license link 2022-07-11 14:16:13 -07:00
simd.h powerpc64: Support ELFv2 asm on Big Endian 2023-04-27 12:49:21 -07:00
stack.h Replace dead opensolaris.org license link 2022-07-11 14:16:13 -07:00
stdtypes.h Replace dead opensolaris.org license link 2022-07-11 14:16:13 -07:00
string.h Forbid b{copy,zero,cmp}(). Don't include <strings.h> for <string.h> 2022-03-15 15:13:48 -07:00
sunddi.h Replace dead opensolaris.org license link 2022-07-11 14:16:13 -07:00
systeminfo.h Replace dead opensolaris.org license link 2022-07-11 14:16:13 -07:00
time.h Replace dead opensolaris.org license link 2022-07-11 14:16:13 -07:00
trace_spl.h Enable use of DTRACE_PROBE* macros in "spl" module 2019-11-01 13:13:43 -07:00
trace_zfs.h Enable use of DTRACE_PROBE* macros in "spl" module 2019-11-01 13:13:43 -07:00
types.h freebsd: simplify MD isa_defs.h 2022-11-07 15:55:37 -08:00
types32.h Replace dead opensolaris.org license link 2022-07-11 14:16:13 -07:00
uio.h dmu: Allow buffer fills to fail 2024-02-20 15:53:02 -08:00
vnode.h Replace dead opensolaris.org license link 2022-07-11 14:16:13 -07:00
wmsum.h Introduce write-mostly sums 2021-05-27 14:27:29 -06:00
zone.h Replace dead opensolaris.org license link 2022-07-11 14:16:13 -07:00