- !(dir_find_next_appendable_volume(dcr) &&
- strcmp(dev->VolHdr.VolName, dcr->VolumeName) == 0)) { /* wrong tape mounted */
- Dmsg0(190, "Wrong tape mounted.\n");
- if (dev->num_writers != 0) {
- DEVICE *d = ((DEVRES *)dev->device)->dev;
- uint32_t open_vols = 0;
- for ( ; d; d=d->next) {
- open_vols++;
- }
- if (dev_state(dev, ST_FILE) && dev->max_open_vols > open_vols) {
- d = init_dev(NULL, (DEVRES *)dev->device); /* init new device */
- d->prev = dev; /* chain in new device */
- d->next = dev->next;
- dev->next = d;
- /* Release old device */
- P(dev->mutex);
- unblock_device(dev);
- V(dev->mutex);
- free_dcr(dcr); /* release dcr pointing to old dev */
- /* Make new device current device and lock it */
- dev = d;
- dcr = new_dcr(jcr, dev); /* get new dcr for new device */
- lock_device(dev);
- block_device(dev, BST_DOING_ACQUIRE);
- unlock_device(dev);
- } else {
- Jmsg(jcr, M_FATAL, 0, _("Device %s is busy writing on another Volume.\n"), dev_name(dev));
- goto get_out;
- }
- }
- /* Wrong tape mounted, release it, then fall through to get correct one */
+ !(dir_find_next_appendable_volume(dcr) &&
+ strcmp(dev->VolHdr.VolumeName, dcr->VolumeName) == 0)) { /* wrong tape mounted */
+ Dmsg2(190, "Wrong tape mounted: %s. wants:%s\n", dev->VolHdr.VolumeName,
+ dcr->VolumeName);
+ /* Release volume reserved by dir_find_next_appendable_volume() */
+ if (dcr->VolumeName[0]) {
+ free_unused_volume(dcr);
+ }
+ if (dev->num_writers != 0) {
+ Jmsg3(jcr, M_FATAL, 0, _("Wanted Volume \"%s\", but device %s is busy writing on \"%s\" .\n"),
+ dcr->VolumeName, dev->print_name(), dev->VolHdr.VolumeName);
+ Dmsg3(200, "Wanted Volume \"%s\", but device %s is busy writing on \"%s\" .\n",
+ dcr->VolumeName, dev->print_name(), dev->VolHdr.VolumeName);
+ goto get_out;
+ }
+ /* Wrong tape mounted, release it, then fall through to get correct one */