From 752f5c972f1a874cc7f93787e1a3bce6396c891e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Axel=20D=C3=B6rfler?= Date: Thu, 19 Jul 2012 23:57:10 +0200 Subject: [PATCH] cache_abort_[sub_]transaction() did not work correctly. * cache_abort_transaction() left the block dirty which was causing bug #8123 as well. * cache_abort_sub_transaction() did, in addition to not clearing the dirty flag, not reset the block's transaction member either if the block was not part of the parent transaction. --- src/system/kernel/cache/block_cache.cpp | 15 ++++++++++++--- 1 file changed, 12 insertions(+), 3 deletions(-) diff --git a/src/system/kernel/cache/block_cache.cpp b/src/system/kernel/cache/block_cache.cpp index cc5b663531..943e6517f0 100644 --- a/src/system/kernel/cache/block_cache.cpp +++ b/src/system/kernel/cache/block_cache.cpp @@ -2877,6 +2877,8 @@ cache_abort_transaction(void* _cache, int32 id) block->transaction_next = NULL; block->transaction = NULL; block->discard = false; + if (block->previous_transaction == NULL) + block->is_dirty = false; } hash_remove(cache->transaction_hash, transaction); @@ -3028,17 +3030,24 @@ cache_abort_sub_transaction(void* _cache, int32 id) next = block->transaction_next; if (block->parent_data == NULL) { - // the parent transaction didn't change the block, but the sub - // transaction did - we need to revert from the original data + // The parent transaction didn't change the block, but the sub + // transaction did - we need to revert to the original data. + // The block is no longer part of the transaction ASSERT(block->original_data != NULL); memcpy(block->current_data, block->original_data, cache->block_size); + block->transaction_next = NULL; + block->transaction = NULL; + if (block->previous_transaction == NULL) + block->is_dirty = false; } else if (block->parent_data != block->current_data) { - // the block has been changed and must be restored + // The block has been changed and must be restored - the block + // is still dirty and part of the transaction TRACE(("cache_abort_sub_transaction(id = %ld): restored contents " "of block %Ld\n", transaction->id, block->block_number)); memcpy(block->current_data, block->parent_data, cache->block_size); cache->Free(block->parent_data); + // The block stays dirty } block->parent_data = NULL;