ftl: cache unmapped translations

tags/0.1.0
S.J.R. van Schaik 7 years ago
parent f68e26ac12
commit 15d2f6dc4b
  1. 1
      include/ftl.h
  2. 15
      source/ftl/map.c

@ -32,6 +32,7 @@ struct ftl_map {
}; };
#define FTL_CACHED_VA BIT(0) #define FTL_CACHED_VA BIT(0)
#define FTL_UNMAPPED BIT(1)
#define FTL_MAX_ATTEMPTS 8 #define FTL_MAX_ATTEMPTS 8

@ -382,8 +382,15 @@ int trace_path(struct ftl_map *map, struct ftl_page_desc *new_page_desc,
uint8_t depth = 0; uint8_t depth = 0;
uint32_t upage = map->root; uint32_t upage = map->root;
if ((map->flags & FTL_CACHED_VA) && map->last_va == va) if ((map->flags & FTL_CACHED_VA) && map->last_va == va) {
return map->last_pa; if (map->flags & FTL_UNMAPPED)
return -1;
if (page)
*page = map->last_pa;
return 0;
}
if (new_page_desc) if (new_page_desc)
new_page_desc->va = va; new_page_desc->va = va;
@ -421,6 +428,7 @@ int trace_path(struct ftl_map *map, struct ftl_page_desc *new_page_desc,
*page = upage; *page = upage;
map->flags |= FTL_CACHED_VA; map->flags |= FTL_CACHED_VA;
map->flags &= ~FTL_UNMAPPED;
map->last_va = va; map->last_va = va;
map->last_pa = upage; map->last_pa = upage;
@ -433,5 +441,8 @@ err_not_found:
} }
} }
map->flags |= FTL_CACHED_VA | FTL_UNMAPPED;
map->last_va = va;
return -ERR_NOT_FOUND; return -ERR_NOT_FOUND;
} }

Loading…
Cancel
Save