]> git.sur5r.net Git - bacula/bacula/blob - bacula/patches/testing/concurent_job.patch
ebl cleanup
[bacula/bacula] / bacula / patches / testing / concurent_job.patch
1
2 This patch try to cleanup MaxConcurrent checks from director
3 It's not usable yet.
4
5
6
7 Index: src/dird/jobq.c
8 ===================================================================
9 --- src/dird/jobq.c     (rĂ©vision 6325)
10 +++ src/dird/jobq.c     (copie de travail)
11 @@ -477,14 +477,14 @@
12            *  put into the ready queue.
13            */
14           if (jcr->acquired_resource_locks) {
15 -            if (jcr->rstore) {
16 -               jcr->rstore->NumConcurrentJobs = 0;
17 -               Dmsg1(200, "Dec rncj=%d\n", jcr->rstore->NumConcurrentJobs);
18 -            }
19 -            if (jcr->wstore) {
20 -               jcr->wstore->NumConcurrentJobs--;
21 -               Dmsg1(200, "Dec wncj=%d\n", jcr->wstore->NumConcurrentJobs);
22 -            }
23 +//            if (jcr->rstore) {
24 +//               jcr->rstore->NumConcurrentJobs = 0;
25 +//               Dmsg1(200, "Dec rncj=%d\n", jcr->rstore->NumConcurrentJobs);
26 +//            }
27 +//            if (jcr->wstore) {
28 +//               jcr->wstore->NumConcurrentJobs--;
29 +//               Dmsg1(200, "Dec wncj=%d\n", jcr->wstore->NumConcurrentJobs);
30 +//            }
31              jcr->client->NumConcurrentJobs--;
32              jcr->job->NumConcurrentJobs--;
33              jcr->acquired_resource_locks = false;
34 @@ -678,69 +678,69 @@
35   */
36  static bool acquire_resources(JCR *jcr)
37  {
38 -   bool skip_this_jcr = false;
39 -
40 -   jcr->acquired_resource_locks = false;
41 -   if (jcr->rstore) {
42 -      Dmsg1(200, "Rstore=%s\n", jcr->rstore->name());
43 -      /*
44 -       * Let only one Restore/Verify job run at a time regardless
45 -       *  of MaxConcurrentjobs.
46 -       */
47 -      if (jcr->rstore->NumConcurrentJobs == 0) {
48 -         jcr->rstore->NumConcurrentJobs = 1;
49 -         Dmsg0(200, "Set rncj=1\n");
50 -      } else {
51 -         Dmsg1(200, "Fail rncj=%d\n", jcr->rstore->NumConcurrentJobs);
52 -         set_jcr_job_status(jcr, JS_WaitStoreRes);
53 -         return false;
54 -      }
55 -   }
56 -
57 -   if (jcr->wstore) {
58 -      Dmsg1(200, "Wstore=%s\n", jcr->wstore->name());
59 -      if (jcr->rstore == jcr->wstore) {           /* deadlock */
60 -         jcr->rstore->NumConcurrentJobs = 0;      /* back out rstore */
61 -         Jmsg(jcr, M_FATAL, 0, _("Job canceled. Attempt to read and write same device.\n"
62 -            "    Read storage \"%s\" (From %s) -- Write storage \"%s\" (From %s)\n"),
63 -            jcr->rstore->name(), jcr->rstore_source, jcr->wstore->name(), jcr->wstore_source);
64 -         set_jcr_job_status(jcr, JS_Canceled);
65 -         return false;
66 -      }
67 -      if (jcr->wstore->NumConcurrentJobs == 0 &&
68 -          jcr->wstore->NumConcurrentJobs < jcr->wstore->MaxConcurrentJobs) {
69 -         /* Simple case, first job */
70 -         jcr->wstore->NumConcurrentJobs = 1;
71 -         Dmsg0(200, "Set wncj=1\n");
72 -      } else if (jcr->wstore->NumConcurrentJobs < jcr->wstore->MaxConcurrentJobs) {
73 -         jcr->wstore->NumConcurrentJobs++;
74 -         Dmsg1(200, "Inc wncj=%d\n", jcr->wstore->NumConcurrentJobs);
75 -      } else if (jcr->rstore) {
76 -         jcr->rstore->NumConcurrentJobs = 0;      /* back out rstore */
77 -         Dmsg1(200, "Fail wncj=%d\n", jcr->wstore->NumConcurrentJobs);
78 -         skip_this_jcr = true;
79 -      } else {
80 -         Dmsg1(200, "Fail wncj=%d\n", jcr->wstore->NumConcurrentJobs);
81 -         skip_this_jcr = true;
82 -      }
83 -   }
84 -   if (skip_this_jcr) {
85 -      set_jcr_job_status(jcr, JS_WaitStoreRes);
86 -      return false;
87 -   }
88 -
89 +//   bool skip_this_jcr = false;
90 +//
91 +//   jcr->acquired_resource_locks = false;
92 +//   if (jcr->rstore) {
93 +//      Dmsg1(200, "Rstore=%s\n", jcr->rstore->name());
94 +//      /*
95 +//       * Let only one Restore/Verify job run at a time regardless
96 +//       *  of MaxConcurrentjobs.
97 +//       */
98 +//      if (jcr->rstore->NumConcurrentJobs == 0) {
99 +//         jcr->rstore->NumConcurrentJobs = 1;
100 +//         Dmsg0(200, "Set rncj=1\n");
101 +//      } else {
102 +//         Dmsg1(200, "Fail rncj=%d\n", jcr->rstore->NumConcurrentJobs);
103 +//         set_jcr_job_status(jcr, JS_WaitStoreRes);
104 +//         return false;
105 +//      }
106 +//   }
107 +//
108 +//   if (jcr->wstore) {
109 +//      Dmsg1(200, "Wstore=%s\n", jcr->wstore->name());
110 +//      if (jcr->rstore == jcr->wstore) {           /* deadlock */
111 +//         jcr->rstore->NumConcurrentJobs = 0;      /* back out rstore */
112 +//         Jmsg(jcr, M_FATAL, 0, _("Job canceled. Attempt to read and write same device.\n"
113 +//            "    Read storage \"%s\" (From %s) -- Write storage \"%s\" (From %s)\n"),
114 +//            jcr->rstore->name(), jcr->rstore_source, jcr->wstore->name(), jcr->wstore_source);
115 +//         set_jcr_job_status(jcr, JS_Canceled);
116 +//         return false;
117 +//      }
118 +//      if (jcr->wstore->NumConcurrentJobs == 0 &&
119 +//          jcr->wstore->NumConcurrentJobs < jcr->wstore->MaxConcurrentJobs) {
120 +//         /* Simple case, first job */
121 +//         jcr->wstore->NumConcurrentJobs = 1;
122 +//         Dmsg0(200, "Set wncj=1\n");
123 +//      } else if (jcr->wstore->NumConcurrentJobs < jcr->wstore->MaxConcurrentJobs) {
124 +//         jcr->wstore->NumConcurrentJobs++;
125 +//         Dmsg1(200, "Inc wncj=%d\n", jcr->wstore->NumConcurrentJobs);
126 +//      } else if (jcr->rstore) {
127 +//         jcr->rstore->NumConcurrentJobs = 0;      /* back out rstore */
128 +//         Dmsg1(200, "Fail wncj=%d\n", jcr->wstore->NumConcurrentJobs);
129 +//         skip_this_jcr = true;
130 +//      } else {
131 +//         Dmsg1(200, "Fail wncj=%d\n", jcr->wstore->NumConcurrentJobs);
132 +//         skip_this_jcr = true;
133 +//      }
134 +//   }
135 +//   if (skip_this_jcr) {
136 +//      set_jcr_job_status(jcr, JS_WaitStoreRes);
137 +//      return false;
138 +//   }
139 +//
140     if (jcr->client->NumConcurrentJobs < jcr->client->MaxConcurrentJobs) {
141        jcr->client->NumConcurrentJobs++;
142     } else {
143 -      /* Back out previous locks */
144 -      if (jcr->wstore) {
145 -         jcr->wstore->NumConcurrentJobs--;
146 -         Dmsg1(200, "Dec wncj=%d\n", jcr->wstore->NumConcurrentJobs);
147 -      }
148 -      if (jcr->rstore) {
149 -         jcr->rstore->NumConcurrentJobs = 0;
150 -         Dmsg1(200, "Dec rncj=%d\n", jcr->rstore->NumConcurrentJobs);
151 -      }
152 +//      /* Back out previous locks */
153 +//      if (jcr->wstore) {
154 +//         jcr->wstore->NumConcurrentJobs--;
155 +//         Dmsg1(200, "Dec wncj=%d\n", jcr->wstore->NumConcurrentJobs);
156 +//      }
157 +//      if (jcr->rstore) {
158 +//         jcr->rstore->NumConcurrentJobs = 0;
159 +//         Dmsg1(200, "Dec rncj=%d\n", jcr->rstore->NumConcurrentJobs);
160 +//      }
161        set_jcr_job_status(jcr, JS_WaitClientRes);
162        return false;
163     }
164 @@ -748,14 +748,14 @@
165        jcr->job->NumConcurrentJobs++;
166     } else {
167        /* Back out previous locks */
168 -      if (jcr->wstore) {
169 -         jcr->wstore->NumConcurrentJobs--;
170 -         Dmsg1(200, "Dec wncj=%d\n", jcr->wstore->NumConcurrentJobs);
171 -      }
172 -      if (jcr->rstore) {
173 -         jcr->rstore->NumConcurrentJobs = 0;
174 -         Dmsg1(200, "Dec rncj=%d\n", jcr->rstore->NumConcurrentJobs);
175 -      }
176 +//      if (jcr->wstore) {
177 +//         jcr->wstore->NumConcurrentJobs--;
178 +//         Dmsg1(200, "Dec wncj=%d\n", jcr->wstore->NumConcurrentJobs);
179 +//      }
180 +//      if (jcr->rstore) {
181 +//         jcr->rstore->NumConcurrentJobs = 0;
182 +//         Dmsg1(200, "Dec rncj=%d\n", jcr->rstore->NumConcurrentJobs);
183 +//      }
184        jcr->client->NumConcurrentJobs--;
185        set_jcr_job_status(jcr, JS_WaitJobRes);
186        return false;