]> git.neil.brown.name Git - LaFS.git/blob - summaries.doc
README update
[LaFS.git] / summaries.doc
1 As blocks are allocated and deallocated, various summaries
2 of block usage need to be adjusted.
3 In particular:
4    per-file block usage
5    per-filesystem block usage
6    per-user/group/tree block usage (for quotas)
7   the first two of these include a data block count and
8   an index block count.which are not directly visible to the fs.
9
10 The segment usage is a little different and will be discussed later.
11
12 For each of these, we need to ensure that the value visible to the
13 OS is consistant with allocations, and the value visible on storage
14 is consistant with stored data.
15
16 To achieve this we need to maintain 3 counters.
17   - a 'commited' total which reflect blocks that are or will be
18     linked to the inode when it is written in this phase
19   - a 'nextphase' total which reflects change that will become
20     visible on storage in the next phase
21   - an 'allocated' total which reflect changes that have been
22     acknowledged to the OS but which are not reflected on storage at all.
23
24 The state of a block is reflected in 2 values:
25    The 'physaddr' which is zero when the block has no image on storage.
26    The 'Prealloc' bit which reflects that the space usage for this block has
27        been acknowledged to the OS, but no actual address has been allocated. content on storage is out of date
28
29 The transitions of interest for data blocks are:
30
31    physaddr == 0, Prealloc changes 0 -> 1
32        'allocated' total must increment
33         This must happen before a new block is dirtied.
34    physaddr != 0, 
35        Prealloc is never set.
36
37    physaddr == 0, Prealloc changes 1 -> 0
38        can only happen when punching a hole in a
39        file that hasn't reached disk yet.
40        'allocated' must decrement
41    physaddr != 0, Prealloc changes 1 -> 0
42        This happens after physaddr is first set.
43         no change is required.
44
45    phyaddr changes 0 -> nonzero
46        Prealloc must be set
47        decrement 'allocated', increment 'commited' or 'nextphase'
48    phyaddr changes nonzero -> 0
49        Prealloc might be set - clear it first
50        decrement 'commited' or 'nextphase'
51        
52
53 For index blocks we do not have the 'allocated' value
54 as we don't need a consistent report to the OS.
55 So we only record transitions on physaddr which are triggered
56 by Dirty and mediated to some extent by Hole
57
58
59 We could call these changes:
60
61 'allocate'  (uncommited block becomes dirty)
62 'deallocate' (uncommited block becomes clean hole)
63 'commit' (allocated block gets commited)
64 'erase'  (commited block becomes a hole)