From: Kern Sibbald Date: Thu, 24 May 2007 19:58:07 +0000 (+0000) Subject: kes Add code to tell the OS that we no longer need a cached X-Git-Tag: Release-7.0.0~6247 X-Git-Url: https://git.sur5r.net/?a=commitdiff_plain;h=616a54dedacdd56c68047bcc81a909ba2c7c0f7f;p=bacula%2Fbacula kes Add code to tell the OS that we no longer need a cached file that we were reading. In findlib/bfile.c. Also, only cache files that we are reading. kes Tweak to bsmtp to eliminate compiler warnings on Win32. kes Implement script to automatically generate cats and dll .def files for Win32 dll. kes Update README.mingw32 to include new .def file generation. git-svn-id: https://bacula.svn.sourceforge.net/svnroot/bacula/trunk@4898 91ce42f0-d328-0410-95d8-f526ca767f89 --- diff --git a/bacula/autoconf/config.h.in b/bacula/autoconf/config.h.in index e860477e18..5806d22ea1 100644 --- a/bacula/autoconf/config.h.in +++ b/bacula/autoconf/config.h.in @@ -296,6 +296,9 @@ /* Set if Bacula conio support enabled */ #undef HAVE_CONIO +/* Define if encryption support should be enabled */ +#undef HAVE_CRYPTO + /* Define to 1 if you have the header file. */ #undef HAVE_CURSES_H @@ -340,6 +343,9 @@ /* Define to 1 if you have the header file. */ #undef HAVE_FCNTL_H +/* Define to 1 if you have the `fdatasync' function. */ +#undef HAVE_FDATASYNC + /* Define to 1 if you have the `fork' function. */ #undef HAVE_FORK @@ -817,9 +823,9 @@ /* If using the C implementation of alloca, define if you know the direction of stack growth for your system; otherwise it will be automatically deduced at runtime. - STACK_DIRECTION > 0 => grows toward higher addresses - STACK_DIRECTION < 0 => grows toward lower addresses - STACK_DIRECTION = 0 => direction of growth unknown */ + STACK_DIRECTION > 0 => grows toward higher addresses + STACK_DIRECTION < 0 => grows toward lower addresses + STACK_DIRECTION = 0 => direction of growth unknown */ #undef STACK_DIRECTION /* Define to 1 if the `S_IS*' macros in do not work properly. */ diff --git a/bacula/autoconf/configure.in b/bacula/autoconf/configure.in index 700d464468..700a9f8922 100644 --- a/bacula/autoconf/configure.in +++ b/bacula/autoconf/configure.in @@ -1640,6 +1640,7 @@ AC_CHECK_FUNCS( \ AC_CHECK_FUNCS(fchdir, [AC_DEFINE(HAVE_FCHDIR)]) AC_CHECK_FUNCS(strtoll, [AC_DEFINE(HAVE_STRTOLL)]) AC_CHECK_FUNCS(posix_fadvise) +AC_CHECK_FUNCS(fdatasync) AC_CHECK_FUNCS(chflags) diff --git a/bacula/configure b/bacula/configure index 02c42ea61d..00383b154f 100755 --- a/bacula/configure +++ b/bacula/configure @@ -30317,6 +30317,116 @@ fi done +for ac_func in fdatasync +do +as_ac_var=`echo "ac_cv_func_$ac_func" | $as_tr_sh` +{ echo "$as_me:$LINENO: checking for $ac_func" >&5 +echo $ECHO_N "checking for $ac_func... $ECHO_C" >&6; } +if { as_var=$as_ac_var; eval "test \"\${$as_var+set}\" = set"; }; then + echo $ECHO_N "(cached) $ECHO_C" >&6 +else + cat >conftest.$ac_ext <<_ACEOF +/* confdefs.h. */ +_ACEOF +cat confdefs.h >>conftest.$ac_ext +cat >>conftest.$ac_ext <<_ACEOF +/* end confdefs.h. */ +/* Define $ac_func to an innocuous variant, in case declares $ac_func. + For example, HP-UX 11i declares gettimeofday. */ +#define $ac_func innocuous_$ac_func + +/* System header to define __stub macros and hopefully few prototypes, + which can conflict with char $ac_func (); below. + Prefer to if __STDC__ is defined, since + exists even on freestanding compilers. */ + +#ifdef __STDC__ +# include +#else +# include +#endif + +#undef $ac_func + +/* Override any GCC internal prototype to avoid an error. + Use char because int might match the return type of a GCC + builtin and then its argument prototype would still apply. */ +#ifdef __cplusplus +extern "C" +#endif +char $ac_func (); +/* The GNU C library defines this for functions which it implements + to always fail with ENOSYS. Some functions are actually named + something starting with __ and the normal name is an alias. */ +#if defined __stub_$ac_func || defined __stub___$ac_func +choke me +#endif + +int +main () +{ +return $ac_func (); + ; + return 0; +} +_ACEOF +rm -f conftest.$ac_objext conftest$ac_exeext +if { (ac_try="$ac_link" +case "(($ac_try" in + *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; + *) ac_try_echo=$ac_try;; +esac +eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5 + (eval "$ac_link") 2>conftest.er1 + ac_status=$? + grep -v '^ *+' conftest.er1 >conftest.err + rm -f conftest.er1 + cat conftest.err >&5 + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); } && + { ac_try='test -z "$ac_c_werror_flag" || test ! -s conftest.err' + { (case "(($ac_try" in + *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; + *) ac_try_echo=$ac_try;; +esac +eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5 + (eval "$ac_try") 2>&5 + ac_status=$? + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); }; } && + { ac_try='test -s conftest$ac_exeext' + { (case "(($ac_try" in + *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; + *) ac_try_echo=$ac_try;; +esac +eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5 + (eval "$ac_try") 2>&5 + ac_status=$? + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); }; }; then + eval "$as_ac_var=yes" +else + echo "$as_me: failed program was:" >&5 +sed 's/^/| /' conftest.$ac_ext >&5 + + eval "$as_ac_var=no" +fi + +rm -f core conftest.err conftest.$ac_objext \ + conftest$ac_exeext conftest.$ac_ext +fi +ac_res=`eval echo '${'$as_ac_var'}'` + { echo "$as_me:$LINENO: result: $ac_res" >&5 +echo "${ECHO_T}$ac_res" >&6; } +if test `eval echo '${'$as_ac_var'}'` = yes; then + cat >>confdefs.h <<_ACEOF +#define `echo "HAVE_$ac_func" | $as_tr_cpp` 1 +_ACEOF + +fi +done + + for ac_func in chflags do diff --git a/bacula/kernstodo b/bacula/kernstodo index 9fef4e1e0f..4488411d17 100644 --- a/bacula/kernstodo +++ b/bacula/kernstodo @@ -83,6 +83,14 @@ Priority: 02-Feb 11:00 btape: Fatal Error because: Bacula interrupted by signal 11: Segmentation violation Kaboom! btape, btape got signal 11. Attempting traceback. +- Encryption -- email from Landon + > The backup encryption algorithm is currently not configurable, and is + > set to AES_128_CBC in src/filed/backup.c. The encryption code + > supports a number of different ciphers (as well as adding arbitrary + > new ones) -- only a small bit of code would be required to map a + > configuration string value to a CRYPTO_CIPHER_* value, if anyone is + > interested in implementing this functionality. + - Ensure that moving a purged Volume in ua_purge.c to the RecyclePool does the right thing. - Why doesn't @"xxx abc" work in a conf file? diff --git a/bacula/src/findlib/bfile.c b/bacula/src/findlib/bfile.c index 48464c0807..9e32afecb5 100644 --- a/bacula/src/findlib/bfile.c +++ b/bacula/src/findlib/bfile.c @@ -49,6 +49,11 @@ ssize_t (*python_write)(BFILE *bfd, void *buf, size_t count) = NULL; #include #endif +#if !defined(HAVE_FDATASYNC) +#define fdatasync(fd) +#endif + + /* =============================================================== * * U N I X AND W I N D O W S @@ -796,6 +801,7 @@ int bopen(BFILE *bfd, const char *fname, int flags, mode_t mode) } } bfd->berrno = errno; + bfd->m_flags = flags; Dmsg1(400, "Open file %d\n", bfd->fid); errno = bfd->berrno; @@ -803,7 +809,7 @@ int bopen(BFILE *bfd, const char *fname, int flags, mode_t mode) bfd->win32DecompContext.liNextHeader = 0; #if defined(HAVE_POSIX_FADVISE) && defined(POSIX_FADV_WILLNEED) - if (bfd->fid != -1) { + if (bfd->fid != -1 && flags & O_RDONLY) { int stat = posix_fadvise(bfd->fid, 0, 0, POSIX_FADV_WILLNEED); Dmsg2(400, "Did posix_fadvise on %s stat=%d\n", fname, stat); } @@ -842,6 +848,13 @@ int bclose(BFILE *bfd) if (bfd->fid == -1) { return 0; } +#if defined(HAVE_POSIX_FADVISE) && defined(POSIX_FADV_DONTNEED) + if (bfd->m_flags & O_RDONLY) { + fdatasync(bfd->fid); /* sync the file */ + /* Tell OS we don't need it any more */ + posix_fadvise(bfd->fid, 0, 0, POSIX_FADV_DONTNEED); + } +#endif /* Close normal file */ stat = close(bfd->fid); diff --git a/bacula/src/findlib/bfile.h b/bacula/src/findlib/bfile.h index 03cdd13ab0..5c856b52d0 100644 --- a/bacula/src/findlib/bfile.h +++ b/bacula/src/findlib/bfile.h @@ -1,14 +1,7 @@ -/* - * Bacula low level File I/O routines. This routine simulates - * open(), read(), write(), and close(), but using native routines. - * I.e. on Windows, we use Windows APIs. - * - * Kern Sibbald May MMIII - */ /* Bacula® - The Network Backup Solution - Copyright (C) 2003-2006 Free Software Foundation Europe e.V. + Copyright (C) 2003-2007 Free Software Foundation Europe e.V. The main author of Bacula is Kern Sibbald, with contributions from many others, a complete list can be found in the file AUTHORS. @@ -32,6 +25,13 @@ (FSFE), Fiduciary Program, Sumatrastrasse 25, 8006 Zürich, Switzerland, email:ftf@fsfeurope.org. */ +/* + * Bacula low level File I/O routines. This routine simulates + * open(), read(), write(), and close(), but using native routines. + * I.e. on Windows, we use Windows APIs. + * + * Kern Sibbald May MMIII + */ #ifndef __BFILE_H #define __BFILE_H @@ -119,6 +119,7 @@ HANDLE bget_handle(BFILE *bfd); /* Basic Unix low level I/O file packet */ struct BFILE { int fid; /* file id on Unix */ + int m_flags; /* open flags */ int berrno; char *prog; /* reader/writer program if any */ JCR *jcr; /* jcr for editing job codes */ diff --git a/bacula/src/stored/spool.c b/bacula/src/stored/spool.c index ee26ee7a86..bf8687945e 100644 --- a/bacula/src/stored/spool.c +++ b/bacula/src/stored/spool.c @@ -81,6 +81,8 @@ void list_spool_stats(void sendit(const char *msg, int len, void *sarg), void *a POOL_MEM msg(PM_MESSAGE); int len; + len = Mmsg(msg, _("Spooling statistics:\n")); + if (spool_stats.data_jobs || spool_stats.max_data_size) { len = Mmsg(msg, _("Data spooling: %u active jobs, %s bytes; %u total jobs, %s max bytes/job.\n"), spool_stats.data_jobs, edit_uint64_with_commas(spool_stats.data_size, ed1), @@ -97,6 +99,8 @@ void list_spool_stats(void sendit(const char *msg, int len, void *sarg), void *a sendit(msg.c_str(), len, arg); } + len = Mmsg(msg, "====\n"); + sendit(msg.c_str(), len, arg); } bool begin_data_spool(DCR *dcr) diff --git a/bacula/src/tools/bsmtp.c b/bacula/src/tools/bsmtp.c index d0b6066e68..0747cc9fd7 100644 --- a/bacula/src/tools/bsmtp.c +++ b/bacula/src/tools/bsmtp.c @@ -175,8 +175,6 @@ static void get_date_string(char *buf, int buf_len) struct tm tm; char tzbuf[MAXSTRING]; long my_timezone; - struct timeval tv; - struct timezone tz; /* Add RFC822 date */ (void)localtime_r(&now, &tm); @@ -191,6 +189,8 @@ __MINGW_IMPORT long _dstbias; my_timezone /= 60; #else + struct timeval tv; + struct timezone tz; gettimeofday(&tv, &tz); my_timezone = tz.tz_minuteswest; /* timezone offset in mins */ #endif diff --git a/bacula/technotes-2.1 b/bacula/technotes-2.1 index ec7bb20f7c..eeb0865b19 100644 --- a/bacula/technotes-2.1 +++ b/bacula/technotes-2.1 @@ -2,6 +2,13 @@ General: 24May07 +kes Add code to tell the OS that we no longer need a cached + file that we were reading. In findlib/bfile.c. Also, + only cache files that we are reading. +kes Tweak to bsmtp to eliminate compiler warnings on Win32. +kes Implement script to automatically generate cats and dll .def + files for Win32 dll. +kes Update README.mingw32 to include new .def file generation. kes Correct typo in UTF-8 error message as reported by: jhernandez kes Add additional sm_check() code on debug level 1.