block_cache: Implement cache_has_block_in_transaction function that will check the existence of block in one specific transaction.
Signed-off-by: Augustin Cavalier <waddlesplash@gmail.com>
This commit is contained in:
parent
8137f447cb
commit
1750cd1e92
@ -53,6 +53,7 @@ extern status_t cache_next_block_in_transaction(void *cache, int32 id,
|
||||
extern int32 cache_blocks_in_transaction(void *cache, int32 id);
|
||||
extern int32 cache_blocks_in_main_transaction(void *cache, int32 id);
|
||||
extern int32 cache_blocks_in_sub_transaction(void *cache, int32 id);
|
||||
extern bool cache_has_block_in_transaction(void* cache, int32 id, off_t blockNumber);
|
||||
|
||||
/* block cache */
|
||||
extern void block_cache_delete(void *cache, bool allowWrites);
|
||||
|
@ -835,6 +835,7 @@
|
||||
#define cache_blocks_in_transaction fssh_cache_blocks_in_transaction
|
||||
#define cache_blocks_in_main_transaction fssh_cache_blocks_in_main_transaction
|
||||
#define cache_blocks_in_sub_transaction fssh_cache_blocks_in_sub_transaction
|
||||
#define cache_has_block_in_transaction fssh_cache_has_block_in_transaction
|
||||
|
||||
/* block cache */
|
||||
#define block_cache_delete fssh_block_cache_delete
|
||||
|
@ -62,6 +62,8 @@ extern int32_t fssh_cache_blocks_in_main_transaction(void *_cache,
|
||||
int32_t id);
|
||||
extern int32_t fssh_cache_blocks_in_sub_transaction(void *_cache,
|
||||
int32_t id);
|
||||
extern bool fssh_cache_has_block_in_transaction(void *_cache,
|
||||
int32_t id, fssh_off_t blockNumber);
|
||||
|
||||
/* block cache */
|
||||
extern void fssh_block_cache_delete(void *_cache, bool allowWrites);
|
||||
|
15
src/system/kernel/cache/block_cache.cpp
vendored
15
src/system/kernel/cache/block_cache.cpp
vendored
@ -3301,6 +3301,21 @@ cache_blocks_in_sub_transaction(void* _cache, int32 id)
|
||||
}
|
||||
|
||||
|
||||
/*! Check if block is in transaction
|
||||
*/
|
||||
bool
|
||||
cache_has_block_in_transaction(void* _cache, int32 id, off_t blockNumber)
|
||||
{
|
||||
block_cache* cache = (block_cache*)_cache;
|
||||
TransactionLocker locker(cache);
|
||||
|
||||
cached_block* block = cache->hash->Lookup(blockNumber);
|
||||
|
||||
return (block != NULL && block->transaction != NULL
|
||||
&& block->transaction->id == id);
|
||||
}
|
||||
|
||||
|
||||
// #pragma mark - public block cache API
|
||||
|
||||
|
||||
|
@ -1462,6 +1462,20 @@ fssh_cache_blocks_in_sub_transaction(void* _cache, int32_t id)
|
||||
}
|
||||
|
||||
|
||||
bool
|
||||
fssh_cache_has_block_in_transaction(void* _cache, int32_t id,
|
||||
fssh_off_t blockNumber)
|
||||
{
|
||||
block_cache* cache = (block_cache*)_cache;
|
||||
MutexLocker locker(&cache->lock);
|
||||
|
||||
cached_block* block = (cached_block*)hash_lookup(cache->hash, &blockNumber);
|
||||
|
||||
return (block != NULL && block->transaction != NULL
|
||||
&& block->transaction->id == id);
|
||||
}
|
||||
|
||||
|
||||
// #pragma mark - public block cache API
|
||||
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user