* As briefly discussed in ticket #2024, I've changed BFS to allow to mount

volumes with a broken log. It will only allow the volume read-only then,
  though (unlike Be's BFS), as your disk could be corrupt.
* Added InitCheck() method to the RecursiveLock class, and now only check
  this one in Journal::InitCheck() instead of also replaying the log there;
  this is now done directly in Volume::Mount().


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@24795 a95241bf-73f2-0310-859d-f6bbb57e9c96
This commit is contained in:
Axel Dörfler
2008-04-04 18:59:17 +00:00
parent 0d69c8378f
commit 64b7ef1d0f
3 changed files with 35 additions and 18 deletions
@@ -355,16 +355,7 @@ Journal::~Journal()
status_t
Journal::InitCheck()
{
// TODO: this logic won't work whenever the size of the pending transaction
// equals the size of the log (happens with the original BFS only)
if (fVolume->LogStart() != fVolume->LogEnd()) {
if (fVolume->SuperBlock().flags != SUPER_BLOCK_DISK_DIRTY)
FATAL(("log_start and log_end differ, but disk is marked clean - trying to replay log...\n"));
return ReplayLog();
}
return B_OK;
return fLock.InitCheck();
}
@@ -493,8 +484,16 @@ Journal::_ReplayRunArray(int32 *_start)
status_t
Journal::ReplayLog()
{
// TODO: this logic won't work whenever the size of the pending transaction
// equals the size of the log (happens with the original BFS only)
if (fVolume->LogStart() == fVolume->LogEnd())
return B_OK;
INFORM(("Replay log, disk was not correctly unmounted...\n"));
if (fVolume->SuperBlock().flags != SUPER_BLOCK_DISK_DIRTY)
INFORM(("log_start and log_end differ, but disk is marked clean - trying to replay log...\n"));
int32 start = fVolume->LogStart();
int32 lastStart = -1;
while (true) {
+15 -7
View File
@@ -1,5 +1,5 @@
/*
* Copyright 2001-2007, Axel Dörfler, axeld@pinc-software.de.
* Copyright 2001-2008, Axel Dörfler, axeld@pinc-software.de.
* This file may be used under the terms of the MIT License.
*/
#ifndef LOCK_H
@@ -48,7 +48,7 @@ class Semaphore {
{
if (fSemaphore < B_OK)
return fSemaphore;
return B_OK;
}
@@ -62,7 +62,7 @@ class Semaphore {
return B_OK;
#endif
}
status_t Unlock()
{
#ifdef USE_BENAPHORE
@@ -109,7 +109,7 @@ class Locker {
};
//**** Recursive Lock
// #pragma mark - Recursive Lock
class RecursiveLock {
public:
@@ -125,6 +125,14 @@ class RecursiveLock {
{
}
status_t InitCheck() const
{
if (fSemaphore < B_OK)
return fSemaphore;
return B_OK;
}
status_t LockWithTimeout(bigtime_t timeout)
{
thread_id thread = find_thread(NULL);
@@ -277,7 +285,7 @@ class ReadWriteLock {
{
if (fSemaphore < B_OK)
return fSemaphore;
return B_OK;
}
@@ -363,7 +371,7 @@ class ReadWriteLock {
{
if (fSemaphore < B_OK)
return fSemaphore;
return B_OK;
}
@@ -543,7 +551,7 @@ class SimpleLock {
break;
if (current == thisThread)
break;
snooze(time);
}
+11 -1
View File
@@ -363,13 +363,23 @@ Volume::Mount(const char *deviceName, uint32 flags)
if (fJournal == NULL)
return B_NO_MEMORY;
// replaying the log is the first thing we will do on this disk
status_t status = fJournal->InitCheck();
if (status < B_OK) {
FATAL(("could not initialize journal: %s!\n", strerror(status)));
return status;
}
// replaying the log is the first thing we will do on this disk
status = fJournal->ReplayLog();
if (status < B_OK) {
FATAL(("Replaying log failed, data may be corrupted, volume read-only.\n"));
fFlags |= VOLUME_READ_ONLY;
// TODO: if this is the boot volume, Bootscript will assume this
// is a CD...
// TODO: it would be nice to have a user visible alert instead
// of letting him just find this in the syslog.
}
status = fBlockAllocator.Initialize();
if (status < B_OK) {
FATAL(("could not initialize block bitmap allocator!\n"));