From 15d2f6dc4b30dbca48af41fe38a94bbd38b1a107 Mon Sep 17 00:00:00 2001 From: "S.J.R. van Schaik" Date: Mon, 24 Jul 2017 13:24:48 +0200 Subject: [PATCH] ftl: cache unmapped translations --- include/ftl.h | 1 + source/ftl/map.c | 15 +++++++++++++-- 2 files changed, 14 insertions(+), 2 deletions(-) diff --git a/include/ftl.h b/include/ftl.h index 8464835..5c8ca7a 100644 --- a/include/ftl.h +++ b/include/ftl.h @@ -32,6 +32,7 @@ struct ftl_map { }; #define FTL_CACHED_VA BIT(0) +#define FTL_UNMAPPED BIT(1) #define FTL_MAX_ATTEMPTS 8 diff --git a/source/ftl/map.c b/source/ftl/map.c index 10c8f48..7296111 100644 --- a/source/ftl/map.c +++ b/source/ftl/map.c @@ -382,8 +382,15 @@ 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->flags & FTL_CACHED_VA) && map->last_va == va) - return map->last_pa; + if ((map->flags & FTL_CACHED_VA) && map->last_va == va) { + if (map->flags & FTL_UNMAPPED) + return -1; + + if (page) + *page = map->last_pa; + + return 0; + } if (new_page_desc) 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; map->flags |= FTL_CACHED_VA; + map->flags &= ~FTL_UNMAPPED; map->last_va = va; 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; }