This page describes various cache configuration parameters. They may be used to alter cache behavior in some situations and to configure the way in which I/O requests are handled by the cache engines.
The cache mode parameter determines how incoming I/O requests are handled by the cache engine. Depending on the cache mode some requests may be inserted to the cache or not. The cache mode determines also if data stored on cache should always be coherent with data stored in the backend storage (if there is a possibility of dirty data).
Currently there are six cache modes supported by OCF:
- Write-Through (WT),
- Write-Back (WB),
- Write-Around (WA),
- Write-Invalidate (WI),
- Write-Only (WO).
- Pass-Through (PT).
In Write-Through mode, the cache engine writes data to the cache storage and simultaneously writes the same data “through” to the backend storage. Write-Through ensures the data written to the core is always in sync with data on the backend storage. This mode will accelerate only read operations, as writes need to be performed on both backend and cache storages.
In Write-Back mode, the cache engine writes the data first to the cache storage and acknowledges to the application that the write is completed before the data is written to the backend storage. Periodically, those writes are “written back” to the backend storage opportunistically (depending on cleaning policy). While Write-Back mode will improve both write and read intensive operations, there is a risk of data loss if the cache storage fails before the data is written to the backend storage.
In Write-Around mode, the cache engine writes data to the cache storage if and only if that cache line is already mapped into the cache (it can be mapped during read request) and simultaneously writes the same data “through” to the backend storage. Write-Around is similar to Write-Through in that it ensures the core is 100% in sync with the backend storage and in that this cache mode will accelerate only read intensive operations. Write-Around further optimizes the cache to avoid cache pollution in cases where written data is not often subsequently re-read.
In Write-Invalidate mode, the cache engine handles write requests by writing data directly to backend storage, and if written cache line is already mapped into the cache, then it becomes invalid. In this mode only read requests are mapped into the cache (they are handled the same way as in Write-Through mode). Write-Invalidate mode will improve only read intensive operation. It also reduces number of eviction operation for workloads where written data is not often subsequently read.
In Write-Only mode, the cache engine writes the data exactly like in Write-Back mode so the data is written to cache storage without writing it to backend storage immediatelly. Read operations do not promote data to cache. Write-Only mode will accelerate only write intensive operations, as reads need to be performed only on the backend storage. There is a risk of data loss if the cache storage fails before the data is written to the backend storage.
In Pass-Through mode, the cache engine will bypass the cache for all operations. This allows the user to enable and disable caching dynamically (by switching between Pass-Through and other cache modes) without need to manually alter I/O path in the application. If the cache contained a dirty data before switching to Pass-Through mode, then read hits will be handled by reading data from cache storage until all the cache lines will be cleaned.
Cache line size
The cache line size parameter determines the size of a data block on which the cache operates (cache line). It’s the minimum portion of data on the backend storage (core line) that can be mapped into the cache.
OCF allows to set cache line size to one of the following values:
- 4 KiB,
- 8 KiB,
- 16 KiB,
- 32 KiB,
- 64 KiB.
[TODO] Add missing parameters