|
|
@ -44,40 +44,51 @@ size_t ftl_read(struct ftl_map *map, void *data, size_t len, uint32_t va) |
|
|
|
len); |
|
|
|
len); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
static int ftl_seek(struct ftl_map *map, uint32_t va) |
|
|
|
static int ftl_start_transaction(struct ftl_map *map, uint32_t va) |
|
|
|
{ |
|
|
|
{ |
|
|
|
size_t len; |
|
|
|
uint32_t page; |
|
|
|
int ret; |
|
|
|
int ret; |
|
|
|
uint32_t offset, page, dst, src; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if (va >= ftl_get_capacity(map)) |
|
|
|
if ((map->outstanding.flags & FTL_PRESENT) && map->outstanding.va == va) |
|
|
|
|
|
|
|
return 0; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if (ftl_sync(map) < 0) |
|
|
|
return -1; |
|
|
|
return -1; |
|
|
|
|
|
|
|
|
|
|
|
offset = va & ((1 << map->log2_page_size) - 1); |
|
|
|
if ((ret = trace_path(map, NULL, &page, va)) < 0 && ret != -ERR_NOT_FOUND) |
|
|
|
va >>= map->log2_page_size; |
|
|
|
return -1; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if (prepare_head(map) < 0) |
|
|
|
|
|
|
|
return -1; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
map->outstanding.flags |= FTL_PRESENT; |
|
|
|
|
|
|
|
map->outstanding.va = va; |
|
|
|
|
|
|
|
map->outstanding.page = page; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if (ret == -ERR_NOT_FOUND) { |
|
|
|
|
|
|
|
map->outstanding.flags |= FTL_NO_MAPPING; |
|
|
|
|
|
|
|
++map->nused_pages; |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
if (!(map->outstanding.flags & FTL_PRESENT) || map->outstanding.va != va) { |
|
|
|
map->offset = 0; |
|
|
|
if (ftl_sync(map) < 0) |
|
|
|
|
|
|
|
return -1; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if ((ret = trace_path(map, NULL, &page, va)) < 0 && |
|
|
|
return 0; |
|
|
|
ret != -ERR_NOT_FOUND) |
|
|
|
} |
|
|
|
return -1; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if (prepare_head(map) < 0) |
|
|
|
static int ftl_seek(struct ftl_map *map, uint32_t va) |
|
|
|
return -1; |
|
|
|
{ |
|
|
|
|
|
|
|
size_t len; |
|
|
|
|
|
|
|
uint32_t offset, dst, src; |
|
|
|
|
|
|
|
int ret; |
|
|
|
|
|
|
|
|
|
|
|
map->outstanding.flags |= FTL_PRESENT; |
|
|
|
if (va >= ftl_get_capacity(map)) |
|
|
|
map->outstanding.va = va; |
|
|
|
return -1; |
|
|
|
map->outstanding.page = page; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if (ret == -ERR_NOT_FOUND) { |
|
|
|
offset = va & ((1 << map->log2_page_size) - 1); |
|
|
|
map->outstanding.flags |= FTL_NO_MAPPING; |
|
|
|
va >>= map->log2_page_size; |
|
|
|
++map->nused_pages; |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
map->offset = 0; |
|
|
|
if (ftl_start_transaction(map, va) < 0) |
|
|
|
} |
|
|
|
return -1; |
|
|
|
|
|
|
|
|
|
|
|
if (offset < map->offset) |
|
|
|
if (offset < map->offset) |
|
|
|
return -1; |
|
|
|
return -1; |
|
|
|