From 22028021ca46040c31fa029586f3e0e676a29072 Mon Sep 17 00:00:00 2001 From: "S.J.R. van Schaik" Date: Fri, 23 Jun 2017 16:03:42 +0200 Subject: [PATCH] ftl: use write_page_desc() in ftl_trim() --- source/ftl/ftl.c | 5 ++++- source/ftl/map.c | 2 +- source/ftl/map.h | 2 ++ 3 files changed, 7 insertions(+), 2 deletions(-) diff --git a/source/ftl/ftl.c b/source/ftl/ftl.c index 63222cb..45d7470 100644 --- a/source/ftl/ftl.c +++ b/source/ftl/ftl.c @@ -125,7 +125,10 @@ int ftl_trim(struct ftl_map *map, uint32_t va) alt_page << map->log2_page_size, 1 << map->log2_page_size) == 0) return -1; - return write_upage(map, NULL, &page_desc); + if (prepare_head(map) < 0) + return -1; + + return write_page_desc(map, &page_desc); } /* Returns the amount of used pages with a unique virtual address multiplied by diff --git a/source/ftl/map.c b/source/ftl/map.c index 4463b1b..7508450 100644 --- a/source/ftl/map.c +++ b/source/ftl/map.c @@ -83,7 +83,7 @@ int read_page_desc(struct ftl_map *map, /* Writes the page descriptor to the footer of the current page group and * increments the head to point to the next free user page. */ -static int write_page_desc(struct ftl_map *map, +int write_page_desc(struct ftl_map *map, const struct ftl_page_desc *page_desc) { struct ftl_page_group group; diff --git a/source/ftl/map.h b/source/ftl/map.h index 0abfa93..e171544 100644 --- a/source/ftl/map.h +++ b/source/ftl/map.h @@ -6,6 +6,8 @@ int read_page_group(struct ftl_map *map, struct ftl_page_group *group, uint32_t group_no); int read_page_desc(struct ftl_map *map, struct ftl_page_desc *page_desc, uint32_t upage); +int write_page_desc(struct ftl_map *map, + const struct ftl_page_desc *page_desc); int write_upage(struct ftl_map *map, const void *page, const struct ftl_page_desc *page_desc); int trace_path(struct ftl_map *map, struct ftl_page_desc *new_page_desc,