⚠ Switch to EXCALIDRAW VIEW in the MORE OPTIONS menu of this document. ⚠ You can decompress Drawing data with the command palette: 'Decompress current Excalidraw file'. For more info check in plugin settings under 'Saving'
Excalidraw Data
Text Elements
ftl_io
write
spdk_ftl_writev
ftl_io_init
queue_io(io)
spdk_ftl_dev *dev
spdk_io_channel *ioch
uint64_t lba
ftl_addr addr
size_t pos
size_t num_blocks
iovec *iov
void *md
size_t iov_cnt
size_t iov_pos
size_t iov_off
ftl_band *band
int status
size_t req_cnt
void *cb_ctx
spdk_ftl_fn user_fn
int flags
ftl_io_type type
bool done
uint64_t trace
TAILQ_ENTRY(ftl_io) queue_entry
ftl_nv_cache_chunk *nv_cache_chunk
ftl_l2p_pin_ctx l2p_pin_ctx
ftl_addr *map
spdk_bdev_io_wait_entry bdev_io_wait
ch->sq
ch->cq
io
io->user_fn
ftl_io_init: 初始化为发起读写操作的相应channel
ftl_io_init:置位FTL_IO_INITIALIZED
ftl_io_init: 初始化为发起读写操作的相应type(WRITE/READ/TRIM)
ftl_io_init: 初始化为发起读写操作的相应LBA
ftl_io_init: 初始化为FTL_ADDR_INVALID
ftl_io_init: 初始化为发起读写操作的相应cb_arg(spdk_bdev_io)
ftl_io_init: 初始化为发起读写操作的相应cb_fn(bdev_ftl_cb)
ftl_io_init: 初始化为发起读写操作的相应iov
ftl_io_init: 初始化为发起读写操作的相应iov_cnt
ftl_io_init: 初始化为发起读写操作的相应num_blocks
ftl_io_init: 初始化为ftl_trace_alloc_id(dev)
channel 1
io
channel 2
channel 3
...
dev->ioch_queue
ftl_process_io_queue(core_poller)
ftl_process_io_channel
FTL_IO_QUEUE_BATCH io
start_io
start_io: 初始化为ftl_mempool_get(ioch->map_pool),大小为sizeof(ftl_addr) * dev->xfer_size(8*(4096/(8+8))=512),这个要记下来这个LBA对应的所有block的之前的PBA,来解决冲突
FTL_IO_READ
FTL_IO_TRIM
FTL_IO_WRITE
dev->wr_sq
...
...
ftl_nv_cache_write(io)
io
ftl_nv_cache_write: 初始化为从nvcache->md_pool中获取vssxsfer_size(84096/(8+8))=512大小的内存区域
ftl_nv_cache_get_wr_buffer(io): 计算chunk上的物理地址:
- 如果当前chunk有足够的剩余空间则写
- 如果没有则跳过剩下的区域(产生碎片),关闭当前的chunk,并尝试使用下一个已经OPEN的chunk
- 如果没有OPEN的chunk了,则把address设置为无效,并直接返回,并重新塞回队列里(重试这笔写)
ftl_nv_cache_get_wr_buffer: 初始化为将要写下的chunk
ftl_nv_cache_fill_md(io)来将xsfer个blocks的vss区域设置好——lba和sql_id
ftl_l2p_pin
ftl_l2p_pin_cb
nv_cache_write
在ftl_nv_cache_write中更改为当前chunk写指针的位置
nv_cahce_write: 如果spdk bdev 写失败了(ENOMEM),则初始化后调用spdk_bdev_queue_io_wait
ftl_nv_cache_submit_cb
ftl_nv_cache_l2p_update
ftl_nv_cache_submit_cb_done
ftl_l2p_update_cache
ftl_io_complete
ftl_io_cb
failed
success
ftl_io_pin_cb: 置位FTL_IP_PINNED
ftl_io_pin_cb: 置位FTL_IP_PINNED
ftl_io_complete: 取消置位FTL_IO_INITIALIZED