From 668b886f2a6e2c5f41fff59aaecd5b536b1ff2f7 Mon Sep 17 00:00:00 2001 From: Kern Sibbald Date: Thu, 4 Aug 2005 08:49:00 +0000 Subject: [PATCH] - Make reservation system single threaded during the search to avoid two threads competing for the same resource. - Correct a return code in find_suitable_device_for_job() Possibly cause of busy writing to another volume. git-svn-id: https://bacula.svn.sourceforge.net/svnroot/bacula/trunk@2291 91ce42f0-d328-0410-95d8-f526ca767f89 --- bacula/kernstodo | 13 +++++++------ bacula/kes-1.37 | 6 ++++++ bacula/src/stored/acquire.c | 2 +- bacula/src/stored/reserve.c | 9 ++++++++- bacula/src/stored/wait.c | 1 + bacula/src/version.h | 4 ++-- 6 files changed, 25 insertions(+), 10 deletions(-) diff --git a/bacula/kernstodo b/bacula/kernstodo index b8da8d6a10..d31a541110 100644 --- a/bacula/kernstodo +++ b/bacula/kernstodo @@ -1,5 +1,5 @@ Kern's ToDo List - 24 July 2005 + 04 August 2005 Major development: Project Developer @@ -10,11 +10,8 @@ Version 1.37 Kern (see below) Final items for 1.37 before release: 1. Fix bugs - Tape xxx in drive 0, requested in drive 1 -- Multi-drive changer seems to only use drive 0 - Multiple drives don't seem to be opened. -- Why isn't the DEVICE structure defined when doing - a reservation? - The mount command does not work with drives other than 0. +- Look at fixing restore status stats in SD. - --without-openssl breaks at least on Solaris. 9. Run the regression scripts on Solaris and FreeBSD @@ -23,7 +20,6 @@ Final items for 1.37 before release: - Arno had to do -- to get update slots=x to work UPDATE Media SET InChanger=0,Slot=0 WHERE InChanger>0 AND Slot>0; (MySQL) - Document: - Document cleaning up the spool files: db, pid, state, bsr, mail, conmsg, spool @@ -1437,3 +1433,8 @@ Block Position: 0 - Add better documentation on how restores can be done 8. Take one more try at making DVD writing work (no go) 7. Write a bacula-web document +- Why isn't the DEVICE structure defined when doing + a reservation? +- Multi-drive changer seems to only use drive 0 + Multiple drives don't seem to be opened. + diff --git a/bacula/kes-1.37 b/bacula/kes-1.37 index ba38515cca..a047660cf3 100644 --- a/bacula/kes-1.37 +++ b/bacula/kes-1.37 @@ -4,6 +4,12 @@ General: Changes to 1.37.34: +04Aug03 +- Make reservation system single threaded during the + search to avoid two threads competing for the same + resource. +- Correct a return code in find_suitable_device_for_job() + Possibly cause of "busy writing to another volume". 03Aug03 - Modify open() for tape so nonblocking really works. - Use fcntl() to reset blocking status rather than close() diff --git a/bacula/src/stored/acquire.c b/bacula/src/stored/acquire.c index 6e82b61dbf..f0ceb6d6a5 100644 --- a/bacula/src/stored/acquire.c +++ b/bacula/src/stored/acquire.c @@ -354,7 +354,7 @@ DCR *acquire_device_for_append(DCR *dcr) free_unused_volume(dcr); } if (dev->num_writers != 0 || dev->reserved_device) { - Jmsg(jcr, M_FATAL, 0, _("Wanted Volume \"%s\", but device %s is busy writing on \"%s\" .\n"), + Jmsg3(jcr, M_FATAL, 0, _("Wanted Volume \"%s\", but device %s is busy writing on \"%s\" .\n"), dcr->VolumeName, dev->print_name(), dev->VolHdr.VolumeName); goto get_out; } diff --git a/bacula/src/stored/reserve.c b/bacula/src/stored/reserve.c index fdaae01386..610093cbbf 100644 --- a/bacula/src/stored/reserve.c +++ b/bacula/src/stored/reserve.c @@ -58,6 +58,7 @@ public: static dlist *vol_list = NULL; static pthread_mutex_t vol_list_lock = PTHREAD_MUTEX_INITIALIZER; +static pthread_mutex_t search_lock = PTHREAD_MUTEX_INITIALIZER; /* Forward referenced functions */ static int can_reserve_drive(DCR *dcr, bool PerferMountedVols); @@ -385,7 +386,7 @@ done: bool find_suitable_device_for_job(JCR *jcr, RCTX &rctx) { bool first = true; - bool ok = false; + bool ok; DCR *dcr = NULL; DIRSTORE *store; char *device_name; @@ -393,6 +394,8 @@ bool find_suitable_device_for_job(JCR *jcr, RCTX &rctx) init_jcr_device_wait_timers(jcr); for ( ;; ) { int need_wait = false; + ok = false; + P(search_lock); foreach_alist(store, jcr->dirstore) { rctx.store = store; foreach_alist(device_name, store->device) { @@ -409,7 +412,11 @@ bool find_suitable_device_for_job(JCR *jcr, RCTX &rctx) /* otherwise error */ // rctx->errors.push(bstrdup(jcr->errmsg)); } + if (ok) { + break; + } } + V(search_lock); /* * If there is some device for which we can wait, then * wait and try again until the wait time expires diff --git a/bacula/src/stored/wait.c b/bacula/src/stored/wait.c index 28d081ba10..39aad6a97d 100644 --- a/bacula/src/stored/wait.c +++ b/bacula/src/stored/wait.c @@ -206,6 +206,7 @@ bool wait_for_device(JCR *jcr, bool first) now = time(NULL); jcr->rem_wait_sec -= (now - start); +/* Not turned on yet */ #ifdef needed /* Note, this always triggers the first time. We want that. */ if (me->heartbeat_interval) { diff --git a/bacula/src/version.h b/bacula/src/version.h index b5d36d79ec..854f38da65 100644 --- a/bacula/src/version.h +++ b/bacula/src/version.h @@ -1,8 +1,8 @@ /* */ #undef VERSION #define VERSION "1.37.34" -#define BDATE "03 August 2005" -#define LSMDATE "03Aug05" +#define BDATE "04 August 2005" +#define LSMDATE "04Aug05" /* Debug flags */ #undef DEBUG -- 2.39.5