master - lvcreate: recognize --wipesignatures arg
by Peter Rajnoha
Gitweb: http://git.fedorahosted.org/git/?p=lvm2.git;a=commitdiff;h=169b4c15864330...
Commit: 169b4c15864330e3fe47efee7b0def06581b8f08
Parent: 5b7e543cae5be52e1dcd79c7f6876acc89138cf1
Author: Peter Rajnoha <prajnoha(a)redhat.com>
AuthorDate: Wed Nov 6 16:05:50 2013 +0100
Committer: Peter Rajnoha <prajnoha(a)redhat.com>
CommitterDate: Wed Nov 27 15:48:15 2013 +0100
lvcreate: recognize --wipesignatures arg
Recognize the new --wipesignatures arg in lvcreate that is supposed
to wipe known signatures if found on newly created LV.
---
WHATS_NEW | 1 +
lib/metadata/metadata-exported.h | 1 +
liblvm/lvm_lv.c | 1 +
tools/args.h | 1 +
tools/commands.h | 4 +++-
tools/lvcreate.c | 28 +++++++++++++++++++++++-----
6 files changed, 30 insertions(+), 6 deletions(-)
diff --git a/WHATS_NEW b/WHATS_NEW
index af489d6..b4d683d 100644
--- a/WHATS_NEW
+++ b/WHATS_NEW
@@ -1,5 +1,6 @@
Version 2.02.105 -
=====================================
+ Add -W/--wipesignatures lvcreate option to support wiping on new LVs.
Add allocation/wipe_signatures_on_new_logical_volumes_when_zeroing to lvm.conf.
Do not fail the whole autoactivation if the VG refresh done before fails.
Do not connect to lvmetad on vg/lvchange --sysinit -aay and socket absent.
diff --git a/lib/metadata/metadata-exported.h b/lib/metadata/metadata-exported.h
index 33c534f..69a0e90 100644
--- a/lib/metadata/metadata-exported.h
+++ b/lib/metadata/metadata-exported.h
@@ -723,6 +723,7 @@ struct lvcreate_params {
int thin; /* thin */
int create_thin_pool; /* thin */
int zero; /* all */
+ int wipe_signatures; /* all */
int major; /* all */
int minor; /* all */
int log_count; /* mirror */
diff --git a/liblvm/lvm_lv.c b/liblvm/lvm_lv.c
index 938a16b..f5c3ab9 100644
--- a/liblvm/lvm_lv.c
+++ b/liblvm/lvm_lv.c
@@ -129,6 +129,7 @@ static void _lv_set_default_params(struct lvcreate_params *lp,
uint64_t extents)
{
lp->zero = 1;
+ lp->wipe_signatures = 0;
lp->major = -1;
lp->minor = -1;
lp->activate = CHANGE_AY;
diff --git a/tools/args.h b/tools/args.h
index 27b97eb..8ca73a3 100644
--- a/tools/args.h
+++ b/tools/args.h
@@ -176,6 +176,7 @@ arg(uuidlist_ARG, 'U', "uuidlist", NULL, 0)
arg(verbose_ARG, 'v', "verbose", NULL, ARG_COUNTABLE)
arg(volumegroup_ARG, 'V', "volumegroup", NULL, 0)
arg(virtualsize_ARG, 'V', "virtualsize", size_mb_arg, 0)
+arg(wipesignatures_ARG, 'W', "wipesignatures", yes_no_arg, 0)
arg(allocatable_ARG, 'x', "allocatable", yes_no_arg, 0)
arg(resizeable_ARG, 'x', "resizeable", yes_no_arg, 0)
arg(yes_ARG, 'y', "yes", NULL, 0)
diff --git a/tools/commands.h b/tools/commands.h
index c299276..c54e812 100644
--- a/tools/commands.h
+++ b/tools/commands.h
@@ -248,6 +248,7 @@ xx(lvcreate,
"\t[-t|--test]\n"
"\t[--type VolumeType]\n"
"\t[-v|--verbose]\n"
+ "\t[-W|--wipesignatures {y|n}]\n"
"\t[-Z|--zero {y|n}]\n"
"\t[--version]\n"
"\tVolumeGroupName [PhysicalVolumePath...]\n\n"
@@ -294,7 +295,8 @@ xx(lvcreate,
raidminrecoveryrate_ARG, raidmaxrecoveryrate_ARG, readahead_ARG,
regionsize_ARG, setactivationskip_ARG, size_ARG, snapshot_ARG, stripes_ARG,
stripesize_ARG, test_ARG, thin_ARG, thinpool_ARG,
- type_ARG, virtualoriginsize_ARG, virtualsize_ARG, zero_ARG)
+ type_ARG, virtualoriginsize_ARG, virtualsize_ARG,
+ wipesignatures_ARG, zero_ARG)
xx(lvdisplay,
"Display information about a logical volume",
diff --git a/tools/lvcreate.c b/tools/lvcreate.c
index 4850872..83c12a7 100644
--- a/tools/lvcreate.c
+++ b/tools/lvcreate.c
@@ -614,8 +614,8 @@ static int _read_activation_params(struct lvcreate_params *lp, struct cmd_contex
return 0;
}
} else if (lp->activate == CHANGE_AAY) {
- if (arg_count(cmd, zero_ARG)) {
- log_error("-Z is incompatible with --activate a");
+ if (arg_count(cmd, zero_ARG) || arg_count(cmd, wipesignatures_ARG)) {
+ log_error("-Z and -W is incompatible with --activate a");
return 0;
}
lp->zero = 0;
@@ -644,9 +644,11 @@ 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 read only volume */
- if (!(lp->permission & LVM_WRITE))
+ /* Must not zero/wipe read only volume */
+ if (!(lp->permission & LVM_WRITE)) {
lp->zero = 0;
+ lp->wipe_signatures = 0;
+ }
if (arg_count(cmd, major_ARG) > 1) {
log_error("Option -j/--major may not be repeated.");
@@ -867,11 +869,27 @@ static int _lvcreate_params(struct lvcreate_params *lp,
}
/*
- * Should we zero the lv.
+ * Should we zero/wipe signatures on the lv.
*/
lp->zero = strcmp(arg_str_value(cmd, zero_ARG,
(lp->segtype->flags & SEG_CANNOT_BE_ZEROED) ? "n" : "y"), "n");
+ if (arg_count(cmd, wipesignatures_ARG)) {
+ /* If -W/--wipesignatures is given on command line directly, respect it. */
+ lp->wipe_signatures = strcmp(arg_str_value(cmd, wipesignatures_ARG,
+ (lp->segtype->flags & SEG_CANNOT_BE_ZEROED) ? "n" : "y"), "n");
+ } else {
+ /*
+ * If -W/--wipesignatures is not given on command line,
+ * look at the allocation/wipe_signatures_on_new_logical_volumes_when_zeroing
+ * to decide what should be done exactly.
+ */
+ if (find_config_tree_bool(cmd, allocation_wipe_signatures_on_new_logical_volumes_when_zeroing_CFG, NULL))
+ lp->wipe_signatures = lp->zero;
+ else
+ lp->wipe_signatures = 0;
+ }
+
if (!_lvcreate_name_params(lp, cmd, &argc, &argv) ||
!_read_size_params(lp, lcp, cmd) ||
!get_stripe_params(cmd, &lp->stripes, &lp->stripe_size) ||
10 years, 5 months
master - conf: add allocation/wipe_signatures_on_new_logical_volumes_when_zeroing
by Peter Rajnoha
Gitweb: http://git.fedorahosted.org/git/?p=lvm2.git;a=commitdiff;h=5b7e543cae5be5...
Commit: 5b7e543cae5be52e1dcd79c7f6876acc89138cf1
Parent: 03c941a4caf411f21045670e205ccdd975be27c7
Author: Peter Rajnoha <prajnoha(a)redhat.com>
AuthorDate: Wed Nov 27 12:54:48 2013 +0100
Committer: Peter Rajnoha <prajnoha(a)redhat.com>
CommitterDate: Wed Nov 27 15:48:06 2013 +0100
conf: add allocation/wipe_signatures_on_new_logical_volumes_when_zeroing
This setting controls whether signature wiping on newly created logical
volumes will follow the state of zeroing (-Z/--zero option).
---
WHATS_NEW | 1 +
conf/default.profile.in | 1 +
conf/example.conf.in | 9 +++++++++
lib/config/config_settings.h | 1 +
4 files changed, 12 insertions(+), 0 deletions(-)
diff --git a/WHATS_NEW b/WHATS_NEW
index 7718b6f..af489d6 100644
--- a/WHATS_NEW
+++ b/WHATS_NEW
@@ -1,5 +1,6 @@
Version 2.02.105 -
=====================================
+ Add allocation/wipe_signatures_on_new_logical_volumes_when_zeroing to lvm.conf.
Do not fail the whole autoactivation if the VG refresh done before fails.
Do not connect to lvmetad on vg/lvchange --sysinit -aay and socket absent.
Use lv_check_not_in_use() when testing device in use before merging.
diff --git a/conf/default.profile.in b/conf/default.profile.in
index 29049ef..5a481de 100644
--- a/conf/default.profile.in
+++ b/conf/default.profile.in
@@ -9,6 +9,7 @@
# Refer to 'man lvm.conf' for further information about profiles and file layout.
allocation {
+ wipe_signatures_on_new_logical_volumes_when_zeroing = 1
thin_pool_chunk_size_policy = "generic"
thin_pool_chunk_size = 64
thin_pool_discards = "passdown"
diff --git a/conf/example.conf.in b/conf/example.conf.in
index 03e1c45..0ac53ef 100644
--- a/conf/example.conf.in
+++ b/conf/example.conf.in
@@ -272,6 +272,15 @@ allocation {
# algorithm.
maximise_cling = 1
+ # Whether do wipe any signatures found on newly created Logical Volumes
+ # automatically in addition to zeroing of the first KB on the LV
+ # (-Z/--zero y option) when running the LVM command without specifying
+ # the -W/--wipesignatures option. If -W/--wipesignatures command line
+ # option is specified, it always takes precedence over this setting.
+ # Default is to wipe signatures when zeroing.
+ #
+ wipe_signatures_on_new_logical_volumes_when_zeroing = 1
+
# Set to 1 to guarantee that mirror logs will always be placed on
# different PVs from the mirror images. This was the default
# until version 2.02.85.
diff --git a/lib/config/config_settings.h b/lib/config/config_settings.h
index 7fdf763..7a7e8e5 100644
--- a/lib/config/config_settings.h
+++ b/lib/config/config_settings.h
@@ -104,6 +104,7 @@ cfg(devices_issue_discards_CFG, "issue_discards", devices_CFG_SECTION, 0, CFG_TY
cfg_array(allocation_cling_tag_list_CFG, "cling_tag_list", allocation_CFG_SECTION, 0, CFG_TYPE_STRING, NULL, vsn(2, 2, 77), NULL)
cfg(allocation_maximise_cling_CFG, "maximise_cling", allocation_CFG_SECTION, 0, CFG_TYPE_BOOL, DEFAULT_MAXIMISE_CLING, vsn(2, 2, 85), NULL)
+cfg(allocation_wipe_signatures_on_new_logical_volumes_when_zeroing_CFG, "wipe_signatures_on_new_logical_volumes_when_zeroing", allocation_CFG_SECTION, 0, CFG_TYPE_BOOL, 1, vsn(2, 2, 105), NULL)
cfg(allocation_mirror_logs_require_separate_pvs_CFG, "mirror_logs_require_separate_pvs", allocation_CFG_SECTION, 0, CFG_TYPE_BOOL, DEFAULT_MIRROR_LOGS_REQUIRE_SEPARATE_PVS, vsn(2, 2, 85), NULL)
cfg(allocation_thin_pool_metadata_require_separate_pvs_CFG, "thin_pool_metadata_require_separate_pvs", allocation_CFG_SECTION, 0, CFG_TYPE_BOOL, DEFAULT_THIN_POOL_METADATA_REQUIRE_SEPARATE_PVS, vsn(2, 2, 89), NULL)
cfg(allocation_thin_pool_zero_CFG, "thin_pool_zero", allocation_CFG_SECTION, CFG_PROFILABLE, CFG_TYPE_BOOL, DEFAULT_THIN_POOL_ZERO, vsn(2, 2, 99), NULL)
10 years, 5 months
master - device: cleanup signature wiping functions
by Peter Rajnoha
Gitweb: http://git.fedorahosted.org/git/?p=lvm2.git;a=commitdiff;h=03c941a4caf411...
Commit: 03c941a4caf411f21045670e205ccdd975be27c7
Parent: 120df5561088f4a5277716117339d9212b666214
Author: Peter Rajnoha <prajnoha(a)redhat.com>
AuthorDate: Wed Nov 6 15:09:29 2013 +0100
Committer: Peter Rajnoha <prajnoha(a)redhat.com>
CommitterDate: Wed Nov 27 12:56:58 2013 +0100
device: cleanup signature wiping functions
The wipe_known_signatures fn now wraps the _wipe_signature fn that is called
for each known signature (currently md, swap and luks). This patch makes the
code more readable, not repeating the same sequence when used anywhere in the
code. We're going to reuse this code later...
---
lib/device/dev-luks.c | 5 +++--
lib/device/dev-md.c | 6 +++---
lib/device/dev-swap.c | 7 +++----
lib/device/dev-type.c | 42 ++++++++++++++++++++++++++++++++++++++++++
lib/device/dev-type.h | 4 ++++
lib/metadata/metadata.c | 46 ++++------------------------------------------
6 files changed, 59 insertions(+), 51 deletions(-)
diff --git a/lib/device/dev-luks.c b/lib/device/dev-luks.c
index 2671d62..572fd1d 100644
--- a/lib/device/dev-luks.c
+++ b/lib/device/dev-luks.c
@@ -18,7 +18,7 @@
#define LUKS_SIGNATURE "LUKS\xba\xbe"
#define LUKS_SIGNATURE_SIZE 6
-int dev_is_luks(struct device *dev, uint64_t *signature)
+int dev_is_luks(struct device *dev, uint64_t *offset_found)
{
char buf[LUKS_SIGNATURE_SIZE];
int ret = -1;
@@ -28,7 +28,8 @@ int dev_is_luks(struct device *dev, uint64_t *signature)
return -1;
}
- *signature = 0;
+ if (offset_found)
+ *offset_found = 0;
if (!dev_read(dev, 0, LUKS_SIGNATURE_SIZE, buf))
goto_out;
diff --git a/lib/device/dev-md.c b/lib/device/dev-md.c
index 9af8074..d6a7609 100644
--- a/lib/device/dev-md.c
+++ b/lib/device/dev-md.c
@@ -81,7 +81,7 @@ static uint64_t _v1_sb_offset(uint64_t size, md_minor_version_t minor_version)
/*
* Returns -1 on error
*/
-int dev_is_md(struct device *dev, uint64_t *sb)
+int dev_is_md(struct device *dev, uint64_t *offset_found)
{
int ret = 1;
md_minor_version_t minor;
@@ -120,8 +120,8 @@ out:
if (!dev_close(dev))
stack;
- if (ret && sb)
- *sb = sb_offset;
+ if (ret && offset_found)
+ *offset_found = sb_offset;
return ret;
}
diff --git a/lib/device/dev-swap.c b/lib/device/dev-swap.c
index cc44008..f506eda 100644
--- a/lib/device/dev-swap.c
+++ b/lib/device/dev-swap.c
@@ -36,7 +36,7 @@ _swap_detect_signature(const char *buf)
return 0;
}
-int dev_is_swap(struct device *dev, uint64_t *signature)
+int dev_is_swap(struct device *dev, uint64_t *offset_found)
{
char buf[10];
uint64_t size;
@@ -53,8 +53,6 @@ int dev_is_swap(struct device *dev, uint64_t *signature)
return -1;
}
- *signature = 0;
-
for (page = 0x1000; page <= MAX_PAGESIZE; page <<= 1) {
/*
* skip 32k pagesize since this does not seem to be supported
@@ -69,7 +67,8 @@ int dev_is_swap(struct device *dev, uint64_t *signature)
break;
}
if (_swap_detect_signature(buf)) {
- *signature = page - SIGNATURE_SIZE;
+ if (offset_found)
+ *offset_found = page - SIGNATURE_SIZE;
ret = 1;
break;
}
diff --git a/lib/device/dev-type.c b/lib/device/dev-type.c
index f3f29b2..e42349d 100644
--- a/lib/device/dev-type.c
+++ b/lib/device/dev-type.c
@@ -443,6 +443,48 @@ out:
return ret;
}
+static int _wipe_signature(struct device *dev, const char *type, const char *name,
+ int wipe_len, int yes, force_t force,
+ int (*signature_detection_fn)(struct device *dev, uint64_t *offset_found))
+{
+ int wipe;
+ uint64_t offset_found;
+
+ wipe = signature_detection_fn(dev, &offset_found);
+ if (wipe == -1) {
+ log_error("Fatal error while trying to detect %s on %s.",
+ type, name);
+ return 0;
+ }
+
+ if (wipe == 0)
+ return 1;
+
+ /* Specifying --yes => do not ask. */
+ if (!yes && (force == PROMPT) &&
+ yes_no_prompt("WARNING: %s detected on %s. Wipe it? [y/n] ",
+ type, name) != 'y')
+ return_0;
+
+ log_print_unless_silent("Wiping %s on %s.", type, name);
+ if (!dev_set(dev, offset_found, wipe_len, 0)) {
+ log_error("Failed to wipe %s on %s.", type, name);
+ return 0;
+ }
+
+ return 1;
+}
+
+int wipe_known_signatures(struct device *dev, const char *name, int yes, force_t force)
+{
+ if (!_wipe_signature(dev, "software RAID md superblock", name, 4, yes, force, dev_is_md) ||
+ !_wipe_signature(dev, "swap signature", name, 10, yes, force, dev_is_swap) ||
+ !_wipe_signature(dev, "LUKS signature", name, 8, yes, force, dev_is_luks))
+ return 0;
+
+ return 1;
+}
+
#ifdef __linux__
static int _snprintf_attr(char *buf, size_t buf_size, const char *sysfs_dir,
diff --git a/lib/device/dev-type.h b/lib/device/dev-type.h
index 2fa32db..895a172 100644
--- a/lib/device/dev-type.h
+++ b/lib/device/dev-type.h
@@ -16,6 +16,7 @@
#define _LVM_DEV_TYPE_H
#include "device.h"
+#include "display.h"
#define NUMBER_OF_MAJORS 4096
@@ -58,6 +59,9 @@ int dev_is_md(struct device *dev, uint64_t *sb);
int dev_is_swap(struct device *dev, uint64_t *signature);
int dev_is_luks(struct device *dev, uint64_t *signature);
+/* Signature wiping. */
+int wipe_known_signatures(struct device *dev, const char *name, 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/metadata.c b/lib/metadata/metadata.c
index c71ec30..f0230f1 100644
--- a/lib/metadata/metadata.c
+++ b/lib/metadata/metadata.c
@@ -1268,40 +1268,6 @@ int vg_split_mdas(struct cmd_context *cmd __attribute__((unused)),
return 1;
}
-static int _wipe_sb(struct device *dev, const char *type, const char *name,
- int wipe_len, struct pvcreate_params *pp,
- int (*func)(struct device *dev, uint64_t *signature))
-{
- int wipe;
- uint64_t superblock;
-
- wipe = func(dev, &superblock);
- if (wipe == -1) {
- log_error("Fatal error while trying to detect %s on %s.",
- type, name);
- return 0;
- }
-
- if (wipe == 0)
- return 1;
-
- /* Specifying --yes => do not ask. */
- if (!pp->yes && (pp->force == PROMPT) &&
- yes_no_prompt("WARNING: %s detected on %s. Wipe it? [y/n] ",
- type, name) != 'y') {
- log_error("Aborting pvcreate on %s.", name);
- return 0;
- }
-
- log_print_unless_silent("Wiping %s on %s.", type, name);
- if (!dev_set(dev, superblock, wipe_len, 0)) {
- log_error("Failed to wipe %s on %s.", type, name);
- return 0;
- }
-
- return 1;
-}
-
/*
* See if we may pvcreate on this device.
* 0 indicates we may not.
@@ -1364,14 +1330,10 @@ static int pvcreate_check(struct cmd_context *cmd, const char *name,
goto bad;
}
- if (!_wipe_sb(dev, "software RAID md superblock", name, 4, pp, dev_is_md))
- goto_bad;
-
- if (!_wipe_sb(dev, "swap signature", name, 10, pp, dev_is_swap))
- goto_bad;
-
- if (!_wipe_sb(dev, "LUKS signature", name, 8, pp, dev_is_luks))
- goto_bad;
+ if (!wipe_known_signatures(dev, name, pp->yes, pp->force)) {
+ log_error("Aborting pvcreate on %s.", name);
+ goto bad;
+ }
if (sigint_caught())
goto_bad;
10 years, 5 months
master - activation: change log_error to log_warn if refresh before autoactivation fails
by Peter Rajnoha
Gitweb: http://git.fedorahosted.org/git/?p=lvm2.git;a=commitdiff;h=120df5561088f4...
Commit: 120df5561088f4a5277716117339d9212b666214
Parent: d6e67b850365864bba91619a40503ff0b0392e2c
Author: Peter Rajnoha <prajnoha(a)redhat.com>
AuthorDate: Wed Nov 27 08:53:26 2013 +0100
Committer: Peter Rajnoha <prajnoha(a)redhat.com>
CommitterDate: Wed Nov 27 08:53:26 2013 +0100
activation: change log_error to log_warn if refresh before autoactivation fails
---
tools/pvscan.c | 2 +-
1 files changed, 1 insertions(+), 1 deletions(-)
diff --git a/tools/pvscan.c b/tools/pvscan.c
index 981a9c2..4f99f45 100644
--- a/tools/pvscan.c
+++ b/tools/pvscan.c
@@ -148,7 +148,7 @@ static int _auto_activation_handler(struct cmd_context *cmd,
}
if (!refresh_done)
- log_error("%s: refresh before autoactivation failed.", vg->name);
+ log_warn("%s: refresh before autoactivation failed.", vg->name);
if (!vgchange_activate(vg->cmd, vg, activate)) {
log_error("%s: autoactivation failed.", vg->name);
10 years, 5 months
master - WHATS_NEW: commit 729b104
by Peter Rajnoha
Gitweb: http://git.fedorahosted.org/git/?p=lvm2.git;a=commitdiff;h=d6e67b85036586...
Commit: d6e67b850365864bba91619a40503ff0b0392e2c
Parent: 729b104413e11412866a549ef8a6702f56c4acd1
Author: Peter Rajnoha <prajnoha(a)redhat.com>
AuthorDate: Wed Nov 27 08:33:02 2013 +0100
Committer: Peter Rajnoha <prajnoha(a)redhat.com>
CommitterDate: Wed Nov 27 08:33:02 2013 +0100
WHATS_NEW: commit 729b104
---
WHATS_NEW | 1 +
1 files changed, 1 insertions(+), 0 deletions(-)
diff --git a/WHATS_NEW b/WHATS_NEW
index 4148754..7718b6f 100644
--- a/WHATS_NEW
+++ b/WHATS_NEW
@@ -1,5 +1,6 @@
Version 2.02.105 -
=====================================
+ Do not fail the whole autoactivation if the VG refresh done before fails.
Do not connect to lvmetad on vg/lvchange --sysinit -aay and socket absent.
Use lv_check_not_in_use() when testing device in use before merging.
Move test for target present from init_snapshot_merge() to lvconvert.
10 years, 5 months
master - activation: continue with autoactivation if refresh fails
by Peter Rajnoha
Gitweb: http://git.fedorahosted.org/git/?p=lvm2.git;a=commitdiff;h=729b104413e114...
Commit: 729b104413e11412866a549ef8a6702f56c4acd1
Parent: 8d5cff5b9bb217942c009dca49d0bffb51e85004
Author: Peter Rajnoha <prajnoha(a)redhat.com>
AuthorDate: Wed Nov 27 08:20:02 2013 +0100
Committer: Peter Rajnoha <prajnoha(a)redhat.com>
CommitterDate: Wed Nov 27 08:20:02 2013 +0100
activation: continue with autoactivation if refresh fails
If the refresh fails for any reason before autoactivation, let's not
make this a stopper for autoactivation itself - just log the error
message if it appears.
The reason is that in some rare situations, we can still hit the
problem with the suspend call to fail (as already described in
commit d8085edf65006a50608edb821b3d30947abaa838, also
https://bugzilla.redhat.com/show_bug.cgi?id=1027314). The refresh
itself is done for only one reason - to refresh any dm tables
for LVs for which the underlying PVs got unplugged/disconnected
and then plugged/connected back (see also
https://bugzilla.redhat.com/show_bug.cgi?id=954061 for more info).
In this case, the major:minor pair is changed and we need to
update dm tables for LVs accordingly.
Now if refresh fails, the error is still logged, but autoactivation
continues.
---
tools/pvscan.c | 4 +---
1 files changed, 1 insertions(+), 3 deletions(-)
diff --git a/tools/pvscan.c b/tools/pvscan.c
index ce8c446..981a9c2 100644
--- a/tools/pvscan.c
+++ b/tools/pvscan.c
@@ -147,10 +147,8 @@ static int _auto_activation_handler(struct cmd_context *cmd,
usleep(REFRESH_BEFORE_AUTOACTIVATION_RETRY_USLEEP_DELAY);
}
- if (!refresh_done) {
+ if (!refresh_done)
log_error("%s: refresh before autoactivation failed.", vg->name);
- goto out;
- }
if (!vgchange_activate(vg->cmd, vg, activate)) {
log_error("%s: autoactivation failed.", vg->name);
10 years, 5 months
master - lv/vgchange: do not try to connect to lvmetad if socket absent and --sysinit -aay used
by Peter Rajnoha
Gitweb: http://git.fedorahosted.org/git/?p=lvm2.git;a=commitdiff;h=8d5cff5b9bb217...
Commit: 8d5cff5b9bb217942c009dca49d0bffb51e85004
Parent: 47110f7e27ce2a4bf329e860cf6eb339d107fde7
Author: Peter Rajnoha <prajnoha(a)redhat.com>
AuthorDate: Tue Nov 26 14:51:23 2013 +0100
Committer: Peter Rajnoha <prajnoha(a)redhat.com>
CommitterDate: Tue Nov 26 14:51:23 2013 +0100
lv/vgchange: do not try to connect to lvmetad if socket absent and --sysinit -aay used
If using lv/vgchange --sysinit -aay and lvmetad is enabled, we'd like to
avoid the direct activation and rely on autoactivation instead so
it fits system initialization scripts.
But if we're calling lv/vgchange --sysinit -aay too early when even
lvmetad service is not started yet, we just need to do the direct
activation instead without printing any error messages (while
trying to connect to lvmetad and not finding its socket).
This patch adds two helper functions - "lvmetad_socket_present" and
"lvmetad_used" which can be used to check for this condition properly
and avoid these lvmetad connections when the socket is not present
(and hence lvmetad is not yet running).
---
WHATS_NEW | 1 +
daemons/lvmetad/lvmetad-client.h | 4 +++-
daemons/lvmetad/lvmetad-core.c | 4 +++-
lib/cache/lvmetad.c | 16 ++++++++++++++++
lib/cache/lvmetad.h | 15 +++++++++++++++
tools/lvchange.c | 30 ++++++++++++++++++++++++++----
tools/vgchange.c | 30 ++++++++++++++++++++++++++----
7 files changed, 90 insertions(+), 10 deletions(-)
diff --git a/WHATS_NEW b/WHATS_NEW
index 9b18ef0..4148754 100644
--- a/WHATS_NEW
+++ b/WHATS_NEW
@@ -1,5 +1,6 @@
Version 2.02.105 -
=====================================
+ Do not connect to lvmetad on vg/lvchange --sysinit -aay and socket absent.
Use lv_check_not_in_use() when testing device in use before merging.
Move test for target present from init_snapshot_merge() to lvconvert.
Check for failure of lvmcache_add_mda() when writing pv.
diff --git a/daemons/lvmetad/lvmetad-client.h b/daemons/lvmetad/lvmetad-client.h
index fe8eedc..8d6ae0e 100644
--- a/daemons/lvmetad/lvmetad-client.h
+++ b/daemons/lvmetad/lvmetad-client.h
@@ -17,6 +17,8 @@
#include "daemon-client.h"
+#define LVMETAD_SOCKET DEFAULT_RUN_DIR "/lvmetad.socket"
+
struct volume_group;
/* Different types of replies we may get from lvmetad. */
@@ -64,7 +66,7 @@ static inline daemon_handle lvmetad_open(const char *socket)
{
daemon_info lvmetad_info = {
.path = "lvmetad",
- .socket = socket ?: DEFAULT_RUN_DIR "/lvmetad.socket",
+ .socket = socket ?: LVMETAD_SOCKET,
.protocol = "lvmetad",
.protocol_version = 1,
.autostart = 0
diff --git a/daemons/lvmetad/lvmetad-core.c b/daemons/lvmetad/lvmetad-core.c
index 03d89c9..87374e8 100644
--- a/daemons/lvmetad/lvmetad-core.c
+++ b/daemons/lvmetad/lvmetad-core.c
@@ -29,6 +29,8 @@
#include <math.h> /* fabs() */
#include <float.h> /* DBL_EPSILON */
+#define LVMETAD_SOCKET DEFAULT_RUN_DIR "/lvmetad.socket"
+
typedef struct {
log_state *log; /* convenience */
const char *log_config;
@@ -1209,7 +1211,7 @@ int main(int argc, char *argv[])
if (!s.socket_path) {
_socket_override = 0;
- s.socket_path = DEFAULT_RUN_DIR "/lvmetad.socket";
+ s.socket_path = LVMETAD_SOCKET;
}
ls.log_config = "";
diff --git a/lib/cache/lvmetad.c b/lib/cache/lvmetad.c
index 5119ab1..1ead9f8 100644
--- a/lib/cache/lvmetad.c
+++ b/lib/cache/lvmetad.c
@@ -72,6 +72,22 @@ void lvmetad_connect_or_warn(void)
strerror(_lvmetad.error));
}
+int lvmetad_used(void)
+{
+ return _lvmetad_use;
+}
+
+int lvmetad_socket_present(void)
+{
+ const char *socket = _lvmetad_socket ?: LVMETAD_SOCKET;
+ int r;
+
+ if ((r = access(socket, F_OK)) && errno != ENOENT)
+ log_sys_error("lvmetad_socket_present", "");
+
+ return !r;
+}
+
int lvmetad_active(void)
{
if (!_lvmetad_use)
diff --git a/lib/cache/lvmetad.h b/lib/cache/lvmetad.h
index ff4cd0a..85b71c2 100644
--- a/lib/cache/lvmetad.h
+++ b/lib/cache/lvmetad.h
@@ -44,6 +44,19 @@ void lvmetad_set_active(int);
void lvmetad_set_socket(const char *);
/*
+ * Check whether lvmetad is used.
+ */
+int lvmetad_used(void);
+
+/*
+ * Check if lvmetad socket is present (either the one set by lvmetad_set_socket
+ * or the default one if not set). For example, this may be used before calling
+ * lvmetad_active() check that does connect to the socket - this would produce
+ * various connection errors if the socket is not present.
+ */
+int lvmetad_socket_present(void);
+
+/*
* Check whether lvmetad is active (where active means both that it is running
* and that we have a working connection with it).
*/
@@ -149,6 +162,8 @@ int lvmetad_pvscan_all_devs(struct cmd_context *cmd, activation_handler handler)
# define lvmetad_disconnect() do { } while (0)
# define lvmetad_set_active(a) do { } while (0)
# define lvmetad_set_socket(a) do { } while (0)
+# define lvmetad_used() (0)
+# define lvmetad_socket_present() (0)
# define lvmetad_active() (0)
# define lvmetad_connect_or_warn() do { } while (0)
# define lvmetad_set_token(a) do { } while (0)
diff --git a/tools/lvchange.c b/tools/lvchange.c
index 1931c03..897ffb2 100644
--- a/tools/lvchange.c
+++ b/tools/lvchange.c
@@ -1235,11 +1235,33 @@ int lvchange(struct cmd_context *cmd, int argc, char **argv)
return EINVALID_CMD_LINE;
}
- if (arg_count(cmd, sysinit_ARG) && lvmetad_active() &&
+ /*
+ * If --sysinit -aay is used and at the same time lvmetad is used,
+ * we want to rely on autoactivation to take place. Also, we
+ * need to take special care here as lvmetad service does
+ * not neet to be running at this moment yet - it could be
+ * just too early during system initialization time.
+ */
+ if (arg_count(cmd, sysinit_ARG) && lvmetad_used() &&
arg_uint_value(cmd, activate_ARG, 0) == CHANGE_AAY) {
- log_warn("lvmetad is active while using --sysinit -a ay, "
- "skipping manual activation");
- return ECMD_PROCESSED;
+ if (!lvmetad_socket_present()) {
+ /*
+ * If lvmetad socket is not present yet,
+ * the service is just not started. It'll
+ * be started a bit later so we need to do
+ * the activation without lvmetad which means
+ * direct activation instead of autoactivation.
+ */
+ log_warn("lvmetad is not active yet, using direct activation during sysinit");
+ lvmetad_set_active(0);
+ } else if (lvmetad_active()) {
+ /*
+ * If lvmetad is active already, we want
+ * to make use of the autoactivation.
+ */
+ log_warn("lvmetad is active, skipping direct activation during sysinit");
+ return ECMD_PROCESSED;
+ }
}
return process_each_lv(cmd, argc, argv,
diff --git a/tools/vgchange.c b/tools/vgchange.c
index 4087fab..b50b444 100644
--- a/tools/vgchange.c
+++ b/tools/vgchange.c
@@ -616,11 +616,33 @@ int vgchange(struct cmd_context *cmd, int argc, char **argv)
return EINVALID_CMD_LINE;
}
- if (arg_count(cmd, sysinit_ARG) && lvmetad_active() &&
+ /*
+ * If --sysinit -aay is used and at the same time lvmetad is used,
+ * we want to rely on autoactivation to take place. Also, we
+ * need to take special care here as lvmetad service does
+ * not neet to be running at this moment yet - it could be
+ * just too early during system initialization time.
+ */
+ if (arg_count(cmd, sysinit_ARG) && lvmetad_used() &&
arg_uint_value(cmd, activate_ARG, 0) == CHANGE_AAY) {
- log_warn("lvmetad is active while using --sysinit -a ay, "
- "skipping manual activation");
- return ECMD_PROCESSED;
+ if (!lvmetad_socket_present()) {
+ /*
+ * If lvmetad socket is not present yet,
+ * the service is just not started. It'll
+ * be started a bit later so we need to do
+ * the activation without lvmetad which means
+ * direct activation instead of autoactivation.
+ */
+ log_warn("lvmetad is not active yet, using direct activation during sysinit");
+ lvmetad_set_active(0);
+ } else if (lvmetad_active()) {
+ /*
+ * If lvmetad is active already, we want
+ * to make use of the autoactivation.
+ */
+ log_warn("lvmetad is active, skipping direct activation during sysinit");
+ return ECMD_PROCESSED;
+ }
}
if (arg_count(cmd, clustered_ARG) && !argc && !arg_count(cmd, yes_ARG) &&
10 years, 5 months
master - tests: add WARNED test to final list
by Zdenek Kabelac
Gitweb: http://git.fedorahosted.org/git/?p=lvm2.git;a=commitdiff;h=47110f7e27ce2a...
Commit: 47110f7e27ce2a4bf329e860cf6eb339d107fde7
Parent: b8f72c0f2c41fa76bdd3f4c0d73cf31dc9ce9b88
Author: Zdenek Kabelac <zkabelac(a)redhat.com>
AuthorDate: Thu Nov 21 10:41:08 2013 +0100
Committer: Zdenek Kabelac <zkabelac(a)redhat.com>
CommitterDate: Fri Nov 22 21:00:56 2013 +0100
tests: add WARNED test to final list
WARNED result should not be forgotten - it's supposed
to be fixed...
keep enum alphabetically sorted
---
test/lib/harness.c | 25 ++++++++++++++-----------
1 files changed, 14 insertions(+), 11 deletions(-)
diff --git a/test/lib/harness.c b/test/lib/harness.c
index 8c9f4a7..dca0198 100644
--- a/test/lib/harness.c
+++ b/test/lib/harness.c
@@ -65,13 +65,13 @@ static struct subst subst[2];
enum {
UNKNOWN,
- PASSED,
- SKIPPED,
FAILED,
- WARNED,
- KNOWNFAIL,
INTERRUPTED,
+ KNOWNFAIL,
+ PASSED,
+ SKIPPED,
TIMEOUT,
+ WARNED,
};
static void handler( int sig ) {
@@ -511,12 +511,12 @@ int main(int argc, char **argv) {
if ((list = fopen(results_list, "w"))) {
for (i = 1; i < argc; ++ i) {
switch (s.status[i]) {
- case PASSED: result = "passed"; break;
case FAILED: result = "failed"; break;
+ case INTERRUPTED: result = "interrupted"; break;
+ case PASSED: result = "passed"; break;
case SKIPPED: result = "skipped"; break;
- case WARNED: result = "warnings"; break;
case TIMEOUT: result = "timeout"; break;
- case INTERRUPTED: result = "interrupted"; break;
+ case WARNED: result = "warnings"; break;
default: result = "unknown"; break;
}
fprintf(list, "%s %s\n", argv[i], result);
@@ -526,24 +526,27 @@ int main(int argc, char **argv) {
perror("fopen result");
/* print out a summary */
- if (s.nfailed || s.nskipped || s.nknownfail || s.ninterrupted) {
+ if (s.nfailed || s.nskipped || s.nknownfail || s.ninterrupted || s.nwarned) {
for (i = 1; i < argc; ++ i) {
switch (s.status[i]) {
case FAILED:
printf("FAILED: %s\n", argv[i]);
break;
+ case INTERRUPTED:
+ printf("INTERRUPTED: %s\n", argv[i]);
+ break;
case KNOWNFAIL:
printf("FAILED (expected): %s\n", argv[i]);
break;
case SKIPPED:
printf("skipped: %s\n", argv[i]);
break;
- case INTERRUPTED:
- printf("INTERRUPTED: %s\n", argv[i]);
- break;
case TIMEOUT:
printf("TIMEOUT: %s\n", argv[i]);
break;
+ case WARNED:
+ printf("WARNED: %s\n", argv[i]);
+ break;
default: /* do nothing */ ;
}
}
10 years, 5 months
master - cleanup: use const format
by Zdenek Kabelac
Gitweb: http://git.fedorahosted.org/git/?p=lvm2.git;a=commitdiff;h=b8f72c0f2c41fa...
Commit: b8f72c0f2c41fa76bdd3f4c0d73cf31dc9ce9b88
Parent: 62db5c1e48467ef846432652dd1058eb85c0bcbd
Author: Zdenek Kabelac <zkabelac(a)redhat.com>
AuthorDate: Fri Nov 22 20:43:30 2013 +0100
Committer: Zdenek Kabelac <zkabelac(a)redhat.com>
CommitterDate: Fri Nov 22 21:00:56 2013 +0100
cleanup: use const format
---
lib/label/label.h | 2 +-
1 files changed, 1 insertions(+), 1 deletions(-)
diff --git a/lib/label/label.h b/lib/label/label.h
index 103e799..253e1e8 100644
--- a/lib/label/label.h
+++ b/lib/label/label.h
@@ -88,7 +88,7 @@ struct label_ops {
struct labeller {
struct label_ops *ops;
- struct format_type *fmt;
+ const struct format_type *fmt;
};
int label_init(void);
10 years, 5 months
master - cleanup: make gcc happier with initializers
by Zdenek Kabelac
Gitweb: http://git.fedorahosted.org/git/?p=lvm2.git;a=commitdiff;h=62db5c1e48467e...
Commit: 62db5c1e48467ef846432652dd1058eb85c0bcbd
Parent: 6ebbf1982892a819dc14045a8dca0ad512cebdf8
Author: Zdenek Kabelac <zkabelac(a)redhat.com>
AuthorDate: Fri Nov 22 20:42:03 2013 +0100
Committer: Zdenek Kabelac <zkabelac(a)redhat.com>
CommitterDate: Fri Nov 22 21:00:56 2013 +0100
cleanup: make gcc happier with initializers
Whole struct will be set to 0, just
if the first member is array, gcc gives warning
we should initialized this element as array,
so pick any later simple type.
---
tools/reporter.c | 4 ++--
1 files changed, 2 insertions(+), 2 deletions(-)
diff --git a/tools/reporter.c b/tools/reporter.c
index dccd785..bf181e7 100644
--- a/tools/reporter.c
+++ b/tools/reporter.c
@@ -141,8 +141,8 @@ static int _pvs_single(struct cmd_context *cmd, struct volume_group *vg,
struct volume_group *old_vg = vg;
char uuid[64] __attribute__((aligned(8)));
struct label *label;
- struct label _dummy_label = { 0 };
- struct device _dummy_device = { 0 };
+ struct label _dummy_label = { .dev = 0 };
+ struct device _dummy_device = { .dev = 0 };
if (is_pv(pv) && !is_orphan(pv) && !vg) {
vg_name = pv_vg_name(pv);
10 years, 5 months