[pve-devel] [PATCH 5/5] DRBD: Implement snapshots.

Philipp Marek philipp.marek at linbit.com
Fri Nov 13 09:23:56 CET 2015

Hi Dietmar,

> I just started to implement a PVE storage driver for lvmthin:
> https://git.proxmox.com/?p=pve-storage.git;a=blob;f=PVE/Storage/LvmThinPlugin.pm
> So far I just use:
> sub volume_snapshot_rollback {
>     my ($class, $scfg, $storeid, $volname, $snap) = @_;
>     my $vg = $scfg->{vgname};
>     my $snapvol = "snap_${volname}_$snap";
>     my $cmd = ['/sbin/lvremove', '-f', "$vg/$volname"];
>     run_command($cmd, errmsg => "lvremove '$vg/$volname' error");
>     $cmd = ['/sbin/lvcreate', '-kn', '-n', $volname, '-s', "$vg/$snapvol"];
>     run_command($cmd, errmsg => "lvm rollback '$vg/$snapvol' error");
> }
> While that works, it is not atomic.
> Maybe you already found a better way to implement rollback within drbdmanage?
Not atomically, no.

We've got an even more interesting problem - we should do atomic changes 
across the whole cluster...

We'll probably have to do the indirection trick - storing the ProxMox names 
in some hash table to index the resource names, and doing an atomic update 
in that one; then all new "attach" commands would take the new resource.

Don't know how you would get the LVM sequence atomically... well, you could 
"lvcreate" *first*, and then do a name-swap via sed/awk/perl and vgcfgrestore...


I guess the most clean way would be to change "lvrename" to allow multiple 
renames in an atomic way - but that's a bit of work.

More information about the pve-devel mailing list