Skip to content

Commit

Permalink
Fix regression problems
Browse files Browse the repository at this point in the history
ua_purge.c: keep blocksizes during relabel
dev.c: do not set dev blocksize to zero

Signed-off-by: Marco van Wieringen <marco.van.wieringen@bareos.com>
  • Loading branch information
pstorz authored and Marco van Wieringen committed Feb 17, 2015
1 parent ae1e832 commit 33e9837
Show file tree
Hide file tree
Showing 2 changed files with 34 additions and 16 deletions.
33 changes: 24 additions & 9 deletions src/dird/ua_purge.c
Expand Up @@ -611,39 +611,54 @@ static void do_truncate_on_purge(UAContext *ua, MEDIA_DBR *mr,
bool ok=false;
uint64_t VolBytes = 0;

/* TODO: Return if not mr->Recyle ? */
/*
* TODO: Return if not mr->Recyle ?
*/
if (!mr->Recycle) {
return;
}

/* Do it only if action on purge = truncate is set */
/*
* Do it only if action on purge = truncate is set
*/
if (!(mr->ActionOnPurge & ON_PURGE_TRUNCATE)) {
return;
}

/*
* Send the command to truncate the volume after purge. If this feature
* is disabled for the specific device, this will be a no-op.
*/

/* Protect us from spaces */
/*
* Protect us from spaces
*/
bash_spaces(mr->VolumeName);
bash_spaces(mr->MediaType);
bash_spaces(pool);
bash_spaces(storage);

/* Do it by relabeling the Volume, which truncates it */
/*
* Do it by relabeling the Volume, which truncates it
*/
sd->fsend("relabel %s OldName=%s NewName=%s PoolName=%s "
"MediaType=%s Slot=%d drive=%d\n",
storage,
mr->VolumeName, mr->VolumeName,
pool, mr->MediaType, mr->Slot, drive);
"MediaType=%s Slot=%d drive=%d MinBlocksize=%d MaxBlocksize=%d\n",
storage,
mr->VolumeName, mr->VolumeName,
pool, mr->MediaType, mr->Slot, drive,
/*
* If relabeling, keep blocksize settings
*/
mr->MinBlocksize, mr->MaxBlocksize);

unbash_spaces(mr->VolumeName);
unbash_spaces(mr->MediaType);
unbash_spaces(pool);
unbash_spaces(storage);

/* Send relabel command, and check for valid response */
/*
* Send relabel command, and check for valid response
*/
while (sd->recv() >= 0) {
ua->send_msg("%s", sd->msg);
if (sscanf(sd->msg, "3000 OK label. VolBytes=%llu ", &VolBytes) == 1) {
Expand Down
17 changes: 10 additions & 7 deletions src/stored/dev.c
Expand Up @@ -363,27 +363,30 @@ m_init_dev(JCR *jcr, DEVRES *device, bool new_init)
* Set the block size of the device.
* If the volume block size is zero, we set the max block size to what is
* configured in the device resource i.e. dev->device->max_block_size.
*
* If dev->device->max_block_size is zero, do nothing and leave dev->max_block_size as it is.
*/
void DEVICE::set_blocksizes(DCR *dcr) {

DEVICE* dev = this;
JCR* jcr = dcr->jcr;
uint32_t max_bs;

Dmsg3(100, "Device %s has dev_max_block_size of %u and max_block_size of %u\n",
dev->print_name(), dev->device->max_block_size, dev->max_block_size);
Dmsg4(100, "Device %s has dev->device->max_block_size of %u and dev->max_block_size of %u, dcr->VolMaxBlocksize is %u\n",
dev->print_name(), dev->device->max_block_size, dev->max_block_size, dcr->VolMaxBlocksize);

if (dcr->VolMaxBlocksize == 0) {
Dmsg2(100, "setting dev->max_block_size to dev_max_block_size=%u "
if (dcr->VolMaxBlocksize == 0 && dev->device->max_block_size != 0) {
Dmsg2(100, "setting dev->max_block_size to dev->device->max_block_size=%u "
"on device %s because dcr->VolMaxBlocksize is 0\n",
dev->device->max_block_size, dev->print_name());
dev->min_block_size = dev->device->min_block_size;
dev->max_block_size = dev->device->max_block_size;
} else {
dev->min_block_size = dcr->VolMinBlocksize;
dev->max_block_size = dcr->VolMaxBlocksize;
} else if (dcr->VolMaxBlocksize != 0) {
dev->min_block_size = dcr->VolMinBlocksize;
dev->max_block_size = dcr->VolMaxBlocksize;
}


/*
* Sanity check
*/
Expand Down

0 comments on commit 33e9837

Please sign in to comment.