[arch-commits] Commit in lvm2/trunk (4 files)

Thomas Bächler thomas at nymeria.archlinux.org
Wed Feb 26 22:37:42 UTC 2014


    Date: Wednesday, February 26, 2014 @ 23:37:42
  Author: thomas
Revision: 206458

upgpkg: lvm2 2.02.105-2: Fix FS#38710 and FS#38729

Added:
  lvm2/trunk/0001-wiping-wipe-DM_snapshot_cow-signature-without-prompt.patch
  lvm2/trunk/0002-snapshot-zero-cow-header-for-read-only-snapshot.patch
Modified:
  lvm2/trunk/PKGBUILD
  lvm2/trunk/sd-lvm2

-----------------------------------------------------------------+
 0001-wiping-wipe-DM_snapshot_cow-signature-without-prompt.patch |  199 ++++++++++
 0002-snapshot-zero-cow-header-for-read-only-snapshot.patch      |   74 +++
 PKGBUILD                                                        |   19 
 sd-lvm2                                                         |    2 
 4 files changed, 287 insertions(+), 7 deletions(-)

Added: 0001-wiping-wipe-DM_snapshot_cow-signature-without-prompt.patch
===================================================================
--- 0001-wiping-wipe-DM_snapshot_cow-signature-without-prompt.patch	                        (rev 0)
+++ 0001-wiping-wipe-DM_snapshot_cow-signature-without-prompt.patch	2014-02-26 22:37:42 UTC (rev 206458)
@@ -0,0 +1,199 @@
+From a29d36c9ac41aa3aa4818c277c9c0e20cbd6175b Mon Sep 17 00:00:00 2001
+From: Peter Rajnoha <prajnoha at redhat.com>
+Date: Mon, 10 Feb 2014 13:28:13 +0100
+Subject: [PATCH 1/2] wiping: wipe DM_snapshot_cow signature without prompt in
+ newly created LVs
+MIME-Version: 1.0
+Content-Type: text/plain; charset=UTF-8
+Content-Transfer-Encoding: 8bit
+
+The libblkid can detect DM_snapshot_cow signature and when creating
+new LVs with blkid wiping used (allocation/use_blkid_wiping=1 lvm.conf
+setting and --wipe y used at the same time - which it is by default).
+
+Do not issue any prompts about this signature when new LV is created
+and just wipe it right away without asking questions. Still keep the
+log in verbose mode though.
+
+Conflicts:
+	WHATS_NEW
+	lib/device/dev-type.c
+
+[backported to 2.02.105 by Thomas Bächler, thomas at archlinux.org]
+---
+ WHATS_NEW               |  2 ++
+ lib/device/dev-type.c   | 47 ++++++++++++++++++++++++++++++++---------------
+ lib/device/dev-type.h   |  6 +++++-
+ lib/metadata/lv_manip.c |  4 +++-
+ lib/metadata/metadata.c |  4 +++-
+ 5 files changed, 45 insertions(+), 18 deletions(-)
+
+diff --git a/WHATS_NEW b/WHATS_NEW
+index 26b63ae..d2a3482 100644
+--- a/WHATS_NEW
++++ b/WHATS_NEW
+@@ -1,3 +1,5 @@
++  Wipe DM_snapshot_cow signature without prompt in new LVs with blkid wiping.
++
+ Version 2.02.105 - 20th January 2014
+ ====================================
+   Fix thin LV flagging for udev to skip scanning only if the LV is wiped.
+diff --git a/lib/device/dev-type.c b/lib/device/dev-type.c
+index 78b093c..d2ff71e 100644
+--- a/lib/device/dev-type.c
++++ b/lib/device/dev-type.c
+@@ -449,17 +449,25 @@ out:
+ 
+ #ifdef BLKID_WIPING_SUPPORT
+ 
++static inline int _type_in_flag_list(const char *type, uint32_t flag_list)
++{
++	return (((flag_list & TYPE_LVM2_MEMBER) && !strcmp(type, "LVM2_member")) ||
++		((flag_list & TYPE_LVM1_MEMBER) && !strcmp(type, "LVM1_member")) ||
++		((flag_list & TYPE_DM_SNAPSHOT_COW) && !strcmp(type, "DM_snapshot_cow")));
++}
++
+ static int _blkid_wipe(blkid_probe probe, struct device *dev, const char *name,
+-		       int exclude_lvm_member, int yes, force_t force)
++		       uint32_t types_to_exclude, uint32_t types_no_prompt,
++		       int yes, force_t force)
+ {
++	static const char* msg_wiping = "Wiping %s signature on %s.";
+ 	const char *offset = NULL, *type = NULL, *magic = NULL,
+ 		   *usage = NULL, *label = NULL, *uuid = NULL;
+ 	loff_t offset_value;
+ 	size_t len;
+ 
+ 	if (!blkid_probe_lookup_value(probe, "TYPE", &type, NULL)) {
+-		if (exclude_lvm_member &&
+-		    (!strcmp(type, "LVM1_member") || !strcmp(type, "LVM2_member")))
++		if (_type_in_flag_list(type, types_to_exclude))
+ 			return 1;
+ 		if (!blkid_probe_lookup_value(probe, "SBMAGIC_OFFSET", &offset, NULL) &&
+ 		     blkid_probe_lookup_value(probe, "SBMAGIC", &magic, &len))
+@@ -483,12 +491,15 @@ static int _blkid_wipe(blkid_probe probe, struct device *dev, const char *name,
+ 		    "UUID=\"%s\" TYPE=\"%s\" USAGE=\"%s\"",
+ 		     name, offset, label, uuid, type, usage);
+ 
+-	if (!yes && (force == PROMPT) &&
+-	    yes_no_prompt("WARNING: %s signature detected on %s at offset %s. "
+-			  "Wipe it? [y/n] ", type, name, offset) != 'y')
+-		return_0;
++	if (!_type_in_flag_list(type, types_no_prompt)) {
++		if (!yes && (force == PROMPT) &&
++		    yes_no_prompt("WARNING: %s signature detected on %s at offset %s. "
++				  "Wipe it? [y/n] ", type, name, offset) != 'y')
++			return_0;
++		log_print_unless_silent(msg_wiping, type, name);
++	} else
++		log_verbose(msg_wiping, type, name);
+ 
+-	log_print_unless_silent("Wiping %s signature on %s.", type, name);
+ 	if (!dev_set(dev, offset_value, len, 0)) {
+ 		log_error("Failed to wipe %s signature on %s.", type, name);
+ 		return 0;
+@@ -498,7 +509,8 @@ static int _blkid_wipe(blkid_probe probe, struct device *dev, const char *name,
+ }
+ 
+ static int _wipe_known_signatures_with_blkid(struct device *dev, const char *name,
+-					     int exclude_lvm_member,
++					     uint32_t types_to_exclude,
++					     uint32_t types_no_prompt,
+ 					     int yes, force_t force)
+ {
+ 	blkid_probe probe = NULL;
+@@ -526,7 +538,7 @@ static int _wipe_known_signatures_with_blkid(struct device *dev, const char *nam
+ 
+ 	while (!blkid_do_probe(probe)) {
+ 		found++;
+-		if (_blkid_wipe(probe, dev, name, exclude_lvm_member, yes, force))
++		if (_blkid_wipe(probe, dev, name, types_to_exclude, types_no_prompt, yes, force))
+ 			wiped++;
+ 	}
+ 
+@@ -580,7 +592,8 @@ static int _wipe_signature(struct device *dev, const char *type, const char *nam
+ }
+ 
+ static int _wipe_known_signatures_with_lvm(struct device *dev, const char *name,
+-					   int exclude_lvm_member,
++					   uint32_t types_to_exclude __attribute__((unused)),
++					   uint32_t types_no_prompt __attribute__((unused)),
+ 					   int yes, force_t force)
+ {
+ 	if (!_wipe_signature(dev, "software RAID md superblock", name, 4, yes, force, dev_is_md) ||
+@@ -592,16 +605,20 @@ static int _wipe_known_signatures_with_lvm(struct device *dev, const char *name,
+ }
+ 
+ int wipe_known_signatures(struct cmd_context *cmd, struct device *dev,
+-			  const char *name, int exclude_lvm_member,
+-			  int yes, force_t force)
++			  const char *name, uint32_t types_to_exclude,
++			  uint32_t types_no_prompt, int yes, force_t force)
+ {
+ #ifdef BLKID_WIPING_SUPPORT
+ 	if (find_config_tree_bool(cmd, allocation_use_blkid_wiping_CFG, NULL))
+ 		return _wipe_known_signatures_with_blkid(dev, name,
+-				exclude_lvm_member, yes, force);
++							 types_to_exclude,
++							 types_no_prompt,
++							 yes, force);
+ #endif
+ 	return _wipe_known_signatures_with_lvm(dev, name,
+-			exclude_lvm_member, yes, force);
++					       types_to_exclude,
++					       types_no_prompt,
++					       yes, force);
+ }
+ 
+ #ifdef __linux__
+diff --git a/lib/device/dev-type.h b/lib/device/dev-type.h
+index 284280e..b1520ee 100644
+--- a/lib/device/dev-type.h
++++ b/lib/device/dev-type.h
+@@ -60,8 +60,12 @@ int dev_is_swap(struct device *dev, uint64_t *signature);
+ int dev_is_luks(struct device *dev, uint64_t *signature);
+ 
+ /* Signature wiping. */
++#define TYPE_LVM1_MEMBER	0x001
++#define TYPE_LVM2_MEMBER	0x002
++#define TYPE_DM_SNAPSHOT_COW	0x004
+ int wipe_known_signatures(struct cmd_context *cmd, struct device *dev, const char *name,
+-			  int exclude_lvm_member, int yes, force_t force);
++			  uint32_t types_to_exclude, uint32_t types_no_prompt,
++			  int yes, force_t force);
+ 
+ /* Type-specific device properties */
+ unsigned long dev_md_stripe_width(struct dev_types *dt, struct device *dev);
+diff --git a/lib/metadata/lv_manip.c b/lib/metadata/lv_manip.c
+index f45c89f..66f3bd7 100644
+--- a/lib/metadata/lv_manip.c
++++ b/lib/metadata/lv_manip.c
+@@ -5448,7 +5448,9 @@ int wipe_lv(struct logical_volume *lv, struct wipe_params wp)
+ 	if (wp.do_wipe_signatures) {
+ 		log_verbose("Wiping known signatures on logical volume \"%s/%s\"",
+ 			     lv->vg->name, lv->name);
+-		if (!wipe_known_signatures(lv->vg->cmd, dev, name, 0, wp.yes, wp.force))
++		if (!wipe_known_signatures(lv->vg->cmd, dev, name, 0,
++					   TYPE_DM_SNAPSHOT_COW,
++					   wp.yes, wp.force))
+ 			stack;
+ 	}
+ 
+diff --git a/lib/metadata/metadata.c b/lib/metadata/metadata.c
+index 4d4778b..e4e1771 100644
+--- a/lib/metadata/metadata.c
++++ b/lib/metadata/metadata.c
+@@ -1372,7 +1372,9 @@ static int pvcreate_check(struct cmd_context *cmd, const char *name,
+ 		goto bad;
+ 	}
+ 
+-	if (!wipe_known_signatures(cmd, dev, name, 1, pp->yes, pp->force)) {
++	if (!wipe_known_signatures(cmd, dev, name,
++				   TYPE_LVM1_MEMBER | TYPE_LVM2_MEMBER,
++				   0, pp->yes, pp->force)) {
+ 		log_error("Aborting pvcreate on %s.", name);
+ 		goto bad;
+ 	}
+-- 
+1.9.0
+

Added: 0002-snapshot-zero-cow-header-for-read-only-snapshot.patch
===================================================================
--- 0002-snapshot-zero-cow-header-for-read-only-snapshot.patch	                        (rev 0)
+++ 0002-snapshot-zero-cow-header-for-read-only-snapshot.patch	2014-02-26 22:37:42 UTC (rev 206458)
@@ -0,0 +1,74 @@
+From d5c2c146ee050905a175b73dd3d0155f46d5cf81 Mon Sep 17 00:00:00 2001
+From: Zdenek Kabelac <zkabelac at 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 at 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
+

Modified: PKGBUILD
===================================================================
--- PKGBUILD	2014-02-26 20:10:01 UTC (rev 206457)
+++ PKGBUILD	2014-02-26 22:37:42 UTC (rev 206458)
@@ -5,7 +5,7 @@
 pkgbase=lvm2
 pkgname=('lvm2' 'device-mapper')
 pkgver=2.02.105
-pkgrel=1
+pkgrel=2
 arch=('i686' 'x86_64')
 url="http://sourceware.org/lvm2/"
 license=('GPL2' 'LGPL2.1')
@@ -21,12 +21,14 @@
         dmeventd.socket
         lvm-monitoring.service
         lvmetad.service
-        lvmetad.socket)
+        lvmetad.socket
+        0001-wiping-wipe-DM_snapshot_cow-signature-without-prompt.patch
+        0002-snapshot-zero-cow-header-for-read-only-snapshot.patch)
 sha1sums=('796163e766480cdc427cd443dc1336ae8e8e3bd7'
           'SKIP'
           '76e83966d1bc84f9a1e30bcaff84b8b8fefbca0f'
           'ff0fdf0a3005a41acd4b36865056109effc3474b'
-          '30777d42e31cb7fe1f4fadc1e8f4c4d4cdd8ffed'
+          'ab1719813fd7e5f5b525b7f38e969d1f855d6083'
           'f6a554eea9557c3c236df2943bb6e7e723945c41'
           'ccefad65fde3d50331a42b0e90a1539dc7c8b9e4'
           '01782ce8e10718c1513e3906b126f30f682f5cab'
@@ -33,12 +35,17 @@
           '1d56f47a81350ae37ffbf61ee036fe31f4c5d504'
           'aad90fce0e12eda41d38571d8eb27c5d5a8c59ec'
           'f857a4a63fcc604a981e56875edda91767d4f1bf'
-          'fcfc265e3b10294cc4b10949a342e9db4310b186')
+          'fcfc265e3b10294cc4b10949a342e9db4310b186'
+          '044d426c49919b5a86fd84228d1c7e1f3a86c59a'
+          '4f83555347e7c3596c53d9009f260c1d65639e6d')
 
 prepare() {
   cd LVM2.${pkgver}
   # enable lvmetad
   sed -i 's|use_lvmetad = 0|use_lvmetad = 1|' conf/example.conf.in
+
+  patch -p1 -i "${srcdir}"/0001-wiping-wipe-DM_snapshot_cow-signature-without-prompt.patch
+  patch -p1 -i "${srcdir}"/0002-snapshot-zero-cow-header-for-read-only-snapshot.patch
 }
 
 build() {
@@ -94,6 +101,6 @@
   install -D -m644 "${srcdir}/lvm-monitoring.service" "${pkgdir}/usr/lib/systemd/system/lvm-monitoring.service"
   install -D -m644 "${srcdir}/lvmetad.service" "${pkgdir}/usr/lib/systemd/system/lvmetad.service"
   install -D -m644 "${srcdir}/lvmetad.socket" "${pkgdir}/usr/lib/systemd/system/lvmetad.socket"
-  install -d -m755 "${pkgdir}/usr/lib/systemd/system/sockets.target.wants"
-  ln -sf /usr/lib/systemd/system/lvmetad.socket "${pkgdir}/usr/lib/systemd/system/sockets.target.wants/lvmetad.socket"
+  install -d -m755 "${pkgdir}/usr/lib/systemd/system/sysinit.target.wants"
+  ln -sf /usr/lib/systemd/system/lvmetad.socket "${pkgdir}/usr/lib/systemd/system/sysinit.target.wants/lvmetad.socket"
 }

Modified: sd-lvm2
===================================================================
--- sd-lvm2	2014-02-26 20:10:01 UTC (rev 206457)
+++ sd-lvm2	2014-02-26 22:37:42 UTC (rev 206458)
@@ -19,7 +19,7 @@
 
     add_file "/usr/lib/systemd/system/lvmetad.service"
     add_file "/usr/lib/systemd/system/lvmetad.socket"
-    add_symlink "/usr/lib/systemd/system/sockets.target.wants/lvmetad.socket"
+    add_symlink "/usr/lib/systemd/system/sysinit.target.wants/lvmetad.socket"
 }
 
 help() {




More information about the arch-commits mailing list