mirror_zfs/tests/zfs-tests/cmd
Brian Atkinson b4e4cbeb20
Always validate checksums for Direct I/O reads
This fixes an oversight in the Direct I/O PR. There is nothing that
stops a process from manipulating the contents of a buffer for a
Direct I/O read while the I/O is in flight. This can lead checksum
verify failures. However, the disk contents are still correct, and this
would lead to false reporting of checksum validation failures.

To remedy this, all Direct I/O reads that have a checksum verification
failure are treated as suspicious. In the event a checksum validation
failure occurs for a Direct I/O read, then the I/O request will be
reissued though the ARC. This allows for actual validation to happen and
removes any possibility of the buffer being manipulated after the I/O
has been issued.

Just as with Direct I/O write checksum validation failures, Direct I/O
read checksum validation failures are reported though zpool status -d in
the DIO column. Also the zevent has been updated to have both:
1. dio_verify_wr -> Checksum verification failure for writes
2. dio_verify_rd -> Checksum verification failure for reads.
This allows for determining what I/O operation was the culprit for the
checksum verification failure. All DIO errors are reported only on the
top-level VDEV.

Even though FreeBSD can write protect pages (stable pages) it still has
the same issue as Linux with Direct I/O reads.

This commit updates the following:
1. Propogates checksum failures for reads all the way up to the
   top-level VDEV.
2. Reports errors through zpool status -d as DIO.
3. Has two zevents for checksum verify errors with Direct I/O. One for
   read and one for write.
4. Updates FreeBSD ABD code to also check for ABD_FLAG_FROM_PAGES and
   handle ABD buffer contents validation the same as Linux.
5. Updated manipulate_user_buffer.c to also manipulate a buffer while a
   Direct I/O read is taking place.
6. Adds a new ZTS test case dio_read_verify that stress tests the new
   code.
7. Updated man pages.
8. Added an IMPLY statement to zio_checksum_verify() to make sure that
   Direct I/O reads are not issued as speculative.
9. Removed self healing through mirror, raidz, and dRAID VDEVs for
   Direct I/O reads.

This issue was first observed when installing a Windows 11 VM on a ZFS
dataset with the dataset property direct set to always. The zpool
devices would report checksum failures, but running a subsequent zpool
scrub would not repair any data and report no errors.

Reviewed-by: Tony Hutter <hutter2@llnl.gov>
Reviewed-by: Brian Behlendorf <behlendorf1@llnl.gov>
Reviewed-by: Alexander Motin <mav@FreeBSD.org>
Signed-off-by: Brian Atkinson <batkinson@lanl.gov>
Closes #16598
2024-10-09 12:28:08 -07:00
..
checksum icp: reorganise SHA2 digest mechanisms 2024-05-31 15:13:23 -07:00
file Handle possible null pointers from malloc/strdup/strndup() 2022-10-06 17:18:40 -07:00
linux_dos_attributes tests: cmd: don't recurse 2022-04-01 17:58:23 -07:00
.gitignore Adding Direct IO Support 2024-09-14 13:47:59 -07:00
badsend.c Handle possible null pointers from malloc/strdup/strndup() 2022-10-06 17:18:40 -07:00
btree_test.c btree: Implement faster binary search algorithm 2023-05-26 10:03:12 -07:00
chg_usr_exec.c Replace dead opensolaris.org license link 2022-07-11 14:16:13 -07:00
clone_mmap_cached.c Fix cloning into mmaped and cached file. 2024-01-17 08:51:07 -08:00
clone_mmap_write.c ZTS: Test for clone, mmap and write for block cloning 2024-01-16 13:15:10 -08:00
clonefile.c fix: variable type with zfs-tests/cmd/clonefile.c 2024-01-17 09:06:14 -08:00
cp_files.c tests: move C test helpers into test cmd 2022-04-01 18:01:39 -07:00
ctime.c Linux 6.7 compat: zfs_setattr fix atime update 2024-01-16 14:01:17 -08:00
devname2devid.c Replace dead opensolaris.org license link 2022-07-11 14:16:13 -07:00
dir_rd_update.c Fix unsafe string operations 2022-09-27 16:47:24 -07:00
dosmode_readonly_write.c FreeBSD: Reduce divergence from in-tree sources 2023-10-09 13:27:18 -07:00
draid.c nvpair: Constify string functions 2023-03-14 15:25:50 -07:00
ereports.c nvpair: Constify string functions 2023-03-14 15:25:50 -07:00
get_diff.c Miscellaneous ZTS fixes 2022-09-29 08:56:42 -07:00
getversion.c tests: cmd: don't recurse 2022-04-01 17:58:23 -07:00
idmap_util.c Support idmapped mount in user namespace 2022-11-08 10:28:56 -08:00
libzfs_input_check.c Use memset to zero stack allocations containing unions 2024-05-24 19:00:29 -07:00
Makefile.am Adding Direct IO Support 2024-09-14 13:47:59 -07:00
manipulate_user_buffer.c Always validate checksums for Direct I/O reads 2024-10-09 12:28:08 -07:00
mkbusy.c Cleanup: Address Clang's static analyzer's unused code complaints 2022-10-14 13:37:54 -07:00
mkfile.c Fix userspace memory leaks found by Clang Static Analzyer 2022-09-26 17:18:05 -07:00
mkfiles.c Enable -Wwrite-strings 2022-06-29 14:08:54 -07:00
mktree.c Replace dead opensolaris.org license link 2022-07-11 14:16:13 -07:00
mmap_exec.c Replace dead opensolaris.org license link 2022-07-11 14:16:13 -07:00
mmap_libaio.c Fix declarations of non-global variables 2022-10-18 11:05:32 -07:00
mmap_seek.c ZTS: small fix for SEEK_DATA/SEEK_HOLE tests (#16413) 2024-08-07 09:52:37 -07:00
mmap_sync.c ZTS: increase timeout of mmap_sync_001_pos 2024-09-17 12:03:08 -07:00
mmapwrite.c ZTS: close in mmapwrite.c 2023-01-06 10:52:08 -08:00
nvlist_to_lua.c nvpair: Constify string functions 2023-03-14 15:25:50 -07:00
readmmap.c readmmap.c: fix building with MUSL libc 2023-08-01 09:01:32 -07:00
rename_dir.c Replace dead opensolaris.org license link 2022-07-11 14:16:13 -07:00
renameat2.c Replace dead opensolaris.org license links 2023-03-14 14:44:01 -07:00
rm_lnkcnt_zero_file.c Replace dead opensolaris.org license link 2022-07-11 14:16:13 -07:00
send_doall.c Replace dead opensolaris.org license link 2022-07-11 14:16:13 -07:00
stride_dd.c Adding Direct IO Support 2024-09-14 13:47:59 -07:00
suid_write_to_file.c Replace dead opensolaris.org license link 2022-07-11 14:16:13 -07:00
threadsappend.c Replace dead opensolaris.org license link 2022-07-11 14:16:13 -07:00
truncate_test.c tests: move C test helpers into test cmd 2022-04-01 18:01:39 -07:00
user_ns_exec.c Cleanup: Address Clang's static analyzer's unused code complaints 2022-10-14 13:37:54 -07:00
xattrtest.c Replace dead opensolaris.org license link 2022-07-11 14:16:13 -07:00
zed_fd_spill-zedlet.c Miscellaneous ZTS fixes 2022-09-29 08:56:42 -07:00
zfs_diff-socket.c Cleanup: Switch to strlcpy from strncpy 2022-09-27 16:35:29 -07:00