HomeFreeBSD

Verify block pointers before writing them out

Description

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

Details

Provenance
mahrensAuthored on May 8 2023, 6:20 PM
GitHub <noreply@github.com>Committed on May 8 2023, 6:20 PM
Parents
rGdd19821149cb: zdb: consistent xattr output
Branches
Unknown
Tags
Unknown