Chapter 6 Checkpoints/Snapshots 6-5
Figure 6-2 shows part of array of mappings for block n. In this example, ckpti+1 is
the most recent checkpoint and thus, the last entry in the mappings and ckpti-2 is
the oldest checkpoint (in this example).
Assume a filesystem operation on checkpoint ckpti-2, and block n is accessed. The
mapping function first checks the mapping for ckpti-2 and given it is empty, it
moves forward and checks the mapping for ckpti-1. It finds m and will use block m
instead of block n.
When accessing block n from ckpti, because there is no mapping, the mapping
function moves forward and will use the mapping for ckpti+1, which is block p.
Note that when searching for a mapping entry, the system will always move forward
from current checkpoint toward more recently created checkpoints. The mapping
entries of checkpoints older than the current checkpoint are never used.
Now let's see how the mappings are created. While checkpointing is active for a
volume, all of the blocks of LFS are shared by checkpoint of its corresponding CFS
until they are changed. As show in Figure 6-3, while block n is not modified, all the
checkpoints of the filesystem use the block n itself with no mapping. If a block in the
live file system is modified, then sfs2cp_notice_update( ) is called. This function first
checks to see if there is an existing mapping for this block. If there is a mapping for
the block, it will do nothing. If no mappings can be found and the change is not
allocation, then it duplicates the block and puts the address of the new block into the
mapping for the most recently created checkpoint. If the change is for block
allocation, the system does not duplicate the block; it just puts a special value
(SFS2CP_ALLO_MARKER) into the mapping. This is because if the block has just
been allocated, there can't be any object on the checkpoints using this block (and no
need to duplicate this block).
FIGURE 6-3 Mappings for Block n Before Modification