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

snapshot: require 3 chunks for creation

There is no point in creation of 2chunks snapshot,
since the snapshot is invalidated immeditelly with the first write
as there is no free chunk for COW blocks
(2 chunks are used by the snap header and the 1st. metadata chunk).

Enhance error message about the lowest usable size.
This commit is contained in:
Zdenek Kabelac 2013-05-29 12:39:33 +02:00
parent 39705ed201
commit 59962d8d3e
2 changed files with 10 additions and 2 deletions

View File

@ -1,5 +1,6 @@
Version 2.02.99 -
===================================
For creation of snapshot require size for at least 3 chunks.
Fix lvresize --use-policies of VALID but 100% full snapshot.
Do not accept size parameters bigger then 16EiB.
Fix release of PV's fid in free_pv_fid().

View File

@ -47,6 +47,8 @@ typedef enum {
#define A_CLING_BY_TAGS 0x08 /* Must match tags against existing segment */
#define A_CAN_SPLIT 0x10
#define SNAPSHOT_MIN_CHUNKS 3 /* Minimum number of chunks in snapshot */
/*
* Constant parameters during a single allocation attempt.
*/
@ -4543,8 +4545,13 @@ static struct logical_volume *_lv_create_an_lv(struct volume_group *vg, struct l
return NULL;
}
if (lp->snapshot && !seg_is_thin(lp) && ((uint64_t)lp->extents * vg->extent_size < 2 * lp->chunk_size)) {
log_error("Unable to create a snapshot smaller than 2 chunks.");
if (lp->snapshot && !seg_is_thin(lp) &&
((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 +
vg->extent_size - 1) / vg->extent_size),
display_size(cmd, (uint64_t) SNAPSHOT_MIN_CHUNKS * lp->chunk_size));
return NULL;
}