From 6059942f901fc5bc151c40f3dab2d748c34e1ba9 Mon Sep 17 00:00:00 2001 From: Kern Sibbald Date: Thu, 31 Aug 2006 21:07:14 +0000 Subject: [PATCH] kes Make find with no args in tree restore return error rather than stopping the selection. Fixes bug #665 kes Rework DVD writing to ensure that the last part is written on open_next_part when dealing with a spool file. kes Correct the lseek_dev() routine to handle end point correctly (bug introduced by me). kes Allow part number to exceed num_dvd_parts in lseek_dev(). git-svn-id: https://bacula.svn.sourceforge.net/svnroot/bacula/trunk@3391 91ce42f0-d328-0410-95d8-f526ca767f89 --- bacula/ReleaseNotes | 22 +++++++++++++++++++--- bacula/src/dird/ua_tree.c | 2 +- bacula/src/stored/block.c | 5 ++++- bacula/src/stored/dev.c | 8 ++++---- bacula/src/stored/dvd.c | 29 ++++++++++++++--------------- bacula/src/version.h | 4 ++-- bacula/technotes-1.39 | 8 ++++++++ 7 files changed, 52 insertions(+), 26 deletions(-) diff --git a/bacula/ReleaseNotes b/bacula/ReleaseNotes index 8442a90b36..35cd4cdd39 100644 --- a/bacula/ReleaseNotes +++ b/bacula/ReleaseNotes @@ -32,6 +32,22 @@ Fixes for 1.39.20: - Eric fixed RunScripts, which I (Kern) had broken in the last beta. - Correct Client migration SQL as pointed out by Marc. +==== IMPORTANT ===== +- The database format has been updated from what was used in + Bacula 1.38.x. You must manually update your database before + running Bacula 1.39.x or higher. Please backup your previous + version of the database before running the update. The update + script will be automatically installed in your scripts directory, + or can also be found in /src/cats. It is called: + + ./update_bacula_tables + + It is necessary to run it only once the first time you move to a + 1.39.x beta or to 1.40.0. Upgrading the Bacula version thereafter + does not require updating the database again. Depending on the size of your + database the script make take a bit of time, to run, but in + general, it should be very fast. + New Features in 1.40.0 (beginning of release info) - There is a new cross-compiled Win32 File daemon that now has all the features that were previously only in the Unix versions. @@ -68,9 +84,9 @@ New Features in 1.40.0 (beginning of release info) Warning for version 1.39.18 and greater: - The documentation is almost non-existent for all new features except RunScripts (written and documented by Eric Bollengier). -- If you have an old pre 1.39.18 database, you must upgrade it using - the upgrade_bacula_tables script. Please backup your database before - upgrading just in case. +- If you have an old pre 1.39.18 database, you must update it using + the update_bacula_tables script. Please backup your database before + updating just in case. - You *should* be able to use 1.38.x FDs with version 1.39.18 Director and SD providing you do not use any of the new features (runscript, data encryption). It seems to work here, but we do not guarantee it. diff --git a/bacula/src/dird/ua_tree.c b/bacula/src/dird/ua_tree.c index 606ad9bbba..5c4f308124 100644 --- a/bacula/src/dird/ua_tree.c +++ b/bacula/src/dird/ua_tree.c @@ -375,7 +375,7 @@ static int findcmd(UAContext *ua, TREE_CTX *tree) if (ua->argc == 1) { bsendmsg(ua, _("No file specification given.\n")); - return 0; + return 1; /* make it non-fatal */ } for (int i=1; i < ua->argc; i++) { diff --git a/bacula/src/stored/block.c b/bacula/src/stored/block.c index 0cf0ea40f2..69f9ab616b 100644 --- a/bacula/src/stored/block.c +++ b/bacula/src/stored/block.c @@ -927,9 +927,11 @@ reread: Dmsg3(100, "Tests : %d %d %d\n", (dev->VolCatInfo.VolCatParts > 0), ((dev->file_addr-dev->part_start) == dev->part_size), (dev->part <= dev->VolCatInfo.VolCatParts));*/ + /* Check for DVD part file end */ if (dev->at_eof() && dev->is_dvd() && dev->num_dvd_parts > 0 && dev->part < dev->num_dvd_parts) { + Dmsg0(400, "Call dvd_open_next_part\n"); if (dvd_open_next_part(dcr) < 0) { Jmsg3(dcr->jcr, M_FATAL, 0, _("Unable to open device part=%d %s: ERR=%s\n"), dev->part, dev->print_name(), dev->bstrerror()); @@ -1096,10 +1098,11 @@ reread: if (block->read_len > block->block_len && !dev->is_tape()) { char ed1[50]; off_t pos = lseek_dev(dev, (off_t)0, SEEK_CUR); /* get curr pos */ + Dmsg1(200, "Current lseek pos=%s\n", edit_int64(pos, ed1)); pos -= (block->read_len - block->block_len); lseek_dev(dev, pos, SEEK_SET); Dmsg3(200, "Did lseek pos=%s blk_size=%d rdlen=%d\n", - edit_uint64(pos, ed1), block->block_len, + edit_int64(pos, ed1), block->block_len, block->read_len); dev->file_addr = pos; dev->file_size = pos; diff --git a/bacula/src/stored/dev.c b/bacula/src/stored/dev.c index 5ecbe103ca..c053980bb3 100644 --- a/bacula/src/stored/dev.c +++ b/bacula/src/stored/dev.c @@ -653,6 +653,10 @@ bool DEVICE::rewind(DCR *dcr) bool first = true; Dmsg3(400, "rewind res=%d fd=%d %s\n", reserved_device, fd, print_name()); + state &= ~(ST_EOT|ST_EOF|ST_WEOT); /* remove EOF/EOT flags */ + block_num = file = 0; + file_size = 0; + file_addr = 0; if (fd < 0) { if (!is_dvd()) { /* In case of major error, the fd is not open on DVD, so we don't want to abort. */ dev_errno = EBADF; @@ -662,10 +666,6 @@ bool DEVICE::rewind(DCR *dcr) } return false; } - state &= ~(ST_EOT|ST_EOF|ST_WEOT); /* remove EOF/EOT flags */ - block_num = file = 0; - file_size = 0; - file_addr = 0; if (is_tape()) { mt_com.mt_op = MTREW; mt_com.mt_count = 1; diff --git a/bacula/src/stored/dvd.c b/bacula/src/stored/dvd.c index bb890056fa..3a7bb90c1f 100644 --- a/bacula/src/stored/dvd.c +++ b/bacula/src/stored/dvd.c @@ -489,10 +489,10 @@ int dvd_open_next_part(DCR *dcr) memcpy(&dev->VolCatInfo, &dcr->VolCatInfo, sizeof(dev->VolCatInfo)); /* - * If we have a part open for write, then write it to + * If we have a spooled part open, write it to the * DVD before opening the next part. */ - if (dev->part > dev->num_dvd_parts && dev->can_append()) { + if (dev->is_part_spooled()) { Dmsg2(100, "Before open next write previous. part=%d num_parts=%d\n", dev->part, dev->num_dvd_parts); if (!dvd_write_part(dcr)) { @@ -606,25 +606,21 @@ off_t lseek_dev(DEVICE *dev, off_t offset, int whence) off_t pos; char ed1[50], ed2[50]; - Dmsg3(400, "Enter lseek_dev fd=%d part=%d nparts=%d\n", dev->fd, - dev->part, dev->num_dvd_parts); + Dmsg5(400, "Enter lseek_dev fd=%d off=%s w=%d part=%d nparts=%d\n", dev->fd, + edit_int64(offset, ed1), whence, dev->part, dev->num_dvd_parts); if (!dev->is_dvd()) { Dmsg0(400, "Using sys lseek\n"); return lseek(dev->fd, offset, whence); } - /* Return I/O error ... no part */ - if (dev->part > dev->num_dvd_parts) { - return 0; - } - dcr = (DCR *)dev->attached_dcrs->first(); /* any dcr will do */ switch(whence) { case SEEK_SET: Dmsg2(400, "lseek_dev SEEK_SET to %s (part_start=%s)\n", - edit_uint64(offset, ed1), edit_uint64(dev->part_start, ed2)); + edit_int64(offset, ed1), edit_uint64(dev->part_start, ed2)); if ((uint64_t)offset >= dev->part_start) { - if ((uint64_t)offset < dev->part_start+dev->part_size) { + if ((uint64_t)offset == dev->part_start || + (uint64_t)offset < dev->part_start+dev->part_size) { /* We are staying in the current part, just seek */ if ((pos = lseek(dev->fd, offset-dev->part_start, SEEK_SET)) < 0) { return pos; @@ -660,20 +656,22 @@ off_t lseek_dev(DEVICE *dev, off_t offset, int whence) } break; case SEEK_CUR: - Dmsg1(400, "lseek_dev SEEK_CUR to %s\n", edit_uint64(offset, ed1)); + Dmsg1(400, "lseek_dev SEEK_CUR to %s\n", edit_int64(offset, ed1)); if ((pos = lseek(dev->fd, (off_t)0, SEEK_CUR)) < 0) { - return pos; + Dmsg0(400, "Seek error.\n"); + return pos; } pos += dev->part_start; if (offset == 0) { Dmsg1(400, "lseek_dev SEEK_CUR returns %s\n", edit_uint64(pos, ed1)); return pos; - } else { /* Not used in Bacula, but should work */ + } else { + Dmsg1(400, "do lseek_dev SEEK_SET %s\n", edit_uint64(pos, ed1)); return lseek_dev(dev, pos, SEEK_SET); } break; case SEEK_END: - Dmsg1(400, "lseek_dev SEEK_END to %s\n", edit_uint64(offset, ed1)); + Dmsg1(400, "lseek_dev SEEK_END to %s\n", edit_int64(offset, ed1)); /* * Bacula does not use offsets for SEEK_END * Also, Bacula uses seek_end only when it wants to @@ -728,6 +726,7 @@ off_t lseek_dev(DEVICE *dev, off_t offset, int whence) } break; default: + Dmsg0(400, "Seek call error.\n"); errno = EINVAL; return -1; } diff --git a/bacula/src/version.h b/bacula/src/version.h index 26fd4d6d89..b5a461f1b6 100644 --- a/bacula/src/version.h +++ b/bacula/src/version.h @@ -4,8 +4,8 @@ #undef VERSION #define VERSION "1.39.21" -#define BDATE "30 August 2006" -#define LSMDATE "30Aug06" +#define BDATE "31 August 2006" +#define LSMDATE "31Aug06" #define BYEAR "2006" /* year for copyright messages in progs */ /* Debug flags */ diff --git a/bacula/technotes-1.39 b/bacula/technotes-1.39 index bc9f422490..d4e5056b1e 100644 --- a/bacula/technotes-1.39 +++ b/bacula/technotes-1.39 @@ -1,6 +1,14 @@ Technical notes on version 1.39 General: +31Aug06 +kes Make find with no args in tree restore return error rather than + stopping the selection. Fixes bug #665 +kes Rework DVD writing to ensure that the last part is written + on open_next_part when dealing with a spool file. +kes Correct the lseek_dev() routine to handle end point correctly + (bug introduced by me). +kes Allow part number to exceed num_dvd_parts in lseek_dev(). 30Aug06 kes Apply dvd-handler patch from Richard Mortimer. kes Apply dvd error check patch from Richard Mortimer. -- 2.39.5