* Some preparations to be able to split transactions if they become too large

for the log.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@31860 a95241bf-73f2-0310-859d-f6bbb57e9c96
This commit is contained in:
Axel Dörfler 2009-07-28 20:55:26 +00:00
parent 0bad839702
commit 4e64310788
2 changed files with 38 additions and 3 deletions

View File

@ -599,6 +599,26 @@ Journal::ReplayLog()
}
size_t
Journal::CurrentTransactionSize() const
{
if (_HasSubTransaction()) {
return cache_blocks_in_sub_transaction(fVolume->BlockCache(),
fTransactionID);
}
return cache_blocks_in_main_transaction(fVolume->BlockCache(),
fTransactionID);
}
bool
Journal::CurrentTransactionTooLarge() const
{
return CurrentTransactionSize() > fLogSize;
}
/*! This is a callback function that is called by the cache, whenever
all blocks of a transaction have been flushed to disk.
This lets us keep track of completed transactions, and update

View File

@ -32,6 +32,8 @@ public:
status_t ReplayLog();
Transaction* CurrentTransaction() const { return fOwner; }
size_t CurrentTransactionSize() const;
bool CurrentTransactionTooLarge() const;
status_t FlushLogAndBlocks();
Volume* GetVolume() const { return fVolume; }
@ -44,7 +46,9 @@ public:
#endif
private:
bool _HasSubTransaction() { return fHasSubtransaction; }
bool _HasSubTransaction() const
{ return fHasSubtransaction; }
status_t _FlushLog(bool canWait, bool flushBlocks);
uint32 _TransactionSize() const;
status_t _WriteTransactionToLog();
@ -127,7 +131,7 @@ public:
return status;
}
bool HasParent()
bool HasParent() const
{
if (fJournal != NULL)
return fJournal->CurrentTransaction() == this;
@ -135,6 +139,11 @@ public:
return false;
}
bool IsTooLarge() const
{
return fJournal->CurrentTransactionTooLarge();
}
status_t WriteBlocks(off_t blockNumber, const uint8* buffer,
size_t numBlocks = 1)
{
@ -159,7 +168,13 @@ public:
return B_OK;
}
Volume *GetVolume()
void Split()
{
cache_start_sub_transaction(fJournal->GetVolume()->BlockCache(),
fJournal->TransactionID());
}
Volume* GetVolume() const
{ return fJournal != NULL ? fJournal->GetVolume() : NULL; }
int32 ID() const
{ return fJournal->TransactionID(); }