kernel: Make StorageCache have a reference to its parent BlockDevice
All checks were successful
Build and test / build (push) Successful in 2m10s
All checks were successful
Build and test / build (push) Successful in 2m10s
This will make it easier to implement sync later on.
This commit is contained in:
parent
bfb45c7d4a
commit
abbfd5825f
@ -33,7 +33,7 @@ void StorageCache::clear()
|
||||
m_mutex.unlock();
|
||||
}
|
||||
|
||||
StorageCache::StorageCache()
|
||||
StorageCache::StorageCache(BlockDevice* device) : m_device(device)
|
||||
{
|
||||
g_storage_caches.append(this);
|
||||
}
|
||||
|
@ -4,12 +4,15 @@
|
||||
#include <luna/HashMap.h>
|
||||
#include <luna/LinkedList.h>
|
||||
|
||||
class BlockDevice;
|
||||
|
||||
class StorageCache : public LinkedListNode<StorageCache>
|
||||
{
|
||||
public:
|
||||
struct CacheEntry
|
||||
{
|
||||
Buffer buffer {};
|
||||
bool dirty;
|
||||
};
|
||||
|
||||
void lock()
|
||||
@ -28,10 +31,11 @@ class StorageCache : public LinkedListNode<StorageCache>
|
||||
|
||||
static void clear_caches();
|
||||
|
||||
StorageCache();
|
||||
StorageCache(BlockDevice* device);
|
||||
~StorageCache();
|
||||
|
||||
private:
|
||||
HashMap<u64, CacheEntry> m_cache_entries;
|
||||
BlockDevice* m_device;
|
||||
Mutex m_mutex;
|
||||
};
|
||||
|
@ -2,7 +2,8 @@
|
||||
#include "arch/MMU.h"
|
||||
#include <luna/Common.h>
|
||||
|
||||
BlockDevice::BlockDevice(u64 block_size, u64 num_blocks) : m_cache(), m_block_size(block_size), m_num_blocks(num_blocks)
|
||||
BlockDevice::BlockDevice(u64 block_size, u64 num_blocks)
|
||||
: m_cache(this), m_block_size(block_size), m_num_blocks(num_blocks)
|
||||
{
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user