]> git.sur5r.net Git - bacula/bacula/commitdiff
Get correct slot when auto unloading a device.
authorKern Sibbald <kern@sibbald.com>
Sat, 31 May 2008 07:17:00 +0000 (07:17 +0000)
committerKern Sibbald <kern@sibbald.com>
Sat, 31 May 2008 07:17:00 +0000 (07:17 +0000)
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
bacula/technotes-2.1

index f29ca9c85a4ef38b16488298bb599e69d9814378..f5870e0ee1d0136e14312f10512782146fe48258 100644 (file)
@@ -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();
index db869752951a9fc6727bb4465279721200bcbfa9..1b14b4db3e5c2722dbce346f329e3c947a7af480 100644 (file)
@@ -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.