Author: axeld Date: 2009-11-04 17:44:06 +0100 (Wed, 04 Nov 2009) New Revision: 33883 Changeset: http://dev.haiku-os.org/changeset/33883/haiku Modified: haiku/trunk/src/add-ons/kernel/file_systems/bfs/Journal.cpp haiku/trunk/src/add-ons/kernel/file_systems/bfs/Journal.h Log: * Nested transactions didn't really work in combination with the separate transaction mechanism. Now we keep track of the parent transactions, and restore fOwner on Journal::Unlock(). * This closes bug #4155 again. Modified: haiku/trunk/src/add-ons/kernel/file_systems/bfs/Journal.cpp =================================================================== --- haiku/trunk/src/add-ons/kernel/file_systems/bfs/Journal.cpp 2009-11-04 16:38:34 UTC (rev 33882) +++ haiku/trunk/src/add-ons/kernel/file_systems/bfs/Journal.cpp 2009-11-04 16:44:06 UTC (rev 33883) @@ -956,6 +956,9 @@ if (separateSubTransactions) fSeparateSubTransactions = true; + if (owner != NULL) + owner->SetParent(fOwner); + fOwner = owner; // TODO: we need a way to find out how big the current transaction is; @@ -992,7 +995,7 @@ // we only end the transaction if we would really unlock it // TODO: what about failing transactions that do not unlock? // (they must make the parent fail, too) - if (fOwner != NULL) { + if (owner != NULL) { status_t status = _TransactionDone(success); if (status != B_OK) return status; @@ -1002,12 +1005,14 @@ // closed. bool separateSubTransactions = fSeparateSubTransactions; fSeparateSubTransactions = true; - fOwner->UnlockInodes(success); + owner->UnlockInodes(success); fSeparateSubTransactions = separateSubTransactions; - } + fOwner = owner->Parent(); + } else + fOwner = NULL; + fTimestamp = system_time(); - fOwner = NULL; if (fSeparateSubTransactions && recursive_lock_get_recursion(&fLock) == 1) Modified: haiku/trunk/src/add-ons/kernel/file_systems/bfs/Journal.h =================================================================== --- haiku/trunk/src/add-ons/kernel/file_systems/bfs/Journal.h 2009-11-04 16:38:34 UTC (rev 33882) +++ haiku/trunk/src/add-ons/kernel/file_systems/bfs/Journal.h 2009-11-04 16:44:06 UTC (rev 33883) @@ -90,21 +90,24 @@ public: Transaction(Volume* volume, off_t refBlock) : - fJournal(NULL) + fJournal(NULL), + fParent(NULL) { Start(volume, refBlock); } Transaction(Volume* volume, block_run refRun) : - fJournal(NULL) + fJournal(NULL), + fParent(NULL) { Start(volume, volume->ToBlock(refRun)); } Transaction() : - fJournal(NULL) + fJournal(NULL), + fParent(NULL) { } @@ -130,10 +133,7 @@ bool HasParent() const { - if (fJournal != NULL) - return fJournal->CurrentTransaction() == this; - - return false; + return fParent != NULL; } bool IsTooLarge() const @@ -182,13 +182,19 @@ void UnlockInodes(bool success); void MoveInodesTo(Transaction* transaction); + void SetParent(Transaction* parent) + { fParent = parent; } + Transaction* Parent() const + { return fParent; } + private: Transaction(const Transaction& other); Transaction& operator=(const Transaction& other); // no implementation - Journal* fJournal; - InodeList fLockedInodes; + Journal* fJournal; + InodeList fLockedInodes; + Transaction* fParent; }; #ifdef BFS_DEBUGGER_COMMANDS