Partial implementation of a rudimentary mtree
This became surprisingly tricky. The main issue is knowing when to split mdirs, and how to determine this without wasting erase cycles. Unlike splitting btree nodes, we can't salvage failed compacts here. As soon as the salvage commit is written to disk, the commit becomes immediately visibile to the filesystem because it still exists in the mtree. This is a problem if we lose power. We're likely going to need to implement rbyd estimates. This is something I hoped to avoid because it brings in quite a bit of complexity and might lead to an annoying amount of storage waste since our estimates will need to be conservative to avoid unrecoverable situations. --- Also changed the on-disk btree/branch struct to store a copy of the weight. This was already required for the root of the btree, requiring the weight to be stored in every btree pointer allows better code deduplication at the cost of some redundancy on btree branches, where the weight is already implied by the rbyd structure. This weight is usually a single byte for most branches anyways. This may be worth revisiting at some point to see if there's any other unexpected tradeoffs.
This commit is contained in:
@@ -371,8 +371,12 @@ typedef union lfsr_btree {
|
||||
} lfsr_btree_t;
|
||||
|
||||
typedef struct lfsr_mdir {
|
||||
lfsr_rbyd_t rbyd;
|
||||
// -2 => an out-of-tree mdir
|
||||
// -1 => supermdir
|
||||
// >=0 => bid in the mtree
|
||||
lfs_ssize_t mid;
|
||||
lfs_block_t other_block;
|
||||
lfsr_rbyd_t rbyd;
|
||||
} lfsr_mdir_t;
|
||||
|
||||
|
||||
@@ -464,6 +468,10 @@ typedef struct lfs {
|
||||
lfs_size_t file_max;
|
||||
lfs_size_t attr_max;
|
||||
|
||||
// begin lfsr things
|
||||
lfsr_mdir_t supermdir;
|
||||
lfsr_btree_t mtree;
|
||||
|
||||
#ifdef LFS_MIGRATE
|
||||
struct lfs1 *lfs1;
|
||||
#endif
|
||||
|
||||
Reference in New Issue
Block a user