aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--CHANGELOG.md1
-rw-r--r--zenstore/blockstore.cpp13
2 files changed, 8 insertions, 6 deletions
diff --git a/CHANGELOG.md b/CHANGELOG.md
index 2dbfa413a..82c062130 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -11,6 +11,7 @@
- Improvement: Bumped limit for storing cache values as separate files to reduce number of loose files
- Improvement: Optimizations when handling compressed buffer (less materialization and reading of headers)
- Improvement: Send attachments as file references if the IoBuffer we find represents a complete file and `AcceptFlags` in RPC request allows it.
+- Improvement: Don't reserve full block size for block store files at creation
## v0.1.8
- Change: Responding with new wire format for RPC requests requires the requestor to add a `Accept` field in the request. This is to allow compatability with older clients for shared instances.
diff --git a/zenstore/blockstore.cpp b/zenstore/blockstore.cpp
index 38371124d..682cc4472 100644
--- a/zenstore/blockstore.cpp
+++ b/zenstore/blockstore.cpp
@@ -57,12 +57,11 @@ BlockStoreFile::Create(uint64_t InitialSize)
}
m_File.Open(m_Path, BasicFile::Mode::kTruncateDelete);
- if (InitialSize > 0)
- {
- m_File.SetFileSize(InitialSize);
- }
void* FileHandle = m_File.Handle();
- m_IoBuffer = IoBuffer(IoBuffer::File, FileHandle, 0, InitialSize);
+
+ // We map our m_IoBuffer beyond the file size as we will grow it over time and want
+ // to be able to create sub-buffers of all the written range later
+ m_IoBuffer = IoBuffer(IoBuffer::File, FileHandle, 0, InitialSize);
}
uint64_t
@@ -204,6 +203,7 @@ BlockStore::Close()
m_WriteBlock = nullptr;
m_CurrentInsertOffset = 0;
m_WriteBlockIndex = 0;
+
m_ChunkBlocks.clear();
m_BlocksBasePath.clear();
}
@@ -786,7 +786,7 @@ TEST_CASE("blockstore.blockfile")
{
BlockStoreFile File1(RootDirectory / "1");
File1.Create(16384);
- CHECK(File1.FileSize() == 16384);
+ CHECK(File1.FileSize() == 0);
File1.Write("data", 5, 0);
IoBuffer DataChunk = File1.GetChunk(0, 5);
File1.Write("boop", 5, 5);
@@ -796,6 +796,7 @@ TEST_CASE("blockstore.blockfile")
const char* Boop = static_cast<const char*>(BoopChunk.GetData());
CHECK(std::string(Boop) == "boop");
File1.Flush();
+ CHECK(File1.FileSize() == 10);
}
{
BlockStoreFile File1(RootDirectory / "1");