]> git.sur5r.net Git - bacula/bacula/commitdiff
kes Modify autochanger locking to attempt to avoid race
authorKern Sibbald <kern@sibbald.com>
Wed, 21 May 2008 20:15:54 +0000 (20:15 +0000)
committerKern Sibbald <kern@sibbald.com>
Wed, 21 May 2008 20:15:54 +0000 (20:15 +0000)
     conditions.
kes  Make sure device not busy before doing label command.

git-svn-id: https://bacula.svn.sourceforge.net/svnroot/bacula/branches/Branch-2.2@7009 91ce42f0-d328-0410-95d8-f526ca767f89

bacula/src/stored/autochanger.c
bacula/src/stored/dircmd.c
bacula/technotes-2.1

index 4ab01cf6bd50bcab7deaa733e413f2318b73cc1b..28caffb45340cafc082a537844c4d4107df9659d 100644 (file)
@@ -371,9 +371,10 @@ bool unload_autochanger(DCR *dcr, int loaded)
          dev->Slot = 0;            /* nothing loaded */
       }
       dev->clear_unload();
+      unlock_changer(dcr);
+
       free_volume(dev);            /* Free any volume associated with this drive */
       free_pool_memory(changer);
-      unlock_changer(dcr);
    }
    return ok;
 }
@@ -482,10 +483,12 @@ bool unload_dev(DCR *dcr, DEVICE *dev)
       dev->Slot = 0;           /* nothing loaded */
       Dmsg0(100, "Slot unloaded\n");
    }
-   free_volume(dev);               /* Free any volume associated with this drive */
    dev->clear_unload();
    unlock_changer(dcr);
+
    dev->dunlock();
+
+   free_volume(dev);               /* Free any volume associated with this drive */
    free_pool_memory(changer_cmd);
    return ok;
 }
index a6208244e59928797ab3da2a8fc7bc81de6f3367..9387a4ac29b5518acc55849d16dec11f6817327f 100644 (file)
@@ -388,7 +388,7 @@ static bool do_label(JCR *jcr, int relabel)
       if (dcr) {
          dev = dcr->dev;
          dev->dlock();                 /* Use P to avoid indefinite block */
-         if (!dev->is_open()) {
+         if (!dev->is_open() && !dev->is_busy()) {
             Dmsg1(400, "Can %slabel. Device is not open\n", relabel?"re":"");
             label_volume_if_ok(dcr, oldname, newname, poolname, slot, relabel);
             dev->close();
index 6f3a1374e9ca328a4f2c12287b84b7880adc3341..46bd3b2fe706475cfbaf2621c620ffee7bc7854d 100644 (file)
@@ -3,6 +3,9 @@
 General:
 
 21May08
+kes  Modify autochanger locking to attempt to avoid race
+     conditions.
+kes  Make sure device not busy before doing label command.
 kes  Display open() errors except when polling. Previously too 
      many were suppressed.  This should fix bug #1070.
 kes  Fix Win32 reparse points. Bacula will not recurse into any