From: Kern Sibbald Date: Sun, 23 Aug 2009 07:58:52 +0000 (+0200) Subject: Free Volume in several places. Fixes virtual-changer problem X-Git-Tag: Release-5.0.0~332^2~2 X-Git-Url: https://git.sur5r.net/?a=commitdiff_plain;h=30e25310bd4cf0e2e8a73dc10e436e545da47d3d;p=bacula%2Fbacula Free Volume in several places. Fixes virtual-changer problem and possibly bug #1346. --- diff --git a/bacula/src/stored/acquire.c b/bacula/src/stored/acquire.c index dc3b7269c3..1d382d1f58 100644 --- a/bacula/src/stored/acquire.c +++ b/bacula/src/stored/acquire.c @@ -245,7 +245,8 @@ bool acquire_device_for_read(DCR *dcr) } goto default_path; case VOL_NAME_ERROR: - Dmsg0(50, "Vol name error.\n"); + Dmsg3(50, "Vol name=%s want=%s drv=%s.\n", dev->VolHdr.VolumeName, + dcr->VolumeName, dev->print_name()); if (dev->is_volume_to_unload()) { goto default_path; } @@ -253,6 +254,7 @@ bool acquire_device_for_read(DCR *dcr) if (!unload_autochanger(dcr, -1)) { /* at least free the device so we can re-open with correct volume */ dev->close(); + free_volume(dev); } dev->set_load(); /* Fall through */ @@ -267,6 +269,7 @@ default_path: */ if (dev->requires_mount()) { dev->close(); + free_volume(dev); } /* Call autochanger only once unless ask_sysop called */ @@ -511,6 +514,7 @@ bool release_device(DCR *dcr) if (dev->num_writers == 0 && (!dev->is_tape() || !dev->has_cap(CAP_ALWAYSOPEN))) { dvd_remove_empty_part(dcr); /* get rid of any empty spool part */ dev->close(); + free_volume(dev); } /* Fire off Alert command and include any output */ diff --git a/bacula/src/stored/dircmd.c b/bacula/src/stored/dircmd.c index 3e1e613c6f..4f4a2d72f9 100644 --- a/bacula/src/stored/dircmd.c +++ b/bacula/src/stored/dircmd.c @@ -814,6 +814,7 @@ static bool unmount_cmd(JCR *jcr) if (!unload_autochanger(dcr, -1)) { /* ***FIXME**** what is this ???? */ dev->close(); + free_volume(dev); } if (dev->is_unmountable() && !dev->unmount(0)) { dir->fsend(_("3907 %s"), dev->bstrerror()); @@ -845,6 +846,7 @@ static bool unmount_cmd(JCR *jcr) clear_thread_id(dev->no_wait_id); if (!unload_autochanger(dcr, -1)) { dev->close(); + free_volume(dev); } if (dev->is_unmountable() && !dev->unmount(0)) { dir->fsend(_("3907 %s"), dev->bstrerror()); diff --git a/bacula/src/stored/label.c b/bacula/src/stored/label.c index 48656a4f3f..cfb43128f0 100644 --- a/bacula/src/stored/label.c +++ b/bacula/src/stored/label.c @@ -237,6 +237,7 @@ int read_dev_volume_label(DCR *dcr) if (reserve_volume(dcr, dev->VolHdr.VolumeName) == NULL) { Mmsg2(jcr->errmsg, _("Could not reserve volume %s on %s\n"), dev->VolHdr.VolumeName, dev->print_name()); + Dmsg2(150, "Could not reserve volume %s on %s\n", dev->VolHdr.VolumeName, dev->print_name()); stat = VOL_NAME_ERROR; goto bail_out; } diff --git a/bacula/src/stored/mount.c b/bacula/src/stored/mount.c index 06d48b36d1..ea8571c757 100644 --- a/bacula/src/stored/mount.c +++ b/bacula/src/stored/mount.c @@ -145,6 +145,7 @@ mount_next_vol: autochanger = false; VolCatInfo.Slot = 0; ask = retry >= 2; + do_find = true; /* do find_a_volume if we retry */ } Dmsg1(150, "autoload_dev returns %d\n", autochanger); /* @@ -180,6 +181,7 @@ mount_next_vol: if (dev->poll && dev->has_cap(CAP_CLOSEONPOLL)) { dev->close(); + free_volume(dev); } /* Ensure the device is open */ @@ -474,6 +476,7 @@ int DCR::check_volume_label(bool &ask, bool &autochanger) /* Needed, so the medium can be changed */ if (dev->requires_mount()) { dev->close(); + free_volume(dev); } goto check_next_volume; } @@ -544,6 +547,12 @@ void DCR::do_swapping(bool is_writing) Dmsg1(100, "=== set in_use vol=%s\n", dev->vol->vol_name); dev->vol->set_in_use(); dev->VolHdr.VolumeName[0] = 0; /* don't yet have right Volume */ + } else { + Dmsg1(100, "No vol on dev=%s\n", dev->print_name()); + } + if (dev->swap_dev->vol) { + Dmsg2(100, "Vol=%s on dev=%s\n", dev->swap_dev->vol->vol_name, + dev->swap_dev->print_name()); } dev->swap_dev = NULL; } diff --git a/bacula/technotes b/bacula/technotes index 68fcabf087..3242f0e63a 100644 --- a/bacula/technotes +++ b/bacula/technotes @@ -2,6 +2,10 @@ General: +23Aug09 +kes Free Volume in several places. Fixes virtual-changer problem + and possibly bug #1346. +kes Add SD Volume debug code 22Aug09 kes Don't print different filesystem. Will not descend message if directory explicitly excluded