diff options
| author | Dan Engelbrecht <[email protected]> | 2022-03-27 20:31:01 +0200 |
|---|---|---|
| committer | Dan Engelbrecht <[email protected]> | 2022-03-31 11:29:28 +0200 |
| commit | 71f53ef9404ceccf3583236260d4f192a251d3ee (patch) | |
| tree | 98491a1571d2dca00b682ea3fd7006c21242df55 /zenstore/blockstore.cpp | |
| parent | keep all block files open from start (diff) | |
| download | zen-71f53ef9404ceccf3583236260d4f192a251d3ee.tar.xz zen-71f53ef9404ceccf3583236260d4f192a251d3ee.zip | |
Remove redundant lock in BlockStoreFile
Diffstat (limited to 'zenstore/blockstore.cpp')
| -rw-r--r-- | zenstore/blockstore.cpp | 29 |
1 files changed, 1 insertions, 28 deletions
diff --git a/zenstore/blockstore.cpp b/zenstore/blockstore.cpp index 3d2d77b4e..350d9bb39 100644 --- a/zenstore/blockstore.cpp +++ b/zenstore/blockstore.cpp @@ -24,7 +24,6 @@ BlockStoreFile::BlockStoreFile(const std::filesystem::path& BlockPath) : m_Path( BlockStoreFile::~BlockStoreFile() { - RwLock::ExclusiveLockScope _(m_FileLock); m_IoBuffer = IoBuffer(); m_File.Detach(); } @@ -38,11 +37,6 @@ BlockStoreFile::GetPath() const void BlockStoreFile::Open() { - RwLock::ExclusiveLockScope _(m_FileLock); - if (m_File.Handle()) - { - return; - } m_File.Open(m_Path, BasicFile::EMode::kDelete); void* FileHandle = m_File.Handle(); m_IoBuffer = IoBuffer(IoBuffer::File, FileHandle, 0, m_File.FileSize()); @@ -51,8 +45,6 @@ BlockStoreFile::Open() void BlockStoreFile::Create(uint64_t InitialSize) { - RwLock::ExclusiveLockScope _(m_FileLock); - auto ParentPath = m_Path.parent_path(); if (!std::filesystem::is_directory(ParentPath)) { @@ -71,24 +63,13 @@ BlockStoreFile::Create(uint64_t InitialSize) uint64_t BlockStoreFile::FileSize() { - RwLock::SharedLockScope _(m_FileLock); return m_File.FileSize(); } void BlockStoreFile::MarkAsDeleteOnClose(std::error_code& Ec) { - RwLock::ExclusiveLockScope _(m_FileLock); - if (m_File.Handle()) - { - m_File.MarkAsDeleteOnClose(Ec); - return; - } - if (std::filesystem::is_regular_file(m_Path)) - { - Ec.clear(); - std::filesystem::remove(m_Path, Ec); - } + m_File.MarkAsDeleteOnClose(Ec); } IoBuffer @@ -100,32 +81,24 @@ BlockStoreFile::GetChunk(uint64_t Offset, uint64_t Size) void BlockStoreFile::Read(void* Data, uint64_t Size, uint64_t FileOffset) { - RwLock::SharedLockScope _(m_FileLock); m_File.Read(Data, Size, FileOffset); } void BlockStoreFile::Write(const void* Data, uint64_t Size, uint64_t FileOffset) { - RwLock::SharedLockScope _(m_FileLock); m_File.Write(Data, Size, FileOffset); } void BlockStoreFile::Flush() { - RwLock::ExclusiveLockScope _(m_FileLock); - if (!m_File.Handle()) - { - return; - } m_File.Flush(); } void BlockStoreFile::StreamByteRange(uint64_t FileOffset, uint64_t Size, std::function<void(const void* Data, uint64_t Size)>&& ChunkFun) { - RwLock::SharedLockScope _(m_FileLock); m_File.StreamByteRange(FileOffset, Size, std::move(ChunkFun)); } |