Subject: Re: how to bring a mounted filesystem to an almost clean state?
To: None <email@example.com>
From: David Young <firstname.lastname@example.org>
Date: 02/25/2003 12:07:20
On Tue, Feb 25, 2003 at 12:31:45PM +0100, Frank van der Linden wrote:
> Yes, this is not an easy problem. If you're looking for a specific
> snapshot solution, picking a filesystem to which it comes naturally
> (like LFS) is the easiest way to go. However, you want the most
> generic solution: a snapshotting device that can be used for any
> filesystem. I quite like that concept, and have thought about this
> in the past, but never got around do implementing anything.
> Since you want to work with any filesystem type, VFS_SYNC is the
> only way to get consistent state. But, you also need to make sure
> that no new writes get pushed in from userspace while doing this.
Do you have to delay user writes? I am not too familiar with the
filesystem or the buffer cache implementation, so maybe what I suggest
cannot work, but here goes: mark every buffer with its generation,
the buffer's generation being the number of VFS_SYNC's done between
boot time and the time the buffer was most recently "dirtied." For
the duration of a snapshot, mark all the buffers in generation N as
"copy-on-write," so that if userspace tries to write a buffer in
generation N, the buffer is copied into generation N+1 before it is
written. In the same snapshot, subsequent writes to the same buffer
affect its copy in generation N+1, only. When a snapshot finishes with
a buffer, it is freed if it has a copy in generation N+1. If not, it
"graduates" to generation N+1.
This idea comes from EROS, the Extremely Reliable Operating System,
which makes "checkpoints" (snapshots, essentially) of the main memory
every five minutes.
(A purported property of checkpoints is that they let EROS achieve
nearer the maximum bandwidth of a disk than other systems by avoiding
seeks. Perhaps snapshots could yield a similar benefit for NetBSD.)
David Young OJC Technologies
email@example.com Engineering from the Right Brain
Urbana, IL * (217) 278-3933