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:
@@ -17,7 +17,6 @@ Journal::Journal(Volume *volume)
|
|||||||
fVolume(volume),
|
fVolume(volume),
|
||||||
fLock("bfs journal"),
|
fLock("bfs journal"),
|
||||||
fOwner(NULL),
|
fOwner(NULL),
|
||||||
fOwningThread(-1),
|
|
||||||
fArray(volume->BlockSize()),
|
fArray(volume->BlockSize()),
|
||||||
fLogSize(volume->Log().length),
|
fLogSize(volume->Log().length),
|
||||||
fMaxTransactionSize(fLogSize / 4 - 5),
|
fMaxTransactionSize(fLogSize / 4 - 5),
|
||||||
@@ -338,10 +337,8 @@ Journal::Lock(Transaction *owner)
|
|||||||
return B_OK;
|
return B_OK;
|
||||||
|
|
||||||
status_t status = fLock.Lock();
|
status_t status = fLock.Lock();
|
||||||
if (status == B_OK) {
|
if (status == B_OK)
|
||||||
fOwner = owner;
|
fOwner = owner;
|
||||||
fOwningThread = find_thread(NULL);
|
|
||||||
}
|
|
||||||
|
|
||||||
// if the last transaction is older than 2 secs, start a new one
|
// if the last transaction is older than 2 secs, start a new one
|
||||||
if (fTransactionsInEntry != 0 && system_time() - fTimestamp > 2000000L)
|
if (fTransactionsInEntry != 0 && system_time() - fTimestamp > 2000000L)
|
||||||
@@ -361,11 +358,27 @@ Journal::Unlock(Transaction *owner, bool success)
|
|||||||
|
|
||||||
fTimestamp = system_time();
|
fTimestamp = system_time();
|
||||||
fOwner = NULL;
|
fOwner = NULL;
|
||||||
fOwningThread = -1;
|
|
||||||
fLock.Unlock();
|
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
|
status_t
|
||||||
Journal::TransactionDone(bool success)
|
Journal::TransactionDone(bool success)
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -53,8 +53,7 @@ class Journal {
|
|||||||
status_t WriteLogEntry();
|
status_t WriteLogEntry();
|
||||||
status_t LogBlocks(off_t blockNumber, const uint8 *buffer, size_t numBlocks);
|
status_t LogBlocks(off_t blockNumber, const uint8 *buffer, size_t numBlocks);
|
||||||
|
|
||||||
thread_id CurrentThread() const { return fOwningThread; }
|
Transaction *CurrentTransaction();
|
||||||
Transaction *CurrentTransaction() const { return fOwner; }
|
|
||||||
uint32 TransactionSize() const { return fArray.CountItems() + fArray.BlocksUsed(); }
|
uint32 TransactionSize() const { return fArray.CountItems() + fArray.BlocksUsed(); }
|
||||||
|
|
||||||
status_t FlushLogAndBlocks();
|
status_t FlushLogAndBlocks();
|
||||||
@@ -69,9 +68,8 @@ class Journal {
|
|||||||
status_t TransactionDone(bool success);
|
status_t TransactionDone(bool success);
|
||||||
|
|
||||||
Volume *fVolume;
|
Volume *fVolume;
|
||||||
Semaphore fLock;
|
RecursiveLock fLock;
|
||||||
Transaction *fOwner;
|
Transaction *fOwner;
|
||||||
thread_id fOwningThread;
|
|
||||||
BlockArray fArray;
|
BlockArray fArray;
|
||||||
uint32 fLogSize, fMaxTransactionSize, fUsed;
|
uint32 fLogSize, fMaxTransactionSize, fUsed;
|
||||||
int32 fTransactionsInEntry;
|
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
|
// If the inode isn't in use anymore, we were called before
|
||||||
// bfs_unlink() returns - in this case, we can just use the
|
// bfs_unlink() returns - in this case, we can just use the
|
||||||
// transaction which has already deleted the inode.
|
// transaction which has already deleted the inode.
|
||||||
Transaction localTransaction, *transaction = &localTransaction;
|
Transaction localTransaction, *transaction = NULL;
|
||||||
Journal *journal = volume->GetJournal(volume->ToBlock(inode->Parent()));
|
|
||||||
|
|
||||||
if (journal != NULL && journal->CurrentThread() == find_thread(NULL))
|
Journal *journal = volume->GetJournal(volume->ToBlock(inode->Parent()));
|
||||||
|
if (journal != NULL)
|
||||||
transaction = journal->CurrentTransaction();
|
transaction = journal->CurrentTransaction();
|
||||||
else
|
|
||||||
|
if (transaction == NULL) {
|
||||||
|
transaction = &localTransaction;
|
||||||
localTransaction.Start(volume, inode->BlockNumber());
|
localTransaction.Start(volume, inode->BlockNumber());
|
||||||
|
}
|
||||||
|
|
||||||
status_t status = inode->Free(transaction);
|
status_t status = inode->Free(transaction);
|
||||||
if (status == B_OK) {
|
if (status == B_OK) {
|
||||||
|
|||||||
Reference in New Issue
Block a user