Skip to content

Fix truncation problem in ChunkedDevice#910

Merged
arogge merged 5 commits intobareos:masterfrom
arogge:dev/arogge/master/chunked-device
Aug 26, 2021
Merged

Fix truncation problem in ChunkedDevice#910
arogge merged 5 commits intobareos:masterfrom
arogge:dev/arogge/master/chunked-device

Conversation

@arogge
Copy link
Member

@arogge arogge commented Aug 16, 2021

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

  • Short description and the purpose of this PR is present above this paragraph
  • Your name is present in the AUTHORS file (optional)

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
  • PR name is meaningful
  • Purpose of the PR is understood
  • Separate commit for this PR in the CHANGELOG.md, PR number referenced is same
  • Commit descriptions are understandable and well formatted
Source code quality
  • Source code changes are understandable
  • Variable and function names are meaningful
  • Code comments are correct (logically and spelling)
  • Required documentation changes are present and part of the PR
  • bareos-check-sources --since-merge does not report any problems
  • git status should not report modifications in the source tree after building and testing
Tests
  • Decision taken that a system- or unittest is required (if not, then remove this paragraph)
  • [ ] The decision towards a systemtest is reasonable compared to a unittest
  • Testname matches exactly what is being tested
  • Output of the test leads quickly to the origin of the fault

@arogge arogge requested review from pstorz and sduehr August 16, 2021 15:07
Copy link
Member

@pstorz pstorz left a comment

Choose a reason for hiding this comment

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

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",
Copy link
Member

Choose a reason for hiding this comment

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

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

Choose a reason for hiding this comment

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

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",
Copy link
Member

Choose a reason for hiding this comment

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

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",

@arogge arogge force-pushed the dev/arogge/master/chunked-device branch from 78737cf to ab34016 Compare August 17, 2021 08:39
@arogge arogge force-pushed the dev/arogge/master/chunked-device branch from ab34016 to 2619e85 Compare August 18, 2021 10:20
@arogge arogge requested a review from pstorz August 18, 2021 13:27
@arogge
Copy link
Member Author

arogge commented Aug 18, 2021

I reworked the commit structure so the fix itself is easier to backport. I also reworded the debug messages again.
What is still missing is a CHANGELOG.md record.

Copy link
Member

@pstorz pstorz left a comment

Choose a reason for hiding this comment

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

Looks Good. Thank you very much for this PR.

arogge added 4 commits August 26, 2021 14:15
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.
@arogge arogge force-pushed the dev/arogge/master/chunked-device branch from 0691f8b to ef21f31 Compare August 26, 2021 12:15
@arogge arogge merged commit cc44bbc into bareos:master Aug 26, 2021
@arogge arogge deleted the dev/arogge/master/chunked-device branch August 26, 2021 12:16
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.

2 participants