Journaling
Since we are going to overwrite cells with GC...
Journaling is to keep the consistency of the storage state including the free list. It is NOT to complete each commit since a commit can be gigantic.
- Cell writes are memory buffered and not performed actually until a sync.
- Cell reads check the write buffer.
- Loops until some amount of cell writes are buffered
- Write the buffered writes to a journal file. The journal file is hash-guarded. (Crash during this step leaves a corrupted journal. The recovery can safely ignore it.)
- Crash at this point can be recovered by replaying the journal
- Execute the journal. (Crash during this step leaves a valid journal. The recovery can replay the journal.)
- Reset the journal. (Crash during this step leaves a corrupted journal. The recovery can safely ignore it.)
- Crash at this point can be safely recovered. The journal is empty.