On 08/25/2010 09:36 AM, Avi Kivity wrote:
If you tried to maintain a free list, then you would need to sync on
TRIM/DISCARD which is potentially a fast path. While a background
task may be less efficient in the short term, it's just as efficient
in the long term and it has the advantage of keeping any fast path
fast.
You only need to sync when the free list size grows beyond the amount
of space you're prepared to lose on power fail. And you may be able
to defer the background task indefinitely by satisfying new
allocations from the free list.
Free does not mean free. If you immediately punch a hole in the l2
without doing a sync, then you're never sure whether the hole is there
on disk or not. So if you then allocate that block and put it
somewhere else in another l2 table, you need to sync the previous l2
change before you update the new l2.
Otherwise you can have two l2 entries pointing to the same block after
a power failure. That's not a leak, that's a data corruption.