From d80e56d26486b97df64fc6a0e9a0ae4420096df9 Mon Sep 17 00:00:00 2001 From: Kern Sibbald Date: Sat, 31 May 2008 07:17:00 +0000 Subject: [PATCH] Get correct slot when auto unloading a device. git-svn-id: https://bacula.svn.sourceforge.net/svnroot/bacula/branches/Branch-2.2@7069 91ce42f0-d328-0410-95d8-f526ca767f89 --- bacula/src/stored/autochanger.c | 22 +++++++++++++++++----- bacula/technotes-2.1 | 2 ++ 2 files changed, 19 insertions(+), 5 deletions(-) diff --git a/bacula/src/stored/autochanger.c b/bacula/src/stored/autochanger.c index f29ca9c85a..f5870e0ee1 100644 --- a/bacula/src/stored/autochanger.c +++ b/bacula/src/stored/autochanger.c @@ -257,6 +257,7 @@ int get_autochanger_loaded_slot(DCR *dcr) if (dev->get_slot() > 0) { return dev->get_slot(); } + /* Virtual disk autochanger */ if (dcr->device->changer_command[0] == 0) { return 1; @@ -433,6 +434,9 @@ static bool unload_other_drive(DCR *dcr, int slot) return unload_dev(dcr, dev); } +/* + * Unconditionally unload a specified drive + */ bool unload_dev(DCR *dcr, DEVICE *dev) { JCR *jcr = dcr->jcr; @@ -442,9 +446,21 @@ bool unload_dev(DCR *dcr, DEVICE *dev) DEVICE *save_dev; int save_slot; - if (!changer || dev->get_slot() <= 0) { + if (!changer) { return false; } + + save_dev = dcr->dev; /* save dcr device */ + dcr->dev = dev; /* temporarily point dcr at other device */ + + if (dev->get_slot() <= 0 && get_autochanger_loaded_slot(dcr) <= 0) { + dcr->VolCatInfo.Slot = save_slot; + dcr->dev = save_dev; + return false; + } + save_slot = dcr->VolCatInfo.Slot; + dcr->VolCatInfo.Slot = dev->get_slot(); + dev->dlock(); POOLMEM *changer_cmd = get_pool_memory(PM_FNAME); @@ -457,10 +473,6 @@ bool unload_dev(DCR *dcr, DEVICE *dev) Dmsg2(100, "Issuing autochanger \"unload slot %d, drive %d\" command.\n", dev->get_slot(), dev->drive_index); - save_dev = dcr->dev; - dcr->dev = dev; - save_slot = dcr->VolCatInfo.Slot; - dcr->VolCatInfo.Slot = dev->get_slot(); changer_cmd = edit_device_codes(dcr, changer_cmd, dcr->device->changer_command, "unload"); dev->close(); diff --git a/bacula/technotes-2.1 b/bacula/technotes-2.1 index db86975295..1b14b4db3e 100644 --- a/bacula/technotes-2.1 +++ b/bacula/technotes-2.1 @@ -1,6 +1,8 @@ Technical notes on version 2.2 General: +31May08 +kes Get correct slot when auto unloading a device. 30May08 kes Fix multiple media restore. kes Make DEVICE Slot private and access it via a method. -- 2.39.2