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

NDMP_BAREOS: support autoxflate plugin #1013

Merged
merged 14 commits into from
Feb 24, 2022

Conversation

pstorz
Copy link
Member

@pstorz pstorz commented Dec 6, 2021

Thank you for contributing to the Bareos Project!

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)

NDMP backups (using NDMP BAREOS) could be configured to use the autoxflate plugin on used storage devices
Unfortunately, the stream was not deflated during restore resulting in non-recoverable Backups.
This PR adds the feature to deflate compressed packages before sending them back to the NDMP data agent.

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

@pstorz pstorz marked this pull request as draft December 6, 2021 16:33
@pstorz pstorz force-pushed the dev/pstorz/master/ndmp-autoxflate-on-restore branch from a12db95 to 252fa19 Compare December 7, 2021 12:08
@pstorz pstorz changed the title NDMP: support autoxflate plugin NDMP_BAREOS: support autoxflate plugin Dec 7, 2021
@pstorz pstorz force-pushed the dev/pstorz/master/ndmp-autoxflate-on-restore branch from 05662ff to a4f1123 Compare December 7, 2021 12:50
@pstorz pstorz requested a review from arogge December 7, 2021 13:33
@pstorz pstorz force-pushed the dev/pstorz/master/ndmp-autoxflate-on-restore branch from a4f1123 to 27b492e Compare December 23, 2021 09:54
Copy link
Member

@arogge arogge left a comment

Choose a reason for hiding this comment

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

I'm still not sure I understand what really happens here 100%.
However, I already have a few remarks.

core/src/stored/ndmp_tape.cc Outdated Show resolved Hide resolved
if (GeneratePluginEvent(jcr, bSdEventReadRecordTranslation, dcr,
/* reverse= */ true)
!= bRC_OK) {
ok = false;
continue;
Copy link
Member

Choose a reason for hiding this comment

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

Doesn't this mean we will ignore the plugin event's error and continue reading?
Is that out intent here?

Copy link
Member Author

Choose a reason for hiding this comment

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

I updated the code to uset the ok variable to end the loop as it is in the original code.

DeviceRecord* rec = rctx->rec;
// Perform record translations only if data is compressed
// as NDMP needs to be decompressed in any case
if (rctx->rec->maskedStream == STREAM_COMPRESSED_DATA) {
Copy link
Member

Choose a reason for hiding this comment

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

When limiting the GeneratePluginEvent() to STREAM_COMPRESSED_DATE, then it will work for autoxflate, but would probably fail (or simply not do the right thing) with other potential plugins.

Copy link
Member Author

Choose a reason for hiding this comment

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

GeneratePluginEvent() is now called no matter what the masked stream type.

However, my tries to adapt the autoxflate settings automatically did not work. I left the commits for that so that we might have a look again.

Copy link
Member

@arogge arogge left a comment

Choose a reason for hiding this comment

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

I really hate fixing this issue by duplicating even more code. Shouldn't we extract the record reading out of ReadRecords() and use that functionality here?

continue;
}
if (dcr->after_rec) { // translation happened?
rec = dcr->after_rec;
Copy link
Member

Choose a reason for hiding this comment

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

if GeneratePluginEvent() set dcr->after_rec, doesn't that mean it allocated a new record that we need to free with FreeRecord()?

@pstorz pstorz self-assigned this Jan 20, 2022
@pstorz pstorz force-pushed the dev/pstorz/master/ndmp-autoxflate-on-restore branch 2 times, most recently from 35dd2cc to 96d1b4f Compare February 1, 2022 13:20
@pstorz pstorz marked this pull request as ready for review February 1, 2022 14:29
@pstorz pstorz requested a review from arogge February 1, 2022 14:29
Comment on lines +397 to +412
if (!record_was_swapped) {
if (AutoxflateModeContainsOut(dcr->autodeflate)) {
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
if (!record_was_swapped) {
if (AutoxflateModeContainsOut(dcr->autodeflate)) {
if (!record_was_swapped && AutoxflateModeContainsOut(dcr->autodeflate)) {

Comment on lines +419 to +434
if (!record_was_swapped) {
if (AutoxflateModeContainsOut(dcr->autodeflate)) {
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
if (!record_was_swapped) {
if (AutoxflateModeContainsOut(dcr->autodeflate)) {
if (!record_was_swapped && AutoxflateModeContainsOut(dcr->autodeflate)) {

Comment on lines -745 to -752
switch (rec->maskedStream) {
case STREAM_COMPRESSED_DATA:
case STREAM_WIN32_COMPRESSED_DATA:
case STREAM_SPARSE_COMPRESSED_DATA:
break;
default:
goto bail_out;
}
Copy link
Member

Choose a reason for hiding this comment

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

I'm not sure this can be safely removed.

Auto Inflate = in
Auto Deflate = out
Copy link
Member

Choose a reason for hiding this comment

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

We should probably have a testcase with Auto Deflate = out and no Auto Inflate at all.
I guess we will also need to always force Auto Inflate = in for NDMP jobs, so NDMP-data is always decompressed if needed (and the autoxflate plugin is loaded).

@arogge arogge force-pushed the dev/pstorz/master/ndmp-autoxflate-on-restore branch from 7c46994 to b8b4a4d Compare February 24, 2022 12:46
@arogge arogge merged commit 16da019 into master Feb 24, 2022
@arogge arogge deleted the dev/pstorz/master/ndmp-autoxflate-on-restore branch February 24, 2022 12:51
pstorz added a commit that referenced this pull request Mar 1, 2022
NDMP_BAREOS AutoXFlate support (backport PR #1013)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants