From 0974feab0f7501918925a72707f254537f8a21fc Mon Sep 17 00:00:00 2001 From: Kern Sibbald Date: Sat, 21 Sep 2002 20:55:48 +0000 Subject: [PATCH] Fixes to making autochanger work with console label command git-svn-id: https://bacula.svn.sourceforge.net/svnroot/bacula/trunk@158 91ce42f0-d328-0410-95d8-f526ca767f89 --- bacula/autoconf/configure.in | 1 + bacula/configure | 1 + bacula/kernstodo | 20 ++++- bacula/src/stored/acquire.c | 2 +- bacula/src/stored/device.c | 2 +- bacula/src/stored/dircmd.c | 2 +- bacula/src/stored/mount.c | 34 ++++++-- bacula/src/stored/protos.h | 150 +++++++++++++++++------------------ bacula/src/version.h | 4 +- 9 files changed, 127 insertions(+), 89 deletions(-) diff --git a/bacula/autoconf/configure.in b/bacula/autoconf/configure.in index 730903eb11..9980b0f955 100644 --- a/bacula/autoconf/configure.in +++ b/bacula/autoconf/configure.in @@ -1254,6 +1254,7 @@ chmod 755 src/cats/create_mysql_database chmod 755 src/cats/alter_mysql_tables chmod 755 src/cats/grant_mysql_privileges chmod 755 src/cats/make_sqlite_tables src/cats/drop_sqlite_tables +chmod 755 src/cats/make_bacula_tables src/cats/drop_bacula_tables chmod 755 src/cats/create_sqlite_database chmod 755 src/cats/alter_sqlite_tables chmod 755 src/cats/sqlite diff --git a/bacula/configure b/bacula/configure index 356bd8844d..d0d775fdb4 100755 --- a/bacula/configure +++ b/bacula/configure @@ -9926,6 +9926,7 @@ chmod 755 src/cats/create_mysql_database chmod 755 src/cats/alter_mysql_tables chmod 755 src/cats/grant_mysql_privileges chmod 755 src/cats/make_sqlite_tables src/cats/drop_sqlite_tables +chmod 755 src/cats/make_bacula_tables src/cats/drop_bacula_tables chmod 755 src/cats/create_sqlite_database chmod 755 src/cats/alter_sqlite_tables chmod 755 src/cats/sqlite diff --git a/bacula/kernstodo b/bacula/kernstodo index 7762d0458c..db09c6c998 100644 --- a/bacula/kernstodo +++ b/bacula/kernstodo @@ -27,7 +27,24 @@ From Chuck: I tried this and it didn't find sqlite.h ======= -- Take another stab at 64 bit file addresses +- Had to label second tape using the autochanger two times. The + first time the second tape was apparently loaded but not labeled. +- Put MaximumVolumeSize in Director. +- Document how to cancel a job that is waiting on a Volume. + Must "cancel" then "mount". +- Document to have patience when SD first starts. +- Document running a test version. +- Attempt to label autochanger tape which is unloaded. + rufus-dir: Start Backup JobId 1, Job=kernsave.2002-09-21.21:07:34 + rufus-sd: Job kernsave.2002-09-21.21:07:34 waiting. Cannot find any appendable volumes. + Please use the "label" command to create a new Volume for: + Storage: FileStorage + Media type: File + Pool: Default + rufus-dir: Error in getmsg.c:129 Job not found: Jmsg Job= type=6 level=0 rufus-sd: Issuing autochanger "load slot 2" command. + + Another try with tape mounted and Job hung in Director. + - When Marking a file in Restore that is a hard link, also mark the link so that the data will be reloaded. - Restore program that errors in SD due to no tape reports @@ -591,3 +608,4 @@ Done: (see kernsdone for more) - sd.conf password does not match dir.conf storage password - Apparently Description records are not freed. Storage daemon Device reported orphaned buffer 45 bytes probably for a Description. +- Take another stab at 64 bit file addresses diff --git a/bacula/src/stored/acquire.c b/bacula/src/stored/acquire.c index 3d9dc37c51..2ba9addb45 100644 --- a/bacula/src/stored/acquire.c +++ b/bacula/src/stored/acquire.c @@ -96,7 +96,7 @@ default_path: dir_get_volume_info(jcr, 0); Dmsg2(200, "calling autoload Vol=%s Slot=%d\n", jcr->VolumeName, jcr->VolCatInfo.Slot); - if (autoload_device(jcr, dev, 0)) { + if (autoload_device(jcr, dev, 0, NULL)) { continue; } /* Mount a specific volume and no other */ diff --git a/bacula/src/stored/device.c b/bacula/src/stored/device.c index 6d41843e64..ecb5f189ea 100644 --- a/bacula/src/stored/device.c +++ b/bacula/src/stored/device.c @@ -113,7 +113,7 @@ int fixup_device_block_write_error(JCR *jcr, DEVICE *dev, DEV_BLOCK *block) unblock_device(dev); return 0; /* device locked */ } - Dmsg0(190, "Back from update_vol_info\n"); + Dmsg0(100, "Back from update_vol_info\n"); strcpy(PrevVolName, dev->VolCatInfo.VolCatName); strcpy(dev->VolHdr.PrevVolName, PrevVolName); diff --git a/bacula/src/stored/dircmd.c b/bacula/src/stored/dircmd.c index c125a2c1ef..aaa26431c2 100644 --- a/bacula/src/stored/dircmd.c +++ b/bacula/src/stored/dircmd.c @@ -324,7 +324,7 @@ static void label_volume_if_ok(JCR *jcr, DEVICE *dev, char *vname, char *poolnam strcpy(jcr->VolumeName, vname); jcr->VolCatInfo.Slot = slot; - autoload_device(jcr, dev, 0); /* autoload if possible */ + autoload_device(jcr, dev, 0, dir); /* autoload if possible */ block = new_block(dev); /* See what we have for a Volume */ diff --git a/bacula/src/stored/mount.c b/bacula/src/stored/mount.c index aac5c57d5b..33b01fc8cf 100644 --- a/bacula/src/stored/mount.c +++ b/bacula/src/stored/mount.c @@ -49,7 +49,7 @@ int mount_next_write_volume(JCR *jcr, DEVICE *dev, DEV_BLOCK *block, int release { int recycle, ask, retry = 0, autochanger; - Dmsg0(190, "Enter mount_next_volume()\n"); + Dmsg0(100, "Enter mount_next_volume()\n"); mount_next_vol: if (retry++ > 5) { @@ -62,7 +62,7 @@ mount_next_vol: } recycle = ask = autochanger = 0; if (release) { - Dmsg0(500, "mount_next_volume release=1\n"); + Dmsg0(100, "mount_next_volume release=1\n"); /* * First erase all memory of the current volume */ @@ -70,6 +70,7 @@ mount_next_vol: dev->file = 0; dev->LastBlockNumWritten = 0; memset(&dev->VolCatInfo, 0, sizeof(dev->VolCatInfo)); + memset(&jcr->VolCatInfo, 0, sizeof(jcr->VolCatInfo)); memset(&dev->VolHdr, 0, sizeof(dev->VolHdr)); dev->state &= ~ST_LABEL; /* label not yet read */ jcr->VolumeName[0] = 0; @@ -99,6 +100,7 @@ mount_next_vol: */ if (!dir_find_next_appendable_volume(jcr)) { ask = 1; /* we must ask */ + Dmsg0(100, "did not find next volume. Must ask.\n"); } Dmsg2(100, "After find_next_append. Vol=%s Slot=%d\n", jcr->VolCatInfo.VolCatName, jcr->VolCatInfo.Slot); @@ -124,7 +126,7 @@ mount_next_vol: jcr->VolFirstFile = jcr->JobFiles; /* first update of Vol FileIndex */ for ( ;; ) { - autochanger = autoload_device(jcr, dev, 1); + autochanger = autoload_device(jcr, dev, 1, NULL); if (autochanger) { ask = 0; /* if autochange no need to ask sysop */ } @@ -132,7 +134,7 @@ mount_next_vol: if (ask && !dir_ask_sysop_to_mount_next_volume(jcr, dev)) { return 0; /* error return */ } - Dmsg1(200, "want vol=%s\n", jcr->VolumeName); + Dmsg1(100, "want vol=%s\n", jcr->VolumeName); /* Open device */ for ( ; !(dev->state & ST_OPENED); ) { @@ -346,10 +348,14 @@ int mount_next_read_volume(JCR *jcr, DEVICE *dev, DEV_BLOCK *block) * On success this routine loads the indicated tape, but the * label is not read, so it must be verified. * + * Note if dir is not NULL, it is the console requesting the + * autoload for labeling, so we respond directly to the + * dir bsock. + * * Returns: 1 on success * 0 on failure */ -int autoload_device(JCR *jcr, DEVICE *dev, int writing) +int autoload_device(JCR *jcr, DEVICE *dev, int writing, BSOCK *dir) { int slot = jcr->VolCatInfo.Slot; int rtn_stat = 0; @@ -359,6 +365,9 @@ int autoload_device(JCR *jcr, DEVICE *dev, int writing) * will return FALSE to ask the sysop. */ if (writing && dev->capabilities && CAP_AUTOCHANGER && slot <= 0) { + if (dir) { + return 0; /* For user, bail out right now */ + } if (dir_find_next_appendable_volume(jcr)) { slot = jcr->VolCatInfo.Slot; } @@ -393,7 +402,11 @@ int autoload_device(JCR *jcr, DEVICE *dev, int writing) force_close_dev(dev); if (loaded != 0) { /* must unload drive */ Dmsg0(100, "Doing changer unload.\n"); - Jmsg(jcr, M_INFO, 0, _("Issuing autochanger \"unload\" command.\n")); + if (dir) { + bnet_fsend(dir, _("3902 Issuing autochanger \"unload\" command.\n")); + } else { + Jmsg(jcr, M_INFO, 0, _("Issuing autochanger \"unload\" command.\n")); + } changer = edit_device_codes(jcr, changer, jcr->device->changer_command, "unload"); status = run_program(changer, timeout, NULL); @@ -403,8 +416,13 @@ int autoload_device(JCR *jcr, DEVICE *dev, int writing) * Load the desired cassette */ Dmsg1(100, "Doing changer load slot %d\n", slot); - Jmsg(jcr, M_INFO, 0, _("Issuing autochanger \"load slot %d\" command.\n"), - slot); + if (dir) { + bnet_fsend(dir, _("3903 Issuing autochanger \"load slot %d\" command.\n"), + slot); + } else { + Jmsg(jcr, M_INFO, 0, _("Issuing autochanger \"load slot %d\" command.\n"), + slot); + } changer = edit_device_codes(jcr, changer, jcr->device->changer_command, "load"); status = run_program(changer, timeout, NULL); diff --git a/bacula/src/stored/protos.h b/bacula/src/stored/protos.h index 9272d43bd3..46720315de 100644 --- a/bacula/src/stored/protos.h +++ b/bacula/src/stored/protos.h @@ -28,34 +28,34 @@ uint32_t new_VolSessionId(); /* From acquire.c */ -int acquire_device_for_append(JCR *jcr, DEVICE *dev, DEV_BLOCK *block); -int acquire_device_for_read(JCR *jcr, DEVICE *dev, DEV_BLOCK *block); -int release_device(JCR *jcr, DEVICE *dev); +int acquire_device_for_append(JCR *jcr, DEVICE *dev, DEV_BLOCK *block); +int acquire_device_for_read(JCR *jcr, DEVICE *dev, DEV_BLOCK *block); +int release_device(JCR *jcr, DEVICE *dev); /* From askdir.c */ -int dir_get_volume_info(JCR *jcr, int writing); -int dir_find_next_appendable_volume(JCR *jcr); -int dir_update_volume_info(JCR *jcr, VOLUME_CAT_INFO *vol, int relabel); -int dir_ask_sysop_to_mount_next_volume(JCR *jcr, DEVICE *dev); -int dir_ask_sysop_to_mount_volume(JCR *jcr, DEVICE *dev); -int dir_update_file_attributes(JCR *jcr, DEV_RECORD *rec); -int dir_send_job_status(JCR *jcr); -int dir_create_jobmedia_record(JCR *jcr); +int dir_get_volume_info(JCR *jcr, int writing); +int dir_find_next_appendable_volume(JCR *jcr); +int dir_update_volume_info(JCR *jcr, VOLUME_CAT_INFO *vol, int relabel); +int dir_ask_sysop_to_mount_next_volume(JCR *jcr, DEVICE *dev); +int dir_ask_sysop_to_mount_volume(JCR *jcr, DEVICE *dev); +int dir_update_file_attributes(JCR *jcr, DEV_RECORD *rec); +int dir_send_job_status(JCR *jcr); +int dir_create_jobmedia_record(JCR *jcr); /* authenticate.c */ -int authenticate_director(JCR *jcr); -int authenticate_filed(JCR *jcr); +int authenticate_director(JCR *jcr); +int authenticate_filed(JCR *jcr); /* From block.c */ -void dump_block(DEV_BLOCK *b, char *msg); +void dump_block(DEV_BLOCK *b, char *msg); DEV_BLOCK *new_block(DEVICE *dev); -void init_block_write(DEV_BLOCK *block); -void empty_block(DEV_BLOCK *block); -void free_block(DEV_BLOCK *block); -int write_block_to_device(JCR *jcr, DEVICE *dev, DEV_BLOCK *block); -int write_block_to_dev(DEVICE *dev, DEV_BLOCK *block); -int read_block_from_device(DEVICE *dev, DEV_BLOCK *block); -int read_block_from_dev(DEVICE *dev, DEV_BLOCK *block); +void init_block_write(DEV_BLOCK *block); +void empty_block(DEV_BLOCK *block); +void free_block(DEV_BLOCK *block); +int write_block_to_device(JCR *jcr, DEVICE *dev, DEV_BLOCK *block); +int write_block_to_dev(DEVICE *dev, DEV_BLOCK *block); +int read_block_from_device(DEVICE *dev, DEV_BLOCK *block); +int read_block_from_dev(DEVICE *dev, DEV_BLOCK *block); /* From butil.c */ void print_ls_output(char *fname, char *link, int type, struct stat *statp); @@ -65,44 +65,44 @@ void display_error_status(DEVICE *dev); /* From dev.c */ -DEVICE *init_dev(DEVICE *dev, char *device); -int open_dev(DEVICE *dev, char *VolName, int mode); -void close_dev(DEVICE *dev); -void force_close_dev(DEVICE *dev); -int truncate_dev(DEVICE *dev); -void term_dev(DEVICE *dev); -char * strerror_dev(DEVICE *dev); -void clrerror_dev(DEVICE *dev, int func); -int update_pos_dev(DEVICE *dev); -int rewind_dev(DEVICE *dev); -int load_dev(DEVICE *dev); -int offline_dev(DEVICE *dev); -int flush_dev(DEVICE *dev); -int weof_dev(DEVICE *dev, int num); -int write_block(DEVICE *dev); -int write_dev(DEVICE *dev, char *buf, size_t len); -int read_dev(DEVICE *dev, char *buf, size_t len); -int status_dev(DEVICE *dev, uint32_t *status); -int eod_dev(DEVICE *dev); -int fsf_dev(DEVICE *dev, int num); -int fsr_dev(DEVICE *dev, int num); -int bsf_dev(DEVICE *dev, int num); -int 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); +DEVICE *init_dev(DEVICE *dev, char *device); +int open_dev(DEVICE *dev, char *VolName, int mode); +void close_dev(DEVICE *dev); +void force_close_dev(DEVICE *dev); +int truncate_dev(DEVICE *dev); +void term_dev(DEVICE *dev); +char * strerror_dev(DEVICE *dev); +void clrerror_dev(DEVICE *dev, int func); +int update_pos_dev(DEVICE *dev); +int rewind_dev(DEVICE *dev); +int load_dev(DEVICE *dev); +int offline_dev(DEVICE *dev); +int flush_dev(DEVICE *dev); +int weof_dev(DEVICE *dev, int num); +int write_block(DEVICE *dev); +int write_dev(DEVICE *dev, char *buf, size_t len); +int read_dev(DEVICE *dev, char *buf, size_t len); +int status_dev(DEVICE *dev, uint32_t *status); +int eod_dev(DEVICE *dev); +int fsf_dev(DEVICE *dev, int num); +int fsr_dev(DEVICE *dev, int num); +int bsf_dev(DEVICE *dev, int num); +int 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); /* 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); -int dev_is_tape(DEVICE *dev); +int dev_is_tape(DEVICE *dev); /* From device.c */ -int open_device(DEVICE *dev); -int fixup_device_block_write_error(JCR *jcr, DEVICE *dev, DEV_BLOCK *block); +int open_device(DEVICE *dev); +int fixup_device_block_write_error(JCR *jcr, DEVICE *dev, DEV_BLOCK *block); void _lock_device(char *file, int line, DEVICE *dev); void _unlock_device(char *file, int line, DEVICE *dev); void _block_device(char *file, int line, DEVICE *dev, int state); @@ -118,39 +118,39 @@ void new_steal_device_lock(DEVICE *dev, brwsteal_t *hold, int state); void new_return_device_lock(DEVICE *dev, brwsteal_t *hold); /* From dircmd.c */ -void connection_request(void *arg); +void connection_request(void *arg); /* From fd_cmds.c */ -void run_job(JCR *jcr); +void run_job(JCR *jcr); /* From fdmsg.c */ -int bget_msg(BSOCK *sock); +int bget_msg(BSOCK *sock); /* 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(JCR *jcr, DEVICE *dev, DEV_BLOCK *block); -void create_session_label(JCR *jcr, DEV_RECORD *rec, int label); -int write_volume_label_to_dev(JCR *jcr, DEVRES *device, char *VolName, char *PoolName); -int write_session_label(JCR *jcr, DEV_BLOCK *block, int label); -int write_volume_label_to_block(JCR *jcr, DEVICE *dev, DEV_BLOCK *block); -void dump_volume_label(DEVICE *dev); -void dump_label_record(DEVICE *dev, DEV_RECORD *rec, int verbose); -int unser_volume_label(DEVICE *dev, DEV_RECORD *rec); -int unser_session_label(SESSION_LABEL *label, DEV_RECORD *rec); +int read_dev_volume_label(JCR *jcr, DEVICE *dev, DEV_BLOCK *block); +void create_session_label(JCR *jcr, DEV_RECORD *rec, int label); +int write_volume_label_to_dev(JCR *jcr, DEVRES *device, char *VolName, char *PoolName); +int write_session_label(JCR *jcr, DEV_BLOCK *block, int label); +int write_volume_label_to_block(JCR *jcr, DEVICE *dev, DEV_BLOCK *block); +void dump_volume_label(DEVICE *dev); +void dump_label_record(DEVICE *dev, DEV_RECORD *rec, int verbose); +int unser_volume_label(DEVICE *dev, DEV_RECORD *rec); +int 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); + SESSION_LABEL *sesrec); /* From mount.c */ -int mount_next_write_volume(JCR *jcr, DEVICE *dev, DEV_BLOCK *block, int release); -int mount_next_read_volume(JCR *jcr, DEVICE *dev, DEV_BLOCK *block); -int autoload_device(JCR *jcr, DEVICE *dev, int writing); +int mount_next_write_volume(JCR *jcr, DEVICE *dev, DEV_BLOCK *block, int release); +int mount_next_read_volume(JCR *jcr, DEVICE *dev, DEV_BLOCK *block); +int autoload_device(JCR *jcr, DEVICE *dev, int writing, BSOCK *dir); /* From parse_bsr.c */ @@ -165,11 +165,11 @@ extern void create_vol_list(JCR *jcr); /* From record.c */ char *FI_to_ascii(int fi); char *stream_to_ascii(int stream); -int write_record_to_block(DEV_BLOCK *block, DEV_RECORD *rec); -int can_write_record_to_block(DEV_BLOCK *block, DEV_RECORD *rec); -int read_record_from_block(DEV_BLOCK *block, DEV_RECORD *rec); +int write_record_to_block(DEV_BLOCK *block, DEV_RECORD *rec); +int can_write_record_to_block(DEV_BLOCK *block, DEV_RECORD *rec); +int read_record_from_block(DEV_BLOCK *block, DEV_RECORD *rec); DEV_RECORD *new_record(); -void free_record(DEV_RECORD *rec); +void free_record(DEV_RECORD *rec); /* From read_record.c */ int read_records(JCR *jcr, DEVICE *dev, diff --git a/bacula/src/version.h b/bacula/src/version.h index 61e381ecff..6c7343678c 100644 --- a/bacula/src/version.h +++ b/bacula/src/version.h @@ -1,8 +1,8 @@ /* */ #define VERSION "1.26" #define VSTRING "1" -#define DATE "14 September 2002" -#define LSMDATE "14Sep02" +#define DATE "21 September 2002" +#define LSMDATE "21Sep02" /* Debug flags */ #define DEBUG 1 -- 2.39.5