From: Kern Sibbald Date: Thu, 27 Mar 2008 09:57:54 +0000 (+0000) Subject: kes Rework certain SD locking based on gdb tracebacks of deadlocks X-Git-Tag: Release-2.2.9-b7~37 X-Git-Url: https://git.sur5r.net/?a=commitdiff_plain;h=fed6599a1713f5f0ba18e4ff1313f900a3a300b1;p=bacula%2Fbacula kes Rework certain SD locking based on gdb tracebacks of deadlocks sent by Eric. This code now uses only the volume_lock() rather than the reservations lock when at EOM and acquiring a new volume. kes Ensure only one exit point in several subroutines. git-svn-id: https://bacula.svn.sourceforge.net/svnroot/bacula/branches/Branch-2.2@6695 91ce42f0-d328-0410-95d8-f526ca767f89 --- diff --git a/bacula/src/stored/askdir.c b/bacula/src/stored/askdir.c index 6d1d2ce823..c5adcdbe5f 100644 --- a/bacula/src/stored/askdir.c +++ b/bacula/src/stored/askdir.c @@ -252,6 +252,7 @@ bool dir_find_next_appendable_volume(DCR *dcr) { JCR *jcr = dcr->jcr; BSOCK *dir = jcr->dir_bsock; + bool rtn; Dmsg2(200, "dir_find_next_appendable_volume: reserved=%d Vol=%s\n", dcr->reserved_device, dcr->VolumeName); @@ -261,7 +262,7 @@ bool dir_find_next_appendable_volume(DCR *dcr) * the most available could already be mounted on another * drive, so we continue looking for a not in use Volume. */ - lock_reservations(); + lock_volumes(); P(vol_info_mutex); dcr->volume_in_use = false; for (int vol_index=1; vol_index < 40; vol_index++) { @@ -271,8 +272,7 @@ bool dir_find_next_appendable_volume(DCR *dcr) unbash_spaces(dcr->media_type); unbash_spaces(dcr->pool_name); Dmsg1(100, ">dird %s", dir->msg); - bool ok = do_get_volume_info(dcr); - if (ok) { + if (do_get_volume_info(dcr)) { if (!is_volume_in_use(dcr)) { Dmsg0(400, "dir_find_next_appendable_volume return true\n"); if (reserve_volume(dcr, dcr->VolumeName) == 0) { @@ -280,9 +280,8 @@ bool dir_find_next_appendable_volume(DCR *dcr) dcr->dev->print_name()); continue; } - V(vol_info_mutex); - unlock_reservations(); - return true; + rtn = true; + goto get_out; } else { Dmsg1(100, "Volume %s is in use.\n", dcr->VolumeName); dcr->volume_in_use = true; @@ -293,11 +292,13 @@ bool dir_find_next_appendable_volume(DCR *dcr) dcr->dev->print_name()); break; } - + rtn = false; dcr->VolumeName[0] = 0; + +get_out: V(vol_info_mutex); - unlock_reservations(); - return false; + unlock_volumes(); + return rtn; } diff --git a/bacula/src/stored/reserve.c b/bacula/src/stored/reserve.c index 33340c1e6e..bc102f2d1b 100644 --- a/bacula/src/stored/reserve.c +++ b/bacula/src/stored/reserve.c @@ -410,7 +410,6 @@ get_out: */ void switch_device(DCR *dcr, DEVICE *dev) { - // lock_reservations(); DCR save_dcr; dev->dlock(); @@ -589,28 +588,36 @@ void free_volume_list() bool is_volume_in_use(DCR *dcr) { - VOLRES *vol = find_volume(dcr); + bool rtn = false; + VOLRES *vol; + + lock_volumes(); + vol = find_volume(dcr); if (!vol) { Dmsg2(dbglvl, "jid=%u Vol=%s not in use.\n", jid(), dcr->VolumeName); - return false; /* vol not in list */ + goto get_out; /* vol not in list */ } ASSERT(vol->dev != NULL); if (dcr->dev == vol->dev) { /* same device OK */ Dmsg2(dbglvl, "jid=%u Vol=%s on same dev.\n", jid(), dcr->VolumeName); - return false; + goto get_out; } else { Dmsg4(dbglvl, "jid=%u Vol=%s on %s we have %s\n", jid(), dcr->VolumeName, vol->dev->print_name(), dcr->dev->print_name()); } if (!vol->dev->is_busy()) { Dmsg3(dbglvl, "jid=%u Vol=%s dev=%s not busy.\n", jid(), dcr->VolumeName, vol->dev->print_name()); - return false; + goto get_out; } else { Dmsg3(dbglvl, "jid=%u Vol=%s dev=%s busy.\n", jid(), dcr->VolumeName, vol->dev->print_name()); } Dmsg3(dbglvl, "jid=%u Vol=%s in use by %s.\n", jid(), dcr->VolumeName, vol->dev->print_name()); - return true; + rtn = true; + +get_out: + unlock_volumes(); + return rtn; } diff --git a/bacula/src/version.h b/bacula/src/version.h index 9ff870d571..25ca63c7c4 100644 --- a/bacula/src/version.h +++ b/bacula/src/version.h @@ -3,9 +3,9 @@ */ #undef VERSION -#define VERSION "2.2.9-b2" -#define BDATE "24 March 2008" -#define LSMDATE "24Mar08" +#define VERSION "2.2.9-b3" +#define BDATE "27 March 2008" +#define LSMDATE "27Mar08" #define PROG_COPYRIGHT "Copyright (C) %d-2008 Free Software Foundation Europe e.V.\n" #define BYEAR "2008" /* year for copyright messages in progs */ diff --git a/bacula/technotes-2.1 b/bacula/technotes-2.1 index b7dcdbeb15..328050599f 100644 --- a/bacula/technotes-2.1 +++ b/bacula/technotes-2.1 @@ -1,6 +1,14 @@ Technical notes on version 2.2 General: +Beta release Version 2.2.9-b3 +27Mar08 +kes Rework certain SD locking based on gdb tracebacks of deadlocks + sent by Eric. This code now uses only the volume_lock() rather + than the reservations lock when at EOM and acquiring a new + volume. +kes Ensure only one exit point in several subroutines. + 22Mar08 kes Fix to JobMedia fix. kes Fix bug pointed out by Peter Much that causes the StorageId to