Skip to content
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

Merged
merged 1 commit into from
Sep 18, 2023

Conversation

BigVan
Copy link
Member

@BigVan BigVan commented Sep 9, 2023

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:

  • Does the affected code have corresponding tests, e.g. unit test, E2E test?
  • Does this change require a documentation update?
  • Does this introduce breaking changes that would require an announcement or bumping the major version?
  • Do all new files have an appropriate license header?

src/overlaybd/zfile/format_spec.md Outdated Show resolved Hide resolved
src/overlaybd/zfile/format_spec.md Outdated Show resolved Hide resolved
src/overlaybd/zfile/format_spec.md Show resolved Hide resolved
src/overlaybd/zfile/format_spec.md Outdated Show resolved Hide resolved
@BigVan BigVan added the enhancement New feature or request label Sep 12, 2023
@BigVan BigVan force-pushed the zfile_digest branch 2 times, most recently from c00ebff to d51b467 Compare September 12, 2023 14:47
@BigVan BigVan changed the title [Draft] record digest of zfile's header/trailer and index save digest of zfile's header/trailer and index Sep 12, 2023
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");

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.");

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?

Copy link
Member Author

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);
Copy link
Contributor

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

@BigVan BigVan force-pushed the zfile_digest branch 2 times, most recently from 749a3ae to 9c1eb35 Compare September 15, 2023 03:20
Copy link
Contributor

@yuchen0cc yuchen0cc left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@yuchen0cc yuchen0cc merged commit 2fb5fbf into containerd:main Sep 18, 2023
2 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants