From: Kern Sibbald Date: Fri, 4 Mar 2005 08:12:17 +0000 (+0000) Subject: - Change Developers to Developer's Guide as requested by Michael. X-Git-Tag: Release-1.38.0~618 X-Git-Url: https://git.sur5r.net/?a=commitdiff_plain;h=b528d4c42b5ae7658459184cec5afc0d36a650f5;p=bacula%2Fbacula - Change Developers to Developer's Guide as requested by Michael. - Fix developers link in manual - Add additional dcr changes in SD to allow multiple dcrs. git-svn-id: https://bacula.svn.sourceforge.net/svnroot/bacula/trunk@1859 91ce42f0-d328-0410-95d8-f526ca767f89 --- diff --git a/bacula/kernstodo b/bacula/kernstodo index e69f45c859..fa64ec71ad 100644 --- a/bacula/kernstodo +++ b/bacula/kernstodo @@ -127,6 +127,8 @@ For 1.37: - Scratch Pool where the volumes can be re-assigned to any Pool. - Upgrade to MySQL 4.1.1 See: http://dev.mysql.com/doc/mysql/en/Server_SQL_mode.html +- Add client version to the Client name line that prints in + the Job report. - Bug: Enter MediaId or Volume name: 32 Enter new Volume name: DLT-20Dec04 diff --git a/bacula/src/stored/acquire.c b/bacula/src/stored/acquire.c index 71c9811a3a..e0543f3e91 100644 --- a/bacula/src/stored/acquire.c +++ b/bacula/src/stored/acquire.c @@ -54,10 +54,39 @@ DCR *new_dcr(JCR *jcr, DEVICE *dev) /* Attach this dcr only if dev is initialized */ if (dev->fd != 0 && jcr && jcr->JobType != JT_SYSTEM) { dev->attached_dcrs->append(dcr); +// jcr->dcrs->append(dcr); } return dcr; } +/* + * Search the dcrs list for the given dcr. If it is found, + * as it should be, then remove it. Also zap the jcr pointer + * to the dcr if it is the same one. + */ +static void remove_dcr_from_dcrs(DCR *dcr) +{ + JCR *jcr = dcr->jcr; + if (jcr->dcrs) { + int i = 0; + DCR *ldcr; + int num = jcr->dcrs->size(); + for (i=0; i < num; i++) { + ldcr = (DCR *)jcr->dcrs->get(i); + if (ldcr == dcr) { + jcr->dcrs->remove(i); + if (jcr->dcr == dcr) { + jcr->dcr = NULL; + } + } + } + } +} + +/* + * Free up all aspects of the given dcr -- i.e. dechain it, + * release allocated memory, zap pointers, ... + */ void free_dcr(DCR *dcr) { JCR *jcr = dcr->jcr; @@ -80,7 +109,8 @@ void free_dcr(DCR *dcr) /* Detach this dcr only if the dev is initialized */ if (dev->fd != 0 && jcr && jcr->JobType != JT_SYSTEM) { - dcr->dev->attached_dcrs->remove(dcr); + dev->attached_dcrs->remove(dcr); +// remove_dcr_from_dcrs(dcr); } if (dcr->block) { free_block(dcr->block); @@ -94,6 +124,7 @@ void free_dcr(DCR *dcr) free(dcr); } + /* * We "reserve" the drive by setting the ST_READ bit. No one else * should touch the drive until that is cleared. @@ -512,9 +543,9 @@ ok_out: * the device remains open. * */ -bool release_device(JCR *jcr) +bool release_device(DCR *dcr) { - DCR *dcr = jcr->dcr; + JCR *jcr = dcr->jcr; DEVICE *dev = dcr->dev; lock_device(dev); Dmsg1(100, "release_device device is %s\n", dev_is_tape(dev)?"tape":"disk"); @@ -592,7 +623,7 @@ bool release_device(JCR *jcr) free_pool_memory(alert); } unlock_device(dev); - free_dcr(jcr->dcr); + free_dcr(dcr); jcr->dcr = NULL; return true; } diff --git a/bacula/src/stored/append.c b/bacula/src/stored/append.c index 95c05cdb0b..5f12108521 100644 --- a/bacula/src/stored/append.c +++ b/bacula/src/stored/append.c @@ -51,6 +51,8 @@ bool do_append_data(JCR *jcr) Dmsg0(10, "Start append data.\n"); + memset(&rec, 0, sizeof(rec)); + ds = fd_sock; if (!bnet_set_buffer_size(ds, dcr->device->max_network_buffer_size, BNET_SETBUF_WRITE)) { @@ -64,22 +66,20 @@ bool do_append_data(JCR *jcr) return false; } - memset(&rec, 0, sizeof(rec)); - set_jcr_job_status(jcr, JS_Running); dir_send_job_status(jcr); if (dev->VolCatInfo.VolCatName[0] == 0) { - Dmsg0(000, "NULL Volume name. This shouldn't happen!!!\n"); + Pmsg0(000, "NULL Volume name. This shouldn't happen!!!\n"); } Dmsg1(20, "Begin append device=%s\n", dev_name(dev)); - begin_data_spool(jcr); + begin_data_spool(dcr); begin_attribute_spool(jcr); Dmsg0(100, "Just after acquire_device_for_append\n"); if (dev->VolCatInfo.VolCatName[0] == 0) { - Dmsg0(000, "NULL Volume name. This shouldn't happen!!!\n"); + Pmsg0(000, "NULL Volume name. This shouldn't happen!!!\n"); } /* * Write Begin Session Record @@ -91,7 +91,7 @@ bool do_append_data(JCR *jcr) ok = false; } if (dev->VolCatInfo.VolCatName[0] == 0) { - Dmsg0(000, "NULL Volume name. This shouldn't happen!!!\n"); + Pmsg0(000, "NULL Volume name. This shouldn't happen!!!\n"); } /* Tell File daemon to send data */ @@ -246,7 +246,7 @@ bool do_append_data(JCR *jcr) Dmsg1(200, "Write session label JobStatus=%d\n", jcr->JobStatus); if (dev->VolCatInfo.VolCatName[0] == 0) { - Dmsg0(000, "NULL Volume name. This shouldn't happen!!!\n"); + Pmsg0(000, "NULL Volume name. This shouldn't happen!!!\n"); } /* @@ -261,7 +261,7 @@ bool do_append_data(JCR *jcr) ok = false; } if (dev->VolCatInfo.VolCatName[0] == 0) { - Dmsg0(000, "NULL Volume name. This shouldn't happen!!!\n"); + Pmsg0(000, "NULL Volume name. This shouldn't happen!!!\n"); } Dmsg0(90, "back from write_end_session_label()\n"); /* Flush out final partial block of this session */ @@ -272,13 +272,13 @@ bool do_append_data(JCR *jcr) } } if (dev->VolCatInfo.VolCatName[0] == 0) { - Dmsg0(000, "NULL Volume name. This shouldn't happen!!!\n"); + Pmsg0(000, "NULL Volume name. This shouldn't happen!!!\n"); } if (!ok) { - discard_data_spool(jcr); + discard_data_spool(dcr); } else { - commit_data_spool(jcr); + commit_data_spool(dcr); } /* If the device is nor a dvd and WritePartAfterJob @@ -306,7 +306,7 @@ bool do_append_data(JCR *jcr) Dmsg1(200, "calling release device JobStatus=%d\n", jcr->JobStatus); /* Release the device */ - if (!release_device(jcr)) { + if (!release_device(dcr)) { Pmsg0(000, _("Error in release_device\n")); set_jcr_job_status(jcr, JS_ErrorTerminated); ok = false; diff --git a/bacula/src/stored/askdir.c b/bacula/src/stored/askdir.c index ac170c3bfa..7671daa1a6 100644 --- a/bacula/src/stored/askdir.c +++ b/bacula/src/stored/askdir.c @@ -221,12 +221,12 @@ bool dir_update_volume_info(DCR *dcr, bool label) if (vol->VolCatName[0] == 0) { Jmsg0(jcr, M_FATAL, 0, _("NULL Volume name. This shouldn't happen!!!\n")); - Dmsg0(000, "NULL Volume name. This shouldn't happen!!!\n"); + Pmsg0(000, "NULL Volume name. This shouldn't happen!!!\n"); return false; } if (dev->can_read()) { Jmsg0(jcr, M_FATAL, 0, _("Attempt to update_volume_info in read mode!!!\n")); - Dmsg0(000, "Attempt to update_volume_info in read mode!!!\n"); + Pmsg0(000, "Attempt to update_volume_info in read mode!!!\n"); return false; } @@ -254,7 +254,7 @@ bool dir_update_volume_info(DCR *dcr, bool label) if (!do_get_volume_info(dcr)) { Jmsg(jcr, M_FATAL, 0, "%s", jcr->errmsg); - Dmsg2(000, "Didn't get vol info vol=%s: ERR=%s", + Pmsg2(000, "Didn't get vol info vol=%s: ERR=%s", vol->VolCatName, jcr->errmsg); return false; } diff --git a/bacula/src/stored/bextract.c b/bacula/src/stored/bextract.c index 90e91e42d3..25d12c838e 100644 --- a/bacula/src/stored/bextract.c +++ b/bacula/src/stored/bextract.c @@ -241,7 +241,7 @@ static void do_extract(char *devname) if (is_bopen(&bfd)) { set_attributes(jcr, attr, &bfd); } - release_device(jcr); + release_device(dcr); free_attr(attr); free_jcr(jcr); term_dev(dev); diff --git a/bacula/src/stored/block.c b/bacula/src/stored/block.c index 64cb165864..e94f7ee9b1 100644 --- a/bacula/src/stored/block.c +++ b/bacula/src/stored/block.c @@ -877,11 +877,11 @@ reread: retry = 0; do { // uint32_t *bp = (uint32_t *)block->buf; -// Dmsg3(000, "Read %p %u at %llu\n", block->buf, block->buf_len, lseek(dev->fd, 0, SEEK_CUR)); +// Pmsg3(000, "Read %p %u at %llu\n", block->buf, block->buf_len, lseek(dev->fd, 0, SEEK_CUR)); stat = read(dev->fd, block->buf, (size_t)block->buf_len); -// Dmsg8(000, "stat=%d Csum=%u blen=%u bnum=%u %c%c%c%c\n",stat, bp[0],bp[1],bp[2], +// Pmsg8(000, "stat=%d Csum=%u blen=%u bnum=%u %c%c%c%c\n",stat, bp[0],bp[1],bp[2], // block->buf[12],block->buf[13],block->buf[14],block->buf[15]); if (retry == 1) { diff --git a/bacula/src/stored/bls.c b/bacula/src/stored/bls.c index 0711259833..276e426392 100644 --- a/bacula/src/stored/bls.c +++ b/bacula/src/stored/bls.c @@ -242,7 +242,7 @@ int main (int argc, char *argv[]) static void do_close(JCR *jcr) { - release_device(jcr); + release_device(jcr->dcr); free_attr(attr); free_record(rec); free_block(block); diff --git a/bacula/src/stored/bscan.c b/bacula/src/stored/bscan.c index 574c740916..3feb4413f0 100644 --- a/bacula/src/stored/bscan.c +++ b/bacula/src/stored/bscan.c @@ -449,7 +449,7 @@ static bool record_cb(DCR *dcr, DEV_RECORD *rec) } else if (verbose) { Pmsg1(000, _("Media type \"%s\" is OK.\n"), mr.MediaType); } - /* Reset some JCR variables */ + /* Reset some DCR variables */ foreach_dlist(dcr, dev->attached_dcrs) { dcr->VolFirstIndex = dcr->FileIndex = 0; dcr->StartBlock = dcr->EndBlock = 0; diff --git a/bacula/src/stored/btape.c b/bacula/src/stored/btape.c index c6e5a09eda..6c0371789b 100644 --- a/bacula/src/stored/btape.c +++ b/bacula/src/stored/btape.c @@ -1960,7 +1960,7 @@ static void fillcmd() jcr->dcr->block = block; /* Release the device if multiple tapes being used */ -// if (!simple && !release_device(jcr)) { +// if (!simple && !release_device(dcr)) { // Pmsg0(-1, _("Error in release_device\n")); // ok = false; // } diff --git a/bacula/src/stored/device.c b/bacula/src/stored/device.c index 682ce6e0a4..2807a97404 100644 --- a/bacula/src/stored/device.c +++ b/bacula/src/stored/device.c @@ -29,7 +29,7 @@ * Version $Id$ */ /* - Copyright (C) 2000-2004 Kern Sibbald and John Walker + Copyright (C) 2000-2005 Kern Sibbald This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as @@ -315,7 +315,7 @@ bool open_device(DCR *dcr) if (!dev->poll) { Jmsg2(dcr->jcr, M_FATAL, 0, _("Unable to open archive %s. ERR=%s\n"), dev_name(dev), strerror_dev(dev)); - Dmsg2(000, "Unable to open archive %s. ERR=%s\n", + Pmsg2(000, "Unable to open archive %s. ERR=%s\n", dev_name(dev), strerror_dev(dev)); } return false; diff --git a/bacula/src/stored/dircmd.c b/bacula/src/stored/dircmd.c index 35c1086871..684b241f9e 100644 --- a/bacula/src/stored/dircmd.c +++ b/bacula/src/stored/dircmd.c @@ -167,6 +167,7 @@ void *handle_connection_request(void *arg) jcr = new_jcr(sizeof(JCR), stored_free_jcr); /* create Job Control Record */ jcr->dir_bsock = bs; /* save Director bsock */ jcr->dir_bsock->jcr = jcr; + jcr->dcrs = New(alist(10, not_owned_by_alist)); /* Initialize FD start condition variable */ int errstat = pthread_cond_init(&jcr->job_start_wait, NULL); if (errstat != 0) { diff --git a/bacula/src/stored/job.c b/bacula/src/stored/job.c index 5bfe6f2b1a..560c98b2ed 100644 --- a/bacula/src/stored/job.c +++ b/bacula/src/stored/job.c @@ -518,6 +518,10 @@ void stored_free_jcr(JCR *jcr) Emsg0(M_FATAL, 0, _("In free_jcr(), but still attached to device!!!!\n")); } pthread_cond_destroy(&jcr->job_start_wait); + if (jcr->dcrs) { + delete jcr->dcrs; + } + jcr->dcrs = NULL; if (jcr->dcr) { free_dcr(jcr->dcr); jcr->dcr = NULL; diff --git a/bacula/src/stored/protos.h b/bacula/src/stored/protos.h index ff315fa688..00c1379fb3 100644 --- a/bacula/src/stored/protos.h +++ b/bacula/src/stored/protos.h @@ -28,182 +28,182 @@ uint32_t new_VolSessionId(); /* From acquire.c */ -bool reserve_device_for_append(JCR *jcr, DEVICE *dev); -DCR *acquire_device_for_append(JCR *jcr, DEVICE *dev); -bool reserve_device_for_read(JCR *jcr, DEVICE *dev); -DCR *acquire_device_for_read(JCR *jcr, DEVICE *dev); -bool release_device(JCR *jcr); -DCR *new_dcr(JCR *jcr, DEVICE *dev); -void free_dcr(DCR *dcr); +bool reserve_device_for_append(JCR *jcr, DEVICE *dev); +DCR *acquire_device_for_append(JCR *jcr, DEVICE *dev); +bool reserve_device_for_read(JCR *jcr, DEVICE *dev); +DCR *acquire_device_for_read(JCR *jcr, DEVICE *dev); +bool release_device(DCR *dcr); +DCR *new_dcr(JCR *jcr, DEVICE *dev); +void free_dcr(DCR *dcr); /* From askdir.c */ enum get_vol_info_rw { GET_VOL_INFO_FOR_WRITE, GET_VOL_INFO_FOR_READ }; -bool dir_get_volume_info(DCR *dcr, enum get_vol_info_rw); -bool dir_find_next_appendable_volume(DCR *dcr); -bool dir_update_volume_info(DCR *dcr, bool label); -bool dir_ask_sysop_to_create_appendable_volume(DCR *dcr); -bool dir_ask_sysop_to_mount_volume(DCR *dcr); -bool dir_update_file_attributes(DCR *dcr, DEV_RECORD *rec); -bool dir_send_job_status(JCR *jcr); -bool dir_create_jobmedia_record(DCR *dcr); +bool dir_get_volume_info(DCR *dcr, enum get_vol_info_rw); +bool dir_find_next_appendable_volume(DCR *dcr); +bool dir_update_volume_info(DCR *dcr, bool label); +bool dir_ask_sysop_to_create_appendable_volume(DCR *dcr); +bool dir_ask_sysop_to_mount_volume(DCR *dcr); +bool dir_update_file_attributes(DCR *dcr, DEV_RECORD *rec); +bool dir_send_job_status(JCR *jcr); +bool dir_create_jobmedia_record(DCR *dcr); /* authenticate.c */ -int authenticate_director(JCR *jcr); -int authenticate_filed(JCR *jcr); +int authenticate_director(JCR *jcr); +int authenticate_filed(JCR *jcr); /* From autochanger.c */ -int autoload_device(DCR *dcr, int writing, BSOCK *dir); -bool autochanger_list(DCR *dcr, BSOCK *dir); -void mark_volume_not_inchanger(DCR *dcr); -char *edit_device_codes(DCR *dcr, char *omsg, const char *cmd); +int autoload_device(DCR *dcr, int writing, BSOCK *dir); +bool autochanger_list(DCR *dcr, BSOCK *dir); +void mark_volume_not_inchanger(DCR *dcr); +char *edit_device_codes(DCR *dcr, char *omsg, const char *cmd); /* From block.c */ -void dump_block(DEV_BLOCK *b, const char *msg); +void dump_block(DEV_BLOCK *b, const char *msg); DEV_BLOCK *new_block(DEVICE *dev); DEV_BLOCK *dup_block(DEV_BLOCK *eblock); -void init_block_write(DEV_BLOCK *block); -void empty_block(DEV_BLOCK *block); -void free_block(DEV_BLOCK *block); -bool write_block_to_device(DCR *dcr); -bool write_block_to_dev(DCR *dcr); -void print_block_read_errors(JCR *jcr, DEV_BLOCK *block); -void ser_block_header(DEV_BLOCK *block); +void init_block_write(DEV_BLOCK *block); +void empty_block(DEV_BLOCK *block); +void free_block(DEV_BLOCK *block); +bool write_block_to_device(DCR *dcr); +bool write_block_to_dev(DCR *dcr); +void print_block_read_errors(JCR *jcr, DEV_BLOCK *block); +void ser_block_header(DEV_BLOCK *block); #define CHECK_BLOCK_NUMBERS true #define NO_BLOCK_NUMBER_CHECK false -bool read_block_from_device(DCR *dcr, bool check_block_numbers); -bool read_block_from_dev(DCR *dcr, bool check_block_numbers); +bool read_block_from_device(DCR *dcr, bool check_block_numbers); +bool read_block_from_dev(DCR *dcr, bool check_block_numbers); /* From butil.c -- utilities for SD tool programs */ -void print_ls_output(const char *fname, const char *link, int type, struct stat *statp); +void print_ls_output(const char *fname, const char *link, int type, struct stat *statp); JCR *setup_jcr(const char *name, char *dev_name, BSR *bsr, - const char *VolumeName, int mode); -void display_tape_error_status(JCR *jcr, DEVICE *dev); + const char *VolumeName, int mode); +void display_tape_error_status(JCR *jcr, DEVICE *dev); /* From dev.c */ -DEVICE *init_dev(JCR *jcr, DEVICE *dev, DEVRES *device); -int open_dev(DEVICE *dev, char *VolName, int mode); -off_t lseek_dev(DEVICE *dev, off_t offset, int whence); -int open_first_part(DEVICE *dev); -int open_next_part(DEVICE *dev); -int open_guess_name_dev(DEVICE *dev); -void close_dev(DEVICE *dev); -void force_close_dev(DEVICE *dev); -bool truncate_dev(DEVICE *dev); -void term_dev(DEVICE *dev); -char * strerror_dev(DEVICE *dev); -void clrerror_dev(DEVICE *dev, int func); -bool update_pos_dev(DEVICE *dev); -bool rewind_dev(DEVICE *dev); -bool load_dev(DEVICE *dev); -bool offline_dev(DEVICE *dev); -int flush_dev(DEVICE *dev); -int weof_dev(DEVICE *dev, int num); -int write_block(DEVICE *dev); +DEVICE *init_dev(JCR *jcr, DEVICE *dev, DEVRES *device); +int open_dev(DEVICE *dev, char *VolName, int mode); +off_t lseek_dev(DEVICE *dev, off_t offset, int whence); +int open_first_part(DEVICE *dev); +int open_next_part(DEVICE *dev); +int open_guess_name_dev(DEVICE *dev); +void close_dev(DEVICE *dev); +void force_close_dev(DEVICE *dev); +bool truncate_dev(DEVICE *dev); +void term_dev(DEVICE *dev); +char * strerror_dev(DEVICE *dev); +void clrerror_dev(DEVICE *dev, int func); +bool update_pos_dev(DEVICE *dev); +bool rewind_dev(DEVICE *dev); +bool load_dev(DEVICE *dev); +bool offline_dev(DEVICE *dev); +int flush_dev(DEVICE *dev); +int weof_dev(DEVICE *dev, int num); +int write_block(DEVICE *dev); uint32_t status_dev(DEVICE *dev); -int eod_dev(DEVICE *dev); -bool fsf_dev(DEVICE *dev, int num); -bool fsr_dev(DEVICE *dev, int num); -bool bsf_dev(DEVICE *dev, int num); -bool bsr_dev(DEVICE *dev, int num); -void attach_jcr_to_device(DEVICE *dev, JCR *jcr); -void detach_jcr_from_device(DEVICE *dev, JCR *jcr); -JCR *next_attached_jcr(DEVICE *dev, JCR *jcr); -bool dev_can_write(DEVICE *dev); -bool offline_or_rewind_dev(DEVICE *dev); -bool reposition_dev(DEVICE *dev, uint32_t file, uint32_t block); -void init_dev_wait_timers(DEVICE *dev); -bool double_dev_wait_time(DEVICE *dev); +int eod_dev(DEVICE *dev); +bool fsf_dev(DEVICE *dev, int num); +bool fsr_dev(DEVICE *dev, int num); +bool bsf_dev(DEVICE *dev, int num); +bool bsr_dev(DEVICE *dev, int num); +void attach_jcr_to_device(DEVICE *dev, JCR *jcr); +void detach_jcr_from_device(DEVICE *dev, JCR *jcr); +JCR *next_attached_jcr(DEVICE *dev, JCR *jcr); +bool dev_can_write(DEVICE *dev); +bool offline_or_rewind_dev(DEVICE *dev); +bool reposition_dev(DEVICE *dev, uint32_t file, uint32_t block); +void init_dev_wait_timers(DEVICE *dev); +bool double_dev_wait_time(DEVICE *dev); /* Get info about device */ -char * dev_name(DEVICE *dev); -char * dev_vol_name(DEVICE *dev); +char * dev_name(DEVICE *dev); +char * dev_vol_name(DEVICE *dev); uint32_t dev_block(DEVICE *dev); uint32_t dev_file(DEVICE *dev); -bool dev_is_tape(DEVICE *dev); +bool dev_is_tape(DEVICE *dev); /* From device.c */ -bool open_device(DCR *dcr); -bool first_open_device(DEVICE *dev); -bool fixup_device_block_write_error(DCR *dcr); -void _lock_device(const char *file, int line, DEVICE *dev); -void _unlock_device(const char *file, int line, DEVICE *dev); -void _block_device(const char *file, int line, DEVICE *dev, int state); -void _unblock_device(const char *file, int line, DEVICE *dev); -void _steal_device_lock(const char *file, int line, DEVICE *dev, bsteal_lock_t *hold, int state); -void _give_back_device_lock(const char *file, int line, DEVICE *dev, bsteal_lock_t *hold); -void set_new_volume_parameters(DCR *dcr); -void set_new_file_parameters(DCR *dcr); -bool device_is_unmounted(DEVICE *dev); -void dev_lock(DEVICE *dev); -void dev_unlock(DEVICE *dev); +bool open_device(DCR *dcr); +bool first_open_device(DEVICE *dev); +bool fixup_device_block_write_error(DCR *dcr); +void _lock_device(const char *file, int line, DEVICE *dev); +void _unlock_device(const char *file, int line, DEVICE *dev); +void _block_device(const char *file, int line, DEVICE *dev, int state); +void _unblock_device(const char *file, int line, DEVICE *dev); +void _steal_device_lock(const char *file, int line, DEVICE *dev, bsteal_lock_t *hold, int state); +void _give_back_device_lock(const char *file, int line, DEVICE *dev, bsteal_lock_t *hold); +void set_new_volume_parameters(DCR *dcr); +void set_new_file_parameters(DCR *dcr); +bool device_is_unmounted(DEVICE *dev); +void dev_lock(DEVICE *dev); +void dev_unlock(DEVICE *dev); const char *edit_blocked_reason(DEVICE *dev); /* From dircmd.c */ -void *handle_connection_request(void *arg); +void *handle_connection_request(void *arg); /* From fd_cmds.c */ -void run_job(JCR *jcr); -bool bootstrap_cmd(JCR *jcr); +void run_job(JCR *jcr); +bool bootstrap_cmd(JCR *jcr); /* From job.c */ -void stored_free_jcr(JCR *jcr); -void connection_from_filed(void *arg); -void handle_filed_connection(BSOCK *fd, char *job_name); +void stored_free_jcr(JCR *jcr); +void connection_from_filed(void *arg); +void handle_filed_connection(BSOCK *fd, char *job_name); /* From label.c */ -int read_dev_volume_label(DCR *dcr); -int read_dev_volume_label_guess(DCR *dcr, bool write); -void create_session_label(DCR *dcr, DEV_RECORD *rec, int label); -void create_volume_label(DEVICE *dev, const char *VolName, const char *PoolName); -bool write_new_volume_label_to_dev(DCR *dcr, const char *VolName, const char *PoolName); -bool write_ansi_ibm_label(DCR *dcr, const char *VolName); -int read_ansi_ibm_label(DCR *dcr); -bool write_session_label(DCR *dcr, int label); -bool write_volume_label_to_block(DCR *dcr); -bool rewrite_volume_label(DCR *dcr, bool recycle); -void dump_volume_label(DEVICE *dev); -void dump_label_record(DEVICE *dev, DEV_RECORD *rec, int verbose); -bool unser_volume_label(DEVICE *dev, DEV_RECORD *rec); -bool unser_session_label(SESSION_LABEL *label, DEV_RECORD *rec); +int read_dev_volume_label(DCR *dcr); +int read_dev_volume_label_guess(DCR *dcr, bool write); +void create_session_label(DCR *dcr, DEV_RECORD *rec, int label); +void create_volume_label(DEVICE *dev, const char *VolName, const char *PoolName); +bool write_new_volume_label_to_dev(DCR *dcr, const char *VolName, const char *PoolName); +bool write_ansi_ibm_label(DCR *dcr, const char *VolName); +int read_ansi_ibm_label(DCR *dcr); +bool write_session_label(DCR *dcr, int label); +bool write_volume_label_to_block(DCR *dcr); +bool rewrite_volume_label(DCR *dcr, bool recycle); +void dump_volume_label(DEVICE *dev); +void dump_label_record(DEVICE *dev, DEV_RECORD *rec, int verbose); +bool unser_volume_label(DEVICE *dev, DEV_RECORD *rec); +bool unser_session_label(SESSION_LABEL *label, DEV_RECORD *rec); /* From match_bsr.c */ -int match_bsr(BSR *bsr, DEV_RECORD *rec, VOLUME_LABEL *volrec, - SESSION_LABEL *sesrec); -int match_bsr_block(BSR *bsr, DEV_BLOCK *block); -void position_bsr_block(BSR *bsr, DEV_BLOCK *block); -BSR *find_next_bsr(BSR *root_bsr, DEVICE *dev); -bool match_set_eof(BSR *bsr, DEV_RECORD *rec); +int match_bsr(BSR *bsr, DEV_RECORD *rec, VOLUME_LABEL *volrec, + SESSION_LABEL *sesrec); +int match_bsr_block(BSR *bsr, DEV_BLOCK *block); +void position_bsr_block(BSR *bsr, DEV_BLOCK *block); +BSR *find_next_bsr(BSR *root_bsr, DEVICE *dev); +bool match_set_eof(BSR *bsr, DEV_RECORD *rec); /* From mount.c */ -bool mount_next_write_volume(DCR *dcr, bool release); -bool mount_next_read_volume(DCR *dcr); -void release_volume(DCR *ddr); -void mark_volume_in_error(DCR *dcr); +bool mount_next_write_volume(DCR *dcr, bool release); +bool mount_next_read_volume(DCR *dcr); +void release_volume(DCR *ddr); +void mark_volume_in_error(DCR *dcr); /* From parse_bsr.c */ -BSR *parse_bsr(JCR *jcr, char *lf); -void dump_bsr(BSR *bsr, bool recurse); -void free_bsr(BSR *bsr); +BSR *parse_bsr(JCR *jcr, char *lf); +void dump_bsr(BSR *bsr, bool recurse); +void free_bsr(BSR *bsr); VOL_LIST *new_vol(); -int add_vol(JCR *jcr, VOL_LIST *vol); -void free_vol_list(JCR *jcr); -void create_vol_list(JCR *jcr); +int add_vol(JCR *jcr, VOL_LIST *vol); +void free_vol_list(JCR *jcr); +void create_vol_list(JCR *jcr); /* From record.c */ const char *FI_to_ascii(int fi); const char *stream_to_ascii(int stream, int fi); -bool write_record_to_block(DEV_BLOCK *block, DEV_RECORD *rec); -bool can_write_record_to_block(DEV_BLOCK *block, DEV_RECORD *rec); -bool read_record_from_block(DEV_BLOCK *block, DEV_RECORD *rec); +bool write_record_to_block(DEV_BLOCK *block, DEV_RECORD *rec); +bool can_write_record_to_block(DEV_BLOCK *block, DEV_RECORD *rec); +bool read_record_from_block(DEV_BLOCK *block, DEV_RECORD *rec); DEV_RECORD *new_record(); -void free_record(DEV_RECORD *rec); -void empty_record(DEV_RECORD *rec); +void free_record(DEV_RECORD *rec); +void empty_record(DEV_RECORD *rec); /* From read_record.c */ bool read_records(DCR *dcr, @@ -211,12 +211,12 @@ bool read_records(DCR *dcr, bool mount_cb(DCR *dcr)); /* From spool.c */ -bool begin_data_spool (JCR *jcr); -bool discard_data_spool (JCR *jcr); -bool commit_data_spool (JCR *jcr); -bool are_attributes_spooled (JCR *jcr); -bool begin_attribute_spool (JCR *jcr); -bool discard_attribute_spool (JCR *jcr); -bool commit_attribute_spool (JCR *jcr); -bool write_block_to_spool_file (DCR *dcr); -void list_spool_stats (BSOCK *bs); +bool begin_data_spool (DCR *dcr); +bool discard_data_spool (DCR *dcr); +bool commit_data_spool (DCR *dcr); +bool are_attributes_spooled (JCR *jcr); +bool begin_attribute_spool (JCR *jcr); +bool discard_attribute_spool (JCR *jcr); +bool commit_attribute_spool (JCR *jcr); +bool write_block_to_spool_file (DCR *dcr); +void list_spool_stats (BSOCK *bs); diff --git a/bacula/src/stored/read.c b/bacula/src/stored/read.c index ec0cdc18b0..b6f5525c07 100644 --- a/bacula/src/stored/read.c +++ b/bacula/src/stored/read.c @@ -80,7 +80,7 @@ bool do_read_data(JCR *jcr) /* Send end of data to FD */ bnet_sig(fd, BNET_EOD); - if (!release_device(jcr)) { + if (!release_device(dcr)) { ok = false; } diff --git a/bacula/src/stored/read_record.c b/bacula/src/stored/read_record.c index 54d355c165..bd50623332 100644 --- a/bacula/src/stored/read_record.c +++ b/bacula/src/stored/read_record.c @@ -11,7 +11,7 @@ * Version $Id$ */ /* - Copyright (C) 2000-2004 Kern Sibbald and John Walker + Copyright (C) 2000-2005 Kern Sibbald This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as @@ -113,7 +113,7 @@ bool read_records(DCR *dcr, display_tape_error_status(jcr, dev); if (forge_on || jcr->ignore_label_errors) { fsr_dev(dev, 1); /* try skipping bad record */ - Dmsg0(000, "Did fsr\n"); + Pmsg0(000, "Did fsr\n"); continue; /* try to continue */ } ok = false; diff --git a/bacula/src/stored/spool.c b/bacula/src/stored/spool.c index ac7bd0f322..5e0b1651c1 100644 --- a/bacula/src/stored/spool.c +++ b/bacula/src/stored/spool.c @@ -6,7 +6,7 @@ * Version $Id$ */ /* - Copyright (C) 2004-2004 Kern Sibbald and John Walker + Copyright (C) 2004-2005 Kern Sibbald This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as @@ -29,9 +29,9 @@ #include "stored.h" /* Forward referenced subroutines */ -static void make_unique_data_spool_filename(JCR *jcr, POOLMEM **name); -static bool open_data_spool_file(JCR *jcr); -static bool close_data_spool_file(JCR *jcr); +static void make_unique_data_spool_filename(DCR *dcr, POOLMEM **name); +static bool open_data_spool_file(DCR *dcr); +static bool close_data_spool_file(DCR *dcr); static bool despool_data(DCR *dcr, bool commit); static int read_block_from_spool_file(DCR *dcr); static bool open_attr_spool_file(JCR *jcr, BSOCK *bs); @@ -84,16 +84,16 @@ void list_spool_stats(BSOCK *bs) } } -bool begin_data_spool(JCR *jcr) +bool begin_data_spool(DCR *dcr) { bool stat = true; - if (jcr->spool_data) { + if (dcr->jcr->spool_data) { Dmsg0(100, "Turning on data spooling\n"); - jcr->dcr->spool_data = true; - stat = open_data_spool_file(jcr); + dcr->spool_data = true; + stat = open_data_spool_file(dcr); if (stat) { - jcr->dcr->spooling = true; - Jmsg(jcr, M_INFO, 0, _("Spooling data ...\n")); + dcr->spooling = true; + Jmsg(dcr->jcr, M_INFO, 0, _("Spooling data ...\n")); P(mutex); spool_stats.data_jobs++; V(mutex); @@ -102,57 +102,57 @@ bool begin_data_spool(JCR *jcr) return stat; } -bool discard_data_spool(JCR *jcr) +bool discard_data_spool(DCR *dcr) { - if (jcr->dcr->spooling) { + if (dcr->spooling) { Dmsg0(100, "Data spooling discarded\n"); - return close_data_spool_file(jcr); + return close_data_spool_file(dcr); } return true; } -bool commit_data_spool(JCR *jcr) +bool commit_data_spool(DCR *dcr) { bool stat; - if (jcr->dcr->spooling) { + if (dcr->spooling) { Dmsg0(100, "Committing spooled data\n"); - stat = despool_data(jcr->dcr, true /*commit*/); + stat = despool_data(dcr, true /*commit*/); if (!stat) { - Pmsg1(000, "Bad return from despool WroteVol=%d\n", jcr->dcr->WroteVol); - close_data_spool_file(jcr); + Pmsg1(000, "Bad return from despool WroteVol=%d\n", dcr->WroteVol); + close_data_spool_file(dcr); return false; } - return close_data_spool_file(jcr); + return close_data_spool_file(dcr); } return true; } -static void make_unique_data_spool_filename(JCR *jcr, POOLMEM **name) +static void make_unique_data_spool_filename(DCR *dcr, POOLMEM **name) { const char *dir; - if (jcr->dcr->dev->device->spool_directory) { - dir = jcr->dcr->dev->device->spool_directory; + if (dcr->dev->device->spool_directory) { + dir = dcr->dev->device->spool_directory; } else { dir = working_directory; } - Mmsg(name, "%s/%s.data.spool.%s.%s", dir, my_name, jcr->Job, - jcr->dcr->device->hdr.name); + Mmsg(name, "%s/%s.data.spool.%s.%s", dir, my_name, dcr->jcr->Job, + dcr->device->hdr.name); } -static bool open_data_spool_file(JCR *jcr) +static bool open_data_spool_file(DCR *dcr) { POOLMEM *name = get_pool_memory(PM_MESSAGE); int spool_fd; - make_unique_data_spool_filename(jcr, &name); + make_unique_data_spool_filename(dcr, &name); if ((spool_fd = open(name, O_CREAT|O_TRUNC|O_RDWR|O_BINARY, 0640)) >= 0) { - jcr->dcr->spool_fd = spool_fd; - jcr->spool_attributes = true; + dcr->spool_fd = spool_fd; + dcr->jcr->spool_attributes = true; } else { berrno be; - Jmsg(jcr, M_FATAL, 0, _("Open data spool file %s failed: ERR=%s\n"), name, + Jmsg(dcr->jcr, M_FATAL, 0, _("Open data spool file %s failed: ERR=%s\n"), name, be.strerror()); free_pool_memory(name); return false; @@ -162,25 +162,25 @@ static bool open_data_spool_file(JCR *jcr) return true; } -static bool close_data_spool_file(JCR *jcr) +static bool close_data_spool_file(DCR *dcr) { POOLMEM *name = get_pool_memory(PM_MESSAGE); P(mutex); spool_stats.data_jobs--; spool_stats.total_data_jobs++; - if (spool_stats.data_size < jcr->dcr->spool_size) { + if (spool_stats.data_size < dcr->spool_size) { spool_stats.data_size = 0; } else { - spool_stats.data_size -= jcr->dcr->spool_size; + spool_stats.data_size -= dcr->spool_size; } - jcr->dcr->spool_size = 0; + dcr->spool_size = 0; V(mutex); - make_unique_data_spool_filename(jcr, &name); - close(jcr->dcr->spool_fd); - jcr->dcr->spool_fd = -1; - jcr->dcr->spooling = false; + make_unique_data_spool_filename(dcr, &name); + close(dcr->spool_fd); + dcr->spool_fd = -1; + dcr->spooling = false; unlink(name); Dmsg1(100, "Deleted spool file: %s\n", name); free_pool_memory(name); diff --git a/bacula/src/stored/stored.c b/bacula/src/stored/stored.c index baea8fd55f..a774a46e2f 100644 --- a/bacula/src/stored/stored.c +++ b/bacula/src/stored/stored.c @@ -322,7 +322,7 @@ void *device_allocation(void *arg) } } if (device->cap_bits & CAP_AUTOMOUNT && device->dev && - device->dev->state & ST_OPENED) { + device->dev->is_open()) { JCR *jcr; DCR *dcr; jcr = new_jcr(sizeof(JCR), stored_free_jcr); diff --git a/bacula/src/version.h b/bacula/src/version.h index a3ba960533..eb3e1f6eda 100644 --- a/bacula/src/version.h +++ b/bacula/src/version.h @@ -1,8 +1,8 @@ /* */ #undef VERSION #define VERSION "1.37.5" -#define BDATE "02 March 2005" -#define LSMDATE "02Mar05" +#define BDATE "04 March 2005" +#define LSMDATE "04Mar05" /* Debug flags */ #undef DEBUG