|
|
@ -36,11 +36,13 @@ static int mufs_do_lookup(struct mufs *fs, uint32_t *page, |
|
|
|
index = va & ((1 << ((depth - 1) * fs->log2_nentries)) - 1); |
|
|
|
index = va & ((1 << ((depth - 1) * fs->log2_nentries)) - 1); |
|
|
|
|
|
|
|
|
|
|
|
if (!table[index]) { |
|
|
|
if (!table[index]) { |
|
|
|
if (depth > 1 && alloc && mufs_alloc_block(fs, &table[index]) < 0) |
|
|
|
if (alloc) { |
|
|
|
return -1; |
|
|
|
if (depth == 1 && new_page) { |
|
|
|
|
|
|
|
|
|
|
|
if (depth == 1 && new_page) |
|
|
|
|
|
|
|
table[index] = new_page; |
|
|
|
table[index] = new_page; |
|
|
|
|
|
|
|
} else if (mufs_alloc_block(fs, &table[index]) < 0) { |
|
|
|
|
|
|
|
return -1; |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
if (flash_write(dev, base << dev->log2_block_size, data, |
|
|
|
if (flash_write(dev, base << dev->log2_block_size, data, |
|
|
|
sizeof data) == 0) |
|
|
|
sizeof data) == 0) |
|
|
@ -72,10 +74,10 @@ int mufs_alloc_page(struct mufs_tree *tree, uint32_t *page, |
|
|
|
{ |
|
|
|
{ |
|
|
|
struct mufs *fs = tree->fs; |
|
|
|
struct mufs *fs = tree->fs; |
|
|
|
|
|
|
|
|
|
|
|
if (mufs_alloc_block(fs, page) < 0) |
|
|
|
if (!tree->root && mufs_alloc_block(fs, &tree->root) < 0) |
|
|
|
return -1; |
|
|
|
return -1; |
|
|
|
|
|
|
|
|
|
|
|
return mufs_map_page(tree, va, *page); |
|
|
|
return mufs_do_lookup(fs, page, tree->root, tree->depth, va, 0, 1); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
static int mufs_do_free_page(struct mufs *fs, uint32_t base, |
|
|
|
static int mufs_do_free_page(struct mufs *fs, uint32_t base, |
|
|
|