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();