Removed the fOwningThread functionality from the Journal class; it now
just uses a RecursiveLock instead. Changed Journal::CurrentTransaction() so that it returns the current transaction only if it's valid for the thread asking for it. That doesn't fix the bug, but changed its timing a bit. git-svn-id: file:///srv/svn/repos/haiku/trunk/current@6356 a95241bf-73f2-0310-859d-f6bbb57e9c96
This commit is contained in:
parent
0057030901
commit
a49b150fff
@ -17,7 +17,6 @@ Journal::Journal(Volume *volume)
|
||||
fVolume(volume),
|
||||
fLock("bfs journal"),
|
||||
fOwner(NULL),
|
||||
fOwningThread(-1),
|
||||
fArray(volume->BlockSize()),
|
||||
fLogSize(volume->Log().length),
|
||||
fMaxTransactionSize(fLogSize / 4 - 5),
|
||||
@ -338,10 +337,8 @@ Journal::Lock(Transaction *owner)
|
||||
return B_OK;
|
||||
|
||||
status_t status = fLock.Lock();
|
||||
if (status == B_OK) {
|
||||
if (status == B_OK)
|
||||
fOwner = owner;
|
||||
fOwningThread = find_thread(NULL);
|
||||
}
|
||||
|
||||
// if the last transaction is older than 2 secs, start a new one
|
||||
if (fTransactionsInEntry != 0 && system_time() - fTimestamp > 2000000L)
|
||||
@ -361,11 +358,27 @@ Journal::Unlock(Transaction *owner, bool success)
|
||||
|
||||
fTimestamp = system_time();
|
||||
fOwner = NULL;
|
||||
fOwningThread = -1;
|
||||
fLock.Unlock();
|
||||
}
|
||||
|
||||
|
||||
/** If there is a current transaction that the current thread has
|
||||
* started, this function will give you access to it.
|
||||
*/
|
||||
|
||||
Transaction *
|
||||
Journal::CurrentTransaction()
|
||||
{
|
||||
if (fLock.LockWithTimeout(0) != B_OK)
|
||||
return NULL;
|
||||
|
||||
Transaction *owner = fOwner;
|
||||
fLock.Unlock();
|
||||
|
||||
return owner;
|
||||
}
|
||||
|
||||
|
||||
status_t
|
||||
Journal::TransactionDone(bool success)
|
||||
{
|
||||
|
@ -53,8 +53,7 @@ class Journal {
|
||||
status_t WriteLogEntry();
|
||||
status_t LogBlocks(off_t blockNumber, const uint8 *buffer, size_t numBlocks);
|
||||
|
||||
thread_id CurrentThread() const { return fOwningThread; }
|
||||
Transaction *CurrentTransaction() const { return fOwner; }
|
||||
Transaction *CurrentTransaction();
|
||||
uint32 TransactionSize() const { return fArray.CountItems() + fArray.BlocksUsed(); }
|
||||
|
||||
status_t FlushLogAndBlocks();
|
||||
@ -69,9 +68,8 @@ class Journal {
|
||||
status_t TransactionDone(bool success);
|
||||
|
||||
Volume *fVolume;
|
||||
Semaphore fLock;
|
||||
RecursiveLock fLock;
|
||||
Transaction *fOwner;
|
||||
thread_id fOwningThread;
|
||||
BlockArray fArray;
|
||||
uint32 fLogSize, fMaxTransactionSize, fUsed;
|
||||
int32 fTransactionsInEntry;
|
||||
|
@ -459,13 +459,16 @@ bfs_remove_vnode(void *_ns, void *_node, char reenter)
|
||||
// If the inode isn't in use anymore, we were called before
|
||||
// bfs_unlink() returns - in this case, we can just use the
|
||||
// transaction which has already deleted the inode.
|
||||
Transaction localTransaction, *transaction = &localTransaction;
|
||||
Journal *journal = volume->GetJournal(volume->ToBlock(inode->Parent()));
|
||||
Transaction localTransaction, *transaction = NULL;
|
||||
|
||||
if (journal != NULL && journal->CurrentThread() == find_thread(NULL))
|
||||
Journal *journal = volume->GetJournal(volume->ToBlock(inode->Parent()));
|
||||
if (journal != NULL)
|
||||
transaction = journal->CurrentTransaction();
|
||||
else
|
||||
|
||||
if (transaction == NULL) {
|
||||
transaction = &localTransaction;
|
||||
localTransaction.Start(volume, inode->BlockNumber());
|
||||
}
|
||||
|
||||
status_t status = inode->Free(transaction);
|
||||
if (status == B_OK) {
|
||||
|
Loading…
Reference in New Issue
Block a user