Fix zhack label repair
checksum repair regression on nonzero TXG
#17732
+111
−68
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Motivation and Context
This change is intended to fix a regression introduced by 64db435 and first noticed when reviewing these error messages.
The aforementioned commit aimed to maintain the
zhack label repair
behavior of d04b5c9 by default, but performed checks and unnecessarily accessed data associated with the new-u
(undetach) instruction when doing so.This caused the old checksum repair behavior (default or
-c
) to fail when an uberblock with a nonzero TXG was encountered, when this behavior was only intended for-u
.The issue was not caught by old tests because there are so few transactions made on a testing zpool that some uberblocks are never assigned a TXG.
Description
The check for an uberblock's TXG being zero is now only performed for the
-u
option, which assumes a clean detach.The ashift value is only accessed when needed by the
-u
option.Determining whether to do byteswap for checksum calculation fails if the magic number doesn't match the expected for either endianness, rather than only if the magic number is zero.
Code is refactored to better separate it into discrete tasks and track return values.
How Has This Been Tested?
Case one (
zhack_label_repair_001.ksh
) of the relevant tests has been revised to do the following 128 times:touch
the test data stored in the pool, then callzpool sync
on the pool. This ensures there are enough updates for every uberblock to be used, so that the checksum repair will encounter a nonzero TXG. Documentation for these tests is updated accordingly.Types of changes
Checklist:
Signed-off-by
.