forked from openzfs/zfs
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
In case if all label checksums will be invalid on any vdev, the pool will become unimportable. The zhack with newly added cli options could be used to restore label checksums and make pool importable again. Reviewed-by: Brian Behlendorf <behlendorf1@llnl.gov> Signed-off-by: Fedor Uporov <fuporov.vstack@gmail.com> Closes openzfs#2510 Closes openzfs#12686
- Loading branch information
1 parent
637771a
commit d04b5c9
Showing
7 changed files
with
252 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -35,6 +35,7 @@ SUBDIRS = \ | |
zfs_unshare \ | ||
zfs_upgrade \ | ||
zfs_wait \ | ||
zhack \ | ||
zpool \ | ||
zpool_add \ | ||
zpool_attach \ | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
pkgdatadir = $(datadir)/@PACKAGE@/zfs-tests/tests/functional/cli_root/zhack | ||
dist_pkgdata_SCRIPTS = \ | ||
zhack_label_checksum.ksh |
64 changes: 64 additions & 0 deletions
64
tests/zfs-tests/tests/functional/cli_root/zhack/zhack_label_checksum.ksh
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,64 @@ | ||
#!/bin/ksh | ||
|
||
# | ||
# This file and its contents are supplied under the terms of the | ||
# Common Development and Distribution License ("CDDL"), version 1.0. | ||
# You may only use this file in accordance with the terms of version | ||
# 1.0 of the CDDL. | ||
# | ||
# A full copy of the text of the CDDL should have accompanied this | ||
# source. A copy of the CDDL is also available via the Internet at | ||
# http://www.illumos.org/license/CDDL. | ||
# | ||
|
||
# | ||
# Copyright (c) 2021 by vStack. All rights reserved. | ||
# | ||
|
||
. $STF_SUITE/include/libtest.shlib | ||
. $STF_SUITE/include/blkdev.shlib | ||
|
||
# | ||
# Description: | ||
# zhack label repair <vdev> will calculate and rewrite label checksum if invalid | ||
# | ||
# Strategy: | ||
# 1. Create pool with some number of vdevs and export it | ||
# 2. Corrupt all labels checksums | ||
# 3. Check that pool cannot be imported | ||
# 4. Use zhack to repair labels checksums | ||
# 5. Check that pool can be imported | ||
# | ||
|
||
log_assert "Verify zhack label repair <vdev> will repair labels checksums" | ||
log_onexit cleanup | ||
|
||
VIRTUAL_DISK=$TEST_BASE_DIR/disk | ||
|
||
function cleanup | ||
{ | ||
poolexists $TESTPOOL && destroy_pool $TESTPOOL | ||
[[ -f $VIRTUAL_DISK ]] && log_must rm $VIRTUAL_DISK | ||
} | ||
|
||
log_must truncate -s $(($MINVDEVSIZE * 8)) $VIRTUAL_DISK | ||
|
||
log_must zpool create $TESTPOOL $VIRTUAL_DISK | ||
log_must zpool export $TESTPOOL | ||
|
||
log_mustnot zhack label repair $VIRTUAL_DISK | ||
|
||
corrupt_label_checksum 0 $VIRTUAL_DISK | ||
corrupt_label_checksum 1 $VIRTUAL_DISK | ||
corrupt_label_checksum 2 $VIRTUAL_DISK | ||
corrupt_label_checksum 3 $VIRTUAL_DISK | ||
|
||
log_mustnot zpool import $TESTPOOL -d $TEST_BASE_DIR | ||
|
||
log_must zhack label repair $VIRTUAL_DISK | ||
|
||
log_must zpool import $TESTPOOL -d $TEST_BASE_DIR | ||
|
||
cleanup | ||
|
||
log_pass "zhack label repair works correctly." |