From e93c2b56093ca819e8fe5d8a2c0f0505dfdce5b4 Mon Sep 17 00:00:00 2001 From: ahenriksson Date: Tue, 10 Jul 2012 14:04:44 +0200 Subject: [PATCH] bfs: BlockAllocator::Reinitialize() Change-Id: I17d5fb7bbf963a4f03458ba9bd4aee49a757d571 Reviewed-on: https://review.haiku-os.org/c/haiku/+/10059 Reviewed-by: Adrien Destugues Tested-by: Commit checker robot --- .../file_systems/bfs/BlockAllocator.cpp | 22 +++++++++++++++++++ .../kernel/file_systems/bfs/BlockAllocator.h | 1 + 2 files changed, 23 insertions(+) diff --git a/src/add-ons/kernel/file_systems/bfs/BlockAllocator.cpp b/src/add-ons/kernel/file_systems/bfs/BlockAllocator.cpp index f714ba360e..171761c261 100644 --- a/src/add-ons/kernel/file_systems/bfs/BlockAllocator.cpp +++ b/src/add-ons/kernel/file_systems/bfs/BlockAllocator.cpp @@ -638,6 +638,28 @@ BlockAllocator::InitializeAndClearBitmap(Transaction& transaction) } +status_t +BlockAllocator::Reinitialize() +{ + // need to write back any pending changes to the block bitmap + // TODO: shall we read through the cache in _Initialize instead? + status_t status = fVolume->GetJournal(0)->FlushLogAndLockJournal(); + if (status != B_OK) + return status; + + recursive_lock_lock(&fLock); + // the lock will be unlocked in the call to Initialize() + + fVolume->GetJournal(0)->Unlock(NULL, true); + // unlock the journal here: we only need to make sure that no one + // starts a transaction before we get the allocator lock, as that + // would cause a deadlock + + delete[] fGroups; + return Initialize(); +} + + status_t BlockAllocator::_Initialize(BlockAllocator* allocator) { diff --git a/src/add-ons/kernel/file_systems/bfs/BlockAllocator.h b/src/add-ons/kernel/file_systems/bfs/BlockAllocator.h index 685de6cae0..021ff5a33d 100644 --- a/src/add-ons/kernel/file_systems/bfs/BlockAllocator.h +++ b/src/add-ons/kernel/file_systems/bfs/BlockAllocator.h @@ -28,6 +28,7 @@ public: status_t Initialize(bool full = true); status_t InitializeAndClearBitmap(Transaction& transaction); + status_t Reinitialize(); void Uninitialize();