Moved the definition of the BlockAddressPool class into block_allocator.cpp, as it's
not used outside of it. Added tracking for the last transaction in the block cache; that way it can test if the last transaction has been closed before opening a new one. git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@13022 a95241bf-73f2-0310-859d-f6bbb57e9c96
This commit is contained in:
parent
584d673049
commit
2a1492f0fa
24
src/system/kernel/cache/block_allocator.cpp
vendored
24
src/system/kernel/cache/block_allocator.cpp
vendored
@ -23,6 +23,30 @@
|
||||
#endif
|
||||
|
||||
|
||||
class BlockAddressPool {
|
||||
public:
|
||||
BlockAddressPool();
|
||||
~BlockAddressPool();
|
||||
|
||||
status_t InitCheck() const { return fArea >= B_OK ? B_OK : fArea; }
|
||||
|
||||
size_t RangeSize() const { return kBlockRangeSize; }
|
||||
size_t RangeShift() const { return kBlockRangeShift; }
|
||||
addr_t BaseAddress() const { return fBase; }
|
||||
|
||||
addr_t Get();
|
||||
void Put(addr_t address);
|
||||
|
||||
private:
|
||||
benaphore fLock;
|
||||
area_id fArea;
|
||||
addr_t fBase;
|
||||
addr_t fFirstFree;
|
||||
int32 fNextFree;
|
||||
int32 fFreeList[kBlockAddressSize / kBlockRangeSize];
|
||||
};
|
||||
|
||||
|
||||
static class BlockAddressPool sBlockAddressPool;
|
||||
|
||||
|
||||
|
8
src/system/kernel/cache/block_cache.cpp
vendored
8
src/system/kernel/cache/block_cache.cpp
vendored
@ -82,6 +82,9 @@ static void
|
||||
delete_transaction(block_cache *cache, cache_transaction *transaction)
|
||||
{
|
||||
hash_remove(cache->transaction_hash, transaction);
|
||||
if (cache->last_transaction == transaction)
|
||||
cache->last_transaction = NULL;
|
||||
|
||||
delete transaction;
|
||||
}
|
||||
|
||||
@ -132,6 +135,7 @@ block_cache::block_cache(int _fd, off_t numBlocks, size_t blockSize)
|
||||
max_blocks(numBlocks),
|
||||
block_size(blockSize),
|
||||
next_transaction_id(1),
|
||||
last_transaction(NULL),
|
||||
transaction_hash(NULL),
|
||||
ranges_hash(NULL),
|
||||
free_ranges(NULL)
|
||||
@ -522,6 +526,9 @@ cache_start_transaction(void *_cache)
|
||||
{
|
||||
block_cache *cache = (block_cache *)_cache;
|
||||
|
||||
if (cache->last_transaction && cache->last_transaction->open)
|
||||
panic("last transaction (%ld) still open!\n", cache->last_transaction->id);
|
||||
|
||||
cache_transaction *transaction = new cache_transaction;
|
||||
if (transaction == NULL)
|
||||
return B_NO_MEMORY;
|
||||
@ -532,6 +539,7 @@ cache_start_transaction(void *_cache)
|
||||
transaction->notification_hook = NULL;
|
||||
transaction->notification_data = NULL;
|
||||
transaction->open = true;
|
||||
cache->last_transaction = transaction;
|
||||
|
||||
TRACE(("cache_transaction_start(): id %ld started\n", transaction->id));
|
||||
|
||||
|
25
src/system/kernel/cache/block_cache_private.h
vendored
25
src/system/kernel/cache/block_cache_private.h
vendored
@ -90,13 +90,13 @@ struct block_range {
|
||||
};
|
||||
|
||||
struct block_cache {
|
||||
|
||||
hash_table *hash;
|
||||
benaphore lock;
|
||||
int fd;
|
||||
off_t max_blocks;
|
||||
size_t block_size;
|
||||
int32 next_transaction_id;
|
||||
cache_transaction *last_transaction;
|
||||
hash_table *transaction_hash;
|
||||
|
||||
hash_table *ranges_hash;
|
||||
@ -120,29 +120,6 @@ struct block_cache {
|
||||
void *Allocate();
|
||||
};
|
||||
|
||||
class BlockAddressPool {
|
||||
public:
|
||||
BlockAddressPool();
|
||||
~BlockAddressPool();
|
||||
|
||||
status_t InitCheck() const { return fArea >= B_OK ? B_OK : fArea; }
|
||||
|
||||
size_t RangeSize() const { return kBlockRangeSize; }
|
||||
size_t RangeShift() const { return kBlockRangeShift; }
|
||||
addr_t BaseAddress() const { return fBase; }
|
||||
|
||||
addr_t Get();
|
||||
void Put(addr_t address);
|
||||
|
||||
private:
|
||||
benaphore fLock;
|
||||
area_id fArea;
|
||||
addr_t fBase;
|
||||
addr_t fFirstFree;
|
||||
int32 fNextFree;
|
||||
int32 fFreeList[kBlockAddressSize / kBlockRangeSize];
|
||||
};
|
||||
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
|
Loading…
Reference in New Issue
Block a user