From d7ae38b770c5aefa185fca3f015ca8790d6673f9 Mon Sep 17 00:00:00 2001 From: Eric Bollengier Date: Sun, 30 Sep 2007 16:27:20 +0000 Subject: [PATCH] ebl Add an option that permit to specify spool size in job definition. git-svn-id: https://bacula.svn.sourceforge.net/svnroot/bacula/trunk@5694 91ce42f0-d328-0410-95d8-f526ca767f89 --- bacula/src/dird/dird_conf.c | 4 ++++ bacula/src/dird/dird_conf.h | 1 + bacula/src/dird/job.c | 1 + bacula/src/dird/msgchan.c | 7 ++++--- bacula/src/jcr.h | 2 ++ bacula/src/stored/acquire.c | 7 ++++++- bacula/src/stored/job.c | 8 +++++--- bacula/technotes-2.3 | 4 ++++ 8 files changed, 27 insertions(+), 7 deletions(-) diff --git a/bacula/src/dird/dird_conf.c b/bacula/src/dird/dird_conf.c index 870a32120a..eb04adaa00 100644 --- a/bacula/src/dird/dird_conf.c +++ b/bacula/src/dird/dird_conf.c @@ -296,6 +296,7 @@ RES_ITEM job_items[] = { {"optimizejobscheduling",store_bool, ITEM(res_job.OptimizeJobScheduling), 0, ITEM_DEFAULT, false}, {"spoolattributes",store_bool, ITEM(res_job.SpoolAttributes), 0, ITEM_DEFAULT, false}, {"spooldata", store_bool, ITEM(res_job.spool_data), 0, ITEM_DEFAULT, false}, + {"spoolsize", store_size, ITEM(res_job.spool_size), 0, 0, 0}, {"rerunfailedlevels", store_bool, ITEM(res_job.rerun_failed_levels), 0, ITEM_DEFAULT, false}, {"prefermountedvolumes", store_bool, ITEM(res_job.PreferMountedVolumes), 0, ITEM_DEFAULT, true}, {"runbeforejob", store_short_runscript, ITEM(res_job.RunScripts), 0, 0, 0}, @@ -607,6 +608,9 @@ void dump_resource(int type, RES *reshdr, void sendit(void *sock, const char *fm res->res_job.RescheduleOnError, res->res_job.RescheduleTimes, edit_uint64_with_commas(res->res_job.RescheduleInterval, ed1), res->res_job.spool_data, res->res_job.write_part_after_job); + if (res->res_job.spool_size) { + sendit(sock, _(" SpoolSize=%s\n"), edit_uint64(res->res_job.spool_size, ed1)); + } if (res->res_job.JobType == JT_MIGRATE) { sendit(sock, _(" SelectionType=%d\n"), res->res_job.selection_type); } diff --git a/bacula/src/dird/dird_conf.h b/bacula/src/dird/dird_conf.h index 2df2d6ad90..61e4a32cdb 100644 --- a/bacula/src/dird/dird_conf.h +++ b/bacula/src/dird/dird_conf.h @@ -380,6 +380,7 @@ public: utime_t RescheduleInterval; /* Reschedule interval */ utime_t JobRetention; /* job retention period in seconds */ uint32_t MaxConcurrentJobs; /* Maximum concurrent jobs */ + int64_t spool_size; /* Size of spool file for this job */ int RescheduleTimes; /* Number of times to reschedule job */ bool RescheduleOnError; /* Set to reschedule on error */ bool PrefixLinks; /* prefix soft links with Where path */ diff --git a/bacula/src/dird/job.c b/bacula/src/dird/job.c index 3b90108b35..df9751a212 100644 --- a/bacula/src/dird/job.c +++ b/bacula/src/dird/job.c @@ -976,6 +976,7 @@ void set_jcr_defaults(JCR *jcr, JOB *job) jcr->fileset = job->fileset; jcr->messages = job->messages; jcr->spool_data = job->spool_data; + jcr->spool_size = job->spool_size; jcr->write_part_after_job = job->write_part_after_job; if (jcr->RestoreBootstrap) { free(jcr->RestoreBootstrap); diff --git a/bacula/src/dird/msgchan.c b/bacula/src/dird/msgchan.c index 935a9d08ab..bca443577f 100644 --- a/bacula/src/dird/msgchan.c +++ b/bacula/src/dird/msgchan.c @@ -51,7 +51,7 @@ static pthread_mutex_t mutex = PTHREAD_MUTEX_INITIALIZER; /* Commands sent to Storage daemon */ static char jobcmd[] = "JobId=%s job=%s job_name=%s client_name=%s " "type=%d level=%d FileSet=%s NoAttr=%d SpoolAttr=%d FileSetMD5=%s " - "SpoolData=%d WritePartAfterJob=%d PreferMountedVols=%d\n"; + "SpoolData=%d SpoolSize=%s WritePartAfterJob=%d PreferMountedVols=%d\n"; static char use_storage[] = "use storage=%s media_type=%s pool_name=%s " "pool_type=%s append=%d copy=%d stripe=%d\n"; static char use_device[] = "use device=%s\n"; @@ -157,7 +157,7 @@ bool start_storage_daemon_job(JCR *jcr, alist *rstore, alist *wstore) POOL_MEM job_name, client_name, fileset_name; int copy = 0; int stripe = 0; - char ed1[30]; + char ed1[30], ed2[30]; sd = jcr->store_bsock; /* @@ -187,7 +187,8 @@ bool start_storage_daemon_job(JCR *jcr, alist *rstore, alist *wstore) jcr->JobType, jcr->JobLevel, fileset_name.c_str(), !jcr->pool->catalog_files, jcr->job->SpoolAttributes, jcr->fileset->MD5, jcr->spool_data, - jcr->write_part_after_job, jcr->job->PreferMountedVolumes); + edit_int64(jcr->spool_size, ed2), jcr->write_part_after_job, + jcr->job->PreferMountedVolumes); Dmsg1(100, ">stored: %s\n", sd->msg); if (bget_dirmsg(sd) > 0) { Dmsg1(100, "msg); diff --git a/bacula/src/jcr.h b/bacula/src/jcr.h index e54a97837a..ad28b3485c 100644 --- a/bacula/src/jcr.h +++ b/bacula/src/jcr.h @@ -247,6 +247,7 @@ public: int replace; /* Replace option */ int NumVols; /* Number of Volume used in pool */ int reschedule_count; /* Number of times rescheduled */ + int64_t spool_size; /* Spool size for this job */ bool spool_data; /* Spool data in SD */ bool acquired_resource_locks; /* set if resource locks acquired */ bool term_wait_inited; /* Set when cond var inited */ @@ -323,6 +324,7 @@ public: bool ignore_label_errors; /* ignore Volume label errors */ bool spool_attributes; /* set if spooling attributes */ bool no_attributes; /* set if no attributes wanted */ + int64_t spool_size; /* Spool size for this job */ bool spool_data; /* set to spool data */ int CurVol; /* Current Volume count */ DIRRES* director; /* Director resource */ diff --git a/bacula/src/stored/acquire.c b/bacula/src/stored/acquire.c index 20cac300a1..e5cad381bb 100644 --- a/bacula/src/stored/acquire.c +++ b/bacula/src/stored/acquire.c @@ -644,7 +644,12 @@ DCR *new_dcr(JCR *jcr, DCR *dcr, DEVICE *dev) if (dcr->attached_to_dev) { detach_dcr_from_dev(dcr); } - dcr->max_job_spool_size = dev->device->max_job_spool_size; + /* Use job spoolsize prior to device spoolsize */ + if (jcr->spool_size) { + dcr->max_job_spool_size = jcr->spool_size; + } else { + dcr->max_job_spool_size = dev->device->max_job_spool_size; + } dcr->device = dev->device; dcr->dev = dev; attach_dcr_to_dev(dcr); diff --git a/bacula/src/stored/job.c b/bacula/src/stored/job.c index 79b7aa58a5..965c197bea 100644 --- a/bacula/src/stored/job.c +++ b/bacula/src/stored/job.c @@ -49,7 +49,7 @@ extern bool do_mac(JCR *jcr); /* Requests from the Director daemon */ static char jobcmd[] = "JobId=%d job=%127s job_name=%127s client_name=%127s " "type=%d level=%d FileSet=%127s NoAttr=%d SpoolAttr=%d FileSetMD5=%127s " - "SpoolData=%d WritePartAfterJob=%d PreferMountedVols=%d\n"; + "SpoolData=%d SpoolSize=%s WritePartAfterJob=%d PreferMountedVols=%d\n"; /* Responses sent to Director daemon */ @@ -73,6 +73,7 @@ bool job_cmd(JCR *jcr) { int JobId; char auth_key[100]; + char spool_size[30]; char seed[100]; BSOCK *dir = jcr->dir_bsock; POOL_MEM job_name, client_name, job, fileset_name, fileset_md5; @@ -88,9 +89,9 @@ bool job_cmd(JCR *jcr) stat = sscanf(dir->msg, jobcmd, &JobId, job.c_str(), job_name.c_str(), client_name.c_str(), &JobType, &level, fileset_name.c_str(), &no_attributes, - &spool_attributes, fileset_md5.c_str(), &spool_data, + &spool_attributes, fileset_md5.c_str(), &spool_data, spool_size, &write_part_after_job, &PreferMountedVols); - if (stat != 13) { + if (stat != 14) { pm_strcpy(jcr->errmsg, dir->msg); dir->fsend(BAD_job, stat, jcr->errmsg); Dmsg1(100, ">dird: %s", dir->msg); @@ -125,6 +126,7 @@ bool job_cmd(JCR *jcr) jcr->no_attributes = no_attributes; jcr->spool_attributes = spool_attributes; jcr->spool_data = spool_data; + jcr->spool_size = str_to_int64(spool_size); jcr->write_part_after_job = write_part_after_job; jcr->fileset_md5 = get_pool_memory(PM_NAME); pm_strcpy(jcr->fileset_md5, fileset_md5); diff --git a/bacula/technotes-2.3 b/bacula/technotes-2.3 index 6d7d711f7c..ac6843319f 100644 --- a/bacula/technotes-2.3 +++ b/bacula/technotes-2.3 @@ -1,6 +1,10 @@ Technical notes on version 2.3 General: +30Sep07 +ebl Add an option that permit to specify spool size in job + definition. (Applying patches/testing/spoolsize_per_job.patch). + You must upgrade SD and DIR at the same time. 28Sep07 kes Fix race condition that drops final block written to volume. This happens in rare cases with multiple simultaneous jobs -- 2.39.5