* 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

View File

@ -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)

View File

@ -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