master - tests: snapshot needs 3 chunks
by Zdenek Kabelac
Gitweb: http://git.fedorahosted.org/git/?p=lvm2.git;a=commitdiff;h=09cc5f65dbe340...
Commit: 09cc5f65dbe34027c91011907e25ea4c21edfd13
Parent: 6f9366696c76863662e6cb12de467b5f748c8495
Author: Zdenek Kabelac <zkabelac(a)redhat.com>
AuthorDate: Thu May 30 17:55:44 2013 +0200
Committer: Zdenek Kabelac <zkabelac(a)redhat.com>
CommitterDate: Thu May 30 17:56:47 2013 +0200
tests: snapshot needs 3 chunks
---
test/shell/lvcreate-small-snap.sh | 15 ++++++++-------
1 files changed, 8 insertions(+), 7 deletions(-)
diff --git a/test/shell/lvcreate-small-snap.sh b/test/shell/lvcreate-small-snap.sh
index 9b43868..e0e6d1a 100644
--- a/test/shell/lvcreate-small-snap.sh
+++ b/test/shell/lvcreate-small-snap.sh
@@ -1,5 +1,5 @@
#!/bin/sh
-# Copyright (C) 2010 Red Hat, Inc. All rights reserved.
+# Copyright (C) 2010-2013 Red Hat, Inc. All rights reserved.
#
# This copyrighted material is made available to anyone wishing to use,
# modify, copy, or redistribute it subject to the terms and conditions
@@ -11,14 +11,15 @@
. lib/test
-aux prepare_pvs 3
+aux prepare_pvs
-vgcreate -c n -s 1k $vg $(cat DEVICES)
+vgcreate -s 1k $vg $(cat DEVICES)
-lvcreate -n one -l 10 $vg
-lvcreate -s -l 8 -n snapA $vg/one
-lvcreate -s -c 4k -l 8 -n snapX1 $vg/one
-lvcreate -s -c 8k -l 16 -n snapX2 $vg/one
+# 3 Chunks
+lvcreate -aey -n one -l 10 $vg
+lvcreate -s -l 12 -n snapA $vg/one
+lvcreate -s -c 4k -l 12 -n snapX1 $vg/one
+lvcreate -s -c 8k -l 24 -n snapX2 $vg/one
# Check that snapshots that are too small are caught with correct error.
not lvcreate -s -c 8k -l 8 -n snapX3 $vg/one 2>&1 | tee lvcreate.out
10 years, 11 months
master - cleanup: fix tabs
by Zdenek Kabelac
Gitweb: http://git.fedorahosted.org/git/?p=lvm2.git;a=commitdiff;h=6f9366696c7686...
Commit: 6f9366696c76863662e6cb12de467b5f748c8495
Parent: a766ea16b86501b6241cf7ba96dd0f28e1cf35b7
Author: Zdenek Kabelac <zkabelac(a)redhat.com>
AuthorDate: Thu May 30 17:56:02 2013 +0200
Committer: Zdenek Kabelac <zkabelac(a)redhat.com>
CommitterDate: Thu May 30 17:56:41 2013 +0200
cleanup: fix tabs
---
tools/lvcreate.c | 2 +-
1 files changed, 1 insertions(+), 1 deletions(-)
diff --git a/tools/lvcreate.c b/tools/lvcreate.c
index 497c474..3f2f17b 100644
--- a/tools/lvcreate.c
+++ b/tools/lvcreate.c
@@ -310,7 +310,7 @@ static int _update_extents_params(struct volume_group *vg,
extents = cow_max_extents(origin, lp->chunk_size);
if (extents < lp->extents) {
- log_print_unless_silent("Reducing COW size %s down to maximum usable size %s.",
+ log_print_unless_silent("Reducing COW size %s down to maximum usable size %s.",
display_size(vg->cmd, (uint64_t) vg->extent_size * lp->extents),
display_size(vg->cmd, (uint64_t) vg->extent_size * extents));
lp->extents = extents;
10 years, 11 months
master - tests: snapshot testing
by Zdenek Kabelac
Gitweb: http://git.fedorahosted.org/git/?p=lvm2.git;a=commitdiff;h=a766ea16b86501...
Commit: a766ea16b86501b6241cf7ba96dd0f28e1cf35b7
Parent: cd9350198e3178251a54c442183465e8b7719251
Author: Zdenek Kabelac <zkabelac(a)redhat.com>
AuthorDate: Wed May 29 23:36:44 2013 +0200
Committer: Zdenek Kabelac <zkabelac(a)redhat.com>
CommitterDate: Thu May 30 17:35:23 2013 +0200
tests: snapshot testing
---
test/shell/snapshots-usage.sh | 87 +++++++++++++++++++++++++++++++++++++++++
1 files changed, 87 insertions(+), 0 deletions(-)
diff --git a/test/shell/snapshots-usage.sh b/test/shell/snapshots-usage.sh
new file mode 100644
index 0000000..ae08378
--- /dev/null
+++ b/test/shell/snapshots-usage.sh
@@ -0,0 +1,87 @@
+#!/bin/bash
+# Copyright (C) 2013 Red Hat, Inc. All rights reserved.
+#
+# This copyrighted material is made available to anyone wishing to use,
+# modify, copy, or redistribute it subject to the terms and conditions
+# of the GNU General Public License v.2.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program; if not, write to the Free Software Foundation,
+# Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+
+# no automatic extensions please
+
+. lib/test
+
+fill() {
+ dd if=/dev/zero of=$DM_DEV_DIR/$vg1/lvol0 bs=$1 count=1
+}
+
+aux prepare_vg
+
+lvcreate -s -l 100%FREE -n $lv $vg --virtualsize 15P
+
+aux lvmconf "activation/snapshot_autoextend_percent = 20" \
+ "activation/snapshot_autoextend_threshold = 50"
+aux lvmconf 'devices/filter = [ "a|dev/mapper/.*$|", "a|dev/LVMTEST|", "r|.*|" ]'
+aux lvmconf 'devices/global_filter = [ "a|dev/mapper/.*$|", "a|dev/LVMTEST|", "r|.*|" ]'
+
+# Check usability with smallest extent size
+pvcreate --setphysicalvolumesize 4T $DM_DEV_DIR/$vg/$lv
+vgcreate -s 1K $vg1 $DM_DEV_DIR/$vg/$lv
+
+# Check border size
+lvcreate -aey -L4095G $vg1
+lvcreate -s -L100K $vg1/lvol0
+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"
+
+not lvcreate -s -c512 -l512 $vg1/lvol0
+lvcreate -aey -s -c128 -l1700 $vg1/lvol0
+# 3 * 128
+check lv_field $vg1/lvol2 size "384.00k"
+
+lvremove -ff $vg1
+
+lvcreate -aey -l20 $vg1
+lvcreate -s -l12 $vg1/lvol0
+
+# Fill 1KB -> 100% snapshot (1x 4KB chunk)
+fill 1K
+check lv_field $vg1/lvol1 data_percent "100.00"
+
+# Check it resizes 100% full valid snapshot
+lvextend --use-policies $vg1/lvol1
+check lv_field $vg1/lvol1 data_percent "80.00"
+
+fill 4K
+lvextend --use-policies $vg1/lvol1
+check lv_field $vg1/lvol1 size "18.00k"
+
+lvextend -l+33 $vg1/lvol1
+check lv_field $vg1/lvol1 size "28.00k"
+
+fill 20K
+vgremove -ff $vg1
+
+# Check usability with large 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"
+
+vgremove -ff $vg1
+vgremove -ff $vg
10 years, 11 months
master - tests: drop testing of raids in cluster
by Zdenek Kabelac
Gitweb: http://git.fedorahosted.org/git/?p=lvm2.git;a=commitdiff;h=cd9350198e3178...
Commit: cd9350198e3178251a54c442183465e8b7719251
Parent: e4dfa785d14643e1efd298af1040f461704b0a67
Author: Zdenek Kabelac <zkabelac(a)redhat.com>
AuthorDate: Wed May 29 12:48:29 2013 +0200
Committer: Zdenek Kabelac <zkabelac(a)redhat.com>
CommitterDate: Thu May 30 17:35:23 2013 +0200
tests: drop testing of raids in cluster
Since raid is not clustered yet - drop it from testing in cluster phase.
(saving running some time)
---
test/shell/lvconvert-raid.sh | 4 +++-
test/shell/lvconvert-raid10.sh | 4 +++-
test/shell/lvcreate-large.sh | 2 +-
3 files changed, 7 insertions(+), 3 deletions(-)
diff --git a/test/shell/lvconvert-raid.sh b/test/shell/lvconvert-raid.sh
index 59c8bdb..61345da 100644
--- a/test/shell/lvconvert-raid.sh
+++ b/test/shell/lvconvert-raid.sh
@@ -11,6 +11,8 @@
. lib/test
+test -e LOCAL_CLVMD && skip
+
get_image_pvs() {
local d
local images
@@ -26,7 +28,7 @@ aux target_at_least dm-raid 1 2 0 || skip
# 9 PVs needed for RAID10 testing (3-stripes/2-mirror - replacing 3 devs)
aux prepare_pvs 9 80
-vgcreate -c n -s 256k $vg $(cat DEVICES)
+vgcreate -s 256k $vg $(cat DEVICES)
###########################################
# RAID1 convert tests
diff --git a/test/shell/lvconvert-raid10.sh b/test/shell/lvconvert-raid10.sh
index 2e4381d..b2d4afd 100644
--- a/test/shell/lvconvert-raid10.sh
+++ b/test/shell/lvconvert-raid10.sh
@@ -11,6 +11,8 @@
. lib/test
+test -e LOCAL_CLVMD && skip
+
get_image_pvs() {
local d
local images
@@ -28,7 +30,7 @@ aux target_at_least dm-raid 1 3 1 || skip
# 9 PVs needed for RAID10 testing (3-stripes/2-mirror - replacing 3 devs)
aux prepare_pvs 9 80
-vgcreate -c n -s 256k $vg $(cat DEVICES)
+vgcreate -s 256k $vg $(cat DEVICES)
lvcreate --type raid10 -m 1 -i 3 -l 3 -n $lv1 $vg
aux wait_for_sync $vg $lv1
diff --git a/test/shell/lvcreate-large.sh b/test/shell/lvcreate-large.sh
index b61ccca..09e323a 100644
--- a/test/shell/lvcreate-large.sh
+++ b/test/shell/lvcreate-large.sh
@@ -23,7 +23,7 @@ lvcreate -s -l 100%FREE -n $lv $vg --virtualsize 1024T
aux lvmconf 'devices/filter = [ "a/dev\/mapper\/.*$/", "a/dev\/LVMTEST/", "r/.*/" ]'
pvcreate $DM_DEV_DIR/$vg/$lv
-vgcreate -c n $vg1 $DM_DEV_DIR/$vg/$lv
+vgcreate $vg1 $DM_DEV_DIR/$vg/$lv
lvcreate -l 100%FREE -n $lv1 $vg1
check lv_field $vg1/$lv1 size "1024.00t"
10 years, 11 months
master - libdm: compensate suspend counter for live table
by Zdenek Kabelac
Gitweb: http://git.fedorahosted.org/git/?p=lvm2.git;a=commitdiff;h=e4dfa785d14643...
Commit: e4dfa785d14643e1efd298af1040f461704b0a67
Parent: b08c3464898f1c1e45fcac95258a495286e4dd47
Author: Zdenek Kabelac <zkabelac(a)redhat.com>
AuthorDate: Thu May 30 11:19:28 2013 +0200
Committer: Zdenek Kabelac <zkabelac(a)redhat.com>
CommitterDate: Thu May 30 17:35:23 2013 +0200
libdm: compensate suspend counter for live table
This patch may not be fully correct. It tries to solve
the imbalanced suspend counter.
The problem starts when some LV is created and fails in resume path.
(i.e. resuming to large PV (enforced) over small loop devices)
This fails in _resume_node() after dm_task_run(). And while
existing device with empty table is left in inactive table,
further calls are reporting this device is in suspend state.
When later the lvm2 tries to rollback created device and deactivate it,
it will end with internal error, when we try to decrement
never incremented suspend counter.
As an 'easy fix' for now update suspend counter only for live nodes.
TODO: explore better fix.
---
libdm/libdm-deptree.c | 2 +-
1 files changed, 1 insertions(+), 1 deletions(-)
diff --git a/libdm/libdm-deptree.c b/libdm/libdm-deptree.c
index 2201b30..4482296 100644
--- a/libdm/libdm-deptree.c
+++ b/libdm/libdm-deptree.c
@@ -1598,7 +1598,7 @@ static int _dm_tree_deactivate_children(struct dm_tree_node *dnode,
info.minor);
r = 0;
continue;
- } else if (info.suspended)
+ } else if (info.suspended && info.live_table)
dec_suspended();
if (child->callback &&
10 years, 11 months
master - lvresize: drop monitoring of 100% covered origin
by Zdenek Kabelac
Gitweb: http://git.fedorahosted.org/git/?p=lvm2.git;a=commitdiff;h=b08c3464898f1c...
Commit: b08c3464898f1c1e45fcac95258a495286e4dd47
Parent: 3ced1bf694359a67162cccc7f0e3d94e50929f6e
Author: Zdenek Kabelac <zkabelac(a)redhat.com>
AuthorDate: Wed May 29 21:23:18 2013 +0200
Committer: Zdenek Kabelac <zkabelac(a)redhat.com>
CommitterDate: Thu May 30 17:35:23 2013 +0200
lvresize: drop monitoring of 100% covered origin
---
tools/lvresize.c | 4 ++++
1 files changed, 4 insertions(+), 0 deletions(-)
diff --git a/tools/lvresize.c b/tools/lvresize.c
index a32930e..ae42ce8 100644
--- a/tools/lvresize.c
+++ b/tools/lvresize.c
@@ -868,6 +868,10 @@ static int _lvresize(struct cmd_context *cmd, struct volume_group *vg,
return ECMD_FAILED;
}
+ if (lv_is_cow_covering_origin(lv))
+ if (!monitor_dev_for_events(cmd, lv, 0, 0))
+ stack;
+
backup(vg);
/*
10 years, 11 months
master - lvresize: check for max snapshot size
by Zdenek Kabelac
Gitweb: http://git.fedorahosted.org/git/?p=lvm2.git;a=commitdiff;h=3ced1bf694359a...
Commit: 3ced1bf694359a67162cccc7f0e3d94e50929f6e
Parent: bd3ece0128926cc156b7fcb6409acc1a2afb16db
Author: Zdenek Kabelac <zkabelac(a)redhat.com>
AuthorDate: Wed May 29 21:23:02 2013 +0200
Committer: Zdenek Kabelac <zkabelac(a)redhat.com>
CommitterDate: Thu May 30 17:35:23 2013 +0200
lvresize: check for max snapshot size
As for lvcreate, lvresize also doesn't need to grow bigger then needed.
---
WHATS_NEW | 1 +
tools/lvresize.c | 10 ++++++++++
2 files changed, 11 insertions(+), 0 deletions(-)
diff --git a/WHATS_NEW b/WHATS_NEW
index d757e2b..7589f12 100644
--- a/WHATS_NEW
+++ b/WHATS_NEW
@@ -1,5 +1,6 @@
Version 2.02.99 -
===================================
+ Detect maximum usable size for snapshot for lvresize.
Creation of snapshot takes at most 100% origin coverage.
Add cow_max_extents() to calc extents for 100% origin coverage.
For creation of snapshot require size for at least 3 chunks.
diff --git a/tools/lvresize.c b/tools/lvresize.c
index b1008ec..a32930e 100644
--- a/tools/lvresize.c
+++ b/tools/lvresize.c
@@ -527,6 +527,16 @@ static int _lvresize(struct cmd_context *cmd, struct volume_group *vg,
return EINVALID_CMD_LINE;
}
lp->extents += lv->le_count;
+ if (lv_is_cow(lv)) {
+ extents_used = cow_max_extents(origin_from_cow(lv), find_cow(lv)->chunk_size);
+ if (extents_used < lp->extents) {
+ log_print_unless_silent("Reached maximum COW size %s.",
+ display_size(vg->cmd, (uint64_t) vg->extent_size * extents_used));
+ lp->extents = extents_used;
+ if (lp->extents == lv->le_count)
+ return ECMD_PROCESSED;
+ }
+ }
}
if (lp->sign == SIGN_MINUS) {
10 years, 11 months
master - lvcreate: reduce too large cow
by Zdenek Kabelac
Gitweb: http://git.fedorahosted.org/git/?p=lvm2.git;a=commitdiff;h=bd3ece0128926c...
Commit: bd3ece0128926cc156b7fcb6409acc1a2afb16db
Parent: eb7e206a73a4fae5b93ffcdf96640675f7a72a73
Author: Zdenek Kabelac <zkabelac(a)redhat.com>
AuthorDate: Wed May 29 21:43:46 2013 +0200
Committer: Zdenek Kabelac <zkabelac(a)redhat.com>
CommitterDate: Thu May 30 17:35:14 2013 +0200
lvcreate: reduce too large cow
Detect maximum usable size of snapshot COW device,
and do not waste more space for such LV then needed.
---
WHATS_NEW | 1 +
tools/lvcreate.c | 18 ++++++++++++++++++
2 files changed, 19 insertions(+), 0 deletions(-)
diff --git a/WHATS_NEW b/WHATS_NEW
index c7eb82a..d757e2b 100644
--- a/WHATS_NEW
+++ b/WHATS_NEW
@@ -1,5 +1,6 @@
Version 2.02.99 -
===================================
+ Creation of snapshot takes at most 100% origin coverage.
Add cow_max_extents() to calc extents for 100% origin coverage.
For creation of snapshot require size for at least 3 chunks.
Fix lvresize --use-policies of VALID but 100% full snapshot.
diff --git a/tools/lvcreate.c b/tools/lvcreate.c
index 7580155..497c474 100644
--- a/tools/lvcreate.c
+++ b/tools/lvcreate.c
@@ -241,6 +241,7 @@ static int _update_extents_params(struct volume_group *vg,
struct logical_volume *origin = NULL;
uint32_t size_rest;
uint32_t stripesize_extents;
+ uint32_t extents;
if (lcp->size &&
!(lp->extents = extents_from_size(vg->cmd, lcp->size,
@@ -299,6 +300,23 @@ static int _update_extents_params(struct volume_group *vg,
break;
}
+ if (lp->snapshot && lp->origin) {
+ if (!origin && !(origin = find_lv(vg, lp->origin))) {
+ log_error("Couldn't find origin volume '%s'.",
+ lp->origin);
+ return 0;
+ }
+
+ extents = cow_max_extents(origin, lp->chunk_size);
+
+ if (extents < lp->extents) {
+ log_print_unless_silent("Reducing COW size %s down to maximum usable size %s.",
+ display_size(vg->cmd, (uint64_t) vg->extent_size * lp->extents),
+ display_size(vg->cmd, (uint64_t) vg->extent_size * extents));
+ lp->extents = extents;
+ }
+ }
+
if (!(stripesize_extents = lp->stripe_size / vg->extent_size))
stripesize_extents = 1;
10 years, 11 months
master - snapshot: add cow_max_extents
by Zdenek Kabelac
Gitweb: http://git.fedorahosted.org/git/?p=lvm2.git;a=commitdiff;h=eb7e206a73a4fa...
Commit: eb7e206a73a4fae5b93ffcdf96640675f7a72a73
Parent: 59962d8d3e1c402da02f7bf1b09978f570fd09d5
Author: Zdenek Kabelac <zkabelac(a)redhat.com>
AuthorDate: Wed May 29 12:44:54 2013 +0200
Committer: Zdenek Kabelac <zkabelac(a)redhat.com>
CommitterDate: Thu May 30 17:30:15 2013 +0200
snapshot: add cow_max_extents
Add more precise calculation of the maximum usable snapshot size.
Using only percentage fails for small size of snapshot and extents.
---
WHATS_NEW | 1 +
lib/metadata/metadata-exported.h | 1 +
lib/metadata/snapshot_manip.c | 40 +++++++++++++++++++++++++++++++++++--
3 files changed, 39 insertions(+), 3 deletions(-)
diff --git a/WHATS_NEW b/WHATS_NEW
index 256adec..c7eb82a 100644
--- a/WHATS_NEW
+++ b/WHATS_NEW
@@ -1,5 +1,6 @@
Version 2.02.99 -
===================================
+ Add cow_max_extents() to calc extents for 100% origin coverage.
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.
diff --git a/lib/metadata/metadata-exported.h b/lib/metadata/metadata-exported.h
index f698b33..7ef4220 100644
--- a/lib/metadata/metadata-exported.h
+++ b/lib/metadata/metadata-exported.h
@@ -717,6 +717,7 @@ int lv_is_virtual_origin(const struct logical_volume *lv);
int lv_is_cow(const struct logical_volume *lv);
int lv_is_merging_origin(const struct logical_volume *origin);
int lv_is_merging_cow(const struct logical_volume *snapshot);
+uint32_t cow_max_extents(const struct logical_volume *origin, uint32_t chunk_size);
int lv_is_cow_covering_origin(const struct logical_volume *lv);
/* Test if given LV is visible from user's perspective */
diff --git a/lib/metadata/snapshot_manip.c b/lib/metadata/snapshot_manip.c
index a7f57a6..c3d1112 100644
--- a/lib/metadata/snapshot_manip.c
+++ b/lib/metadata/snapshot_manip.c
@@ -31,11 +31,45 @@ int lv_is_cow(const struct logical_volume *lv)
return (!lv_is_origin(lv) && lv->snapshot) ? 1 : 0;
}
+static uint64_t _cow_max_size(uint64_t origin_size, uint32_t chunk_size)
+{
+ /* Snapshot disk layout:
+ * COW is divided into chunks
+ * 1st. chunk is reserved for header
+ * 2nd. chunk is the 1st. metadata chunk
+ * 3rd. chunk is the 1st. data chunk
+ */
+
+ /* Size of metadata for snapshot in sectors */
+ uint64_t mdata_size = ((origin_size + chunk_size - 1) / chunk_size * 16 + 511) >> SECTOR_SHIFT;
+
+ /* Sum all chunks - header + metadata size + origin size (aligned on chunk boundary) */
+ uint64_t size = chunk_size +
+ ((mdata_size + chunk_size - 1) & ~(uint64_t)(chunk_size - 1)) +
+ ((origin_size + chunk_size - 1) & ~(uint64_t)(chunk_size - 1));
+
+ /* Does not overflow since size is in sectors (9 bits) */
+ return size;
+}
+
+uint32_t cow_max_extents(const struct logical_volume *origin, uint32_t chunk_size)
+{
+ uint64_t size = _cow_max_size(origin->size, chunk_size);
+ uint32_t extent_size = origin->vg->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 */
+
+ return (uint32_t) (size / extent_size);
+}
+
int lv_is_cow_covering_origin(const struct logical_volume *lv)
{
- /* TODO: we need less then 1% of origin size, depends on chunk size */
- return lv_is_cow(lv) ?
- (origin_from_cow(lv)->size * UINT64_C(101) <= lv->size * UINT64_C(100)) : 0;
+ return lv_is_cow(lv) &&
+ (lv->size >= _cow_max_size(origin_from_cow(lv)->size, find_cow(lv)->chunk_size));
}
int lv_is_visible(const struct logical_volume *lv)
10 years, 11 months
master - snapshot: require 3 chunks for creation
by Zdenek Kabelac
Gitweb: http://git.fedorahosted.org/git/?p=lvm2.git;a=commitdiff;h=59962d8d3e1c40...
Commit: 59962d8d3e1c402da02f7bf1b09978f570fd09d5
Parent: 39705ed20123d394f1f0d122704855ec783973da
Author: Zdenek Kabelac <zkabelac(a)redhat.com>
AuthorDate: Wed May 29 12:39:33 2013 +0200
Committer: Zdenek Kabelac <zkabelac(a)redhat.com>
CommitterDate: Thu May 30 17:28:03 2013 +0200
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.
---
WHATS_NEW | 1 +
lib/metadata/lv_manip.c | 11 +++++++++--
2 files changed, 10 insertions(+), 2 deletions(-)
diff --git a/WHATS_NEW b/WHATS_NEW
index 1888c62..256adec 100644
--- a/WHATS_NEW
+++ b/WHATS_NEW
@@ -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().
diff --git a/lib/metadata/lv_manip.c b/lib/metadata/lv_manip.c
index af000af..48a1515 100644
--- a/lib/metadata/lv_manip.c
+++ b/lib/metadata/lv_manip.c
@@ -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;
}
10 years, 11 months