From: Kern Sibbald Date: Wed, 21 May 2008 20:15:54 +0000 (+0000) Subject: kes Modify autochanger locking to attempt to avoid race X-Git-Tag: Release-2.4.0~32 X-Git-Url: https://git.sur5r.net/?a=commitdiff_plain;h=1b0c652d9fa660085409958c817d19eb5b48400e;p=bacula%2Fbacula kes Modify autochanger locking to attempt to avoid race 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 --- diff --git a/bacula/src/stored/autochanger.c b/bacula/src/stored/autochanger.c index 4ab01cf6bd..28caffb453 100644 --- a/bacula/src/stored/autochanger.c +++ b/bacula/src/stored/autochanger.c @@ -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; } diff --git a/bacula/src/stored/dircmd.c b/bacula/src/stored/dircmd.c index a6208244e5..9387a4ac29 100644 --- a/bacula/src/stored/dircmd.c +++ b/bacula/src/stored/dircmd.c @@ -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(); diff --git a/bacula/technotes-2.1 b/bacula/technotes-2.1 index 6f3a1374e9..46bd3b2fe7 100644 --- a/bacula/technotes-2.1 +++ b/bacula/technotes-2.1 @@ -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