diff options
Diffstat (limited to 'lib/backupstore')
-rw-r--r-- | lib/backupstore/BackupStoreCheck.cpp | 37 | ||||
-rw-r--r-- | lib/backupstore/BackupStoreCheck2.cpp | 74 |
2 files changed, 61 insertions, 50 deletions
diff --git a/lib/backupstore/BackupStoreCheck.cpp b/lib/backupstore/BackupStoreCheck.cpp index b7bd23ce..957475e4 100644 --- a/lib/backupstore/BackupStoreCheck.cpp +++ b/lib/backupstore/BackupStoreCheck.cpp @@ -746,24 +746,27 @@ void BackupStoreCheck::CheckDirectories() BOX_FORMAT_OBJECTID(en->GetObjectID()) << " with flags " << en->GetFlags()); } - // otherwise it's a good file, add to sizes - else if(en->IsDeleted()) // even if it's Old, - // it's still Deleted, don't count it twice. + else // it's a good file, add to sizes { - mNumFiles++; - mNumDeletedFiles++; - mBlocksInDeletedFiles += en->GetSizeInBlocks(); - } - else if(en->IsOld()) - { - mNumFiles++; - mNumOldFiles++; - mBlocksInOldFiles += en->GetSizeInBlocks(); - } - else - { - mNumFiles++; - mBlocksInCurrentFiles += en->GetSizeInBlocks(); + // It can be both old and deleted. + // If neither, then it's current. + if(en->IsDeleted()) + { + mNumDeletedFiles++; + mBlocksInDeletedFiles += en->GetSizeInBlocks(); + } + + if(en->IsOld()) + { + mNumOldFiles++; + mBlocksInOldFiles += en->GetSizeInBlocks(); + } + + if(!en->IsDeleted() && !en->IsOld()) + { + mNumFiles++; + mBlocksInCurrentFiles += en->GetSizeInBlocks(); + } } } } diff --git a/lib/backupstore/BackupStoreCheck2.cpp b/lib/backupstore/BackupStoreCheck2.cpp index 90e21e7f..0e3502d4 100644 --- a/lib/backupstore/BackupStoreCheck2.cpp +++ b/lib/backupstore/BackupStoreCheck2.cpp @@ -178,6 +178,8 @@ void BackupStoreCheck::CheckUnattachedObjects() RaidFileWrite del(mDiscSetNumber, filename); del.Delete(); } + + mBlocksUsed -= pblock->mObjectSizeInBlocks[e]; // Move on to next item continue; @@ -587,47 +589,40 @@ void BackupStoreCheck::WriteNewStoreInfo() ++mNumberErrorsFound; } - BOX_NOTICE("Total files: " << mNumFiles << " (of which " + BOX_INFO("Current files: " << mNumFiles << ", " "old files: " << mNumOldFiles << ", " - "deleted files: " << mNumDeletedFiles << "), " + "deleted files: " << mNumDeletedFiles << ", " "directories: " << mNumDirectories); - // Minimum soft and hard limits + // Minimum soft and hard limits to ensure that nothing gets deleted + // by housekeeping. int64_t minSoft = ((mBlocksUsed * 11) / 10) + 1024; int64_t minHard = ((minSoft * 11) / 10) + 1024; - // Need to do anything? - if(pOldInfo.get() != 0 && - mNumberErrorsFound == 0 && - pOldInfo->GetAccountID() == mAccountID) - { - // 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. - return; - } - - // NOTE: We will always build a new store info, so the client store marker gets changed. + int64_t softLimit = pOldInfo.get() ? pOldInfo->GetBlocksSoftLimit() : minSoft; + int64_t hardLimit = pOldInfo.get() ? pOldInfo->GetBlocksHardLimit() : minHard; - // Work out the new limits - int64_t softLimit = minSoft; - int64_t hardLimit = minHard; - 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) + if(mNumberErrorsFound && pOldInfo.get()) { - hardLimit = pOldInfo->GetBlocksHardLimit(); - } - else - { - BOX_WARNING("Hard limit for account changed to ensure " - "housekeeping doesn't delete files on next run."); + if(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->GetBlocksHardLimit() > minHard) + { + hardLimit = pOldInfo->GetBlocksHardLimit(); + } + else + { + BOX_WARNING("Hard limit for account changed to ensure " + "housekeeping doesn't delete files on next run."); + } } // Object ID @@ -667,6 +662,19 @@ void BackupStoreCheck::WriteNewStoreInfo() info->AdjustNumDeletedFiles(mNumDeletedFiles); info->AdjustNumDirectories(mNumDirectories); + // If there are any errors (apart from wrong block counts), then we + // should reset the ClientStoreMarker to zero, which + // CreateForRegeneration does. But if there are no major errors, then + // we should maintain the old ClientStoreMarker, to avoid invalidating + // the client's directory cache. + if (pOldInfo.get() && !mNumberErrorsFound) + { + BOX_INFO("No major errors found, preserving old " + "ClientStoreMarker: " << + pOldInfo->GetClientStoreMarker()); + info->SetClientStoreMarker(pOldInfo->GetClientStoreMarker()); + } + if(pOldInfo.get()) { mNumberErrorsFound += info->ReportChangesTo(*pOldInfo); |