1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
|
From d5c2c146ee050905a175b73dd3d0155f46d5cf81 Mon Sep 17 00:00:00 2001
From: Zdenek Kabelac <zkabelac@redhat.com>
Date: Wed, 26 Feb 2014 00:17:11 +0100
Subject: [PATCH 2/2] snapshot: zero cow header for read-only snapshot
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
When read-only snapshot was created, tool was skipping header
initialization of cow device. If it happened device has been
already containing header from some previous snapshot, it's
been 'reused' for a newly created snapshot instead of being cleared.
Conflicts:
WHATS_NEW
[Backported to 2.02.105 by Thomas Bächler (thomas@archlinux.org)]
---
WHATS_NEW | 1 +
test/shell/snapshot-usage.sh | 11 +++++++++++
tools/lvcreate.c | 8 ++++++--
3 files changed, 18 insertions(+), 2 deletions(-)
diff --git a/WHATS_NEW b/WHATS_NEW
index d2a3482..eeb3517 100644
--- a/WHATS_NEW
+++ b/WHATS_NEW
@@ -1,3 +1,4 @@
+ Zero snapshot COW header when creating read-only snapshot.
Wipe DM_snapshot_cow signature without prompt in new LVs with blkid wiping.
Version 2.02.105 - 20th January 2014
diff --git a/test/shell/snapshot-usage.sh b/test/shell/snapshot-usage.sh
index 9e6a14f..17abe9b 100644
--- a/test/shell/snapshot-usage.sh
+++ b/test/shell/snapshot-usage.sh
@@ -128,4 +128,15 @@ vgremove -ff $vg1
fi
+lvremove -f $vg
+
+# Check snapshot really deletes COW header for read-only snapshot
+aux lvmconf "allocation/wipe_signatures_when_zeroing_new_lvs = 1"
+lvcreate -L10 -n $lv1 $vg
+lvcreate -s -L10 -n snap $vg/$lv1
+# Populate snapshot with some filesystem signatures
+mkfs.ext4 "$DM_DEV_DIR/$vg/snap"
+lvremove -f $vg/snap
+lvcreate -s -pr -l12 -n snap $vg/$lv1
+
vgremove -ff $vg
diff --git a/tools/lvcreate.c b/tools/lvcreate.c
index d0ca7bc..e8270c4 100644
--- a/tools/lvcreate.c
+++ b/tools/lvcreate.c
@@ -644,8 +644,12 @@ static int _read_activation_params(struct lvcreate_params *lp, struct cmd_contex
lp->permission = arg_uint_value(cmd, permission_ARG,
LVM_READ | LVM_WRITE);
- /* Must not zero/wipe read only volume */
- if (!(lp->permission & LVM_WRITE)) {
+ if (lp->snapshot) {
+ /* Snapshot has to zero COW header */
+ lp->zero = 1;
+ lp->wipe_signatures = 0;
+ } else if (!(lp->permission & LVM_WRITE)) {
+ /* Must not zero/wipe read only volume */
lp->zero = 0;
lp->wipe_signatures = 0;
}
--
1.9.0
|