Added revision sum as tracking for filesystem stability

The idea is pretty simple: The revision count for each metadata block
only really needs 3 distinct states. The additional bit-width of the
revision count is available for other information. In this case, we can
sum all revision counts in the filesystem to encode state that can be
updated for free during any metadata block update.

The obvious state to store first is if the filesystem is in a bad state
that requires a deorphan step.

The allows us to sidestep the expensive O(n^2) operation for the O(n)
sum in the much more common case.

This patch adds the following rule:
If the sum of all revision count is odd, the filesystem was caught
mid-operation and must be deorphaned.
This commit is contained in:
Christopher Haster
2017-10-10 01:47:23 -05:00
parent 539409e2fb
commit b24ddac95e
2 changed files with 41 additions and 11 deletions

3
lfs.h
View File

@@ -243,7 +243,8 @@ typedef struct lfs {
lfs_cache_t pcache;
lfs_free_t free;
bool deorphaned;
uint8_t unstable;
uint8_t sum;
} lfs_t;