Reimplemented the block-allocator over mtree traversal
Took the opportunity to make some allocator tweaks: - Renamed lfs.free -> lfs.lookahead, it's previous name did cause some confusion. - Renamed lfs.free.off -> lfs.lookahead.start - Renamed lfs.free.i -> lfs.lookahead.next - Renamed lfs.free.ack -> lfs.lookahead.acked - Changed bitmap from using 32-bit words to using 8-bit bytes, dropping the alignment requirement. One of the reasons for 32-bit alignment was an attempt at future proofing for some sort of free-list. This never landed, and if it did, it could have been provided without breaking backwards compatiblity via an additional config option, at a minor RAM cost. We never used ffs/clz instructions for this bitmap, so I don't think using 32-bit words offers much advantage. It just creates another potential issue for users if their lookahead buffer is unaligned. These changes should probably also be upstreamed to the current version. They don't depend on anything rbyd specific. Note, at some point lfs_alloc will need to be extended to mark block tags, etc, as in-use during traversal.
This commit is contained in:
@@ -241,9 +241,8 @@ struct lfs_config {
|
||||
// By default lfs_malloc is used to allocate this buffer.
|
||||
void *prog_buffer;
|
||||
|
||||
// Optional statically allocated lookahead buffer. Must be lookahead_size
|
||||
// and aligned to a 32-bit boundary. By default lfs_malloc is used to
|
||||
// allocate this buffer.
|
||||
// Optional statically allocated lookahead buffer. Must be lookahead_size.
|
||||
// By default lfs_malloc is used to allocate this buffer.
|
||||
void *lookahead_buffer;
|
||||
|
||||
// Optional upper limit on length of file names in bytes. No downside for
|
||||
@@ -461,13 +460,13 @@ typedef struct lfs {
|
||||
lfs_gstate_t gdisk;
|
||||
lfs_gstate_t gdelta;
|
||||
|
||||
struct lfs_free {
|
||||
lfs_block_t off;
|
||||
struct lfs_lookahead {
|
||||
lfs_block_t start;
|
||||
lfs_block_t size;
|
||||
lfs_block_t i;
|
||||
lfs_block_t ack;
|
||||
uint32_t *buffer;
|
||||
} free;
|
||||
lfs_block_t next;
|
||||
lfs_block_t acked;
|
||||
uint8_t *buffer;
|
||||
} lookahead;
|
||||
|
||||
const struct lfs_config *cfg;
|
||||
lfs_size_t name_max;
|
||||
|
||||
Reference in New Issue
Block a user