FEMU
原版 master 7e238cc
FEMU: Accurate, Scalable and Extensible NVMe SSD Emulator (FAST'18)
|
|
浏览该文件的文档.
12 #define INVALID_PPA (~(0ULL))
13 #define INVALID_LPN (~(0ULL))
14 #define UNMAPPED_PPA (~(0ULL))
265 #ifdef FEMU_DEBUG_FTL
266 #define ftl_debug(fmt, ...) \
267 do { printf("[FEMU] FTL-Dbg: " fmt, ## __VA_ARGS__); } while (0)
269 #define ftl_debug(fmt, ...) \
273 #define ftl_err(fmt, ...) \
274 do { fprintf(stderr, "[FEMU] FTL-Err: " fmt, ## __VA_ARGS__); } while (0)
276 #define ftl_log(fmt, ...) \
277 do { printf("[FEMU] FTL-Log: " fmt, ## __VA_ARGS__); } while (0)
281 #ifdef FEMU_DEBUG_FTL
282 #define ftl_assert(expression) assert(expression)
284 #define ftl_assert(expression)
@ GC_IO
Definition: ftl.h:32
int ipc
Definition: ftl.h:104
static int do_gc(struct ssd *ssd, bool force)
gc函数,清理一整个line
Definition: ftl.c:865
static void ssd_init_nand_page(struct nand_page *pg, struct ssdparams *spp)
Definition: ftl.c:352
@ SEC_FREE
Definition: ftl.h:36
uint64_t lun
Definition: ftl.h:76
int ch_xfer_lat
Definition: ftl.h:159
uint16_t nvme_rw(FemuCtrl *n, NvmeNamespace *ns, NvmeCmd *cmd, NvmeRequest *req)
nvme读写命令
Definition: nvme-io.c:370
int64_t stime
Definition: ftl.h:240
struct ssd_channel * ch
Definition: ftl.h:250
struct line * lines
Definition: ftl.h:225
@ NAND_ERASE_LATENCY
Definition: ftl.h:27
int npgs
Definition: ftl.h:103
int pg_rd_lat
Definition: ftl.h:156
模拟一个ssd
Definition: ftl.h:247
struct nand_lun * lun
Definition: ftl.h:136
int pg_wr_lat
Definition: ftl.h:157
femu相关控制参数和数据成员
Definition: nvme.h:1184
bool print_log
Definition: nvme.h:1334
static uint64_t ppa2pgidx(struct ssd *ssd, struct ppa *ppa)
Definition: ftl.c:55
void * pqueue_pop(pqueue_t *q)
Definition: pqueue.c:172
FemuExtCtrlOps ext_ops
nvme到各模式ssd接口
Definition: nvme.h:1220
bool busy
Definition: ftl.h:127
@ FEMU_DISABLE_LOG
Definition: ftl.h:54
struct line * curline
Definition: ftl.h:212
#define PG_BITS
Definition: ftl.h:59
static struct ssd_channel * get_ch(struct ssd *ssd, struct ppa *ppa)
Definition: ftl.c:498
static struct nand_page * get_pg(struct ssd *ssd, struct ppa *ppa)
Definition: ftl.c:526
@ NVME_CMD_DSM
Definition: nvme.h:345
static void ssd_init_rmap(struct ssd *ssd)
Definition: ftl.c:416
void pqueue_change_priority(pqueue_t *q, pqueue_pri_t new_pri, void *d)
Definition: pqueue.c:147
#define femu_log(fmt,...)
Definition: nvme.h:1514
int victim_line_cnt
Definition: ftl.h:233
int pls_per_ch
Definition: ftl.h:188
int blk
Definition: ftl.h:216
struct FemuExtCtrlOps FemuExtCtrlOps
扩展操作接口,具体实现在各模式ssd中
static struct line * get_line(struct ssd *ssd, struct ppa *ppa)
Definition: ftl.c:521
static struct line * get_next_free_line(struct ssd *ssd)
Definition: ftl.c:184
static uint64_t ssd_read(struct ssd *ssd, NvmeRequest *req)
Definition: ftl.c:911
static void * ftl_thread(void *arg)
ftl线程函数,不断从to_ftl中取req,处理(计算出时延)后放入to_poller
Definition: ftl.c:1015
static void mark_page_invalid(struct ssd *ssd, struct ppa *ppa)
update SSD status about one page from PG_VALID -> PG_INVALID
Definition: ftl.c:617
static void ssd_init_lines(struct ssd *ssd)
初始化lines,所有line加入free_line_list,而full_line_list和victim_line_pq为空
Definition: ftl.c:122
int blks_per_lun
Definition: ftl.h:179
uint64_t sec
Definition: ftl.h:74
@ NAND_ERASE
Definition: ftl.h:23
uint64_t lba
Definition: oc12.h:2
#define femu_debug(fmt,...)
Definition: nvme.h:1507
uint64_t gc_endtime
Definition: ftl.h:128
static void mark_block_free(struct ssd *ssd, struct ppa *ppa)
将一个空block中所有页标记为PG_FREE
Definition: ftl.c:698
uint64_t pg
Definition: ftl.h:73
@ NVME_SUCCESS
Definition: nvme.h:526
@ NVME_ADM_CMD_FEMU_FLIP
Definition: nvme.h:335
uint32_t num_poller
nvme poller个数(前提是multupoller_enabled开启)
Definition: nvme.h:1337
uint64_t pl
Definition: ftl.h:75
unsigned long long pqueue_pri_t
Definition: pqueue.h:39
static bool valid_lpn(struct ssd *ssd, uint64_t lpn)
Definition: ftl.c:488
int tt_pls
Definition: ftl.h:189
#define SEC_BITS
Definition: ftl.h:60
double gc_thres_pcent_high
Definition: ftl.h:163
#define PL_BITS
Definition: ftl.h:61
static void set_rmap_ent(struct ssd *ssd, uint64_t lpn, struct ppa *ppa)
赋值一个反向映射表项(rmap[page_no(ppa)] -> lpn)
Definition: ftl.c:85
uint16_t nlb
逻辑块个数
Definition: nvme.h:974
struct write_pointer wp
Definition: ftl.h:253
记录各种line的列表和数量
Definition: ftl.h:224
int pg
Definition: ftl.h:215
@ NVME_CMD_WRITE
Definition: nvme.h:340
@ NVME_DNR
Definition: nvme.h:581
int nchs
Definition: ftl.h:154
static void mark_page_valid(struct ssd *ssd, struct ppa *ppa)
将一个page从PG_FREE标记为PG_VALID
Definition: ftl.c:670
@ FEMU_ENABLE_GC_DELAY
Definition: ftl.h:46
static struct nand_plane * get_pl(struct ssd *ssd, struct ppa *ppa)
Definition: ftl.c:509
struct ppa * maptbl
页映射表
Definition: ftl.h:251
size_t femu_ring_dequeue(struct rte_ring *ring, void **objs, size_t count)
Definition: rte_ring.c:228
static void gc_read_page(struct ssd *ssd, struct ppa *ppa)
gc产生的读page
Definition: ftl.c:724
QemuThread ftl_thread
Definition: ftl.h:260
#define UNMAPPED_PPA
Definition: ftl.h:14
@ NAND_WRITE
Definition: ftl.h:22
int luns_per_ch
Definition: ftl.h:153
@ FEMU_ENABLE_DELAY_EMU
Definition: ftl.h:49
static bool should_gc_high(struct ssd *ssd)
gc阈值
Definition: ftl.c:32
static void victim_line_set_pos(void *a, size_t pos)
Definition: ftl.c:112
pqueue_t * pqueue_init(size_t n, pqueue_cmp_pri_f cmppri, pqueue_get_pri_f getpri, pqueue_set_pri_f setpri, pqueue_get_pos_f getpos, pqueue_set_pos_f setpos)
Definition: pqueue.c:37
struct line_mgmt lm
Definition: ftl.h:254
uint64_t ppa
Definition: ftl.h:81
@ FEMU_RESET_ACCT
Definition: ftl.h:52
int blk_er_lat
Definition: ftl.h:158
int status
Definition: ftl.h:94
static uint64_t ssd_advance_status(struct ssd *ssd, struct ppa *ppa, struct nand_cmd *ncmd)
根据操作类型,给出模拟的时延
Definition: ftl.c:540
int tt_luns
Definition: ftl.h:191
#define CH_BITS
Definition: ftl.h:63
static void ssd_init_params(struct ssdparams *spp)
设置nand大小/并行参数,做相关计算
Definition: ftl.c:300
int64_t stime
io开始时间
Definition: nvme.h:987
static uint64_t get_rmap_ent(struct ssd *ssd, struct ppa *ppa)
Definition: ftl.c:71
static void mark_line_free(struct ssd *ssd, struct ppa *ppa)
将该line加入空闲line队列
Definition: ftl.c:847
int gc_thres_lines
Definition: ftl.h:162
void nvme_set_ctrl_name(FemuCtrl *n, const char *mn, const char *sn, int *dev_id)
Definition: nvme-util.c:294
QTAILQ_HEAD(free_line_list, line) free_line_list
int secs_per_pl
Definition: ftl.h:169
int64_t nr_tt_ios
总io数量
Definition: nvme.h:1332
@ PG_FREE
Definition: ftl.h:40
uint64_t blk
Definition: ftl.h:72
#define ftl_err(fmt,...)
Definition: ftl.h:273
int nsecs
Definition: ftl.h:93
char * ssdname
Definition: ftl.h:248
int vpc
Definition: ftl.h:105
Definition: rte_ring.h:127
static struct line * select_victim_line(struct ssd *ssd, bool force)
为gc选择一个victim line,优先队列中出队即可
Definition: ftl.c:790
int blks_per_line
Definition: ftl.h:185
int pqueue_insert(pqueue_t *q, void *d)
Definition: pqueue.c:122
static size_t victim_line_get_pos(void *a)
Definition: ftl.c:107
static void bb_flip(FemuCtrl *n, NvmeCmd *cmd)
blackbox自定义admin命令
Definition: bb.c:38
uint64_t ch
Definition: ftl.h:77
@ SEC_VALID
Definition: ftl.h:38
int type
Definition: ftl.h:238
int tt_blks
Definition: ftl.h:181
int ch
Definition: ftl.h:213
static bool mapped_ppa(struct ppa *ppa)
Definition: ftl.c:493
int npls
Definition: ftl.h:125
int blks_per_pl
Definition: ftl.h:151
int erase_cnt
Definition: ftl.h:106
struct rte_ring ** to_poller
存放完成的req,交给nvme线程
Definition: ftl.h:258
int pgs_per_ch
Definition: ftl.h:176
int nvme_register_bbssd(FemuCtrl *n)
注册blackbox相关函数
Definition: bb.c:145
@ FEMU_DISABLE_DELAY_EMU
Definition: ftl.h:50
@ NAND_READ
Definition: ftl.h:21
bool enable_gc_delay
Definition: ftl.h:165
struct nand_plane * pl
Definition: ftl.h:124
static uint16_t bb_nvme_rw(FemuCtrl *n, NvmeNamespace *ns, NvmeCmd *cmd, NvmeRequest *req)
blackbox 读写命令
Definition: bb.c:94
static void check_params(struct ssdparams *spp)
Definition: ftl.c:284
int secs_per_ch
Definition: ftl.h:171
@ FEMU_DISABLE_GC_DELAY
Definition: ftl.h:47
static void victim_line_set_pri(void *a, pqueue_pri_t pri)
Definition: ftl.c:102
int vpc
Definition: ftl.h:201
plane
Definition: ftl.h:114
static void ssd_init_nand_plane(struct nand_plane *pl, struct ssdparams *spp)
Definition: ftl.c:375
static void bb_init(FemuCtrl *n, Error **errp)
Definition: bb.c:20
static struct ppa get_new_page(struct ssd *ssd)
获取新的page(wpp已经更新,取其指向的page地址即可)
Definition: ftl.c:269
static void ssd_init_maptbl(struct ssd *ssd)
Definition: ftl.c:406
int secs_per_line
Definition: ftl.h:183
@ NVME_INVALID_OPCODE
Definition: nvme.h:527
double gc_thres_pcent
Definition: ftl.h:161
#define LUN_BITS
Definition: ftl.h:62
static void check_addr(int a, int max)
Definition: ftl.c:179
int tt_lines
Definition: ftl.h:186
int64_t nr_tt_late_ios
没有按预计时延(超时)返回的io数量
Definition: nvme.h:1333
int secs_per_lun
Definition: ftl.h:170
line
Definition: ftl.h:198
@ NAND_READ_LATENCY
Definition: ftl.h:25
size_t femu_ring_enqueue(struct rte_ring *ring, void **objs, size_t count)
Definition: rte_ring.c:223
int blks_per_ch
Definition: ftl.h:180
bool busy
Definition: ftl.h:139
size_t pos
Definition: ftl.h:204
@ PG_VALID
Definition: ftl.h:42
int gc_thres_lines_high
Definition: ftl.h:164
static void ssd_init_nand_lun(struct nand_lun *lun, struct ssdparams *spp)
Definition: ftl.c:384
struct ssd * ssd
指向模拟的ssd
Definition: nvme.h:1321
static void set_maptbl_ent(struct ssd *ssd, uint64_t lpn, struct ppa *ppa)
赋值一个page映射表项
Definition: ftl.c:49
int wp
Definition: ftl.h:107
int tt_lines
Definition: ftl.h:231
int full_line_cnt
Definition: ftl.h:234
int pl
Definition: ftl.h:217
uint32_t cdw10
Definition: nvme.h:306
struct nand_page * pg
Definition: ftl.h:102
uint16_t opcode
Definition: nvme.h:297
static pqueue_pri_t victim_line_get_pri(void *a)
Definition: ftl.c:97
uint64_t * rmap
反向映射表, assume it's stored in OOB
Definition: ftl.h:252
int tt_pgs
Definition: ftl.h:177
struct rte_ring ** to_ftl
生产者:nvme poller;消费者:ftl
Definition: nvme.h:1326
@ FEMU_ENABLE_LOG
Definition: ftl.h:53
static bool should_gc(struct ssd *ssd)
空闲gc阈值
Definition: ftl.c:20
void * pqueue_peek(pqueue_t *q)
Definition: pqueue.c:186
int ipc
Definition: ftl.h:200
int nand_sec_status_t
Definition: ftl.h:85
int secsz
Definition: ftl.h:148
int pgs_per_lun
Definition: ftl.h:175
@ USER_IO
Definition: ftl.h:31
uint64_t next_ch_avail_time
Definition: ftl.h:138
@ NAND_PROG_LATENCY
Definition: ftl.h:26
wp: record next write addr
Definition: ftl.h:211
**param ssd *param old_ppa *return uint64_t *static uint64_t gc_write_page(struct ssd *ssd, struct ppa *old_ppa)
gc产生的写
Definition: ftl.c:745
int cmd
Definition: ftl.h:239
static uint64_t ssd_write(struct ssd *ssd, NvmeRequest *req)
ssd写延迟模拟
Definition: ftl.c:954
struct nand_block * blk
Definition: ftl.h:115
struct rte_ring ** to_poller
生产者:ftl;消费者:nvme poller
Definition: nvme.h:1327
int pls_per_lun
Definition: ftl.h:152
uint64_t rsv
Definition: ftl.h:78
void ssd_init(FemuCtrl *n)
初始化ssd参数,为ssd各层结构体分配空间,创建ftl线程
Definition: ftl.c:431
int secs_per_pg
Definition: ftl.h:149
int pgs_per_blk
Definition: ftl.h:150
int pgs_per_pl
Definition: ftl.h:174
static void bb_init_ctrl_str(FemuCtrl *n)
Definition: bb.c:10
#define ftl_assert(expression)
Definition: ftl.h:284
void ssd_init(FemuCtrl *n)
初始化ssd参数,为ssd各层结构体分配空间,创建ftl线程
Definition: ftl.c:431
int pgs_per_line
Definition: ftl.h:184
int tt_secs
Definition: ftl.h:172
#define BLK_BITS
Definition: ftl.h:58
void * state
Definition: nvme.h:1170
describe a physical page addr
Definition: ftl.h:69
static void ssd_advance_write_pointer(struct ssd *ssd)
写指针后移,每次写操作结束后调用
Definition: ftl.c:205
static int victim_line_cmp_pri(pqueue_pri_t next, pqueue_pri_t curr)
Definition: ftl.c:92
@ NVME_CMD_READ
Definition: nvme.h:341
#define ftl_debug(fmt,...)
Definition: ftl.h:269
ssd参数
Definition: ftl.h:147
char devname[64]
Definition: nvme.h:1325
size_t femu_ring_count(struct rte_ring *ring)
Definition: rte_ring.c:218
uint64_t slba
开始lba
Definition: nvme.h:972
static uint16_t bb_admin_cmd(FemuCtrl *n, NvmeCmd *cmd)
blackbox admin命令
Definition: bb.c:128
static struct nand_block * get_blk(struct ssd *ssd, struct ppa *ppa)
Definition: ftl.c:515
int secs_per_blk
Definition: ftl.h:168
int nluns
Definition: ftl.h:137
int nblks
Definition: ftl.h:116
uint64_t next_lun_avail_time
Definition: ftl.h:126
static void ssd_init_nand_blk(struct nand_block *blk, struct ssdparams *spp)
Definition: ftl.c:362
bool * dataplane_started_ptr
Definition: ftl.h:259
static struct ppa get_maptbl_ent(struct ssd *ssd, uint64_t lpn)
Definition: ftl.c:37
int lun
Definition: ftl.h:214
@ SEC_INVALID
Definition: ftl.h:37
pqueue_t * victim_line_pq
Definition: ftl.h:228
static struct nand_lun * get_lun(struct ssd *ssd, struct ppa *ppa)
Definition: ftl.c:503
bool dataplane_started
Definition: nvme.h:1273
static void ssd_init_write_pointer(struct ssd *ssd)
写指针初始化,指向0
Definition: ftl.c:160
static uint16_t bb_io_cmd(FemuCtrl *n, NvmeNamespace *ns, NvmeCmd *cmd, NvmeRequest *req)
blackbox io命令
Definition: bb.c:109
static void ssd_init_ch(struct ssd_channel *ch, struct ssdparams *spp)
Definition: ftl.c:395
int id
Definition: ftl.h:199
int free_line_cnt
Definition: ftl.h:232
struct ssdparams sp
Definition: ftl.h:249
nand_sec_status_t * sec
Definition: ftl.h:92
struct rte_ring ** to_ftl
无锁ring队列,用于接收nvme下传的req
Definition: ftl.h:257
#define INVALID_LPN
Definition: ftl.h:13
@ PG_INVALID
Definition: ftl.h:41
static void clean_one_block(struct ssd *ssd, struct ppa *ppa)
gc清理一个block,将有效页转移
Definition: ftl.c:819
uint64_t gc_endtime
Definition: ftl.h:140
static bool valid_ppa(struct ssd *ssd, struct ppa *ppa)
判断ppa地址是否越界
Definition: ftl.c:470