From: Kern Sibbald Date: Wed, 21 May 2008 20:09:05 +0000 (+0000) Subject: kes Modify autochanger locking to attempt to avoid race X-Git-Tag: Release-3.0.0~1402 X-Git-Url: https://git.sur5r.net/?a=commitdiff_plain;h=a698b6e3cd8527d96541276cd912496b5ca0e175;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/trunk@7008 91ce42f0-d328-0410-95d8-f526ca767f89 --- diff --git a/bacula/src/stored/autochanger.c b/bacula/src/stored/autochanger.c index 57ad48194b..97c0e1fbc4 100644 --- a/bacula/src/stored/autochanger.c +++ b/bacula/src/stored/autochanger.c @@ -372,9 +372,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; } @@ -483,10 +484,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.3 b/bacula/technotes-2.3 index 1272046672..f4ce34889c 100644 --- a/bacula/technotes-2.3 +++ b/bacula/technotes-2.3 @@ -25,6 +25,9 @@ Add long term statistics job table 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