forked from ARMmbed/mbed-os
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Revised free-list structure to adopt a lazy scanning allocator of sorts
The free-list structure, while efficient for allocations, had one big issue: complexity. Storing free blocks as a simple fifo made sense when dealing with a single file, but as soon as you have two files open for writing, updating the free list atomicly when the two files can not necessarily even be written atomicly proved problematic. It's a solvable problem, but requires many writes to keep track of everything. Now changing direction to pursue a more "drop it on the floor" strategy. Since allocated blocks are tracked by the filesystem, we can simply subtract from all available blocks the blocks we know of to allocate new blocks. This is very expensive (O(blocks in use * blocks on device)), but greatly simplifies any interactions that result in deallocated blocks. Additionally, it's impossible to corrupt the free list structure during a power failure. Anything blocks that aren't tracked are simply "dropped on the floor", and can be allocated later. There's still a bit of work around the actually allocator to make it run in a somewhat reasonable frame of time while still avoiding dynamic allocations. Currently looking at a bit-vector of free blocks so at least strides of blocks can be skipped in a single filesystem iteration.
- Loading branch information
Showing
2 changed files
with
16 additions
and
65 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters