diff options
Diffstat (limited to 'lib/backupstore/BackupStoreCheck2.cpp')
-rw-r--r-- | lib/backupstore/BackupStoreCheck2.cpp | 145 |
1 files changed, 145 insertions, 0 deletions
diff --git a/lib/backupstore/BackupStoreCheck2.cpp b/lib/backupstore/BackupStoreCheck2.cpp index bcb5c5e9..341ac524 100644 --- a/lib/backupstore/BackupStoreCheck2.cpp +++ b/lib/backupstore/BackupStoreCheck2.cpp @@ -12,6 +12,7 @@ #include <stdio.h> #include <string.h> +<<<<<<< HEAD #include "BackupStoreCheck.h" #include "StoreStructure.h" #include "RaidFileRead.h" @@ -23,6 +24,20 @@ #include "BackupStoreDirectory.h" #include "BackupStoreConstants.h" #include "BackupStoreInfo.h" +======= +#include "autogen_BackupStoreException.h" +#include "BackupStoreCheck.h" +#include "BackupStoreConstants.h" +#include "BackupStoreDirectory.h" +#include "BackupStoreFile.h" +#include "BackupStoreFileWire.h" +#include "BackupStoreInfo.h" +#include "BackupStoreObjectMagic.h" +#include "MemBlockStream.h" +#include "RaidFileRead.h" +#include "RaidFileWrite.h" +#include "StoreStructure.h" +>>>>>>> 0.12 #include "MemLeakFindOn.h" @@ -137,7 +152,11 @@ void BackupStoreCheck::CheckUnattachedObjects() if((flags & Flags_IsContained) == 0) { // Unattached object... +<<<<<<< HEAD BOX_WARNING("Object " << +======= + BOX_ERROR("Object " << +>>>>>>> 0.12 BOX_FORMAT_OBJECTID(pblock->mID[e]) << " is unattached."); ++mNumberErrorsFound; @@ -157,6 +176,10 @@ void BackupStoreCheck::CheckUnattachedObjects() int64_t diffFromObjectID = 0; std::string filename; StoreStructure::MakeObjectFilename(pblock->mID[e], mStoreRoot, mDiscSetNumber, filename, false /* don't attempt to make sure the dir exists */); +<<<<<<< HEAD +======= + +>>>>>>> 0.12 // The easiest way to do this is to verify it again. Not such a bad penalty, because // this really shouldn't be done very often. { @@ -382,7 +405,11 @@ void BackupStoreDirectoryFixer::InsertObject(int64_t ObjectID, bool IsDirectory, } // Add a new entry in an appropriate place +<<<<<<< HEAD mDirectory.AddUnattactedObject(objectStoreFilename, modTime, +======= + mDirectory.AddUnattachedObject(objectStoreFilename, modTime, +>>>>>>> 0.12 ObjectID, sizeInBlocks, IsDirectory?(BackupStoreDirectory::Entry::Flags_Dir):(BackupStoreDirectory::Entry::Flags_File)); } @@ -573,6 +600,7 @@ void BackupStoreCheck::FixDirsWithLostDirs() void BackupStoreCheck::WriteNewStoreInfo() { // Attempt to load the existing store info file +<<<<<<< HEAD std::auto_ptr<BackupStoreInfo> poldInfo; try { @@ -584,12 +612,37 @@ void BackupStoreCheck::WriteNewStoreInfo() ++mNumberErrorsFound; } +======= + std::auto_ptr<BackupStoreInfo> pOldInfo; + try + { + pOldInfo.reset(BackupStoreInfo::Load(mAccountID, mStoreRoot, mDiscSetNumber, true /* read only */).release()); + mAccountName = pOldInfo->GetAccountName(); + } + catch(...) + { + BOX_ERROR("Load of existing store info failed, regenerating."); + ++mNumberErrorsFound; + } + + BOX_NOTICE("Total files: " << mNumFiles << " (of which " + "old files: " << mNumOldFiles << ", " + "deleted files: " << mNumDeletedFiles << "), " + "directories: " << mNumDirectories); + +>>>>>>> 0.12 // Minimum soft and hard limits int64_t minSoft = ((mBlocksUsed * 11) / 10) + 1024; int64_t minHard = ((minSoft * 11) / 10) + 1024; // Need to do anything? +<<<<<<< HEAD if(poldInfo.get() != 0 && mNumberErrorsFound == 0 && poldInfo->GetAccountID() == mAccountID) +======= + if(pOldInfo.get() != 0 && + mNumberErrorsFound == 0 && + pOldInfo->GetAccountID() == mAccountID) +>>>>>>> 0.12 { // Leave the store info as it is, no need to alter it because nothing really changed, // and the only essential thing was that the account ID was correct, which is was. @@ -601,6 +654,7 @@ void BackupStoreCheck::WriteNewStoreInfo() // Work out the new limits int64_t softLimit = minSoft; int64_t hardLimit = minHard; +<<<<<<< HEAD if(poldInfo.get() != 0 && poldInfo->GetBlocksSoftLimit() > minSoft) { softLimit = poldInfo->GetBlocksSoftLimit(); @@ -616,6 +670,25 @@ void BackupStoreCheck::WriteNewStoreInfo() else { BOX_WARNING("Hard limit for account changed to ensure housekeeping doesn't delete files on next run."); +======= + if(pOldInfo.get() != 0 && pOldInfo->GetBlocksSoftLimit() > minSoft) + { + softLimit = pOldInfo->GetBlocksSoftLimit(); + } + else + { + BOX_WARNING("Soft limit for account changed to ensure " + "housekeeping doesn't delete files on next run."); + } + if(pOldInfo.get() != 0 && pOldInfo->GetBlocksHardLimit() > minHard) + { + hardLimit = pOldInfo->GetBlocksHardLimit(); + } + else + { + BOX_WARNING("Hard limit for account changed to ensure " + "housekeeping doesn't delete files on next run."); +>>>>>>> 0.12 } // Object ID @@ -626,17 +699,51 @@ void BackupStoreCheck::WriteNewStoreInfo() } // Build a new store info +<<<<<<< HEAD + std::auto_ptr<BackupStoreInfo> info(BackupStoreInfo::CreateForRegeneration( + mAccountID, +======= + std::auto_ptr<MemBlockStream> extra_data; + if(pOldInfo.get()) + { + extra_data.reset(new MemBlockStream(pOldInfo->GetExtraData())); + } + else + { + extra_data.reset(new MemBlockStream(/* empty */)); + } std::auto_ptr<BackupStoreInfo> info(BackupStoreInfo::CreateForRegeneration( mAccountID, + mAccountName, +>>>>>>> 0.12 mStoreRoot, mDiscSetNumber, lastObjID, mBlocksUsed, +<<<<<<< HEAD +======= + mBlocksInCurrentFiles, +>>>>>>> 0.12 mBlocksInOldFiles, mBlocksInDeletedFiles, mBlocksInDirectories, softLimit, +<<<<<<< HEAD hardLimit)); +======= + hardLimit, + (pOldInfo.get() ? pOldInfo->IsAccountEnabled() : true), + *extra_data)); + info->AdjustNumFiles(mNumFiles); + info->AdjustNumOldFiles(mNumOldFiles); + info->AdjustNumDeletedFiles(mNumDeletedFiles); + info->AdjustNumDirectories(mNumDirectories); + + if(pOldInfo.get()) + { + mNumberErrorsFound += info->ReportChangesTo(*pOldInfo); + } +>>>>>>> 0.12 // Save to disc? if(mFixErrors) @@ -663,7 +770,16 @@ bool BackupStoreDirectory::CheckAndFix() bool changed = false; // Check that if a file depends on a new version, that version is in this directory +<<<<<<< HEAD + { +======= + bool restart; + + do { + restart = false; + +>>>>>>> 0.12 std::vector<Entry*>::iterator i(mEntries.begin()); for(; i != mEntries.end(); ++i) { @@ -674,7 +790,11 @@ bool BackupStoreDirectory::CheckAndFix() if(newerEn == 0) { // Depends on something, but it isn't there. +<<<<<<< HEAD BOX_TRACE("Entry id " << FMT_i << +======= + BOX_WARNING("Entry id " << FMT_i << +>>>>>>> 0.12 " removed because depends " "on newer version " << FMT_OID(dependsNewer) << @@ -684,11 +804,20 @@ bool BackupStoreDirectory::CheckAndFix() delete *i; mEntries.erase(i); +<<<<<<< HEAD // Start again at the beginning of the vector, the iterator is now invalid i = mEntries.begin(); // Mark as changed changed = true; +======= + // Mark as changed + changed = true; + + // Start again at the beginning of the vector, the iterator is now invalid + restart = true; + break; +>>>>>>> 0.12 } else { @@ -710,6 +839,10 @@ bool BackupStoreDirectory::CheckAndFix() } } } +<<<<<<< HEAD +======= + while(restart); +>>>>>>> 0.12 // Check that if a file has a dependency marked, it exists, and remove it if it doesn't { @@ -834,7 +967,11 @@ bool BackupStoreDirectory::CheckAndFix() // erase the thing from the list Entry *pentry = (*i); mEntries.erase(i); +<<<<<<< HEAD +======= + +>>>>>>> 0.12 // And delete the entry object delete pentry; @@ -852,12 +989,20 @@ bool BackupStoreDirectory::CheckAndFix() // -------------------------------------------------------------------------- // // Function +<<<<<<< HEAD // Name: BackupStoreDirectory::AddUnattactedObject(...) +======= +// Name: BackupStoreDirectory::AddUnattachedObject(...) +>>>>>>> 0.12 // Purpose: Adds an object which is currently unattached. Assume that CheckAndFix() will be called afterwards. // Created: 22/4/04 // // -------------------------------------------------------------------------- +<<<<<<< HEAD void BackupStoreDirectory::AddUnattactedObject(const BackupStoreFilename &rName, +======= +void BackupStoreDirectory::AddUnattachedObject(const BackupStoreFilename &rName, +>>>>>>> 0.12 box_time_t ModificationTime, int64_t ObjectID, int64_t SizeInBlocks, int16_t Flags) { Entry *pnew = new Entry(rName, ModificationTime, ObjectID, SizeInBlocks, Flags, |