Update lfs_find_free_blocks to match the latest changes.

This commit is contained in:
ondrap
2023-08-02 11:51:52 +02:00
committed by Christopher Haster
parent 1ba4ed03f0
commit b637379210
2 changed files with 21 additions and 10 deletions
+17 -10
View File
@@ -654,20 +654,27 @@ static int lfs_alloc(lfs_t *lfs, lfs_block_t *block) {
return LFS_ERR_NOSPC;
}
lfs->free.off = (lfs->free.off + lfs->free.size)
% lfs->block_count;
lfs->free.size = lfs_min(8*lfs->cfg->lookahead_size, lfs->free.ack);
lfs->free.i = 0;
// find mask of free blocks from tree
memset(lfs->free.buffer, 0, lfs->cfg->lookahead_size);
int err = lfs_fs_rawtraverse(lfs, lfs_alloc_lookahead, lfs, true);
if (err) {
lfs_alloc_drop(lfs);
int err = lfs_find_free_blocks(lfs);
if(err) {
return err;
}
}
}
int lfs_find_free_blocks(lfs_t *lfs){
lfs->free.off = (lfs->free.off + lfs->free.size)
% lfs->block_count;
lfs->free.size = lfs_min(8*lfs->cfg->lookahead_size, lfs->free.ack);
lfs->free.i = 0;
// find mask of free blocks from tree
memset(lfs->free.buffer, 0, lfs->cfg->lookahead_size);
int const err = lfs_fs_rawtraverse(lfs, lfs_alloc_lookahead, lfs, true);
if (err) {
lfs_alloc_drop(lfs);
}
return err;
}
#endif
/// Metadata pair and directory operations ///