From 73a19dfe5d66e0cc860d4ab24868284571b0bf5b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Axel=20D=C3=B6rfler?= Date: Wed, 4 Nov 2009 16:44:06 +0000 Subject: [PATCH] * 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. git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@33883 a95241bf-73f2-0310-859d-f6bbb57e9c96 --- .../kernel/file_systems/bfs/Journal.cpp | 13 ++++++---- src/add-ons/kernel/file_systems/bfs/Journal.h | 24 ++++++++++++------- 2 files changed, 24 insertions(+), 13 deletions(-) diff --git a/src/add-ons/kernel/file_systems/bfs/Journal.cpp b/src/add-ons/kernel/file_systems/bfs/Journal.cpp index 8e9aeb0a48..939dbeb855 100644 --- a/src/add-ons/kernel/file_systems/bfs/Journal.cpp +++ b/src/add-ons/kernel/file_systems/bfs/Journal.cpp @@ -956,6 +956,9 @@ Journal::Lock(Transaction* owner, bool separateSubTransactions) 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 @@ Journal::Unlock(Transaction* owner, bool success) // 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 @@ Journal::Unlock(Transaction* owner, bool success) // 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) diff --git a/src/add-ons/kernel/file_systems/bfs/Journal.h b/src/add-ons/kernel/file_systems/bfs/Journal.h index 9bc5858637..210b9193e8 100644 --- a/src/add-ons/kernel/file_systems/bfs/Journal.h +++ b/src/add-ons/kernel/file_systems/bfs/Journal.h @@ -90,21 +90,24 @@ class Transaction { 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 @@ public: bool HasParent() const { - if (fJournal != NULL) - return fJournal->CurrentTransaction() == this; - - return false; + return fParent != NULL; } bool IsTooLarge() const @@ -182,13 +182,19 @@ public: 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