* 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
This commit is contained in:
Axel Dörfler
2009-11-04 16:44:06 +00:00
parent 32c29a08ba
commit 73a19dfe5d
2 changed files with 24 additions and 13 deletions
@@ -956,6 +956,9 @@ Journal::Lock(Transaction* owner, bool separateSubTransactions)
if (separateSubTransactions) if (separateSubTransactions)
fSeparateSubTransactions = true; fSeparateSubTransactions = true;
if (owner != NULL)
owner->SetParent(fOwner);
fOwner = owner; fOwner = owner;
// TODO: we need a way to find out how big the current transaction is; // 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 // we only end the transaction if we would really unlock it
// TODO: what about failing transactions that do not unlock? // TODO: what about failing transactions that do not unlock?
// (they must make the parent fail, too) // (they must make the parent fail, too)
if (fOwner != NULL) { if (owner != NULL) {
status_t status = _TransactionDone(success); status_t status = _TransactionDone(success);
if (status != B_OK) if (status != B_OK)
return status; return status;
@@ -1002,12 +1005,14 @@ Journal::Unlock(Transaction* owner, bool success)
// closed. // closed.
bool separateSubTransactions = fSeparateSubTransactions; bool separateSubTransactions = fSeparateSubTransactions;
fSeparateSubTransactions = true; fSeparateSubTransactions = true;
fOwner->UnlockInodes(success); owner->UnlockInodes(success);
fSeparateSubTransactions = separateSubTransactions; fSeparateSubTransactions = separateSubTransactions;
}
fOwner = owner->Parent();
} else
fOwner = NULL;
fTimestamp = system_time(); fTimestamp = system_time();
fOwner = NULL;
if (fSeparateSubTransactions if (fSeparateSubTransactions
&& recursive_lock_get_recursion(&fLock) == 1) && recursive_lock_get_recursion(&fLock) == 1)
+13 -7
View File
@@ -90,21 +90,24 @@ class Transaction {
public: public:
Transaction(Volume* volume, off_t refBlock) Transaction(Volume* volume, off_t refBlock)
: :
fJournal(NULL) fJournal(NULL),
fParent(NULL)
{ {
Start(volume, refBlock); Start(volume, refBlock);
} }
Transaction(Volume* volume, block_run refRun) Transaction(Volume* volume, block_run refRun)
: :
fJournal(NULL) fJournal(NULL),
fParent(NULL)
{ {
Start(volume, volume->ToBlock(refRun)); Start(volume, volume->ToBlock(refRun));
} }
Transaction() Transaction()
: :
fJournal(NULL) fJournal(NULL),
fParent(NULL)
{ {
} }
@@ -130,10 +133,7 @@ public:
bool HasParent() const bool HasParent() const
{ {
if (fJournal != NULL) return fParent != NULL;
return fJournal->CurrentTransaction() == this;
return false;
} }
bool IsTooLarge() const bool IsTooLarge() const
@@ -182,6 +182,11 @@ public:
void UnlockInodes(bool success); void UnlockInodes(bool success);
void MoveInodesTo(Transaction* transaction); void MoveInodesTo(Transaction* transaction);
void SetParent(Transaction* parent)
{ fParent = parent; }
Transaction* Parent() const
{ return fParent; }
private: private:
Transaction(const Transaction& other); Transaction(const Transaction& other);
Transaction& operator=(const Transaction& other); Transaction& operator=(const Transaction& other);
@@ -189,6 +194,7 @@ private:
Journal* fJournal; Journal* fJournal;
InodeList fLockedInodes; InodeList fLockedInodes;
Transaction* fParent;
}; };
#ifdef BFS_DEBUGGER_COMMANDS #ifdef BFS_DEBUGGER_COMMANDS