]> git.neil.brown.name Git - LaFS.git/blob - checkpoint.doc
README update
[LaFS.git] / checkpoint.doc
1
2 Notes on checkpointing.
3
4 All locked (pinned) blocks that do not have locked children should
5 be in the phase_leafs list or ....
6
7 To complete a checkpoint, we process each of these, allocating them
8 to a cluster.  As we allocate them, they get marked B_Alloc and drop
9 off the phase_leafs list.
10 When all phase leafs are processed (and earlier as clusters get full)
11 we flush out the cluster.  This causes each block to be allocated
12 a phys address and so it gets incorporated.
13
14 When B_Alloc gets cleared the block can change phase.  However we
15 still need to protect it from updates until we know that the write
16 is complete.  For this we have another state bit 'B_WritePhase'.
17 When a write completes, we set WritePhase to match Phase.
18 If we inhibit writes if either Phase or WritePhase are wrong.
19
20 So when B_Alloc is cleared, we are free to flip the phase.
21
22 So:
23
24  A block is on the leaf list if it is pinned and has no pinned children.
25  If it has unincorporated changes, we incorporate them.
26  If it doesn't but is dirty, we start the write processes.
27     This sets B_Alloc, then on cluster_flush it clears
28      B_Alloc and B_Dirty.
29  If it has no unincorporated changes and is not dirty, we
30    flip the phase.
31
32  Incorporating changes makes the block dirty.
33  Allocating clears the Dirty bit, so we can flip phase.
34
35
36 Yuck: A page can potentially be under writeback multiple times, in
37 that it can get into a cluster, then be updated and get into the next
38 cluster.  Due to double-clustering, we can start one write before finishing
39 another.  This means that the finish of a write doesn't prove that it
40 is written...
41 However we have a list of all blocks in a cluster.  And this list is used
42 to report completion, so either we never move between lists, and we can only
43 be in one place at a time, or we do move, and we only get the final
44 completion signalled.  So everything is fine.
45
46
47 But: