Subject: Re: Which snapshot strategy to use? was: How to capture all
To: Jason Thorpe <thorpej@wasabisystems.com>
From: Christian Limpach <chris@pin.lu>
List: tech-kern
Date: 10/23/2003 14:47:32
> > FWIW I use a pseudo disk device to do block interception.
>
> What is the procedure you use for snapshotting a file system?
>
> Let's say you have /u1 mounted from /dev/sd1a.  How would you then take
> a snapshot?

The driver provides virtualization, so you'd use it with a userland volume
manager or with wedges and then every device you mount is provided through
the driver.  For devices mounted through the driver, you can ask the driver
to suspend access to the device (while keeping it mounted), replace the
mapping and then resume access to the device.

Each mapping describes how a sector range on the created device is build
from other devices:
"b s module params" defines the range starting at b of size s to be mapped
through module "module" with parameters "params".

Example:
sd1's disklabel:
 a:    204800   7782784     unused      0     0         # (Cyl.    0 -
7648*)
 b:    106496   7987584     unused      0     0         # (Cyl.    0 -
7648*)
 d:  12666022         0     unused      0     0         # (Cyl.    0 -
7648*)

regular operation:
/dev/mapper/vgdelight-test is mounted on /u1
mapping for device vgdelight-test:
0 204800 linear /dev/sd1d 7782784
(there's a possibility for a shortcut where you use sd1 instead of /dev/sd1d
and the driver for sd1 is looked up in config in the kernel)

taking a snapshot (snapshot backing store is on /dev/sd1b):
mapping for device vgdelight-test:
0 204800 snapshot-origin /dev/mapper/vgdelight-test-real

mapping for vgdelight-test-real:
0 204800 linear /dev/sd1d 7782784

mapping for vgdelight-testsnap (the snapshot device):
0 204800 snapshot /dev/mapper/vgdelight-test-real
/dev/mapper/vgdelight-testsnap-cow P 16

mapping for vgdelight-testsnap-cow:
0 106496 linear /dev/sd1d 7987584

You can then mount /dev/mapper/vgdelight-testsnap to get access to the
snapshot.  And you can even mount the snapshot writable.

At the moment the driver provides an ioctl interface compatible with the
Linux device-mapper driver.  The features are also similar to the Linux
driver.  The core of the driver (strategy request remapping) is ccd with
some extensions.

I think that we should also have snapshots at the filesystem level,
basically what Bill said:
> They are each better for different uses. So neither one will win out
> overall.

But I don't think we should have block level snapshots implemented at the
filesystem level.

     christian