zdb: Report bad label checksum

In case if all label checksums will be invalid on any vdev, the pool
will become unimportable. From other side zdb with -l option will not
provide any useful information why it happened. Add notifications
about corrupted label checksums.

Reviewed-by: Brian Behlendorf <behlendorf1@llnl.gov>
Reviewed-by: John Kennedy <john.kennedy@delphix.com>
Signed-off-by: Fedor Uporov <fuporov.vstack@gmail.com>
Closes #2509
Closes #12685
This commit is contained in:
Fedor Uporov
2021-11-10 11:22:00 -08:00
committed by GitHub
parent 6c8f03232a
commit 2a9c572059
5 changed files with 143 additions and 6 deletions
+13
View File
@@ -652,3 +652,16 @@ function corrupt_blocks_at_level # input_file corrupt_level
# This is necessary for pools made of loop devices.
sync
}
function corrupt_label_checksum # label_number vdev_path
{
typeset label_size=$((256*1024))
typeset vdev_size=$(stat_size ${2})
typeset -a offsets=("$((128*1024 - 32))" \
"$(($label_size + (128*1024 - 32)))" \
"$(($vdev_size - $label_size - (128*1024 + 32)))" \
"$(($vdev_size - (128*1024 + 32)))")
dd if=/dev/urandom of=${2} seek=${offsets[$1]} bs=1 count=32 \
conv=notrunc
}