[Box Backup-commit] COMMIT r3178 - box/trunk/lib/backupstore

subversion at boxbackup.org subversion at boxbackup.org
Thu Aug 22 01:31:58 BST 2013


Author: chris
Date: 2013-08-22 01:31:57 +0100 (Thu, 22 Aug 2013)
New Revision: 3178

Modified:
   box/trunk/lib/backupstore/BackupStoreCheck.cpp
Log:
Improve debugging messages after repairing a directory.

Report whether the directory still had errors after the first pass of
dir.CheckAndFix(), and also whether a file is marked as both Old and
Deleted, which means that its block usage is not accounted for anywhere.

There's possibly still a bug here where an invalid directory entry that
is itself a directory may not result in the parent directory being marked
as isModified and written back out afterwards, which may be what's
happening to Markus Grunwald (failure to correct the error with "check fix").

Modified: box/trunk/lib/backupstore/BackupStoreCheck.cpp
===================================================================
--- box/trunk/lib/backupstore/BackupStoreCheck.cpp	2013-08-22 00:28:23 UTC (rev 3177)
+++ box/trunk/lib/backupstore/BackupStoreCheck.cpp	2013-08-22 00:31:57 UTC (rev 3178)
@@ -653,20 +653,21 @@
 							*en, pblock->mID[e],
 							iIndex, isModified);
 					}
+					// Item can't be found. Is it a directory?
+					else if(en->IsDir())
+					{
+						// Store the directory for later attention
+						mDirsWhichContainLostDirs[en->GetObjectID()] = pblock->mID[e];
+					}
 					else
 					{
-						// Item can't be found. Is it a directory?
-						if(en->IsDir())
-						{
-							// Store the directory for later attention
-							mDirsWhichContainLostDirs[en->GetObjectID()] = pblock->mID[e];
-						}
-						else
-						{
-							// Just remove the entry
-							badEntry = true;
-							BOX_WARNING("Directory ID " << BOX_FORMAT_OBJECTID(pblock->mID[e]) << " references object " << BOX_FORMAT_OBJECTID(en->GetObjectID()) << " which does not exist.");
-						}
+						// Just remove the entry
+						badEntry = true;
+						BOX_WARNING("Directory ID " << 
+							BOX_FORMAT_OBJECTID(pblock->mID[e]) <<
+							" references object " << 
+							BOX_FORMAT_OBJECTID(en->GetObjectID()) <<
+							" which does not exist.");
 					}
 					
 					// Is this entry worth keeping?
@@ -674,23 +675,32 @@
 					{
 						toDelete.push_back(en->GetObjectID());
 					}
-					else if (en->IsFile())
+					else if(!en->IsFile())
 					{
-						// Add to sizes?
-						if(en->IsOld())
-						{
-							mBlocksInOldFiles += en->GetSizeInBlocks();
-						}
-						if(en->IsDeleted())
-						{
-							mBlocksInDeletedFiles += en->GetSizeInBlocks();
-						}
-						if(!en->IsOld() &&
-							!en->IsDeleted())
-						{
-							mBlocksInCurrentFiles += en->GetSizeInBlocks();
-						}
+						BOX_TRACE("Not counting object " << 
+							BOX_FORMAT_OBJECTID(en->GetObjectID()) <<
+							" with flags " << en->GetFlags());
 					}
+					else // it's a good file, add to sizes
+					if(en->IsOld() && en->IsDeleted())
+					{
+						BOX_WARNING("File " << 
+							BOX_FORMAT_OBJECTID(en->GetObjectID()) <<
+							" is both old and deleted, "
+							"this should not happen!");
+					}
+					else if(en->IsOld())
+					{
+						mBlocksInOldFiles += en->GetSizeInBlocks();
+					}
+					else if(en->IsDeleted())
+					{
+						mBlocksInDeletedFiles += en->GetSizeInBlocks();
+					}
+					else
+					{
+						mBlocksInCurrentFiles += en->GetSizeInBlocks();
+					}
 				}
 				
 				if(toDelete.size() > 0)
@@ -704,11 +714,25 @@
 					// Mark as modified
 					isModified = true;
 					
-					// Check the directory again, now that entries have been removed
-					dir.CheckAndFix();
-					
 					// Errors found
 					++mNumberErrorsFound;
+
+					// Check the directory again, now that entries have been removed
+					if(dir.CheckAndFix())
+					{
+						// Wasn't quite right, and has been modified
+						BOX_WARNING("Directory ID " <<
+							BOX_FORMAT_OBJECTID(pblock->mID[e]) <<
+							" was still bad after first pass");
+						++mNumberErrorsFound;
+						isModified = true;
+					}
+					else
+					{
+						BOX_INFO("Directory ID " <<
+							BOX_FORMAT_OBJECTID(pblock->mID[e]) <<
+							" was OK after fixing");
+					}
 				}
 				
 				if(isModified && mFixErrors)




More information about the Boxbackup-commit mailing list