]> git.sur5r.net Git - bacula/bacula/blob - bacula/patches/2.2.x/2.2.6-maxconcurrentjobs.patch
Added preliminary AFS acl support. The code may need some testing on a real AFS enabl...
[bacula/bacula] / bacula / patches / 2.2.x / 2.2.6-maxconcurrentjobs.patch
1
2  This patch corrects a problem where the maximum concurrent storage
3  jobs counter gets out of sync during restore jobs causing jobs to
4  "wait on max Storage jobs".  This patch fixes bug #1009.
5
6  Apply this patch to 2.2.6 and probably any 2.2.x version with the
7  following:
8
9  cd <bacula-source>
10  patch -p0 <2.2.6-maxconcurrentjobs.patch
11  ./configure <your-options>
12  make
13  ...
14  make install
15
16
17 Index: src/dird/jobq.c
18 ===================================================================
19 --- src/dird/jobq.c     (revision 6019)
20 +++ src/dird/jobq.c     (working copy)
21 @@ -1,23 +1,4 @@
22  /*
23 - * Bacula job queue routines.
24 - *
25 - *  This code consists of three queues, the waiting_jobs
26 - *  queue, where jobs are initially queued, the ready_jobs
27 - *  queue, where jobs are placed when all the resources are
28 - *  allocated and they can immediately be run, and the
29 - *  running queue where jobs are placed when they are
30 - *  running.
31 - *
32 - *  Kern Sibbald, July MMIII
33 - *
34 - *   Version $Id$
35 - *
36 - *  This code was adapted from the Bacula workq, which was
37 - *    adapted from "Programming with POSIX Threads", by
38 - *    David R. Butenhof
39 - *
40 - */
41 -/*
42     Bacula® - The Network Backup Solution
43  
44     Copyright (C) 2003-2007 Free Software Foundation Europe e.V.
45 @@ -44,6 +25,25 @@
46     (FSFE), Fiduciary Program, Sumatrastrasse 25, 8006 Zürich,
47     Switzerland, email:ftf@fsfeurope.org.
48  */
49 +/*
50 + * Bacula job queue routines.
51 + *
52 + *  This code consists of three queues, the waiting_jobs
53 + *  queue, where jobs are initially queued, the ready_jobs
54 + *  queue, where jobs are placed when all the resources are
55 + *  allocated and they can immediately be run, and the
56 + *  running queue where jobs are placed when they are
57 + *  running.
58 + *
59 + *  Kern Sibbald, July MMIII
60 + *
61 + *   Version $Id$
62 + *
63 + *  This code was adapted from the Bacula workq, which was
64 + *    adapted from "Programming with POSIX Threads", by
65 + *    David R. Butenhof
66 + *
67 + */
68  
69  #include "bacula.h"
70  #include "dird.h"
71 @@ -453,6 +453,7 @@
72              }
73           }
74           jq->running_jobs->append(je);
75 +//       set_jcr_in_tsd(jcr);
76           Dmsg1(2300, "Took jobid=%d from ready and appended to run\n", jcr->JobId);
77  
78           /* Release job queue lock */
79 @@ -682,14 +683,13 @@
80     jcr->acquired_resource_locks = false;
81     if (jcr->rstore) {
82        Dmsg1(200, "Rstore=%s\n", jcr->rstore->name());
83 -      if (jcr->rstore->NumConcurrentJobs == 0 &&
84 -          jcr->rstore->NumConcurrentJobs < jcr->rstore->MaxConcurrentJobs) {
85 -         /* Simple case, first job */
86 +      /*
87 +       * Let only one Restore/Verify job run at a time regardless
88 +       *  of MaxConcurrentjobs.
89 +       */
90 +      if (jcr->rstore->NumConcurrentJobs == 0) {
91           jcr->rstore->NumConcurrentJobs = 1;
92           Dmsg0(200, "Set rncj=1\n");
93 -      } else if (jcr->rstore->NumConcurrentJobs < jcr->rstore->MaxConcurrentJobs) {
94 -         jcr->rstore->NumConcurrentJobs++;
95 -         Dmsg1(200, "Inc rncj=%d\n", jcr->rstore->NumConcurrentJobs);
96        } else {
97           Dmsg1(200, "Fail rncj=%d\n", jcr->rstore->NumConcurrentJobs);
98           set_jcr_job_status(jcr, JS_WaitStoreRes);
99 @@ -700,7 +700,7 @@
100     if (jcr->wstore) {
101        Dmsg1(200, "Wstore=%s\n", jcr->wstore->name());
102        if (jcr->rstore == jcr->wstore) {           /* deadlock */
103 -         jcr->rstore->NumConcurrentJobs--;        /* back out rstore */
104 +         jcr->rstore->NumConcurrentJobs = 0;      /* back out rstore */
105           Jmsg(jcr, M_FATAL, 0, _("Job canceled. Attempt to read and write same device.\n"
106              "    Read storage \"%s\" (From %s) -- Write storage \"%s\" (From %s)\n"), 
107              jcr->rstore->name(), jcr->rstore_source, jcr->wstore->name(), jcr->wstore_source);
108 @@ -716,7 +716,7 @@
109           jcr->wstore->NumConcurrentJobs++;
110           Dmsg1(200, "Inc wncj=%d\n", jcr->wstore->NumConcurrentJobs);
111        } else if (jcr->rstore) {
112 -         jcr->rstore->NumConcurrentJobs--;        /* back out rstore */
113 +         jcr->rstore->NumConcurrentJobs = 0;      /* back out rstore */
114           Dmsg1(200, "Fail wncj=%d\n", jcr->wstore->NumConcurrentJobs);
115           skip_this_jcr = true;
116        } else {
117 @@ -738,7 +738,7 @@
118           Dmsg1(200, "Dec wncj=%d\n", jcr->wstore->NumConcurrentJobs);
119        }
120        if (jcr->rstore) {
121 -         jcr->rstore->NumConcurrentJobs--;  
122 +         jcr->rstore->NumConcurrentJobs = 0;
123           Dmsg1(200, "Dec rncj=%d\n", jcr->rstore->NumConcurrentJobs);
124        }
125        set_jcr_job_status(jcr, JS_WaitClientRes);
126 @@ -753,7 +753,7 @@
127           Dmsg1(200, "Dec wncj=%d\n", jcr->wstore->NumConcurrentJobs);
128        }
129        if (jcr->rstore) {
130 -         jcr->rstore->NumConcurrentJobs--;
131 +         jcr->rstore->NumConcurrentJobs = 0;
132           Dmsg1(200, "Dec rncj=%d\n", jcr->rstore->NumConcurrentJobs);
133        }
134        jcr->client->NumConcurrentJobs--;