ftl: implement flags to keep track of state

This commit is contained in:
S.J.R. van Schaik 2017-07-24 13:12:54 +02:00
parent 8f061a808d
commit f68e26ac12
2 changed files with 10 additions and 1 deletions

View file

@ -309,6 +309,9 @@ static void reset_map(struct ftl_map *map)
map->nblocks = flash_get_size(map->dev) >> map->log2_block_size;
map->flags = 0;
map->last_va = 0;
map->last_pa = 0;
map->head = 0;
map->tail = 0;
map->root = UINT32_MAX;
@ -379,7 +382,7 @@ int trace_path(struct ftl_map *map, struct ftl_page_desc *new_page_desc,
uint8_t depth = 0;
uint32_t upage = map->root;
if (map->last_va == va)
if ((map->flags & FTL_CACHED_VA) && map->last_va == va)
return map->last_pa;
if (new_page_desc)
@ -417,6 +420,7 @@ int trace_path(struct ftl_map *map, struct ftl_page_desc *new_page_desc,
if (page)
*page = upage;
map->flags |= FTL_CACHED_VA;
map->last_va = va;
map->last_pa = upage;