Skip to content

Fix btape fill-test problem#2018

Merged
BareosBot merged 4 commits intobareos:masterfrom
arogge:fix-btape-1997
Feb 12, 2025
Merged

Fix btape fill-test problem#2018
BareosBot merged 4 commits intobareos:masterfrom
arogge:fix-btape-1997

Conversation

@arogge
Copy link
Member

@arogge arogge commented Nov 15, 2024

This PR fixes a break of btape introduced in #1958.

When we disabled the PRE_LABEL, we introduced a file-mark right after the label block. As the btape mutli-tape test blindly repositions the tape to the location where it thinks the data starts, tests started to fail.
The PR also fixes two memory-issues in btape as well as a possible out-of-bounds access when using the modulo scheduler.

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)

Make sure you check/merge the PR using devtools/pr-tool to have some simple automated checks run and a proper changelog record added.

General
  • Is the PR title usable as CHANGELOG entry?
  • Purpose of the PR is understood
  • Commit descriptions are understandable and well formatted
  • Required backport PRs have been created
  • Correct milestone is set
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

@arogge arogge force-pushed the fix-btape-1997 branch 2 times, most recently from 5c5db16 to fe7339f Compare November 15, 2024 11:43
@arogge arogge self-assigned this Dec 17, 2024
@arogge arogge requested a review from sebsura December 17, 2024 11:31
@arogge arogge added this to the 25.0.0 milestone Dec 17, 2024
@arogge arogge linked an issue Dec 18, 2024 that may be closed by this pull request
Copy link
Contributor

@sebsura sebsura left a comment

Choose a reason for hiding this comment

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

Great work! I added some comments, but those are just nice-to-haves and are not required.

Comment on lines +548 to +549
for (int week = code; week <= 53; week += code2) {
SetBit(week, res_run.date_time_bitfield.woy);
Copy link
Contributor

Choose a reason for hiding this comment

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

This does basically the same as the previous version except it sets week 53 if code=0 (and code2 is e.g. 1).
But i would consider this a bug in the old code, so this should be ok!

Copy link
Contributor

Choose a reason for hiding this comment

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

One thing i noticed: Should we also update the "module scheduler" for days as well ? It basically uses the same logic/code.

p = dev_name + strlen(dev_name);

while (p >= dev_name && !IsPathSeparator(*p)) p--;
while (p > dev_name && !IsPathSeparator(*p)) p--;
Copy link
Contributor

Choose a reason for hiding this comment

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

Good catch! Issues like this are really hard to spot while looking over the code. I feel like something like this would be even more clearer

std::string_view v{dev_name};

if (auto pos = v.find_last_of("/"); pos != v.npos) {
  // use the filename as volume name ...
  bstrncpy(VolName, &dev_name[pos + 1], sizeof(VolName));
  // ... and then delete it from the device name
  dev_name[pos] = 0;
}

except that "/" would need to be replaced by whatever IsPathSeparator() checks for -- i.e. "\\/" on windows.

remove alias for g_dcr->block as this is unsafe. The memory will be
reallocated during operation which will invalidate the alias-pointer.
move to 1:0 instead of 0:1 when doing multi-tape unfill.
As we now have a file-mark right after the label block, btape needs to
move to the first block after that file-mark instead of the second block
in the first file.
This change also adds reading the volume label of the second tape, which
was not done before.
replace the old implementation for the modulo scheduler with a nicer
one. This will also fix an out-of-bounds error that was present in the
previous code.

Co-Authored-By: Sebastian Sura <sebastian.sura@bareos.com>
@BareosBot BareosBot merged commit 8de4606 into bareos:master Feb 12, 2025
1 check was pending
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.

Btape multiple tapes fill test issue

3 participants