]> git.sur5r.net Git - bacula/bacula/blob - bacula/patches/testing/spoolsize_per_job.patch
ebl add SpoolSize to Job definition
[bacula/bacula] / bacula / patches / testing / spoolsize_per_job.patch
1 Index: src/dird/msgchan.c
2 ===================================================================
3 --- src/dird/msgchan.c  (revision 5107)
4 +++ src/dird/msgchan.c  (working copy)
5 @@ -51,7 +51,7 @@
6  /* Commands sent to Storage daemon */
7  static char jobcmd[]     = "JobId=%s job=%s job_name=%s client_name=%s "
8     "type=%d level=%d FileSet=%s NoAttr=%d SpoolAttr=%d FileSetMD5=%s "
9 -   "SpoolData=%d WritePartAfterJob=%d PreferMountedVols=%d\n";
10 +   "SpoolData=%d SpoolSize=%s WritePartAfterJob=%d PreferMountedVols=%d\n";
11  static char use_storage[] = "use storage=%s media_type=%s pool_name=%s "
12     "pool_type=%s append=%d copy=%d stripe=%d\n";
13  static char use_device[] = "use device=%s\n";
14 @@ -157,7 +157,7 @@
15     POOL_MEM job_name, client_name, fileset_name;
16     int copy = 0;
17     int stripe = 0;
18 -   char ed1[30];
19 +   char ed1[30], ed2[30];
20  
21     sd = jcr->store_bsock;
22     /*
23 @@ -186,8 +186,9 @@
24                job_name.c_str(), client_name.c_str(), 
25                jcr->JobType, jcr->JobLevel,
26                fileset_name.c_str(), !jcr->pool->catalog_files,
27 -              jcr->job->SpoolAttributes, jcr->fileset->MD5, jcr->spool_data, 
28 -              jcr->write_part_after_job, jcr->job->PreferMountedVolumes);
29 +              jcr->job->SpoolAttributes, jcr->fileset->MD5, jcr->spool_data,
30 +              edit_int64(jcr->spool_size, ed2), jcr->write_part_after_job, 
31 +              jcr->job->PreferMountedVolumes);
32     Dmsg1(100, ">stored: %s\n", sd->msg);
33     if (bget_dirmsg(sd) > 0) {
34         Dmsg1(100, "<stored: %s", sd->msg);
35 Index: src/dird/job.c
36 ===================================================================
37 --- src/dird/job.c      (revision 5107)
38 +++ src/dird/job.c      (working copy)
39 @@ -927,6 +927,7 @@
40     jcr->fileset = job->fileset;
41     jcr->messages = job->messages;
42     jcr->spool_data = job->spool_data;
43 +   jcr->spool_size = job->spool_size;
44     jcr->write_part_after_job = job->write_part_after_job;
45     if (jcr->RestoreBootstrap) {
46        free(jcr->RestoreBootstrap);
47 Index: src/dird/dird_conf.c
48 ===================================================================
49 --- src/dird/dird_conf.c        (revision 5107)
50 +++ src/dird/dird_conf.c        (working copy)
51 @@ -295,6 +295,7 @@
52     {"enabled",     store_bool, ITEM(res_job.enabled), 0, ITEM_DEFAULT, true},
53     {"spoolattributes",store_bool, ITEM(res_job.SpoolAttributes), 0, ITEM_DEFAULT, false},
54     {"spooldata",   store_bool, ITEM(res_job.spool_data), 0, ITEM_DEFAULT, false},
55 +   {"spoolsize",   store_size, ITEM(res_job.spool_size), 0, 0, 0},
56     {"rerunfailedlevels",   store_bool, ITEM(res_job.rerun_failed_levels), 0, ITEM_DEFAULT, false},
57     {"prefermountedvolumes", store_bool, ITEM(res_job.PreferMountedVolumes), 0, ITEM_DEFAULT, true},
58     {"runbeforejob", store_short_runscript,  ITEM(res_job.RunScripts),  0, 0, 0},
59 Index: src/dird/dird_conf.h
60 ===================================================================
61 --- src/dird/dird_conf.h        (revision 5107)
62 +++ src/dird/dird_conf.h        (working copy)
63 @@ -380,6 +380,7 @@
64     utime_t RescheduleInterval;        /* Reschedule interval */
65     utime_t JobRetention;              /* job retention period in seconds */
66     uint32_t MaxConcurrentJobs;        /* Maximum concurrent jobs */
67 +   int64_t spool_size;                /* Size of spool file for this job */
68     int RescheduleTimes;               /* Number of times to reschedule job */
69     bool RescheduleOnError;            /* Set to reschedule on error */
70     bool PrefixLinks;                  /* prefix soft links with Where path */
71 Index: src/stored/job.c
72 ===================================================================
73 --- src/stored/job.c    (revision 5107)
74 +++ src/stored/job.c    (working copy)
75 @@ -49,7 +49,7 @@
76  /* Requests from the Director daemon */
77  static char jobcmd[] = "JobId=%d job=%127s job_name=%127s client_name=%127s "
78        "type=%d level=%d FileSet=%127s NoAttr=%d SpoolAttr=%d FileSetMD5=%127s "
79 -      "SpoolData=%d WritePartAfterJob=%d PreferMountedVols=%d\n";
80 +      "SpoolData=%d SpoolSize=%s WritePartAfterJob=%d PreferMountedVols=%d\n";
81  
82  
83  /* Responses sent to Director daemon */
84 @@ -73,6 +73,7 @@
85  {
86     int JobId;
87     char auth_key[100];
88 +   char spool_size[30];
89     BSOCK *dir = jcr->dir_bsock;
90     POOL_MEM job_name, client_name, job, fileset_name, fileset_md5;
91     int JobType, level, spool_attributes, no_attributes, spool_data;
92 @@ -87,9 +88,9 @@
93     stat = sscanf(dir->msg, jobcmd, &JobId, job.c_str(), job_name.c_str(),
94                client_name.c_str(),
95                &JobType, &level, fileset_name.c_str(), &no_attributes,
96 -              &spool_attributes, fileset_md5.c_str(), &spool_data, 
97 +              &spool_attributes, fileset_md5.c_str(), &spool_data, spool_size,
98                &write_part_after_job, &PreferMountedVols);
99 -   if (stat != 13) {
100 +   if (stat != 14) {
101        pm_strcpy(jcr->errmsg, dir->msg);
102        bnet_fsend(dir, BAD_job, stat, jcr->errmsg);
103        Dmsg1(100, ">dird: %s", dir->msg);
104 @@ -124,6 +125,7 @@
105     jcr->no_attributes = no_attributes;
106     jcr->spool_attributes = spool_attributes;
107     jcr->spool_data = spool_data;
108 +   jcr->spool_size = str_to_int64(spool_size);
109     jcr->write_part_after_job = write_part_after_job;
110     jcr->fileset_md5 = get_pool_memory(PM_NAME);
111     pm_strcpy(jcr->fileset_md5, fileset_md5);
112 Index: src/stored/acquire.c
113 ===================================================================
114 --- src/stored/acquire.c        (revision 5107)
115 +++ src/stored/acquire.c        (working copy)
116 @@ -609,7 +609,12 @@
117        if (dcr->attached_to_dev) {
118           detach_dcr_from_dev(dcr);
119        }
120 -      dcr->max_job_spool_size = dev->device->max_job_spool_size;
121 +      /* Use job spoolsize prior to device spoolsize*/
122 +      if (jcr->spool_size) {
123 +        dcr->max_job_spool_size = jcr->spool_size;
124 +      } else {
125 +        dcr->max_job_spool_size = dev->device->max_job_spool_size;
126 +      }
127        dcr->device = dev->device;
128        dcr->dev = dev;
129        attach_dcr_to_dev(dcr);
130 Index: src/jcr.h
131 ===================================================================
132 --- src/jcr.h   (revision 5107)
133 +++ src/jcr.h   (working copy)
134 @@ -246,6 +246,7 @@
135     int replace;                       /* Replace option */
136     int NumVols;                       /* Number of Volume used in pool */
137     int reschedule_count;              /* Number of times rescheduled */
138 +   int64_t spool_size;                /* Spool size for this job */
139     bool spool_data;                   /* Spool data in SD */
140     bool acquired_resource_locks;      /* set if resource locks acquired */
141     bool term_wait_inited;             /* Set when cond var inited */
142 @@ -323,6 +324,7 @@
143     bool spool_attributes;             /* set if spooling attributes */
144     bool no_attributes;                /* set if no attributes wanted */
145     bool spool_data;                   /* set to spool data */
146 +   int64_t spool_size;                /* Spool size for this job */
147     int CurVol;                        /* Current Volume count */
148     DIRRES* director;                  /* Director resource */
149     alist *write_store;                /* list of write storage devices sent by DIR */