-
Notifications
You must be signed in to change notification settings - Fork 58
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
save digest of zfile's header/trailer and index #262
Conversation
c00ebff
to
d51b467
Compare
50798f3
to
982e02f
Compare
LOG_INFO("check jumptable CRC32 (` expected)", pht->index_crc); | ||
auto crc = crc32::crc32c(ibuf.get(), index_bytes); | ||
if (crc != pht->index_crc) { | ||
LOG_ERRNO_RETURN(0, false, "checksum of jumptable is incorrect"); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nit: might just print out the expected and actual if the string is not too long?
@@ -674,7 +706,9 @@ bool load_jump_table(IFile *file, CompressionFile::HeaderTrailer *pheader_traile | |||
if (!pht->verify_magic() || !pht->is_header()) { | |||
LOG_ERROR_RETURN(0, false, "header magic/type don't match"); | |||
} | |||
|
|||
if (pht->is_valid() == false) { | |||
LOG_ERROR_RETURN(0, false, "digest verification failed."); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Just to confirm, will this trigger eviction?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
it will be evict when build_jump_table failed
@@ -745,8 +786,7 @@ IFile *zfile_open_ro(IFile *file, bool verify, bool ownership) { | |||
auto res = file->fallocate(0, 0, -1); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
if load_jump_table
fails, it will evict the whole file from cache and retry @shuaichang
749a3ae
to
9c1eb35
Compare
Signed-off-by: Yifan Yuan <[email protected]>
9c1eb35
to
7315c31
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
What this PR does / why we need it:
Since there is unexpected behavior if incorrect data gets during the process of zfile loading, we should add a digest of header/trailer and index to make the dirty data can be evicted.
Which issue(s) this PR fixes (optional, in
fixes #<issue number>(, fixes #<issue_number>, ...)
format, will close the issue(s) when PR gets merged):releated issues: #253 #254 #255 #261
Please check the following list: