Skip to content

compressor: zstd error checking and more tests - #69733

Merged
tchaikov merged 1 commit into
ceph:mainfrom
chpatrick:zstd-fixes
Nov 13, 2026
Merged

tchaikov merged 1 commit into
ceph:mainfrom
chpatrick:zstd-fixes

Conversation

@chpatrick

@chpatrick chpatrick commented Jun 25, 2026 •

Copy link
Copy Markdown
Contributor

This addresses some current issues in ZstdCompressor (https://tracker.ceph.com/issues/77334)

  • decompressStream was unchecked, which could silently return corrupt data.
  • compressStream2 and decompressStream are now called repeatedly until they say they're finished. According to the zstd manual this is not guaranteed by a single call.
  • Check overflow of uint32 compressed length field.

Enhancements:

  • Removed unnecessary CCtx_reset on a fresh CCtx.
  • unique_ptr for the contexts so we can't forget to free.
  • Some more tests for ZstdCompressor.

Contribution Guidelines

  • To sign and title your commits, please refer to Submitting Patches to Ceph.

  • If you are submitting a fix for a stable branch (e.g. "quincy"), please refer to Submitting Patches to Ceph - Backports for the proper workflow.

  • When filling out the below checklist, you may click boxes directly in the GitHub web UI. When entering or editing the entire PR message in the GitHub web UI editor, you may also select a checklist item by adding an x between the brackets: [x]. Spaces and capitalization matter when checking off items this way.

Checklist

  • Tracker (select at least one)
    • References tracker ticket
    • Very recent bug; references commit where it was introduced
    • New feature (ticket optional)
    • Doc update (no ticket needed)
    • Code cleanup (no ticket needed)
  • Component impact
    • Affects Dashboard, opened tracker ticket
    • Affects Orchestrator, opened tracker ticket
    • No impact that needs to be tracked
  • Documentation (select at least one)
    • Updates relevant documentation
    • No doc update is appropriate
  • Tests (select at least one)
Show available Jenkins commands

You must only issue one Jenkins command per-comment. Jenkins does not understand
comments with more than one command.

@ceph-jenkins

Copy link
Copy Markdown
Collaborator

Thank you for your contribution. Since you, the author, are not a member of the Ceph GitHub Org yet, our CI will not automatically run. Any member of the Ceph Org may comment "ok - to - test" (without the dashes) to allow the Jenkins jobs to run.

16 similar comments
@ceph-jenkins

Copy link
Copy Markdown
Collaborator

Thank you for your contribution. Since you, the author, are not a member of the Ceph GitHub Org yet, our CI will not automatically run. Any member of the Ceph Org may comment "ok - to - test" (without the dashes) to allow the Jenkins jobs to run.

@ceph-jenkins

Copy link
Copy Markdown
Collaborator

Thank you for your contribution. Since you, the author, are not a member of the Ceph GitHub Org yet, our CI will not automatically run. Any member of the Ceph Org may comment "ok - to - test" (without the dashes) to allow the Jenkins jobs to run.

@ceph-jenkins

Copy link
Copy Markdown
Collaborator

Thank you for your contribution. Since you, the author, are not a member of the Ceph GitHub Org yet, our CI will not automatically run. Any member of the Ceph Org may comment "ok - to - test" (without the dashes) to allow the Jenkins jobs to run.

@ceph-jenkins

Copy link
Copy Markdown
Collaborator

Thank you for your contribution. Since you, the author, are not a member of the Ceph GitHub Org yet, our CI will not automatically run. Any member of the Ceph Org may comment "ok - to - test" (without the dashes) to allow the Jenkins jobs to run.

@ceph-jenkins

Copy link
Copy Markdown
Collaborator

Thank you for your contribution. Since you, the author, are not a member of the Ceph GitHub Org yet, our CI will not automatically run. Any member of the Ceph Org may comment "ok - to - test" (without the dashes) to allow the Jenkins jobs to run.

@ceph-jenkins

Copy link
Copy Markdown
Collaborator

Thank you for your contribution. Since you, the author, are not a member of the Ceph GitHub Org yet, our CI will not automatically run. Any member of the Ceph Org may comment "ok - to - test" (without the dashes) to allow the Jenkins jobs to run.

@ceph-jenkins

Copy link
Copy Markdown
Collaborator

Thank you for your contribution. Since you, the author, are not a member of the Ceph GitHub Org yet, our CI will not automatically run. Any member of the Ceph Org may comment "ok - to - test" (without the dashes) to allow the Jenkins jobs to run.

@ceph-jenkins

Copy link
Copy Markdown
Collaborator

Thank you for your contribution. Since you, the author, are not a member of the Ceph GitHub Org yet, our CI will not automatically run. Any member of the Ceph Org may comment "ok - to - test" (without the dashes) to allow the Jenkins jobs to run.

@ceph-jenkins

Copy link
Copy Markdown
Collaborator

Thank you for your contribution. Since you, the author, are not a member of the Ceph GitHub Org yet, our CI will not automatically run. Any member of the Ceph Org may comment "ok - to - test" (without the dashes) to allow the Jenkins jobs to run.

@ceph-jenkins

Copy link
Copy Markdown
Collaborator

Thank you for your contribution. Since you, the author, are not a member of the Ceph GitHub Org yet, our CI will not automatically run. Any member of the Ceph Org may comment "ok - to - test" (without the dashes) to allow the Jenkins jobs to run.

@ceph-jenkins

Copy link
Copy Markdown
Collaborator

Thank you for your contribution. Since you, the author, are not a member of the Ceph GitHub Org yet, our CI will not automatically run. Any member of the Ceph Org may comment "ok - to - test" (without the dashes) to allow the Jenkins jobs to run.

@ceph-jenkins

Copy link
Copy Markdown
Collaborator

Thank you for your contribution. Since you, the author, are not a member of the Ceph GitHub Org yet, our CI will not automatically run. Any member of the Ceph Org may comment "ok - to - test" (without the dashes) to allow the Jenkins jobs to run.

@ceph-jenkins

Copy link
Copy Markdown
Collaborator

Thank you for your contribution. Since you, the author, are not a member of the Ceph GitHub Org yet, our CI will not automatically run. Any member of the Ceph Org may comment "ok - to - test" (without the dashes) to allow the Jenkins jobs to run.

@ceph-jenkins

Copy link
Copy Markdown
Collaborator

Thank you for your contribution. Since you, the author, are not a member of the Ceph GitHub Org yet, our CI will not automatically run. Any member of the Ceph Org may comment "ok - to - test" (without the dashes) to allow the Jenkins jobs to run.

@ceph-jenkins

Copy link
Copy Markdown
Collaborator

Thank you for your contribution. Since you, the author, are not a member of the Ceph GitHub Org yet, our CI will not automatically run. Any member of the Ceph Org may comment "ok - to - test" (without the dashes) to allow the Jenkins jobs to run.

@ceph-jenkins

Copy link
Copy Markdown
Collaborator

Thank you for your contribution. Since you, the author, are not a member of the Ceph GitHub Org yet, our CI will not automatically run. Any member of the Ceph Org may comment "ok - to - test" (without the dashes) to allow the Jenkins jobs to run.

@github-actions

Copy link
Copy Markdown

This pull request has been automatically marked as stale because it has not had any activity for 60 days. It will be closed if no further activity occurs for another 30 days.
If you are a maintainer or core committer, please follow-up on this pull request to identify what steps should be taken by the author to move this proposed change forward.
If you are the author of this pull request, thank you for your proposed contribution. If you believe this change is still appropriate, please ensure that any feedback has been addressed and ask for a code review.

@github-actions github-actions Bot added the stale label Aug 24, 2026
@nh2

nh2 commented Sep 10, 2026

Copy link
Copy Markdown
Contributor

Hello Ceph maintainers, could you have a look at this?

@chpatrick
chpatrick requested a review from a team as a code owner September 10, 2026 13:43
@chpatrick
chpatrick force-pushed the zstd-fixes branch 2 times, most recently from 7fd746d to 3bba173 Compare September 10, 2026 14:19
@chpatrick

Copy link
Copy Markdown
Contributor Author

@tchaikov could you have a look please?

Comment thread src/test/compressor/test_compression.cc Resolved

@tchaikov tchaikov left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

thanks for picking this up.

and please use imperative mood in the title. see https://github.com/ceph/ceph/blob/main/SubmittingPatches.rst#commit-title

could you add a "Signed-off-by" line at the end of your commit message? "git commit -s" will do the trick for you. see https://github.com/ceph/ceph/blob/master/SubmittingPatches.rst#sign-your-work

Comment thread src/compressor/zstd/ZstdCompressor.h Resolved
Comment thread src/compressor/zstd/ZstdCompressor.h Resolved
Comment thread src/compressor/zstd/ZstdCompressor.h Resolved
Comment thread src/compressor/zstd/ZstdCompressor.h Resolved
Comment thread src/compressor/zstd/ZstdCompressor.h Resolved
@chpatrick

Copy link
Copy Markdown
Contributor Author

@tchaikov @jacquesh I addressed the review comments, the commit message and added the signoff, PTAL.

@jacquesh jacquesh left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

I'll take another/closer look on Monday (I've not looked over the tests yet) but the runtime logic itself seems at least correct to me now. Awesome!

