OCF介绍

转译自 https://open-cas.github.io/cache.html

https://open-cas.github.io/doxygen/ocf/

https://www.sdnlab.com/23341.html

相关概念

cache

In general a cache (1) is a component that mediates data exchange between an application and a backend storage (2), selectively storing most accessed data on a relatively smaller and faster cache storage (3). Every time the cached data is accessed by the application, an I/O operation is performed on the cache storage, decreasing data access time and improving performance of the whole system.

cache line 是cache处理应用数据的基本单位。 每个cache line 和一个core line对应,但是在一定时间中不是每个core line有对应的cache line。 如果有,那么这个core line被mapped 到cache中,否则是unmapped。

当一个应用执行IO操作时,cache检查被访问的core line是否已经映射到cache的cache line了。如果没有,那就是cache miss,cache engine需要从后端的存储设备访问数据。然后根据cache mode 决定是否把core line 映射到cache line,如果映射的话,执行的是cache insert的操作。若是cache hit,那么应用程序从cache获取数据。

cache object

在OCF中,一个cache object提供了一个和cache 状态机交互的接口。其API可以attach cache storage, add and remove cores, modify various configuration parameters and get statistics. 每个cache操作一个单一的cache storage( cache volume), 其存储数据和元数据。

Single cache can handle data from many cores. It’s called a multi-core configuration. The core object can become backend storage of another core or cache storage of some cache, which makes it possible to construct complex multilevel configurations.

cache operation

mapping

Mapping is an operation of linking up a core line with a cache line in the cache metadata. 在映射的过程中,cache storage的一个cache line大小的区域被分配给core line。之后在cache操作中,这块区域可以用来存储core line数据,直到cache line被驱逐evicted了。

mapping 更新cache line metadata中的core id和core line number以及哈希表的信息。

insertion

Insertion is an operation of writing core line data to a cache line. During insertion the data of I/O request is being written to an area of cache storage storing data of the cache line corresponding to the core line being accessed. 元数据中cache line的valid和dirty bit被更新。

insertion不改变cache line mapping metadata,只是改变valid和 dirty bit。Because of that it can be done only after successfull mapping operation. However, unlike mapping, which operates on whole cache linesinsertion is performed with sector granularity. Every change of valid bit from 0 to 1 is considered an insertion.

Insertion may occur for both read and write requests. Additionally, in the Write-Back mode the insertion may introduce a dirty data. In such situation, besides setting a valid bit, it also sets a dirty bit for accessed sectors.

update

Update is an operation of overwriting cache line data in the cache storage. update发生在当写请求的core line被mapped到cache line了且被访问的sector是valid。若cache line中一些被写的sectors是invalid的,那么这些sector被inserted,这意味着update和insertion可能在一个io 请求中被执行。

Update can be performed only during a write request (a read can never change the data) and similarly to insert it can introduce dirty data, so it may update dirty bit for accessed sectors in the cache line. However it will never change valid bit, as update touches only sectors that are already valid.

invalidation

eviction

flushing

cleaning

猜你喜欢

转载自www.cnblogs.com/yi-mu-xi/p/11583409.html