From e98e361785ed4d4f6c3e7d8049825addbdf52f31 Mon Sep 17 00:00:00 2001 From: Kern Sibbald Date: Wed, 4 Dec 2002 20:15:22 +0000 Subject: [PATCH] FSF to file on restore git-svn-id: https://bacula.svn.sourceforge.net/svnroot/bacula/trunk@231 91ce42f0-d328-0410-95d8-f526ca767f89 --- bacula/kernstodo | 20 ++++++++------------ bacula/src/stored/acquire.c | 14 +++++++++++++- bacula/src/stored/btape.c | 7 +++++++ bacula/src/stored/butil.c | 1 - bacula/src/stored/mount.c | 9 --------- bacula/src/stored/parse_bsr.c | 9 ++++++--- 6 files changed, 34 insertions(+), 26 deletions(-) diff --git a/bacula/kernstodo b/bacula/kernstodo index c42cb4c63b..7f2acd5f5a 100644 --- a/bacula/kernstodo +++ b/bacula/kernstodo @@ -14,23 +14,15 @@ Testing to do: (painful) For 1.28 release: -- Make BSR accept count (total files to be restored). -- Make BSR return next_block when it knows record is not - in block, done when count is reached, and possibly other - optimizations. I.e. add a state word. -- Continue improving the restore process (handling - of tapes, efficiency improvements e.g. use FSF to - position the tape, ...) -- Add code to fast seek to proper place on tape/file - when doing Restore. If it doesn't work, try linear - search as before. +- Add code to put VolFile in bsr for restore command. - Add code to reject whole blocks if not wanted on restore. +- Add watchdog timeout for child processes start_child_timer() + end_child_timer(); - Figure out how to allow multiple simultaneous file Volumes on a single device. - Start working on Base jobs. - Implement FileOptions (see end of this document) -- Replace popen() and pclose() -- fail safe and timeout, no SIG dep. - Ensure that restore of differential jobs works (check SQL). - Make sure the MaxVolFiles is fully implemented in SD - Flush all the daemon messages at the end of every job. @@ -40,7 +32,6 @@ For 1.28 release: - Need return status on read_cb() from read_records(). Need multiple records -- one per Job, maybe a JCR or some other structure with a block and a record. -- Think about how to make Bacula work better with File archives. - Work more on how to to a Bacula restore beginning with just a Bacula tape and a boot floppy (bare metal recovery). @@ -113,6 +104,7 @@ For 1.28 release: - Handle ctl-c in Console - Implement LabelTemplate (at least first cut). - Implement script driven addition of File daemon to config files. +- Think about how to make Bacula work better with File archives. - see setgroup and user for Bacula p4-5 of stunnel.c - Implement new serialize subroutines @@ -619,3 +611,7 @@ Done: (see kernsdone for more) - Make Job err if WriteBootstrap fails. - Test that mod of restore options works. - Test that week position schedule code works. +- Make BSR accept count (total files to be restored). +- Add code to fast seek to proper place on tape/file when doing Restore. +- Replace popen() and pclose() -- fail safe and timeout, no SIG dep. + diff --git a/bacula/src/stored/acquire.c b/bacula/src/stored/acquire.c index 612721160d..9dd7f3a5d3 100644 --- a/bacula/src/stored/acquire.c +++ b/bacula/src/stored/acquire.c @@ -41,6 +41,7 @@ int acquire_device_for_read(JCR *jcr, DEVICE *dev, DEV_BLOCK *block) { int stat = 0; int tape_previously_mounted; + VOL_LIST *vol; lock_device(dev); block_device(dev, BST_DOING_ACQUIRE); @@ -53,6 +54,14 @@ int acquire_device_for_read(JCR *jcr, DEVICE *dev, DEV_BLOCK *block) goto get_out; } + /* Find next Volume, if any */ + vol = jcr->VolList; + jcr->CurVolume++; + for (int i=1; iCurVolume; i++) { + vol = vol->next; + } + pm_strcpy(&jcr->VolumeName, vol->VolumeName); + for (;;) { if (job_cancelled(jcr)) { Mmsg0(&dev->errmsg, _("Job cancelled.\n")); @@ -72,7 +81,6 @@ int acquire_device_for_read(JCR *jcr, DEVICE *dev, DEV_BLOCK *block) } Dmsg1(129, "open_dev %s OK\n", dev_name(dev)); } - /* ***FIXME*** this is probably not necessary */ dev->state &= ~ST_LABEL; /* force reread of label */ Dmsg0(200, "calling read-vol-label\n"); switch (read_dev_volume_label(jcr, dev, block)) { @@ -114,6 +122,10 @@ default_path: dev->state |= ST_READ; attach_jcr_to_device(dev, jcr); /* attach jcr to device */ stat = 1; /* good return */ + if ((dev->state & ST_TAPE) && vol->start_file > 0) { + Dmsg1(100, "====== Got start_file = %d\n", vol->start_file); + fsf_dev(dev, vol->start_file); + } get_out: P(dev->mutex); diff --git a/bacula/src/stored/btape.c b/bacula/src/stored/btape.c index 0a38b1b38a..28f769700c 100644 --- a/bacula/src/stored/btape.c +++ b/bacula/src/stored/btape.c @@ -944,7 +944,10 @@ static void unfillcmd() end_of_tape = 0; get_cmd("Mount first of two tapes. Press enter when ready: "); + free_vol_list(jcr); pm_strcpy(&jcr->VolumeName, "TestVolume1"); + jcr->bsr = NULL; + create_vol_list(jcr); close_dev(dev); dev->state &= ~ST_READ; if (!acquire_device_for_read(jcr, dev, block)) { @@ -1259,7 +1262,11 @@ static int my_mount_next_read_volume(JCR *jcr, DEVICE *dev, DEV_BLOCK *block) end_of_tape = 1; return 0; } + + free_vol_list(jcr); pm_strcpy(&jcr->VolumeName, "TestVolume2"); + jcr->bsr = NULL; + create_vol_list(jcr); close_dev(dev); dev->state &= ~ST_READ; if (!acquire_device_for_read(jcr, dev, block)) { diff --git a/bacula/src/stored/butil.c b/bacula/src/stored/butil.c index e27f52c973..318408428a 100644 --- a/bacula/src/stored/butil.c +++ b/bacula/src/stored/butil.c @@ -104,7 +104,6 @@ DEVICE *setup_to_access_device(JCR *jcr, int read_access) create_vol_list(jcr); - Dmsg1(100, "Volume=%s\n", jcr->VolumeName); if (read_access) { if (!acquire_device_for_read(jcr, dev, block)) { Emsg0(M_ERROR, 0, dev->errmsg); diff --git a/bacula/src/stored/mount.c b/bacula/src/stored/mount.c index e32579ad0c..1a88f1ea7d 100644 --- a/bacula/src/stored/mount.c +++ b/bacula/src/stored/mount.c @@ -342,15 +342,6 @@ int mount_next_read_volume(JCR *jcr, DEVICE *dev, DEV_BLOCK *block) * End Of Tape -- mount next Volume (if another specified) */ if (jcr->NumVolumes > 1 && jcr->CurVolume < jcr->NumVolumes) { - VOL_LIST *vol = jcr->VolList; - /* Find next Volume */ - jcr->CurVolume++; - for (int i=1; iCurVolume; i++) { - vol = vol->next; - } - pm_strcpy(&jcr->VolumeName, vol->VolumeName); - Dmsg1(400, "There is another volume %s.\n", jcr->VolumeName); - close_dev(dev); dev->state &= ~ST_READ; if (!acquire_device_for_read(jcr, dev, block)) { diff --git a/bacula/src/stored/parse_bsr.c b/bacula/src/stored/parse_bsr.c index 553854985f..3cc924e8c0 100755 --- a/bacula/src/stored/parse_bsr.c +++ b/bacula/src/stored/parse_bsr.c @@ -720,6 +720,10 @@ void free_vol_list(JCR *jcr) jcr->VolList = NULL; } +/* + * Create a list of Volumes (and Slots and Start positions) to be + * used in the current restore job. + */ void create_vol_list(JCR *jcr) { char *p, *n; @@ -729,17 +733,16 @@ void create_vol_list(JCR *jcr) * Build a list of volumes to be processed */ jcr->NumVolumes = 0; - jcr->CurVolume = 1; + jcr->CurVolume = 0; if (jcr->bsr) { BSR *bsr = jcr->bsr; if (!bsr->volume || !bsr->volume->VolumeName) { return; } - strcpy(jcr->VolumeName, bsr->volume->VolumeName); /* setup first volume */ for ( ; bsr; bsr=bsr->next) { BSR_VOLUME *bsrvol; BSR_VOLFILE *volfile; - uint32_t sfile = 0; + uint32_t sfile = UINT32_MAX; /* Find minimum start file so that we can forward space to it */ for (volfile = bsr->volfile; volfile; volfile=volfile->next) { -- 2.39.5