if (ZSTD_isError(r)) {
return -EINVAL;
}
if (inbuf.pos == inbuf.size && (zed != ZSTD_e_end || r == 0)) {

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Minor suggestion: I believe this condition is correct but personally I find it opaque and difficult to think about. Not critical but for ease-of-understanding, I'd suggest either adding a comment describing the two cases, such as:

Suggested change
if (inbuf.pos == inbuf.size && (zed != ZSTD_e_end || r == 0)) {
// Done if we've consumed all input, are ending the frame and have received the
// full compressed output frame, or if we've consumed all input and are still
// pushing input data into the compressor.
if (inbuf.pos == inbuf.size && (zed != ZSTD_e_end || r == 0)) {

Or just splitting it into two conditions (which I'm pretty sure the optimiser would merge anyway), e.g:

Suggested change
if (inbuf.pos == inbuf.size && (zed != ZSTD_e_end || r == 0)) {
if (inbuf.pos == inbuf.size && zed == ZSTD_e_end && r == 0)) {
break; // All data compressed and written to output
}
if (inbuf.pos == inbuf.size && zed == ZSTD_e_continue) {
break; // All input data written to compressor state
}

Certainly not critical, but thought I'd throw out the suggestion since if it took me a while to convince myself that this was correct then others might too.

@tchaikov tchaikov Nov 13, 2026 •

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

@jacquesh hi Jacques, good idea. probably we can have a follow-up PR to improve the readability?

@tchaikov tchaikov left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

lgtm

@anrao19

anrao19 commented Nov 2, 2026

Copy link
Copy Markdown
Contributor

This PR has been added to wip-anrao4-testing-2026-11-02-0647-main.

@anrao19

anrao19 commented Nov 12, 2026

Copy link
Copy Markdown
Contributor

This PR has been added to wip-anrao4-testing-2026-11-02-0647-main.

pr testing completed and approved by @ivancich more details on :https://tracker.ceph.com/issues/82521
@chpatrick, if no further testing is needed then this pr can be merged

@tchaikov

Copy link
Copy Markdown
Contributor

jenkins test make check arm64

@tchaikov
tchaikov merged commit ce17991 into ceph:main Nov 13, 2026
28 checks passed
@github-actions

Copy link
Copy Markdown

This is an automated message by src/script/redmine-upkeep.py.

I have resolved the following tracker ticket due to the merge of this PR:

No backports are pending for the ticket. If this is incorrect, please update the tracker
ticket and reset to Pending Backport state.

Update Log: https://github.com/ceph/ceph/actions/runs/43354553661

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

6 participants