From 2308ede5f153013956031b1023b4a075681ddc38 Mon Sep 17 00:00:00 2001 From: Kern Sibbald Date: Thu, 17 Mar 2005 14:19:28 +0000 Subject: [PATCH] Add restore speed patch git-svn-id: https://bacula.svn.sourceforge.net/svnroot/bacula/trunk@1889 91ce42f0-d328-0410-95d8-f526ca767f89 --- bacula/patches/1.36.2-console.patch | 32 ++++++ bacula/patches/1.36.2-netbsd.patch | 47 +++++++++ bacula/patches/1.36.2-restore-speed.patch | 120 ++++++++++++++++++++++ bacula/patches/patches-1.36.2 | 19 ++++ 4 files changed, 218 insertions(+) create mode 100644 bacula/patches/1.36.2-console.patch create mode 100644 bacula/patches/1.36.2-netbsd.patch create mode 100644 bacula/patches/1.36.2-restore-speed.patch diff --git a/bacula/patches/1.36.2-console.patch b/bacula/patches/1.36.2-console.patch new file mode 100644 index 0000000000..b46228f4e8 --- /dev/null +++ b/bacula/patches/1.36.2-console.patch @@ -0,0 +1,32 @@ + + This patch causes the output directed to a file to be + flushed after every line. This is a bit overkill, IMO, but + a user complained about it. + + Apply to 1.36.2 with: + + cd + patch -p0 <1.36.2-console.patch + make + ... + +Index: src/console/console.c +=================================================================== +RCS file: /cvsroot/bacula/bacula/src/console/console.c,v +retrieving revision 1.53.6.1 +diff -u -b -r1.53.6.1 console.c +--- src/console/console.c 25 Feb 2005 09:47:06 -0000 1.53.6.1 ++++ src/console/console.c 16 Mar 2005 11:36:43 -0000 +@@ -748,10 +748,11 @@ + } + #else + fputs(buf, output); ++ fflush(output); + if (tee) { + fputs(buf, stdout); + } +- if (output == stdout || tee) { ++ if (output != stdout || tee) { + fflush(stdout); + } + #endif diff --git a/bacula/patches/1.36.2-netbsd.patch b/bacula/patches/1.36.2-netbsd.patch new file mode 100644 index 0000000000..33a0354f9f --- /dev/null +++ b/bacula/patches/1.36.2-netbsd.patch @@ -0,0 +1,47 @@ + + This patch corrects a compile problem because of no statfs() + on NetBSD. The patch was submitted by kardel with bug 258. + + Apply the patch to version 1.36.2 with: + + cd + patch -p0 <1.36.2-netbsd.patch + make + ... + +Index: src/findlib/fstype.c +=================================================================== +RCS file: /cvsroot/bacula/bacula/src/findlib/fstype.c,v +retrieving revision 1.7.2.2 +diff -u -r1.7.2.2 fstype.c +--- src/findlib/fstype.c 25 Feb 2005 09:47:06 -0000 1.7.2.2 ++++ src/findlib/fstype.c 15 Mar 2005 14:01:44 -0000 +@@ -61,7 +61,6 @@ + */ + #if defined(HAVE_DARWIN_OS) \ + || defined(HAVE_FREEBSD_OS ) \ +- || defined(HAVE_NETBSD_OS) \ + || defined(HAVE_OPENBSD_OS) + + #include +@@ -77,7 +76,20 @@ + Dmsg1(50, "statfs() failed for \"%s\"\n", fname); + return false; + } ++#elif defined(HAVE_NETBSD_OS) ++#include ++#include + ++bool fstype(const char *fname, char *fs, int fslen) ++{ ++ struct statvfs st; ++ if (statvfs(fname, &st) == 0) { ++ bstrncpy(fs, st.f_fstypename, fslen); ++ return true; ++ } ++ Dmsg1(50, "statfs() failed for \"%s\"\n", fname); ++ return false; ++} + #elif defined(HAVE_HPUX_OS) \ + || defined(HAVE_IRIX_OS) + diff --git a/bacula/patches/1.36.2-restore-speed.patch b/bacula/patches/1.36.2-restore-speed.patch new file mode 100644 index 0000000000..4acae6c998 --- /dev/null +++ b/bacula/patches/1.36.2-restore-speed.patch @@ -0,0 +1,120 @@ + + This patch will fix a subtle bug that was introduced in 1.36.2 + which causes Bacula to be very slow restoring a few files. This + is because it reads completely to the end of the Volume rather + than stopping when all the files on the Volume are loaded. The + introduction of the bug was caused by a patch that fixed + Bacula truncating tapes after a restore. + + Apply the patch to 1.36.2 with the following: + + cd + patch -p0 <1.36.2-restore-speed.patch + make + ... + + Note that all source files will be rebuilt during the make. + +Index: src/jcr.h +=================================================================== +RCS file: /cvsroot/bacula/bacula/src/jcr.h,v +retrieving revision 1.76.4.1 +diff -u -u -b -r1.76.4.1 jcr.h +--- src/jcr.h 27 Feb 2005 21:53:28 -0000 1.76.4.1 ++++ src/jcr.h 17 Mar 2005 14:14:18 -0000 +@@ -243,6 +243,7 @@ + + /* Parmaters for Open Read Session */ + BSR *bsr; /* Bootstrap record -- has everything */ ++ bool mount_next_volume; /* set to cause next volume mount */ + uint32_t read_VolSessionId; + uint32_t read_VolSessionTime; + uint32_t read_StartFile; +Index: src/stored/read_record.c +=================================================================== +RCS file: /cvsroot/bacula/bacula/src/stored/read_record.c,v +retrieving revision 1.47.4.1 +diff -u -u -b -r1.47.4.1 read_record.c +--- src/stored/read_record.c 15 Feb 2005 11:51:04 -0000 1.47.4.1 ++++ src/stored/read_record.c 17 Mar 2005 14:14:18 -0000 +@@ -5,13 +5,16 @@ + * archive. It uses a callback to pass you each record in turn, + * as well as a callback for mounting the next tape. It takes + * care of reading blocks, applying the bsr, ... ++ * Note, this routine is really the heart of the restore routines, ++ * and we are *really* bit pushing here so be careful about making ++ * any modifications. + * + * Kern E. Sibbald, August MMII + * +- * Version $Id$ ++ * 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 +@@ -57,6 +60,7 @@ + + recs = New(dlist(rec, &rec->link)); + position_to_first_file(jcr, dev); ++ jcr->mount_next_volume = false; + + for ( ; ok && !done; ) { + if (job_canceled(jcr)) { +@@ -66,12 +70,11 @@ + if (!read_block_from_device(dcr, CHECK_BLOCK_NUMBERS)) { + if (dev->at_eot()) { + DEV_RECORD *trec = new_record(); +- + Jmsg(jcr, M_INFO, 0, "End of Volume at file %u on device %s, Volume \"%s\"\n", + dev->file, dev_name(dev), dcr->VolumeName); + if (!mount_cb(dcr)) { + Jmsg(jcr, M_INFO, 0, "End of all volumes.\n"); +- ok = false; ++ ok = false; /* Stop everything */ + /* + * Create EOT Label so that Media record may + * be properly updated because this is the last +@@ -81,8 +84,13 @@ + trec->File = dev->file; + ok = record_cb(dcr, trec); + free_record(trec); ++ if (jcr->mount_next_volume) { ++ jcr->mount_next_volume = false; ++ dev->state &= ~ST_EOT; ++ } + break; + } ++ jcr->mount_next_volume = false; + /* + * We just have a new tape up, now read the label (first record) + * and pass it off to the callback routine, then continue +@@ -113,10 +121,10 @@ + 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; ++ ok = false; /* stop everything */ + break; + } + } +@@ -259,7 +267,11 @@ + Dmsg2(300, "Current postion (file:block) %d:%d\n", + dev->file, dev->block_num); + jcr->bsr->mount_next_volume = false; +-// dev->state |= ST_EOT; ++ if (!dev->at_eot()) { ++ /* Set EOT flag to force mount of next Volume */ ++ jcr->mount_next_volume = true; ++ dev->state |= ST_EOT; ++ } + rec->Block = 0; + return 1; + } diff --git a/bacula/patches/patches-1.36.2 b/bacula/patches/patches-1.36.2 index bae9d5dabf..75312c1905 100644 --- a/bacula/patches/patches-1.36.2 +++ b/bacula/patches/patches-1.36.2 @@ -12,3 +12,22 @@ This patch will prevent the Win32 FD from printing an error message when it attempts to restore the permissions for a drive (which Win32 doesn't permit). The error is harmless in any case. + +15Mar05 1.36.2-netbsd.patch + This patch corrects a compile problem because of no statfs() + on NetBSD. The patch was submitted by kardel with bug 258. + +16Mar05 1.36.2-console.patch + This patch causes the output directed to a file to be + flushed after every line. This is a bit overkill, IMO, but + a user complained about it. + +17Mar05 1.36.2-restore-speed.patch + This patch will fix a subtle bug that was introduced in 1.36.2 + which causes Bacula to be very slow restoring a few files. This + is because it reads completely to the end of the Volume rather + than stopping when all the files on the Volume are loaded. The + introduction of the bug was caused by a patch that fixed + Bacula truncating tapes after a restore. + Note that all source files will be rebuilt during the make. + -- 2.39.5