3 * Bacula Director Job processing routines
5 * Kern Sibbald, October MM
10 Copyright (C) 2000-2005 Kern Sibbald
12 This program is free software; you can redistribute it and/or
13 modify it under the terms of the GNU General Public License as
14 published by the Free Software Foundation; either version 2 of
15 the License, or (at your option) any later version.
17 This program is distributed in the hope that it will be useful,
18 but WITHOUT ANY WARRANTY; without even the implied warranty of
19 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
20 General Public License for more details.
22 You should have received a copy of the GNU General Public
23 License along with this program; if not, write to the Free
24 Software Foundation, Inc., 59 Temple Place - Suite 330, Boston,
32 /* Forward referenced subroutines */
33 static void *job_thread(void *arg);
34 static void job_monitor_watchdog(watchdog_t *self);
35 static void job_monitor_destructor(watchdog_t *self);
36 static bool job_check_maxwaittime(JCR *control_jcr, JCR *jcr);
37 static bool job_check_maxruntime(JCR *control_jcr, JCR *jcr);
39 /* Exported subroutines */
41 /* Imported subroutines */
42 extern void term_scheduler();
43 extern void term_ua_server();
44 extern int do_backup(JCR *jcr);
45 extern bool do_mac(JCR *jcr);
46 extern int do_admin(JCR *jcr);
47 extern int do_restore(JCR *jcr);
48 extern bool do_verify(JCR *jcr);
50 /* Imported variables */
51 extern time_t watchdog_time;
55 void init_job_server(int max_workers)
60 if ((stat = jobq_init(&job_queue, max_workers, job_thread)) != 0) {
62 Emsg1(M_ABORT, 0, _("Could not init job queue: ERR=%s\n"), be.strerror(stat));
64 if ((wd = new_watchdog()) == NULL) {
65 Emsg0(M_ABORT, 0, _("Could not init job monitor watchdogs\n"));
67 wd->callback = job_monitor_watchdog;
68 wd->destructor = job_monitor_destructor;
71 wd->data = new_control_jcr("*JobMonitor*", JT_SYSTEM);
72 register_watchdog(wd);
75 void term_job_server()
77 jobq_destroy(&job_queue); /* ignore any errors */
81 * Run a job -- typically called by the scheduler, but may also
82 * be called by the UA (Console program).
84 * Returns: 0 on failure
88 JobId_t run_job(JCR *jcr)
94 sm_check(__FILE__, __LINE__, true);
95 init_msg(jcr, jcr->messages);
97 /* Initialize termination condition variable */
98 if ((errstat = pthread_cond_init(&jcr->term_wait, NULL)) != 0) {
100 Jmsg1(jcr, M_FATAL, 0, _("Unable to init job cond variable: ERR=%s\n"), be.strerror(errstat));
103 jcr->term_wait_inited = true;
108 Dmsg0(50, "Open database\n");
109 jcr->db=db_init_database(jcr, jcr->catalog->db_name, jcr->catalog->db_user,
110 jcr->catalog->db_password, jcr->catalog->db_address,
111 jcr->catalog->db_port, jcr->catalog->db_socket,
112 jcr->catalog->mult_db_connections);
113 if (!jcr->db || !db_open_database(jcr, jcr->db)) {
114 Jmsg(jcr, M_FATAL, 0, _("Could not open database \"%s\".\n"),
115 jcr->catalog->db_name);
117 Jmsg(jcr, M_FATAL, 0, "%s", db_strerror(jcr->db));
121 Dmsg0(50, "DB opened\n");
126 create_unique_job_name(jcr, jcr->job->hdr.name);
127 set_jcr_job_status(jcr, JS_Created);
128 init_jcr_job_record(jcr);
129 if (!db_create_job_record(jcr, jcr->db, &jcr->jr)) {
130 Jmsg(jcr, M_FATAL, 0, "%s", db_strerror(jcr->db));
133 JobId = jcr->JobId = jcr->jr.JobId;
135 Dmsg4(100, "Created job record JobId=%d Name=%s Type=%c Level=%c\n",
136 jcr->JobId, jcr->Job, jcr->jr.JobType, jcr->jr.JobLevel);
138 if (!get_or_create_client_record(jcr)) {
143 jcr->fname = get_pool_memory(PM_FNAME);
146 Dmsg0(200, "Add jrc to work queue\n");
148 /* Queue the job to be run */
149 if ((stat = jobq_add(&job_queue, jcr)) != 0) {
151 Jmsg(jcr, M_FATAL, 0, _("Could not add job queue: ERR=%s\n"), be.strerror(stat));
155 Dmsg0(100, "Done run_job()\n");
161 set_jcr_job_status(jcr, JS_ErrorTerminated);
169 * This is the engine called by jobq.c:jobq_add() when we were pulled
170 * from the work queue.
171 * At this point, we are running in our own thread and all
172 * necessary resources are allocated -- see jobq.c
174 static void *job_thread(void *arg)
176 JCR *jcr = (JCR *)arg;
178 jcr->my_thread_id = pthread_self();
179 pthread_detach(jcr->my_thread_id);
180 sm_check(__FILE__, __LINE__, true);
183 Dmsg0(200, "=====Start Job=========\n");
184 jcr->start_time = time(NULL); /* set the real start time */
185 jcr->jr.StartTime = jcr->start_time;
186 set_jcr_job_status(jcr, JS_Running);
187 if (!db_update_job_start_record(jcr, jcr->db, &jcr->jr)) {
188 Jmsg(jcr, M_FATAL, 0, "%s", db_strerror(jcr->db));
191 if (job_canceled(jcr)) {
192 update_job_end_record(jcr);
193 } else if (jcr->job->MaxStartDelay != 0 && jcr->job->MaxStartDelay <
194 (utime_t)(jcr->start_time - jcr->sched_time)) {
195 Jmsg(jcr, M_FATAL, 0, _("Job canceled because max start delay time exceeded.\n"));
196 set_jcr_job_status(jcr, JS_Canceled);
197 update_job_end_record(jcr);
201 generate_event(jcr, "StartJob");
202 if (jcr->job->RunBeforeJob) {
203 POOLMEM *before = get_pool_memory(PM_FNAME);
206 char line[MAXSTRING];
208 before = edit_job_codes(jcr, before, jcr->job->RunBeforeJob, "");
209 bpipe = open_bpipe(before, 0, "r");
210 free_pool_memory(before);
211 while (fgets(line, sizeof(line), bpipe->rfd)) {
212 Jmsg(jcr, M_INFO, 0, _("RunBefore: %s"), line);
214 status = close_bpipe(bpipe);
217 Jmsg(jcr, M_FATAL, 0, _("RunBeforeJob error: ERR=%s\n"), be.strerror(status));
218 set_jcr_job_status(jcr, JS_FatalError);
219 update_job_end_record(jcr);
223 switch (jcr->JobType) {
226 if (jcr->JobStatus == JS_Terminated) {
232 if (jcr->JobStatus == JS_Terminated) {
238 if (jcr->JobStatus == JS_Terminated) {
244 if (jcr->JobStatus == JS_Terminated) {
251 do_mac(jcr); /* migration, archive, copy */
252 if (jcr->JobStatus == JS_Terminated) {
257 Pmsg1(0, "Unimplemented job type: %d\n", jcr->JobType);
260 if ((jcr->job->RunAfterJob && jcr->JobStatus == JS_Terminated) ||
261 (jcr->job->RunAfterFailedJob && jcr->JobStatus != JS_Terminated)) {
262 POOLMEM *after = get_pool_memory(PM_FNAME);
265 char line[MAXSTRING];
267 if (jcr->JobStatus == JS_Terminated) {
268 after = edit_job_codes(jcr, after, jcr->job->RunAfterJob, "");
270 after = edit_job_codes(jcr, after, jcr->job->RunAfterFailedJob, "");
272 bpipe = open_bpipe(after, 0, "r");
273 free_pool_memory(after);
274 while (fgets(line, sizeof(line), bpipe->rfd)) {
275 Jmsg(jcr, M_INFO, 0, _("RunAfter: %s"), line);
277 status = close_bpipe(bpipe);
279 * Note, if we get an error here, do not mark the
280 * job in error, simply report the error condition.
284 if (jcr->JobStatus == JS_Terminated) {
285 Jmsg(jcr, M_WARNING, 0, _("RunAfterJob error: ERR=%s\n"), be.strerror(status));
287 Jmsg(jcr, M_FATAL, 0, _("RunAfterFailedJob error: ERR=%s\n"), be.strerror(status));
291 generate_event(jcr, "EndJob");
292 /* Send off any queued messages */
293 if (jcr->msg_queue->size() > 0) {
294 dequeue_messages(jcr);
301 Dmsg1(50, "======== End Job stat=%c ==========\n", jcr->JobStatus);
302 sm_check(__FILE__, __LINE__, true);
308 * Cancel a job -- typically called by the UA (Console program), but may also
309 * be called by the job watchdog.
311 * Returns: 1 if cancel appears to be successful
312 * 0 on failure. Message sent to ua->jcr.
314 int cancel_job(UAContext *ua, JCR *jcr)
318 switch (jcr->JobStatus) {
321 case JS_WaitClientRes:
322 case JS_WaitStoreRes:
323 case JS_WaitPriority:
325 case JS_WaitStartTime:
326 set_jcr_job_status(jcr, JS_Canceled);
327 bsendmsg(ua, _("JobId %d, Job %s marked to be canceled.\n"),
328 jcr->JobId, jcr->Job);
329 jobq_remove(&job_queue, jcr); /* attempt to remove it from queue */
333 set_jcr_job_status(jcr, JS_Canceled);
335 /* Cancel File daemon */
336 if (jcr->file_bsock) {
337 ua->jcr->client = jcr->client;
338 if (!connect_to_file_daemon(ua->jcr, 10, FDConnectTimeout, 1)) {
339 bsendmsg(ua, _("Failed to connect to File daemon.\n"));
342 Dmsg0(200, "Connected to file daemon\n");
343 fd = ua->jcr->file_bsock;
344 bnet_fsend(fd, "cancel Job=%s\n", jcr->Job);
345 while (bnet_recv(fd) >= 0) {
346 bsendmsg(ua, "%s", fd->msg);
348 bnet_sig(fd, BNET_TERMINATE);
350 ua->jcr->file_bsock = NULL;
353 /* Cancel Storage daemon */
354 if (jcr->store_bsock) {
355 if (!ua->jcr->storage) {
356 copy_storage(ua->jcr, jcr);
358 set_storage(ua->jcr, jcr->store);
360 if (!connect_to_storage_daemon(ua->jcr, 10, SDConnectTimeout, 1)) {
361 bsendmsg(ua, _("Failed to connect to Storage daemon.\n"));
364 Dmsg0(200, "Connected to storage daemon\n");
365 sd = ua->jcr->store_bsock;
366 bnet_fsend(sd, "cancel Job=%s\n", jcr->Job);
367 while (bnet_recv(sd) >= 0) {
368 bsendmsg(ua, "%s", sd->msg);
370 bnet_sig(sd, BNET_TERMINATE);
372 ua->jcr->store_bsock = NULL;
380 static void job_monitor_destructor(watchdog_t *self)
382 JCR *control_jcr = (JCR *) self->data;
384 free_jcr(control_jcr);
387 static void job_monitor_watchdog(watchdog_t *self)
389 JCR *control_jcr, *jcr;
391 control_jcr = (JCR *)self->data;
393 Dmsg1(800, "job_monitor_watchdog %p called\n", self);
400 if (jcr->JobId == 0) {
401 Dmsg2(800, "Skipping JCR %p (%s) with JobId 0\n",
403 /* Keep reference counts correct */
404 free_locked_jcr(jcr);
408 /* check MaxWaitTime */
409 cancel = job_check_maxwaittime(control_jcr, jcr);
411 /* check MaxRunTime */
412 cancel |= job_check_maxruntime(control_jcr, jcr);
415 Dmsg3(800, "Cancelling JCR %p jobid %d (%s)\n",
416 jcr, jcr->JobId, jcr->Job);
418 UAContext *ua = new_ua_context(jcr);
419 ua->jcr = control_jcr;
423 Dmsg1(800, "Have cancelled JCR %p\n", jcr);
426 /* Keep reference counts correct */
427 free_locked_jcr(jcr);
433 * Check if the maxwaittime has expired and it is possible
436 static bool job_check_maxwaittime(JCR *control_jcr, JCR *jcr)
439 bool ok_to_cancel = false;
442 if (job->MaxWaitTime == 0 && job->FullMaxWaitTime == 0 &&
443 job->IncMaxWaitTime == 0 && job->DiffMaxWaitTime == 0) {
446 if (jcr->JobLevel == L_FULL && job->FullMaxWaitTime != 0 &&
447 (watchdog_time - jcr->start_time) >= job->FullMaxWaitTime) {
449 } else if (jcr->JobLevel == L_DIFFERENTIAL && job->DiffMaxWaitTime != 0 &&
450 (watchdog_time - jcr->start_time) >= job->DiffMaxWaitTime) {
452 } else if (jcr->JobLevel == L_INCREMENTAL && job->IncMaxWaitTime != 0 &&
453 (watchdog_time - jcr->start_time) >= job->IncMaxWaitTime) {
455 } else if (job->MaxWaitTime != 0 &&
456 (watchdog_time - jcr->start_time) >= job->MaxWaitTime) {
462 Dmsg3(800, "Job %d (%s): MaxWaitTime of %d seconds exceeded, "
464 jcr->JobId, jcr->Job, job->MaxWaitTime);
465 switch (jcr->JobStatus) {
470 case JS_WaitStoreRes:
471 case JS_WaitClientRes:
473 case JS_WaitPriority:
475 case JS_WaitStartTime:
477 Dmsg0(200, "JCR blocked in #1\n");
480 Dmsg0(800, "JCR running, checking SD status\n");
481 switch (jcr->SDJobStatus) {
486 Dmsg0(800, "JCR blocked in #2\n");
489 Dmsg0(800, "JCR not blocked in #2\n");
494 case JS_ErrorTerminated:
497 Dmsg0(800, "JCR already dead in #3\n");
500 Jmsg1(jcr, M_ERROR, 0, _("Unhandled job status code %d\n"),
503 Dmsg3(800, "MaxWaitTime result: %scancel JCR %p (%s)\n",
504 cancel ? "" : "do not ", jcr, jcr->job);
510 * Check if maxruntime has expired and if the job can be
513 static bool job_check_maxruntime(JCR *control_jcr, JCR *jcr)
517 if (jcr->job->MaxRunTime == 0) {
520 if ((watchdog_time - jcr->start_time) < jcr->job->MaxRunTime) {
521 Dmsg3(200, "Job %p (%s) with MaxRunTime %d not expired\n",
522 jcr, jcr->Job, jcr->job->MaxRunTime);
526 switch (jcr->JobStatus) {
532 case JS_WaitStoreRes:
533 case JS_WaitClientRes:
535 case JS_WaitPriority:
537 case JS_WaitStartTime:
542 case JS_ErrorTerminated:
548 Jmsg1(jcr, M_ERROR, 0, _("Unhandled job status code %d\n"),
552 Dmsg3(200, "MaxRunTime result: %scancel JCR %p (%s)\n",
553 cancel ? "" : "do not ", jcr, jcr->job);
560 * Get or create a Client record for this Job
562 bool get_or_create_client_record(JCR *jcr)
566 memset(&cr, 0, sizeof(cr));
567 bstrncpy(cr.Name, jcr->client->hdr.name, sizeof(cr.Name));
568 cr.AutoPrune = jcr->client->AutoPrune;
569 cr.FileRetention = jcr->client->FileRetention;
570 cr.JobRetention = jcr->client->JobRetention;
571 if (!jcr->client_name) {
572 jcr->client_name = get_pool_memory(PM_NAME);
574 pm_strcpy(jcr->client_name, jcr->client->hdr.name);
575 if (!db_create_client_record(jcr, jcr->db, &cr)) {
576 Jmsg(jcr, M_FATAL, 0, _("Could not create Client record. ERR=%s\n"),
577 db_strerror(jcr->db));
580 jcr->jr.ClientId = cr.ClientId;
582 if (!jcr->client_uname) {
583 jcr->client_uname = get_pool_memory(PM_NAME);
585 pm_strcpy(jcr->client_uname, cr.Uname);
587 Dmsg2(100, "Created Client %s record %d\n", jcr->client->hdr.name,
592 bool get_or_create_fileset_record(JCR *jcr, FILESET_DBR *fsr)
595 * Get or Create FileSet record
597 memset(fsr, 0, sizeof(FILESET_DBR));
598 bstrncpy(fsr->FileSet, jcr->fileset->hdr.name, sizeof(fsr->FileSet));
599 if (jcr->fileset->have_MD5) {
600 struct MD5Context md5c;
601 unsigned char signature[16];
602 memcpy(&md5c, &jcr->fileset->md5c, sizeof(md5c));
603 MD5Final(signature, &md5c);
604 bin_to_base64(fsr->MD5, (char *)signature, 16); /* encode 16 bytes */
605 bstrncpy(jcr->fileset->MD5, fsr->MD5, sizeof(jcr->fileset->MD5));
607 Jmsg(jcr, M_WARNING, 0, _("FileSet MD5 signature not found.\n"));
609 if (!jcr->fileset->ignore_fs_changes ||
610 !db_get_fileset_record(jcr, jcr->db, fsr)) {
611 if (!db_create_fileset_record(jcr, jcr->db, fsr)) {
612 Jmsg(jcr, M_ERROR, 0, _("Could not create FileSet \"%s\" record. ERR=%s\n"),
613 fsr->FileSet, db_strerror(jcr->db));
617 jcr->jr.FileSetId = fsr->FileSetId;
619 Jmsg(jcr, M_INFO, 0, _("Created new FileSet record \"%s\" %s\n"),
620 fsr->FileSet, fsr->cCreateTime);
622 Dmsg2(119, "Created FileSet %s record %u\n", jcr->fileset->hdr.name,
627 void init_jcr_job_record(JCR *jcr)
629 jcr->jr.SchedTime = jcr->sched_time;
630 jcr->jr.StartTime = jcr->start_time;
631 jcr->jr.EndTime = 0; /* perhaps rescheduled, clear it */
632 jcr->jr.JobType = jcr->JobType;
633 jcr->jr.JobLevel = jcr->JobLevel;
634 jcr->jr.JobStatus = jcr->JobStatus;
635 jcr->jr.JobId = jcr->JobId;
636 bstrncpy(jcr->jr.Name, jcr->job->hdr.name, sizeof(jcr->jr.Name));
637 bstrncpy(jcr->jr.Job, jcr->Job, sizeof(jcr->jr.Job));
641 * Write status and such in DB
643 void update_job_end_record(JCR *jcr)
645 jcr->jr.EndTime = time(NULL);
646 jcr->end_time = jcr->jr.EndTime;
647 jcr->jr.JobId = jcr->JobId;
648 jcr->jr.JobStatus = jcr->JobStatus;
649 jcr->jr.JobFiles = jcr->JobFiles;
650 jcr->jr.JobBytes = jcr->JobBytes;
651 jcr->jr.VolSessionId = jcr->VolSessionId;
652 jcr->jr.VolSessionTime = jcr->VolSessionTime;
653 if (!db_update_job_end_record(jcr, jcr->db, &jcr->jr)) {
654 Jmsg(jcr, M_WARNING, 0, _("Error updating job record. %s"),
655 db_strerror(jcr->db));
660 * Takes base_name and appends (unique) current
661 * date and time to form unique job name.
663 * Returns: unique job name in jcr->Job
664 * date/time in jcr->start_time
666 void create_unique_job_name(JCR *jcr, const char *base_name)
668 /* Job start mutex */
669 static pthread_mutex_t mutex = PTHREAD_MUTEX_INITIALIZER;
670 static time_t last_start_time = 0;
673 char dt[MAX_TIME_LENGTH];
674 char name[MAX_NAME_LENGTH];
677 /* Guarantee unique start time -- maximum one per second, and
678 * thus unique Job Name
680 P(mutex); /* lock creation of jobs */
682 while (now == last_start_time) {
683 bmicrosleep(0, 500000);
686 last_start_time = now;
687 V(mutex); /* allow creation of jobs */
688 jcr->start_time = now;
689 /* Form Unique JobName */
690 localtime_r(&now, &tm);
691 /* Use only characters that are permitted in Windows filenames */
692 strftime(dt, sizeof(dt), "%Y-%m-%d_%H.%M.%S", &tm);
693 bstrncpy(name, base_name, sizeof(name));
694 name[sizeof(name)-22] = 0; /* truncate if too long */
695 bsnprintf(jcr->Job, sizeof(jcr->Job), "%s.%s", name, dt); /* add date & time */
696 /* Convert spaces into underscores */
697 for (p=jcr->Job; *p; p++) {
705 * Free the Job Control Record if no one is still using it.
706 * Called from main free_jcr() routine in src/lib/jcr.c so
707 * that we can do our Director specific cleanup of the jcr.
709 void dird_free_jcr(JCR *jcr)
711 Dmsg0(200, "Start dird free_jcr\n");
713 if (jcr->sd_auth_key) {
714 free(jcr->sd_auth_key);
715 jcr->sd_auth_key = NULL;
721 if (jcr->file_bsock) {
722 Dmsg0(200, "Close File bsock\n");
723 bnet_close(jcr->file_bsock);
724 jcr->file_bsock = NULL;
726 if (jcr->store_bsock) {
727 Dmsg0(200, "Close Store bsock\n");
728 bnet_close(jcr->store_bsock);
729 jcr->store_bsock = NULL;
732 Dmsg0(200, "Free JCR fname\n");
733 free_pool_memory(jcr->fname);
737 Dmsg0(200, "Free JCR stime\n");
738 free_pool_memory(jcr->stime);
741 if (jcr->RestoreBootstrap) {
742 free(jcr->RestoreBootstrap);
743 jcr->RestoreBootstrap = NULL;
745 if (jcr->client_uname) {
746 free_pool_memory(jcr->client_uname);
747 jcr->client_uname = NULL;
749 if (jcr->term_wait_inited) {
750 pthread_cond_destroy(&jcr->term_wait);
752 /* Delete lists setup to hold storage pointers */
756 jcr->job_end_push.destroy();
757 Dmsg0(200, "End dird free_jcr\n");
761 * Set some defaults in the JCR necessary to
762 * run. These items are pulled from the job
763 * definition as defaults, but can be overridden
764 * later either by the Run record in the Schedule resource,
765 * or by the Console program.
767 void set_jcr_defaults(JCR *jcr, JOB *job)
771 jcr->JobType = job->JobType;
772 switch (jcr->JobType) {
775 jcr->JobLevel = L_NONE;
778 jcr->JobLevel = job->JobLevel;
781 jcr->JobPriority = job->Priority;
782 /* Copy storage definitions -- deleted in dir_free_jcr above */
787 jcr->storage = New(alist(10, not_owned_by_alist));
788 foreach_alist(st, job->storage) {
789 jcr->storage->append(st);
793 jcr->store = (STORE *)jcr->storage->first();
795 jcr->client = job->client;
796 if (!jcr->client_name) {
797 jcr->client_name = get_pool_memory(PM_NAME);
799 pm_strcpy(jcr->client_name, jcr->client->hdr.name);
800 jcr->pool = job->pool;
801 jcr->full_pool = job->full_pool;
802 jcr->inc_pool = job->inc_pool;
803 jcr->dif_pool = job->dif_pool;
804 jcr->catalog = job->client->catalog;
805 jcr->fileset = job->fileset;
806 jcr->messages = job->messages;
807 jcr->spool_data = job->spool_data;
808 jcr->write_part_after_job = job->write_part_after_job;
809 if (jcr->RestoreBootstrap) {
810 free(jcr->RestoreBootstrap);
811 jcr->RestoreBootstrap = NULL;
813 /* This can be overridden by Console program */
814 if (job->RestoreBootstrap) {
815 jcr->RestoreBootstrap = bstrdup(job->RestoreBootstrap);
817 /* This can be overridden by Console program */
818 jcr->verify_job = job->verify_job;
819 /* If no default level given, set one */
820 if (jcr->JobLevel == 0) {
821 switch (jcr->JobType) {
823 jcr->JobLevel = L_VERIFY_CATALOG;
826 jcr->JobLevel = L_INCREMENTAL;
830 jcr->JobLevel = L_NONE;
839 * copy the storage definitions from an old JCR to a new one
841 void copy_storage(JCR *new_jcr, JCR *old_jcr)
843 if (old_jcr->storage) {
845 if (old_jcr->storage) {
846 delete old_jcr->storage;
848 new_jcr->storage = New(alist(10, not_owned_by_alist));
849 foreach_alist(st, old_jcr->storage) {
850 new_jcr->storage->append(st);
853 if (old_jcr->store) {
854 new_jcr->store = old_jcr->store;
855 } else if (new_jcr->storage) {
856 new_jcr->store = (STORE *)new_jcr->storage->first();
860 /* Set storage override */
861 void set_storage(JCR *jcr, STORE *store)
866 foreach_alist(storage, jcr->storage) {
867 if (store == storage) {
871 /* Store not in list, so add it */
872 jcr->storage->prepend(store);