diff --git a/include/ftl.h b/include/ftl.h index f31ba7e..b1e67ff 100644 --- a/include/ftl.h +++ b/include/ftl.h @@ -14,6 +14,8 @@ struct ftl_page_desc { struct ftl_map { struct flash_dev *dev; + uint32_t last_va; + uint32_t last_pa; uint32_t head, tail; uint32_t root; uint32_t nused_pages; diff --git a/source/ftl/map.c b/source/ftl/map.c index 7508450..abce785 100644 --- a/source/ftl/map.c +++ b/source/ftl/map.c @@ -379,6 +379,9 @@ 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) + return map->last_pa; + if (new_page_desc) new_page_desc->va = va; @@ -414,6 +417,9 @@ int trace_path(struct ftl_map *map, struct ftl_page_desc *new_page_desc, if (page) *page = upage; + map->last_va = va; + map->last_pa = upage; + return 0; err_not_found: