From 24d6529a935852c39c2048164bb7f91d522ff3b3 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Axel=20D=C3=B6rfler?= Date: Wed, 28 May 2003 01:10:22 +0000 Subject: [PATCH] Journal::LogBlocks() now calls cache_write() if the block is already in the log entry - this is only necessary if the buffer is not the one of the CachedBlock object. Journal::TransactionDone() now properly aborts transactions if possible, instead of just writing them to disk (does only work if the log entry was not used by other transactions already). Added a comment about how to speed up writing the log entries a bit more (though it's not so easy to do, and might not be much faster). git-svn-id: file:///srv/svn/repos/haiku/trunk/current@3362 a95241bf-73f2-0310-859d-f6bbb57e9c96 --- .../kernel/file_systems/bfs/Journal.cpp | 24 ++++++++++++++++--- 1 file changed, 21 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 200171126a..27b4e5cdb5 100644 --- a/src/add-ons/kernel/file_systems/bfs/Journal.cpp +++ b/src/add-ons/kernel/file_systems/bfs/Journal.cpp @@ -258,6 +258,8 @@ Journal::WriteLogEntry() CachedBlock cached(fVolume); for (int32 i = 0;i < array->count;i++) { + // ToDo: combine blocks if possible (using iovecs)! + uint8 *block = cached.SetTo(array->values[i]); if (block == NULL) return B_IO_ERROR; @@ -368,8 +370,15 @@ Journal::TransactionDone(bool success) { if (!success && fTransactionsInEntry == 0) { // we can safely abort the transaction - // ToDo: abort the transaction - PRINT(("should abort transaction...\n")); + sorted_array *array = fArray.Array(); + if (array != NULL) { + // release the lock for all blocks in the array (we don't need + // to be notified when they are actually written to disk) + for (int32 i = 0; i < array->count; i++) + release_block(fVolume->Device(), array->values[i]); + } + + return B_OK; } // Up to a maximum size, we will just batch several @@ -396,8 +405,17 @@ Journal::LogBlocks(off_t blockNumber, const uint8 *buffer, size_t numBlocks) int32 blockSize = fVolume->BlockSize(); for (;numBlocks-- > 0; blockNumber++, buffer += blockSize) { - if (fArray.Find(blockNumber) >= 0) + if (fArray.Find(blockNumber) >= 0) { + // The block is already in the log, so just update its data + // Note, this is only necessary if this method is called with a buffer + // different from the cached block buffer - which is unlikely but + // we'll make sure this way (costs one cache lookup, though). + status_t status = cached_write(fVolume->Device(), blockNumber, buffer, 1, blockSize); + if (status < B_OK) + return status; + continue; + } // Insert the block into the transaction's array, and write the changes // back into the locked cache buffer