mirror_zfs/cmd
Matthew Ahrens 3095ca91c2
Verify block pointers before writing them out
If a block pointer is corrupted (but the block containing it checksums
correctly, e.g. due to a bug that overwrites random memory), we can
often detect it before the block is read, with the `zfs_blkptr_verify()`
function, which is used in `arc_read()`, `zio_free()`, etc.

However, such corruption is not typically recoverable.  To recover from
it we would need to detect the memory error before the block pointer is
written to disk.

This PR verifies BP's that are contained in indirect blocks and dnodes
before they are written to disk, in `dbuf_write_ready()`. This way,
we'll get a panic before the on-disk data is corrupted. This will help
us to diagnose what's causing the corruption, as well as being much
easier to recover from.

To minimize performance impact, only checks that can be done without
holding the spa_config_lock are performed.

Additionally, when corruption is detected, the raw words of the block
pointer are logged.  (Note that `dprintf_bp()` is a no-op by default,
but if enabled it is not safe to use with invalid block pointers.)

Reviewed-by: Rich Ercolani <rincebrain@gmail.com>
Reviewed-by: Brian Behlendorf <behlendorf1@llnl.gov>
Reviewed-by: Paul Zuchowski <pzuchowski@datto.com>
Reviewed-by: Alexander Motin <mav@FreeBSD.org>
Signed-off-by: Matthew Ahrens <mahrens@delphix.com>
Closes #14817
2023-05-08 11:20:23 -07:00
..
raidz_test Fix multiplication converted to larger type 2022-10-28 09:30:37 -07:00
zdb Verify block pointers before writing them out 2023-05-08 11:20:23 -07:00
zed nvpair: Constify string functions 2023-03-14 15:25:50 -07:00
zfs libzfs: add v2 iterator interfaces 2023-04-10 11:53:02 -07:00
zinject Fix unsafe string operations 2022-09-27 16:47:24 -07:00
zpool Add support for zpool user properties 2023-04-21 10:20:36 -07:00
zpool_influxdb nvpair: Constify string functions 2023-03-14 15:25:50 -07:00
zstream Reject streams that set ->drr_payloadlen to unreasonably large values 2023-01-23 13:16:22 -08:00
arc_summary More adaptive ARC eviction 2023-03-08 11:17:23 -08:00
arcstat.in Update arc_summary and arcstat outputs 2023-01-05 09:29:13 -08:00
dbufstat.in Replace dead opensolaris.org license link 2022-07-11 14:16:13 -07:00
fsck.zfs.in cmd: move single-file binaries up, extract udev programs to udev/ 2022-05-10 10:20:34 -07:00
Makefile.am Add zilstat script to report zil kstats in a user friendly manner 2022-09-02 13:24:07 -07:00
mount_zfs.c nvpair: Constify string functions 2023-03-14 15:25:50 -07:00
zfs_ids_to_path.c Replace dead opensolaris.org license link 2022-07-11 14:16:13 -07:00
zgenhostid.c Replace dead opensolaris.org license link 2022-07-11 14:16:13 -07:00
zhack.c Allow zhack label repair to restore detached devices. 2023-05-03 09:03:57 -07:00
zilstat.in Add zilstat script to report zil kstats in a user friendly manner 2022-09-02 13:24:07 -07:00
ztest.c Implementation of block cloning for ZFS 2023-03-10 11:59:53 -08:00
zvol_wait zvol_wait logic may terminate prematurely 2022-10-11 12:12:04 -07:00