From 4e6431078812df05c84361aee80e27d458589cc5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Axel=20D=C3=B6rfler?= Date: Tue, 28 Jul 2009 20:55:26 +0000 Subject: [PATCH] * 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 --- .../kernel/file_systems/bfs/Journal.cpp | 20 ++++++++++++++++++ src/add-ons/kernel/file_systems/bfs/Journal.h | 21 ++++++++++++++++--- 2 files changed, 38 insertions(+), 3 deletions(-) diff --git a/src/add-ons/kernel/file_systems/bfs/Journal.cpp b/src/add-ons/kernel/file_systems/bfs/Journal.cpp index 926b775353..d9470a4ae4 100644 --- a/src/add-ons/kernel/file_systems/bfs/Journal.cpp +++ b/src/add-ons/kernel/file_systems/bfs/Journal.cpp @@ -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 diff --git a/src/add-ons/kernel/file_systems/bfs/Journal.h b/src/add-ons/kernel/file_systems/bfs/Journal.h index b84b30872c..08b8719295 100644 --- a/src/add-ons/kernel/file_systems/bfs/Journal.h +++ b/src/add-ons/kernel/file_systems/bfs/Journal.h @@ -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(); }