From c8e7eefcb60f496e90e65ca4aa2318330c87cede Mon Sep 17 00:00:00 2001 From: Kern Sibbald Date: Thu, 16 Apr 2009 13:13:28 +0000 Subject: [PATCH] Fix bug #1246 Sometimes access denied with VSS enabled. UCS conversion cache was not properly flushed at the end of a Job git-svn-id: https://bacula.svn.sourceforge.net/svnroot/bacula/trunk@8737 91ce42f0-d328-0410-95d8-f526ca767f89 --- bacula/patches/2.4.x/2.4.4-winvss.patch | 170 ++++++++++++++++++++++++ bacula/src/filed/job.c | 3 +- bacula/technotes | 2 + 3 files changed, 174 insertions(+), 1 deletion(-) create mode 100644 bacula/patches/2.4.x/2.4.4-winvss.patch diff --git a/bacula/patches/2.4.x/2.4.4-winvss.patch b/bacula/patches/2.4.x/2.4.4-winvss.patch new file mode 100644 index 0000000000..86eea75d9e --- /dev/null +++ b/bacula/patches/2.4.x/2.4.4-winvss.patch @@ -0,0 +1,170 @@ + + This patch is fixes Fix bug #1246 Sometimes access with + VSS enabled. UCS conversion cache was not properly flushed + at the end of a Job. + + Apply it to version 2.4.4 with: + + cd + patch -p0 <2.4.4-winvss.patch + ./configure + make + ... + make install + + +Index: src/filed/job.c +=================================================================== +--- src/filed/job.c (revision 8733) ++++ src/filed/job.c (working copy) +@@ -1,7 +1,7 @@ + /* + Bacula® - The Network Backup Solution + +- Copyright (C) 2000-2007 Free Software Foundation Europe e.V. ++ Copyright (C) 2000-2009 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. +@@ -41,7 +41,7 @@ + #include "vss.h" + + static pthread_mutex_t vss_mutex = PTHREAD_MUTEX_INITIALIZER; +-static int enable_vss; ++static int enable_vss = 0; + #endif + + extern CLIENT *me; /* our client resource */ +@@ -1422,7 +1422,7 @@ + /* inform user about writer states */ + for (i=0; i < (int)g_pVSSClient->GetWriterCount(); i++) + if (g_pVSSClient->GetWriterState(i) < 1) { +- Jmsg(jcr, M_WARNING, 0, _("VSS Writer (PrepareForBackup): %s\n"), g_pVSSClient->GetWriterInfo(i)); ++ Jmsg(jcr, M_WARNING, 0, _("VSS Writer (PrepareForBackup): %s\n"), g_pVSSClient->GetWriterInfo(i)); + jcr->Errors++; + } + } +@@ -1506,6 +1506,7 @@ + Jmsg(jcr, msg_type, 0, _("VSS Writer (BackupComplete): %s\n"), g_pVSSClient->GetWriterInfo(i)); + } + } ++ Win32ConvCleanupCache(); + V(vss_mutex); + } + #endif +Index: src/win32/Makefile +=================================================================== +--- src/win32/Makefile (revision 8733) ++++ src/win32/Makefile (working copy) +@@ -30,7 +30,7 @@ + Makefile.inc: Makefile.inc.in + @echo Creating $@ + $(ECHO_CMD)TOPDIR=`(cd ../../..;pwd)`; \ +- if test -e ../../../cross-tools/mingw32/bin/mingw32-gcc; then \ ++ if test -e $${TOPDIR}/cross-tools/mingw32/bin/mingw32-gcc; then \ + BINDIR=$${TOPDIR}/cross-tools/mingw32/bin; \ + INCDIR=$${TOPDIR}/cross-tools/mingw32/mingw32/include; \ + DLLDIR=$${TOPDIR}/cross-tools/mingw32/mingw32/bin; \ +@@ -43,7 +43,7 @@ + echo "You must run build-win32-cross-tools and build-dependencies first.\n"; \ + exit 1; \ + fi ; \ +- $(ECHO_CMD)BUILDDIR=`(pwd)`; \ ++ BUILDDIR=`(pwd)`; \ + sed \ + -e "s^@BUILDDIR@^$${BUILDDIR}^" \ + -e "s^@TOPDIR@^$${TOPDIR}^" \ +Index: src/win32/compat/compat.cpp +=================================================================== +--- src/win32/compat/compat.cpp (revision 8733) ++++ src/win32/compat/compat.cpp (working copy) +@@ -1,7 +1,7 @@ + /* + Bacula® - The Network Backup Solution + +- Copyright (C) 2004-2008 Free Software Foundation Europe e.V. ++ Copyright (C) 2004-2009 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. +@@ -51,8 +51,8 @@ + conversion is called 3 times (lstat, attribs, open), + by using the cache this is reduced to 1 time */ + +-static POOLMEM *g_pWin32ConvUTF8Cache = get_pool_memory(PM_FNAME); +-static POOLMEM *g_pWin32ConvUCS2Cache = get_pool_memory(PM_FNAME); ++static POOLMEM *g_pWin32ConvUTF8Cache = NULL; ++static POOLMEM *g_pWin32ConvUCS2Cache = NULL; + static DWORD g_dwWin32ConvUTF8strlen = 0; + static pthread_mutex_t Win32Convmutex = PTHREAD_MUTEX_INITIALIZER; + +@@ -69,8 +69,19 @@ + g_pVSSPathConvertW = pPathConvertW; + } + ++static void Win32ConvInitCache() ++{ ++ if (g_pWin32ConvUTF8Cache) { ++ return; ++ } ++ g_pWin32ConvUTF8Cache = get_pool_memory(PM_FNAME); ++ g_pWin32ConvUCS2Cache = get_pool_memory(PM_FNAME); ++} ++ ++ + void Win32ConvCleanupCache() + { ++ P(Win32Convmutex); + if (g_pWin32ConvUTF8Cache) { + free_pool_memory(g_pWin32ConvUTF8Cache); + g_pWin32ConvUTF8Cache = NULL; +@@ -82,6 +93,7 @@ + } + + g_dwWin32ConvUTF8strlen = 0; ++ V(Win32Convmutex); + } + + +@@ -451,11 +463,14 @@ + /* if we find the utf8 string in cache, we use the cached ucs2 version. + we compare the stringlength first (quick check) and then compare the content. + */ +- if (g_dwWin32ConvUTF8strlen == strlen(pszUTF)) { ++ if (!g_pWin32ConvUTF8Cache) { ++ Win32ConvInitCache(); ++ } else if (g_dwWin32ConvUTF8strlen == strlen(pszUTF)) { + if (bstrcmp(pszUTF, g_pWin32ConvUTF8Cache)) { ++ /* Return cached value */ + int32_t nBufSize = sizeof_pool_memory(g_pWin32ConvUCS2Cache); + *pszUCS = check_pool_memory_size(*pszUCS, nBufSize); +- wcscpy((LPWSTR) *pszUCS, (LPWSTR) g_pWin32ConvUCS2Cache); ++ wcscpy((LPWSTR) *pszUCS, (LPWSTR)g_pWin32ConvUCS2Cache); + V(Win32Convmutex); + return nBufSize / sizeof (WCHAR); + } +@@ -477,7 +492,7 @@ + wcscpy((LPWSTR) g_pWin32ConvUCS2Cache, (LPWSTR) *pszUCS); + + g_dwWin32ConvUTF8strlen = strlen(pszUTF); +- g_pWin32ConvUTF8Cache = check_pool_memory_size(g_pWin32ConvUTF8Cache, g_dwWin32ConvUTF8strlen+1); ++ g_pWin32ConvUTF8Cache = check_pool_memory_size(g_pWin32ConvUTF8Cache, g_dwWin32ConvUTF8strlen+2); + bstrncpy(g_pWin32ConvUTF8Cache, pszUTF, g_dwWin32ConvUTF8strlen+1); + V(Win32Convmutex); + +Index: src/win32/Makefile.inc.in +=================================================================== +--- src/win32/Makefile.inc.in (revision 8733) ++++ src/win32/Makefile.inc.in (working copy) +@@ -11,9 +11,9 @@ + + BUILDDIR := @BUILDDIR@ + TOPDIR := @TOPDIR@ +-DEPKGS := $(TOPDIR)/depkgs-mingw32 ++DEPKGS := @TOPDIR@/depkgs-mingw32 + +-DOCDIR := $(TOPDIR)/docs ++DOCDIR := @TOPDIR@/docs + BINDIR := ../release + LIBDIR := ../release + OBJDIR := . diff --git a/bacula/src/filed/job.c b/bacula/src/filed/job.c index ddc7faa955..c85e5ad0b0 100644 --- a/bacula/src/filed/job.c +++ b/bacula/src/filed/job.c @@ -41,7 +41,7 @@ #include "vss.h" static pthread_mutex_t vss_mutex = PTHREAD_MUTEX_INITIALIZER; -static int enable_vss; +static int enable_vss = 0; #endif extern CLIENT *me; /* our client resource */ @@ -1591,6 +1591,7 @@ cleanup: Jmsg(jcr, msg_type, 0, _("VSS Writer (BackupComplete): %s\n"), g_pVSSClient->GetWriterInfo(i)); } } + Win32ConvCleanupCache(); V(vss_mutex); } #endif diff --git a/bacula/technotes b/bacula/technotes index 3334291aed..9594ff90cf 100644 --- a/bacula/technotes +++ b/bacula/technotes @@ -3,6 +3,8 @@ General: 14Apr09 +kes Fix bug #1246 Sometimes access denied with VSS enabled. UCS + conversion cache was not properly flushed at the end of a Job. kes Fix bug #1268 Full Max Run Time cancels jobs (when Max Run Time = 0). 11Apr09 kes Modify insertion of read Volumes in SD to be done before the -- 2.39.5