zdb -R doesn't always print the full output. #15723
Merged
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
zdb -R has a minor flaw in which it will not always print the full output of a decompressed block. Oops.
While I was in there, I also reworked the logic so it won't try ZLE unless everything else fails, which will hopefully avoid most cases of the problem ZDB_NO_ZLE was intended to mitigate of reporting a lot of false positives of ZLE compressed blocks without needing an explicit env option...
Description
Reworked
zdb_decompress_block
to return the lsize it found, or -1 if it decided nothing worked, so that if the lsize we gave it wasn't accurate (like, say, if we just gave it a DVA and it doesn't know the lsize or compression type), it doesn't fail to print things longer than the asize.Also reworked the testing logic so it only tries ZLE after trying literally everything else and finding nothing worked, so that we both don't waste time on ZLE for most use cases and we don't fail to decompress those cases when we did before, so this reordering shouldn't affect any correct behavior anyone was using...
How Has This Been Tested?
Previously, attempting decompression of a random 128k zstd record on my pool only printed up to the compressed size of 0x19000, and also printed incorrect results of ZLE compression when you run it without
ZDB_NO_ZLE=1
. With this change, it prints the correct full 128k record decompressed, and correctly picks zstd without that flag.Types of changes
Checklist:
Signed-off-by
.