1
0
mirror of git://sourceware.org/git/lvm2.git synced 2024-12-21 13:34:40 +03:00

snapshot: %ORIGIN is relative to data size

Let's use the size of origin as the real base for percenta calculation,
and 'silenly' add needed metadata space for snapshot.

So now command   'lvcreate -s -l100%ORIGIN vg/lv' should always create a
snapshot to handle full device overwrite.
This commit is contained in:
Zdenek Kabelac 2014-06-17 13:33:42 +02:00
parent cd6d6fc24e
commit 494db11004
3 changed files with 13 additions and 4 deletions

View File

@ -1,5 +1,6 @@
Version 2.02.107 -
==================================
Automatically add snapshot metadata size for -l %ORIGIN calculation.
When converting RAID origin to cache LV, properly rename sub-LVs.
Use RemoveOnStop for lvm2-lvmetad.socket systemd unit.
Add thin-generic configuration profile for generic thin settings.

View File

@ -240,7 +240,8 @@ remaining free space in the Volume Group with the suffix \fI%FREE\fR, as a
percentage of the remaining free space for the specified
PhysicalVolume(s) with the suffix \fI%PVS\fR, or (for a snapshot) as a
percentage of the total space in the Origin Logical Volume with the
suffix \fI%ORIGIN\fR. When expressed as a percentage, the number is treated
suffix \fI%ORIGIN\fR (i.e. \fI100%ORIGIN\fR provides space for the whole origin).
When expressed as a percentage, the number is treated
as an approximate upper limit for the total number of physical extents
to be allocated (including extents used by any mirrors, for example).
.TP
@ -492,8 +493,8 @@ This operation would require 2 devices - the log is "in-memory":
.sp
.B lvcreate \-m1 \-\-mirrorlog core \-L 500M vg00
Creates a snapshot logical volume named /dev/vg00/snap which has access to the
contents of the original logical volume named /dev/vg00/lvol1
Creates a snapshot logical volume named "vg00/snap" which has access to the
contents of the original logical volume named "vg00/lvol1"
at snapshot logical volume creation time. If the original logical volume
contains a file system, you can mount the snapshot logical volume on an
arbitrary directory in order to access the contents of the filesystem to run
@ -501,6 +502,11 @@ a backup while the original filesystem continues to get updated:
.sp
.B lvcreate \-\-size 100m \-\-snapshot \-\-name snap /dev/vg00/lvol1
Creates a snapshot logical volume named "vg00/snap" with size
for overwriting 20% of the original logical volume named "vg00/lvol1".:
.sp
.B lvcreate \-s \-l 20%ORIGIN \-\-name snap vg00/lvol1
Creates a sparse device named /dev/vg1/sparse of size 1TiB with space for just
under 100MiB of actual data on it:
.sp

View File

@ -394,7 +394,9 @@ static int _update_extents_params(struct volume_group *vg,
log_error(INTERNAL_ERROR "Couldn't find origin volume.");
return 0;
}
extents = percent_of_extents(lp->extents, origin->le_count, 0);
/* Add whole metadata size estimation */
extents = cow_max_extents(origin, lp->chunk_size) - origin->le_count +
percent_of_extents(lp->extents, origin->le_count, 1);
break;
case PERCENT_NONE:
extents = lp->extents;