Fix truncation problem in ChunkedDevice#910
Merged
arogge merged 5 commits intobareos:masterfrom Aug 26, 2021
Merged
Conversation
pstorz
requested changes
Aug 16, 2021
Member
pstorz
left a comment
There was a problem hiding this comment.
Good work! I think it might make sense to skip these messages:
106: (1000): backends/droplet_device.cc:250-0 chunk /testvol/9957 does not exist. Skipped.
as they fill up the logs without much information.
|
|
||
| Dmsg2(200, "Writing %d bytes at offset %d in chunk buffer\n", count, | ||
| wanted_offset); | ||
| Dmsg2(200, "Writing all %d of %d bytes at offset %d in chunk buffer\n", |
Member
There was a problem hiding this comment.
Suggested change
| Dmsg2(200, "Writing all %d of %d bytes at offset %d in chunk buffer\n", | |
| Dmsg2(200, "Writing all full %d bytes at offset %d in chunk buffer\n", |
| Dmsg2(200, "Writing %d bytes at offset %d in chunk buffer\n", count, | ||
| wanted_offset); | ||
| Dmsg2(200, "Writing all %d of %d bytes at offset %d in chunk buffer\n", | ||
| count, count, wanted_offset); |
Member
There was a problem hiding this comment.
Suggested change
| count, count, wanted_offset); | |
| count, wanted_offset); |
| Dmsg2(200, "Writing %d bytes at offset %d in chunk buffer\n", | ||
| bytes_left, 0); | ||
| Dmsg2(200, | ||
| "Writing last %d of %d bytes at offset %d in chunk buffer\n", |
Member
There was a problem hiding this comment.
Suggested change
| "Writing last %d of %d bytes at offset %d in chunk buffer\n", | |
| "Writing last %d of %d bytes at offset %d in chunk buffer\n", |
78737cf to
ab34016
Compare
ab34016 to
2619e85
Compare
Member
Author
|
I reworked the commit structure so the fix itself is easier to backport. I also reworded the debug messages again. |
pstorz
approved these changes
Aug 26, 2021
Member
pstorz
left a comment
There was a problem hiding this comment.
Looks Good. Thank you very much for this PR.
When a chunk is filled to exactly chunk_size-1 bytes, another write will ignore the remaining byte and will write to the next chunk. However, the buffer written in this way will lose its last byte. The new test sd.droplet_write_read will provoke this situation and check that data can be re-read correctly.
0691f8b to
ef21f31
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
This PR fixes an issue with ChunkedDevice where single bytes could be lost on read and write in an incorrectly handled corner-case. When the internal offset pointer pointed to the last byte of a chunk, instead of using that byte the code would simply continue with the next chunk.
Please check
If you have any questions or problems, please give a comment in the PR.
Helpful documentation and best practices
Checklist for the reviewer of the PR (will be processed by the Bareos team)
General
Source code quality
bareos-check-sources --since-mergedoes not report any problemsgit statusshould not report modifications in the source tree after building and testingTests
[ ] The decision towards a systemtest is reasonable compared to a unittest