Skip to content

Commit

Permalink
Fix btape bug with big blocksizes
Browse files Browse the repository at this point in the history
there is an overflow when calculating the maximum file size, which leads
to a eof being written to the tape where btape does not expect it.

Then during the read of the data the unexpected eof lets the test fail.

This fix corrects this overflow.

We also set a higher debug level on the block writings in block.c

Fixes #381: btape tests fail on blocksizes > 256k
  • Loading branch information
pstorz authored and Marco van Wieringen committed Feb 17, 2015
1 parent 1341e5c commit b533940
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 5 deletions.
4 changes: 2 additions & 2 deletions src/stored/block.c
Expand Up @@ -503,15 +503,15 @@ bool DCR::write_block_to_dev()
}
}

Dmsg4(100, "writing block of size %d to dev=%s with max_block_size %d and min_block_size %d\n",
Dmsg4(400, "writing block of size %d to dev=%s with max_block_size %d and min_block_size %d\n",
wlen, dev->print_name(), dev->max_block_size, dev->min_block_size);

if (wlen-blen > 0) {
memset(block->bufp, 0, wlen-blen); /* clear garbage */
}
}

Dmsg4(100, "writing block of size %d to dev=%s with max_block_size %d and min_block_size %d\n",
Dmsg4(400, "writing block of size %d to dev=%s with max_block_size %d and min_block_size %d\n",
wlen, dev->print_name(), dev->max_block_size, dev->min_block_size);


Expand Down
7 changes: 4 additions & 3 deletions src/stored/btape.c
Expand Up @@ -1109,7 +1109,7 @@ static void speed_test()
}
}

const int num_recs = 10000;
const uint64_t num_recs = 10000LL;

static bool write_two_files()
{
Expand All @@ -1125,10 +1125,11 @@ static bool write_two_files()
* doesn't insert any additional EOF marks
*/
if (dev->max_block_size) {
dev->max_file_size = (uint64_t)2 * (num_recs * dev->max_block_size);
dev->max_file_size = 2LL * num_recs * (uint64_t)dev->max_block_size;
} else {
dev->max_file_size = 2 * (num_recs * DEFAULT_BLOCK_SIZE);
dev->max_file_size = 2LL * num_recs * (uint64_t)DEFAULT_BLOCK_SIZE;
}
Dmsg1(100, "max_file_size was set to %lld\n", dev->max_file_size);

Pmsg2(-1, _("\n=== Write, rewind, and re-read test ===\n\n"
"I'm going to write %d records and an EOF\n"
Expand Down

0 comments on commit b533940

Please sign in to comment.