]> git.sur5r.net Git - bacula/bacula/blob - bacula/patches/1.36.1/1.36.1-pool.patch
ebl update
[bacula/bacula] / bacula / patches / 1.36.1 / 1.36.1-pool.patch
1
2  This patch should hold jobs in the Director's start queue if
3  more than one simultaneous backup job wants to use the same
4  Storage device with two different Pools (i.e. 2 Volumes).
5  Apply the patch to version 1.36.1 with:
6
7  cd <bacula-source>
8  patch -p0 <1.36.1-pool.patch
9  make
10  make install
11  ...
12
13 Index: src/dird/jobq.c
14 ===================================================================
15 RCS file: /cvsroot/bacula/bacula/src/dird/jobq.c,v
16 retrieving revision 1.25
17 retrieving revision 1.26
18 diff -u -r1.25 -r1.26
19 --- src/dird/jobq.c     24 Sep 2004 12:30:14 -0000      1.25
20 +++ src/dird/jobq.c     3 Dec 2004 21:00:18 -0000       1.26
21 @@ -10,7 +10,7 @@
22   *
23   *  Kern Sibbald, July MMIII
24   *
25 - *   Version $Id$
26 + *   Version $Id$
27   *
28   *  This code was adapted from the Bacula workq, which was
29   *    adapted from "Programming with POSIX Threads", by
30 @@ -40,6 +40,7 @@
31  #include "bacula.h"
32  #include "dird.h"
33  
34 +extern JCR *jobs;
35  
36  /* Forward referenced functions */
37  extern "C" void *jobq_server(void *arg);
38 @@ -47,6 +48,8 @@
39  
40  static int   start_server(jobq_t *jq);
41  
42 +
43 +
44  /*   
45   * Initialize a job queue
46   *
47 @@ -544,6 +547,7 @@
48          for ( ; je;  ) {
49             /* je is current job item on the queue, jn is the next one */
50             JCR *jcr = je->jcr;
51 +           bool skip_this_jcr = false;
52             jobq_item_t *jn = (jobq_item_t *)jq->waiting_jobs->next(je);
53              Dmsg3(300, "Examining Job=%d JobPri=%d want Pri=%d\n",
54                jcr->JobId, jcr->JobPriority, Priority);
55 @@ -560,14 +564,40 @@
56                   jcr->store->MaxConcurrentJobs = 1;
57                } else {
58                   set_jcr_job_status(jcr, JS_WaitStoreRes);
59 -                 je = jn;
60 +                 je = jn;            /* point to next waiting job */
61                   continue;
62                }
63 +           /* We are not doing a Restore or Verify */
64 +           } else if (jcr->store->NumConcurrentJobs == 0 &&
65 +                      jcr->store->NumConcurrentJobs < jcr->store->MaxConcurrentJobs) {
66 +               /* Simple case, first job */
67 +               jcr->store->NumConcurrentJobs = 1;  
68             } else if (jcr->store->NumConcurrentJobs < jcr->store->MaxConcurrentJobs) {
69 -              jcr->store->NumConcurrentJobs++;
70 -           } else {
71 +              /*
72 +               * At this point, we already have at least one Job running 
73 +               *  for this Storage daemon, so we must ensure that there
74 +               *  is no Volume conflict. In general, it should be OK, if
75 +               *  all Jobs pull from the same Pool, so we check the Pools.
76 +               */
77 +               JCR *njcr;
78 +               lock_jcr_chain();
79 +               for (njcr=jobs; njcr; njcr=njcr->next) {
80 +                  if (njcr->JobId == 0 || njcr == jcr) {
81 +                     continue;
82 +                  }
83 +                  if (njcr->pool != jcr->pool) {
84 +                     skip_this_jcr = true;
85 +                     break;
86 +                  }
87 +               }  
88 +               unlock_jcr_chain();
89 +               if (!skip_this_jcr) {
90 +                  jcr->store->NumConcurrentJobs++;    
91 +               }
92 +           } 
93 +           if (skip_this_jcr) {
94                set_jcr_job_status(jcr, JS_WaitStoreRes);
95 -              je = jn;
96 +              je = jn;               /* point to next waiting job */
97                continue;
98             }
99  
100 @@ -580,7 +610,7 @@
101                   jcr->store->MaxConcurrentJobs = jcr->saveMaxConcurrentJobs;  
102                }
103                set_jcr_job_status(jcr, JS_WaitClientRes);
104 -              je = jn;
105 +              je = jn;               /* point to next waiting job */
106                continue;
107             }
108             if (jcr->job->NumConcurrentJobs < jcr->job->MaxConcurrentJobs) {
109 @@ -593,7 +623,7 @@
110                }
111                jcr->client->NumConcurrentJobs--;
112                set_jcr_job_status(jcr, JS_WaitJobRes);
113 -              je = jn;
114 +              je = jn;               /* Point to next waiting job */
115                continue;
116             }
117             /* Got all locks, now remove it from wait queue and append it
118 @@ -603,7 +633,7 @@
119             jq->waiting_jobs->remove(je);
120             jq->ready_jobs->append(je);
121              Dmsg1(300, "moved JobId=%d from wait to ready queue\n", je->jcr->JobId);
122 -           je = jn;
123 +           je = jn;                  /* Point to next waiting job */
124          } /* end for loop */
125          break;
126        } /* end while loop */
127 Index: src/lib/jcr.c
128 ===================================================================
129 RCS file: /cvsroot/bacula/bacula/src/lib/jcr.c,v
130 retrieving revision 1.61
131 retrieving revision 1.62
132 diff -u -r1.61 -r1.62
133 --- src/lib/jcr.c       15 Nov 2004 22:43:33 -0000      1.61
134 +++ src/lib/jcr.c       3 Dec 2004 21:00:19 -0000       1.62
135 @@ -3,7 +3,7 @@
136   *
137   *  Kern E. Sibbald, December 2000
138   *
139 - *  Version $Id$
140 + *  Version $Id$
141   *
142   *  These routines are thread safe.
143   *
144 @@ -43,7 +43,7 @@
145  dlist *last_jobs = NULL;
146  const int max_last_jobs = 10;
147  
148 -static JCR *jobs = NULL;             /* pointer to JCR chain */
149 +JCR *jobs = NULL;                    /* pointer to JCR chain */
150  static brwlock_t lock;               /* lock for last jobs and JCR chain */
151  
152  void init_last_jobs_list()