1
0
mirror of git://sourceware.org/git/lvm2.git synced 2025-01-03 05:18:29 +03:00

snapshot: fix max size limit check for COW device

Use proper max size as a multiple of extent size.
And use 64bit arithmentic for validation of minsize.
(in release fix).
This commit is contained in:
Zdenek Kabelac 2013-06-16 21:32:11 +02:00
parent 2f334b16d2
commit d4308a558d
3 changed files with 22 additions and 20 deletions

View File

@ -4544,7 +4544,8 @@ static struct logical_volume *_lv_create_an_lv(struct volume_group *vg, struct l
}
if (lp->snapshot && !seg_is_thin(lp) &&
((uint64_t)(lp->extents * vg->extent_size) < (SNAPSHOT_MIN_CHUNKS * lp->chunk_size))) {
(((uint64_t)lp->extents * vg->extent_size) <
(SNAPSHOT_MIN_CHUNKS * lp->chunk_size))) {
log_error("Unable to create a snapshot smaller than "
DM_TO_STRING(SNAPSHOT_MIN_CHUNKS) " chunks (%u extents, %s).",
(unsigned) (((uint64_t) SNAPSHOT_MIN_CHUNKS * lp->chunk_size +

View File

@ -56,12 +56,13 @@ uint32_t cow_max_extents(const struct logical_volume *origin, uint32_t chunk_siz
{
uint64_t size = _cow_max_size(origin->size, chunk_size);
uint32_t extent_size = origin->vg->extent_size;
uint64_t max_size = (uint64_t) MAX_EXTENT_COUNT * extent_size;
if (size % extent_size)
size += extent_size - size % extent_size;
if (size > UINT32_MAX)
size = UINT32_MAX; /* Origin is too big for 100% snapshot anyway */
if (size > max_size)
size = max_size; /* Origin is too big for 100% snapshot anyway */
return (uint32_t) (size / extent_size);
}

View File

@ -37,18 +37,17 @@ fill 1K
check lv_field $vg1/lvol1 data_percent "12.00"
lvremove -ff $vg1
# Create 1KB snapshot
lvcreate -aey -l1 $vg1
not lvcreate -s -l1 $vg1/lvol0
not lvcreate -s -l3 $vg1/lvol0
lvcreate -s -l30 $vg1/lvol0
check lv_field $vg1/lvol1 size "12.00k"
# Create 1KB snapshot, no need to be active active here
lvcreate -an -Zn -l1 -n $lv1 $vg1
not lvcreate -s -l1 $vg1/$lv1
not lvcreate -s -l3 $vg1/$lv1
lvcreate -s -l30 -n $lv2 $vg1/$lv1
check lv_field $vg1/$lv2 size "12.00k"
not lvcreate -s -c512 -l512 $vg1/lvol0
lvcreate -aey -s -c128 -l1700 $vg1/lvol0
not lvcreate -s -c512 -l512 $vg1/$lv1
lvcreate -s -c128 -l1700 -n $lv3 $vg1/$lv1
# 3 * 128
check lv_field $vg1/lvol2 size "384.00k"
check lv_field $vg1/$lv3 size "384.00k"
lvremove -ff $vg1
lvcreate -aey -l20 $vg1
@ -72,16 +71,17 @@ check lv_field $vg1/lvol1 size "28.00k"
fill 20K
vgremove -ff $vg1
# Check usability with large extent size
# Check usability with largest extent size
pvcreate $DM_DEV_DIR/$vg/$lv
vgcreate -s 4G $vg1 $DM_DEV_DIR/$vg/$lv
lvcreate -aey -l1 $vg1
lvcreate -s -l1 $vg1/lvol0
check lv_field $vg1/lvol1 size "4.00g"
lvcreate -aey -V15E -l1 -s $vg1
check lv_field $vg1/lvol2 origin_size "15.00e"
lvcreate -an -Zn -l50%FREE -n $lv1 $vg1
lvcreate -s -l100%FREE -n $lv2 $vg1/$lv1
check lv_field $vg1/$lv2 size "7.50p"
lvremove -ff $vg1
lvcreate -aey -V15E -l1 -n $lv1 -s $vg1
check lv_field $vg1/$lv1 origin_size "15.00e"
vgremove -ff $vg1
vgremove -ff $vg