1.概述
什么是flashcache?flashcache是Facebook的一个开源项目。
将这个单词拆开:flash + cache,可以理解为用flash做cache。flash即SSD,所以flashcache是三层结构,实现的是一种混合存储方式。
2.Device-Mapper
Flashcache是基于Device-Mapper的,所以要理解Flashcache,必须先了解Device-Mapper,至少是Flashcache使用到的数据结构和接口
Device-Mapper Framework
详见: http://www.ibm.com/developerworks/cn/linux/l-devmapper/
2.1.DM
flashcache挂载在这个模块上。
2.2.Target
相当于一个逻辑句柄,DM模块通过此对象流入Flashcache。
Structure
结构如下(3.17 include/linux/device-mapper.h)
195 struct dm_target {
196 struct dm_table *table;
197 <span style="color:#ff6666;">struct target_type *type;</span>
198
199 /* target limits */
200 sector_t begin;
201 sector_t len;
202
203 /* If non-zero, maximum size of I/O submitted to a target. */
204 uint32_t max_io_len;
205
206 /*
207 * A number of zero-length barrier bios that will be submitted
208 * to the target for the purpose of flushing cache.
209 *
210 * The bio number can be accessed with dm_bio_get_target_bio_nr.
211 * It is a responsibility of the target driver to remap these bios
212 * to the real underlying devices.
213 */
214 unsigned num_flush_bios;
215
216 /*
217 * The number of discard bios that will be submitted to the target.
218 * The bio number can be accessed with dm_bio_get_target_bio_nr.
219 */
220 unsigned num_discard_bios;
221
222 /*
223 * The number of WRITE SAME bios that will be submitted to the target.
224 * The bio number can be accessed with dm_bio_get_target_bio_nr.
225 */
226 unsigned num_write_same_bios;
227
228