ftl: use byte-offset from VA in ftl_read()

tags/0.1.0
S.J.R. van Schaik 8 years ago
parent dafc3d7071
commit 563db297a3
  1. 10
      source/ftl/ftl.c

@ -15,7 +15,11 @@
int ftl_read(struct ftl_map *map, void *data, size_t len, uint32_t va)
{
int ret;
uint32_t page;
uint32_t mask, offset, page;
mask = ((1 << map->log2_page_size) - 1);
offset = va & mask;
va = va & ~mask;
if ((ret = trace_path(map, NULL, &page, va)) < 0) {
memset(data, 0, len);
@ -25,8 +29,8 @@ int ftl_read(struct ftl_map *map, void *data, size_t len, uint32_t va)
if (!data)
return 0;
return flash_read(map->dev, page << map->log2_page_size, data,
min(map->log2_page_size, len));
return flash_read(map->dev, (page << map->log2_page_size) + offset, data,
min(map->log2_page_size - offset, len));
}
int ftl_write(struct ftl_map *map, uint32_t va, const uint8_t *data)

Loading…
Cancel
Save