From: Kern Sibbald Date: Fri, 3 Feb 2012 13:36:29 +0000 (+0100) Subject: Implement more robust check in other drives for tape slot wanted X-Git-Tag: Release-7.0.0~292 X-Git-Url: https://git.sur5r.net/?a=commitdiff_plain;h=da910d81527b582052265dfacc1cfb0268d95111;p=bacula%2Fbacula Implement more robust check in other drives for tape slot wanted --- diff --git a/bacula/src/stored/autochanger.c b/bacula/src/stored/autochanger.c index 3d38739f44..67d1780edd 100644 --- a/bacula/src/stored/autochanger.c +++ b/bacula/src/stored/autochanger.c @@ -425,6 +425,7 @@ bool unload_autochanger(DCR *dcr, int loaded) static bool unload_other_drive(DCR *dcr, int slot) { DEVICE *dev = NULL; + DEVICE *dev_save; bool found = false; AUTOCHANGER *changer = dcr->dev->device->changer_res; DEVRES *device; @@ -437,16 +438,35 @@ static bool unload_other_drive(DCR *dcr, int slot) return true; } + /* + * We look for the slot number corresponding to the tape + * we want in other drives, and if possible, unload + * it. + */ + Dmsg0(100, "Wiffle through devices looking for slot\n"); foreach_alist(device, changer->device) { - if (device->dev && device->dev->get_slot() == slot) { + dev = device->dev; + if (!dev) { + continue; + } + dev_save = dcr->dev; + dcr->dev = dev; + if (dev->get_slot() <= 0 && get_autochanger_loaded_slot(dcr) <= 0) { + dcr->dev = dev_save; + continue; + } + dcr->dev = dev_save; + if (dev->get_slot() == slot) { found = true; - dev = device->dev; break; } } if (!found) { + Dmsg1(100, "Slot=%d not found in another device\n", slot); return true; - } + } else { + Dmsg1(100, "Slot=%d found in another device\n", slot); + } /* The Volume we want is on another device. */ if (dev->is_busy()) {