aboutsummaryrefslogtreecommitdiff
path: root/zenstore/compactcas.cpp
diff options
context:
space:
mode:
authorDan Engelbrecht <[email protected]>2022-03-31 10:14:44 +0200
committerDan Engelbrecht <[email protected]>2022-03-31 11:29:28 +0200
commit3aebe78d461778bd743d63e1a296fcc7df564911 (patch)
treeebdd9f2b12d9c3f140b11078e09d33ceb7252635 /zenstore/compactcas.cpp
parentimproved logging for gc/migration (diff)
downloadzen-3aebe78d461778bd743d63e1a296fcc7df564911.tar.xz
zen-3aebe78d461778bd743d63e1a296fcc7df564911.zip
Truncate migrated and new blocks after gc to save disk space
Diffstat (limited to 'zenstore/compactcas.cpp')
-rw-r--r--zenstore/compactcas.cpp12
1 files changed, 12 insertions, 0 deletions
diff --git a/zenstore/compactcas.cpp b/zenstore/compactcas.cpp
index 9461d7d3a..dfaf72727 100644
--- a/zenstore/compactcas.cpp
+++ b/zenstore/compactcas.cpp
@@ -564,6 +564,7 @@ namespace {
ChunkBlock.Write(Buffer.data(), Size, Offset);
Offset += Size;
}
+ ChunkBlock.Truncate(Offset);
ChunkBlock.Flush();
std::vector<CasDiskIndexEntry> LogEntries;
@@ -1152,6 +1153,11 @@ CasContainerStrategy::CollectGarbage(GcContext& GcCtx)
m_CasLog.Append(LogEntries);
m_CasLog.Flush();
+ if (NewBlockFile)
+ {
+ NewBlockFile->Truncate(WriteOffset);
+ NewBlockFile->Flush();
+ }
{
RwLock::ExclusiveLockScope __(m_LocationMapLock);
Stopwatch Timer;
@@ -1229,6 +1235,12 @@ CasContainerStrategy::CollectGarbage(GcContext& GcCtx)
WriteOffset = RoundUp(WriteOffset + Chunk.size(), m_PayloadAlignment);
}
Chunk.clear();
+ if (NewBlockFile)
+ {
+ NewBlockFile->Truncate(WriteOffset);
+ NewBlockFile->Flush();
+ NewBlockFile = Ref<BlockStoreFile>();
+ }
const std::vector<IoHash>& DeleteMap = DeleteChunks[ChunkMapIndex];
std::vector<CasDiskIndexEntry> LogEntries = MakeCasDiskEntries(MovedBlockChunks, DeleteMap);