Skip to content

Read caching implementation

Akira Hayakawa edited this page Sep 4, 2016 · 5 revisions

Writeboost implements read-caching using write-caching.

The algorithm is:

  1. Only caches 4KB (full-sized) read requests
  2. Hold read data into the read-cache cells in the endio callback (read_cache_cell_copy_data). There are 2048 cells preallocated by default. reserve_read_cache_cell is called when the read request result in cache miss, will be read from the backing store, and the function reserves a new cell. In endio, the read data payload is copied to the cell.
  3. Once all cells are occupied writeboost injects the read data in the cells into the write-caching routine. (inject_read_cache) This is something like read-requests turn into writers. But the code path is simpler than the real write path because the data is assured to be 4KB (not partial) and there is no chance of overwriting the existing cache block because the cell data should have been cancelled if other thread in write-caching wrote the same address. (might_cancel_read_cache_cell)
struct read_cache_cell {
    sector_t sector;
    void *data; /* 4KB data read */
    bool cancelled; /* Don't include this */
    struct rb_node rb_node;
};

Clone this wiki locally