diff --git a/headers/os/drivers/fs_cache.h b/headers/os/drivers/fs_cache.h index beeda1e1f3..a21c7187ec 100644 --- a/headers/os/drivers/fs_cache.h +++ b/headers/os/drivers/fs_cache.h @@ -11,11 +11,12 @@ #include +/* transaction events */ enum { - TRANSACTION_WRITTEN, - TRANSACTION_ABORTED, - TRANSACTION_ENDED, - TRANSACTION_IDLE + TRANSACTION_WRITTEN = 0x01, + TRANSACTION_ABORTED = 0x02, + TRANSACTION_ENDED = 0x04, + TRANSACTION_IDLE = 0x08 }; typedef void (*transaction_notification_hook)(int32 id, int32 event, @@ -36,7 +37,8 @@ extern int32 cache_detach_sub_transaction(void *_cache, int32 id, extern status_t cache_abort_sub_transaction(void *_cache, int32 id); extern status_t cache_start_sub_transaction(void *_cache, int32 id); extern status_t cache_add_transaction_listener(void *_cache, int32 id, - transaction_notification_hook hook, void *data); + int32 events, transaction_notification_hook hook, + void *data); extern status_t cache_remove_transaction_listener(void *_cache, int32 id, transaction_notification_hook hook, void *data); extern status_t cache_next_block_in_transaction(void *_cache, int32 id, diff --git a/headers/private/fs_shell/fssh_fs_cache.h b/headers/private/fs_shell/fssh_fs_cache.h index ace1b2b0db..db9550ee94 100644 --- a/headers/private/fs_shell/fssh_fs_cache.h +++ b/headers/private/fs_shell/fssh_fs_cache.h @@ -12,10 +12,10 @@ enum { - FSSH_TRANSACTION_WRITTEN, - FSSH_TRANSACTION_ABORTED, - FSSH_TRANSACTION_ENDED, - FSSH_TRANSACTION_IDLE + FSSH_TRANSACTION_WRITTEN = 0x01, + FSSH_TRANSACTION_ABORTED = 0x02, + FSSH_TRANSACTION_ENDED = 0x04, + FSSH_TRANSACTION_IDLE = 0x08 }; typedef void (*fssh_transaction_notification_hook)(int32_t id, int32_t event, @@ -40,7 +40,8 @@ extern fssh_status_t fssh_cache_abort_sub_transaction(void *_cache, extern fssh_status_t fssh_cache_start_sub_transaction(void *_cache, int32_t id); extern fssh_status_t fssh_cache_add_transaction_listener(void *_cache, - int32_t id, fssh_transaction_notification_hook hook, + int32_t id, int32_t events, + fssh_transaction_notification_hook hook, void *data); extern fssh_status_t fssh_cache_remove_transaction_listener(void *_cache, int32_t id, fssh_transaction_notification_hook hook, diff --git a/src/add-ons/kernel/file_systems/bfs/Inode.cpp b/src/add-ons/kernel/file_systems/bfs/Inode.cpp index de8bd4d4a8..403d9fff39 100644 --- a/src/add-ons/kernel/file_systems/bfs/Inode.cpp +++ b/src/add-ons/kernel/file_systems/bfs/Inode.cpp @@ -252,7 +252,7 @@ InodeAllocator::Keep() if (status == B_OK) { cache_add_transaction_listener(volume->BlockCache(), fTransaction->ID(), - &_TransactionListener, fInode); + TRANSACTION_ABORTED, &_TransactionListener, fInode); } fTransaction = NULL; diff --git a/src/add-ons/kernel/file_systems/bfs/Journal.cpp b/src/add-ons/kernel/file_systems/bfs/Journal.cpp index 8dbde436d8..4f1dbb6c4a 100644 --- a/src/add-ons/kernel/file_systems/bfs/Journal.cpp +++ b/src/add-ons/kernel/file_systems/bfs/Journal.cpp @@ -536,9 +536,6 @@ Journal::_TransactionWritten(int32 transactionID, int32 event, void *_logEntry) { LogEntry *logEntry = (LogEntry *)_logEntry; - if (event != TRANSACTION_WRITTEN) - return; - PRINT(("Log entry %p has been finished, transaction ID = %ld\n", logEntry, transactionID)); @@ -588,9 +585,6 @@ Journal::_TransactionWritten(int32 transactionID, int32 event, void *_logEntry) /*static*/ void Journal::_TransactionListener(int32 transactionID, int32 event, void *_journal) { - if (event != TRANSACTION_IDLE) - return; - // The current transaction seems to be idle - flush it Journal *journal = (Journal *)_journal; @@ -865,7 +859,7 @@ Journal::Lock(Transaction *owner) } cache_add_transaction_listener(fVolume->BlockCache(), fTransactionID, - _TransactionListener, this); + TRANSACTION_IDLE, _TransactionListener, this); return B_OK; } diff --git a/src/tools/fs_shell/block_cache.cpp b/src/tools/fs_shell/block_cache.cpp index 8e7a133d99..2d4200db1b 100644 --- a/src/tools/fs_shell/block_cache.cpp +++ b/src/tools/fs_shell/block_cache.cpp @@ -50,7 +50,7 @@ struct cache_hook : DoublyLinkedListLinkImpl { void *data; }; -typedef DoublyLinkedList HookList; +typedef DoublyLinkedList HookList; struct cache_transaction { cache_transaction(); @@ -377,7 +377,7 @@ put_cached_block(block_cache *cache, fssh_off_t blockNumber) fssh_panic("put_cached_block: invalid block number %lld (max %lld)", blockNumber, cache->max_blocks - 1); } - + cached_block *block = (cached_block *)hash_lookup(cache->hash, &blockNumber); if (block != NULL) put_cached_block(cache, block); @@ -974,9 +974,11 @@ fssh_cache_start_sub_transaction(void *_cache, int32_t id) The listener gets automatically removed in this case. */ fssh_status_t -fssh_cache_add_transaction_listener(void *_cache, int32_t id, +fssh_cache_add_transaction_listener(void *_cache, int32_t id, int32_t events, fssh_transaction_notification_hook hookFunction, void *data) { +// TODO: this is currently not used in a critical context in BFS +#if 0 block_cache *cache = (block_cache *)_cache; cache_hook *hook = new(std::nothrow) cache_hook; @@ -995,6 +997,7 @@ fssh_cache_add_transaction_listener(void *_cache, int32_t id, hook->data = data; transaction->listeners.Add(hook); +#endif return FSSH_B_OK; } @@ -1061,7 +1064,7 @@ fssh_cache_next_block_in_transaction(void *_cache, int32_t id, bool mainOnly, *_unchangedData = block->original_data; *_cookie = (fssh_addr_t)block; - return FSSH_B_OK; + return FSSH_B_OK; } @@ -1130,7 +1133,7 @@ fssh_block_cache_delete(void *_cache, bool allowWrites) cache->FreeBlock(block); } - // free all transactions (they will all be aborted) + // free all transactions (they will all be aborted) cookie = 0; cache_transaction *transaction;