I am writing this blog as a documentation draft and the aim is to make all users feel easy to use read-caching in their production.
writeboost is a log-structured writeback-caching software so it sounds bit strange that it can supports read-caching. The idea is implement read-caching as lightweight write-caching. The basic idea is:
- Only caches 4KB (full-sized) read requests
- Captivate read data into the read-cache cells, in the endio callback. (
read_cache_cell_copy_data
) There are 2048 cells preallocated.reserve_read_cache_cell
is called when the read request results in cache miss (then read from the backing device) and the function reserves one of the cells. In endio, the read data payload is copied to the cell reserved. - Once all cells are occupied writeboost "injects" the read data captivated in the cells into the write-caching path. (
inject_read_cache
) This is something like read-requests turns into writers. But the code path is simpler than the actual write path because the data is assure