Block Cache
include/block/bcache.h View source View on GitHubStructs
Section titled “Structs”bcache_entry
Section titled “bcache_entry” struct bcache_entry (9 fields) source
must be allocated with malloc
§
uint8_t *buffer cc_counted_by(size) allocated upon new reads
§
uint64_t size §
uint64_t lba logical block address
§
uint64_t access_time used with a counter - not a real ‘timestamp’
§
bool dirty §
bool no_evict §
struct bio_request *request associated outgoing request
§
refcount_t refcount bcache_wrapper
Section titled “bcache_wrapper” struct bcache_wrapper (4 fields) source
§
uint64_t key block number
§
struct bcache_entry *value pointer to cache entry
§
bool occupied §
struct bcache_wrapper *next bcache
Section titled “bcache” struct bcache (6 fields) source
TODO
bitmap to mark present entries
§
struct bcache_wrapper **entries §
atomic_uint64_t ticks §
uint64_t capacity §
uint64_t count §
uint64_t spb Functions
Section titled “Functions”bcache_hash
Section titled “bcache_hash”uint64_t bcache_hash(uint64_t x, uint64_t capacity) source bcache_init
Section titled “bcache_init”bcache_get
Section titled “bcache_get”void * bcache_get(
struct block_device *disk,
uint64_t lba,
uint64_t block_size,
uint64_t spb,
bool no_evict,
struct bcache_entry **out_entry
) source bcache_writethrough
Section titled “bcache_writethrough”bool bcache_writethrough(
struct block_device *disk,
struct bcache_entry *ent,
uint64_t spb
) source bcache_write_queue
Section titled “bcache_write_queue”void bcache_write_queue(
struct block_device *disk,
struct bcache_entry *ent,
uint64_t spb,
enum bio_request_priority prio
) source bcache_stat
Section titled “bcache_stat”void bcache_stat(
struct block_device *disk,
uint64_t *total_dirty_out,
uint64_t *total_present_out
) source bcache_insert
Section titled “bcache_insert”bool bcache_insert(
struct block_device *disk,
uint64_t lba,
struct bcache_entry *ent,
uint64_t spb
) source bcache_evict
Section titled “bcache_evict”bool bcache_evict(struct block_device *disk, uint64_t spb) source bcache_prefetch_async
Section titled “bcache_prefetch_async”enum err bcache_prefetch_async(
struct block_device *disk,
uint64_t lba,
uint64_t block_size,
uint64_t spb
) source bcache_create_ent
Section titled “bcache_create_ent”void * bcache_create_ent(
struct block_device *disk,
uint64_t lba,
uint64_t block_size,
uint64_t sectors_per_block,
bool no_evict,
struct bcache_entry **out_entry
) source bcache_increment_ticks
Section titled “bcache_increment_ticks”bcache_get_ticks
Section titled “bcache_get_ticks”bcache_ent_lock
Section titled “bcache_ent_lock”void bcache_ent_lock(struct bcache_entry *ent) source bcache_ent_unlock
Section titled “bcache_ent_unlock”void bcache_ent_unlock(struct bcache_entry *ent) source bcache_ent_pin
Section titled “bcache_ent_pin”void bcache_ent_pin(struct bcache_entry *ent) source bcache_ent_unpin
Section titled “bcache_ent_unpin”void bcache_ent_unpin(struct bcache_entry *ent) source bcache_ent_acquire
Section titled “bcache_ent_acquire”void bcache_ent_acquire(struct bcache_entry *ent) source bcache_ent_release
Section titled “bcache_ent_release”void bcache_ent_release(struct bcache_entry *ent) source bcache_destroy
Section titled “bcache_destroy”Macros
Section titled “Macros”DEFAULT_BLOCK_CACHE_SIZE
Section titled “DEFAULT_BLOCK_CACHE_SIZE”#define DEFAULT_BLOCK_CACHE_SIZE 2048 source DEFAULT_MAX_DIRTY_ENTS
Section titled “DEFAULT_MAX_DIRTY_ENTS”#define DEFAULT_MAX_DIRTY_ENTS 64 source