From 470bcaafb2aa49e64d14854b9a9fca74e2cf4bf4 Mon Sep 17 00:00:00 2001 From: Kern Sibbald Date: Tue, 1 Jun 2004 20:10:04 +0000 Subject: [PATCH] Make restore jobs wait for exclusive use of Storage device git-svn-id: https://bacula.svn.sourceforge.net/svnroot/bacula/trunk@1381 91ce42f0-d328-0410-95d8-f526ca767f89 --- bacula/src/dird/jobq.c | 25 ++++++++++++++++++++++++- bacula/src/jcr.h | 1 + bacula/src/version.h | 4 ++-- 3 files changed, 27 insertions(+), 3 deletions(-) diff --git a/bacula/src/dird/jobq.c b/bacula/src/dird/jobq.c index 9fc62f3f8f..112584fcd4 100755 --- a/bacula/src/dird/jobq.c +++ b/bacula/src/dird/jobq.c @@ -443,6 +443,9 @@ static void *jobq_server(void *arg) */ if (jcr->acquired_resource_locks) { jcr->store->NumConcurrentJobs--; + if (jcr->JobType == JT_RESTORE) { + jcr->store->MaxConcurrentJobs = jcr->saveMaxConcurrentJobs; + } jcr->client->NumConcurrentJobs--; jcr->job->NumConcurrentJobs--; } @@ -532,17 +535,33 @@ static void *jobq_server(void *arg) set_jcr_job_status(jcr, JS_WaitPriority); break; } - if (jcr->store->NumConcurrentJobs < jcr->store->MaxConcurrentJobs) { + if (jcr->JobType == JT_RESTORE) { + /* Let only one Restore job run at a time regardless of MaxConcurrentJobs */ + if (jcr->store->NumConcurrentJobs == 0) { + jcr->store->NumConcurrentJobs++; + jcr->saveMaxConcurrentJobs = jcr->store->MaxConcurrentJobs; + jcr->store->MaxConcurrentJobs = 1; + } else { + set_jcr_job_status(jcr, JS_WaitStoreRes); + je = jn; + continue; + } + } else if (jcr->store->NumConcurrentJobs < jcr->store->MaxConcurrentJobs) { jcr->store->NumConcurrentJobs++; } else { set_jcr_job_status(jcr, JS_WaitStoreRes); je = jn; continue; } + if (jcr->client->NumConcurrentJobs < jcr->client->MaxConcurrentJobs) { jcr->client->NumConcurrentJobs++; } else { + /* Back out previous locks */ jcr->store->NumConcurrentJobs--; + if (jcr->JobType == JT_RESTORE) { + jcr->store->MaxConcurrentJobs = jcr->saveMaxConcurrentJobs; + } set_jcr_job_status(jcr, JS_WaitClientRes); je = jn; continue; @@ -550,7 +569,11 @@ static void *jobq_server(void *arg) if (jcr->job->NumConcurrentJobs < jcr->job->MaxConcurrentJobs) { jcr->job->NumConcurrentJobs++; } else { + /* Back out previous locks */ jcr->store->NumConcurrentJobs--; + if (jcr->JobType == JT_RESTORE) { + jcr->store->MaxConcurrentJobs = jcr->saveMaxConcurrentJobs; + } jcr->client->NumConcurrentJobs--; set_jcr_job_status(jcr, JS_WaitJobRes); je = jn; diff --git a/bacula/src/jcr.h b/bacula/src/jcr.h index 6f037c77ab..720d3ef432 100644 --- a/bacula/src/jcr.h +++ b/bacula/src/jcr.h @@ -175,6 +175,7 @@ struct JCR { uint32_t RestoreJobId; /* Id specified by UA */ POOLMEM *client_uname; /* client uname */ int replace; /* Replace option */ + int saveMaxConcurrentJobs; /* save for restore jobs */ bool acquired_resource_locks; /* set if resource locks acquired */ int NumVols; /* Number of Volume used in pool */ int reschedule_count; /* Number of times rescheduled */ diff --git a/bacula/src/version.h b/bacula/src/version.h index a33d94ca73..70903504ac 100644 --- a/bacula/src/version.h +++ b/bacula/src/version.h @@ -2,8 +2,8 @@ #undef VERSION #define VERSION "1.34.3" #define VSTRING "1" -#define BDATE "31 May 2004" -#define LSMDATE "31May04" +#define BDATE "01 June 2004" +#define LSMDATE "01Jun04" /* Debug flags */ #undef DEBUG -- 2.39.5