Files | |
| file | libblock.c |
| file | libblock.h |
Data Structures | |
| struct | block |
| struct | cache_t |
| struct | devcon_t |
Defines | |
| #define | BLOCK_FLAGS_NONE 0 |
| This macro is a symbolic value for situations where no special flags are needed. | |
| #define | BLOCK_FLAGS_NOREAD 1 |
| When the client of block_get() intends to overwrite the current contents of the block, this flag is used to avoid the unnecessary read. | |
| #define | CACHE_BUCKETS (1 << CACHE_BUCKETS_LOG2) |
| #define | CACHE_BUCKETS_LOG2 10 |
| #define | CACHE_HI_WATERMARK 20 |
| #define | CACHE_LO_WATERMARK 10 |
Enumerations | |
| enum | cache_mode { CACHE_MODE_WT, CACHE_MODE_WB } |
| Caching mode. More... | |
Functions | |
| static aoff64_t | ba_ltop (devcon_t *devcon, aoff64_t lba) |
| Convert logical block address to physical block address. | |
| void * | block_bb_get (devmap_handle_t devmap_handle) |
| int | block_bb_read (devmap_handle_t devmap_handle, aoff64_t ba) |
| int | block_cache_fini (devmap_handle_t devmap_handle) |
| int | block_cache_init (devmap_handle_t devmap_handle, size_t size, unsigned blocks, enum cache_mode mode) |
| void | block_fini (devmap_handle_t devmap_handle) |
| int | block_get (block_t **block, devmap_handle_t devmap_handle, aoff64_t ba, int flags) |
| Instantiate a block in memory and get a reference to it. | |
| int | block_get_bsize (devmap_handle_t devmap_handle, size_t *bsize) |
| Get device block size. | |
| int | block_get_nblocks (devmap_handle_t devmap_handle, aoff64_t *nblocks) |
| Get number of blocks on device. | |
| int | block_init (devmap_handle_t devmap_handle, size_t comm_size) |
| static void | block_initialize (block_t *b) |
| int | block_put (block_t *block) |
| Release a reference to a block. | |
| int | block_read_direct (devmap_handle_t devmap_handle, aoff64_t ba, size_t cnt, void *buf) |
| Read blocks directly from device (bypass cache). | |
| int | block_seqread (devmap_handle_t devmap_handle, size_t *bufpos, size_t *buflen, aoff64_t *pos, void *dst, size_t size) |
| Read sequential data from a block device. | |
| int | block_write_direct (devmap_handle_t devmap_handle, aoff64_t ba, size_t cnt, const void *data) |
| Write blocks directly to device (bypass cache). | |
| static bool | cache_can_grow (cache_t *cache) |
| static int | cache_compare (unsigned long *key, hash_count_t keys, link_t *item) |
| static hash_index_t | cache_hash (unsigned long *key) |
| static void | cache_remove_callback (link_t *item) |
| static int | devcon_add (devmap_handle_t devmap_handle, int dev_phone, size_t bsize, void *comm_area, size_t comm_size) |
| static void | devcon_remove (devcon_t *devcon) |
| static devcon_t * | devcon_search (devmap_handle_t devmap_handle) |
| static | FIBRIL_MUTEX_INITIALIZE (dcl_lock) |
| Lock protecting the device connection list. | |
| static int | get_block_size (int dev_phone, size_t *bsize) |
| Get block size used by the device. | |
| static int | get_num_blocks (int dev_phone, aoff64_t *nblocks) |
| Get total number of blocks on block device. | |
| static | LIST_INITIALIZE (dcl_head) |
| Device connection list head. | |
| static int | read_blocks (devcon_t *devcon, aoff64_t ba, size_t cnt) |
| Read blocks from block device. | |
| static int | write_blocks (devcon_t *devcon, aoff64_t ba, size_t cnt) |
| Write block to block device. | |
Variables | |
| static hash_table_operations_t | cache_ops |
| enum cache_mode |
| int block_get | ( | block_t ** | block, | |
| devmap_handle_t | devmap_handle, | |||
| aoff64_t | ba, | |||
| int | flags | |||
| ) |
Instantiate a block in memory and get a reference to it.
| block | Pointer to where the function will store the block pointer on success. | |
| devmap_handle | Device handle of the block device. | |
| ba | Block address (logical). | |
| flags | If BLOCK_FLAGS_NOREAD is specified, block_get() will not read the contents of the block from the device. |
Definition at line 392 of file libblock.c.
| int block_get_bsize | ( | devmap_handle_t | devmap_handle, | |
| size_t * | bsize | |||
| ) |
Get device block size.
| devmap_handle | Device handle of the block device. | |
| bsize | Output block size. |
Definition at line 802 of file libblock.c.
| int block_get_nblocks | ( | devmap_handle_t | devmap_handle, | |
| aoff64_t * | nblocks | |||
| ) |
Get number of blocks on device.
| devmap_handle | Device handle of the block device. | |
| nblocks | Output number of blocks. |
Definition at line 819 of file libblock.c.
| int block_put | ( | block_t * | block | ) |
Release a reference to a block.
If the last reference is dropped, the block is put on the free list.
| block | Block of which a reference is to be released. |
Definition at line 575 of file libblock.c.
| int block_read_direct | ( | devmap_handle_t | devmap_handle, | |
| aoff64_t | ba, | |||
| size_t | cnt, | |||
| void * | buf | |||
| ) |
Read blocks directly from device (bypass cache).
| devmap_handle | Device handle of the block device. | |
| ba | Address of first block (physical). | |
| cnt | Number of blocks. | |
| src | Buffer for storing the data. |
Definition at line 748 of file libblock.c.
| int block_seqread | ( | devmap_handle_t | devmap_handle, | |
| size_t * | bufpos, | |||
| size_t * | buflen, | |||
| aoff64_t * | pos, | |||
| void * | dst, | |||
| size_t | size | |||
| ) |
Read sequential data from a block device.
| devmap_handle | Device handle of the block device. | |
| bufpos | Pointer to the first unread valid offset within the communication buffer. | |
| buflen | Pointer to the number of unread bytes that are ready in the communication buffer. | |
| pos | Device position to be read. | |
| dst | Destination buffer. | |
| size | Size of the destination buffer. | |
| block_size | Block size to be used for the transfer. |
Definition at line 687 of file libblock.c.
| int block_write_direct | ( | devmap_handle_t | devmap_handle, | |
| aoff64_t | ba, | |||
| size_t | cnt, | |||
| const void * | data | |||
| ) |
Write blocks directly to device (bypass cache).
| devmap_handle | Device handle of the block device. | |
| ba | Address of first block (physical). | |
| cnt | Number of blocks. | |
| src | The data to be written. |
Definition at line 776 of file libblock.c.
Read blocks from block device.
| devcon | Device connection. | |
| ba | Address of first block. | |
| cnt | Number of blocks. | |
| src | Buffer for storing the data. |
Definition at line 838 of file libblock.c.
Write block to block device.
| devcon | Device connection. | |
| ba | Address of first block. | |
| cnt | Number of blocks. | |
| src | Buffer containing the data to write. |
Definition at line 865 of file libblock.c.
1.4.7