master - cmirrord: Prevent secondary checkpoints from corrupting bitmaps
by Jonathan Brassow
Gitweb: http://git.fedorahosted.org/git/?p=lvm2.git;a=commitdiff;h=f0be9ac9047a30...
Commit: f0be9ac9047a30bb2befe6a8d9130f466d37d9fd
Parent: 99fd710cfd8beb88eb860e16007209d0acb1c440
Author: Jonathan Brassow <jbrassow(a)redhat.com>
AuthorDate: Tue Aug 20 13:21:09 2013 -0500
Committer: Jonathan Brassow <jbrassow(a)redhat.com>
CommitterDate: Tue Aug 20 13:21:09 2013 -0500
cmirrord: Prevent secondary checkpoints from corrupting bitmaps
The bug addressed by this patch manifested itself during testing
by showing a mirror that never became 'in-sync' after creation.
The bug is isolated to distributions that do not have support
for openAIS checkpointing (i.e. > RHEL6, > F16).
When a node joins a group that is managing a mirror log, the other
machines in the group send it a checkpoint representing the current
state of the bitmap. More than one machine can send a checkpoint,
but only the initial one should be imported. Once the bitmap state
has been imported from the initial checkpoint, operations (such
as resync, mark, and clear operations) can begin. When subsequent
checkpoints are allowed to be imported, it has the effect of erasing
all the log operations between the initial checkpoint and the ones
that follow.
When cmirrord was updated to handle the absence of openAIS
checkpointing (commit 62e38da133d9801cdf36b0f2aaec615ce14b9000),
the new import_checkpoint() function failed to honor the 'no_read'
parameter. This parameter was designed to avoid reading all but
the initial checkpoint. Honoring this parameter has solved the
issue of corrupting bitmap data with secondary checkpoints.
---
WHATS_NEW | 1 +
daemons/cmirrord/cluster.c | 43 +++++++++++++++++++++++++++++++++++++++++--
2 files changed, 42 insertions(+), 2 deletions(-)
diff --git a/WHATS_NEW b/WHATS_NEW
index 3cf3e47..0d58e66 100644
--- a/WHATS_NEW
+++ b/WHATS_NEW
@@ -1,5 +1,6 @@
Version 2.02.101 -
===================================
+ Prevent cluster mirror logs from being corrupted by redundant checkpoints.
Fix ignored lvmetad update on loop device configuration (2.02.99).
Use LVM_PATH instead of hardcoded value in lvm2 activation systemd generator.
Refresh existing VG before autoactivation (event retrigger/device reappeared).
diff --git a/daemons/cmirrord/cluster.c b/daemons/cmirrord/cluster.c
index f19b2a9..fea739a 100644
--- a/daemons/cmirrord/cluster.c
+++ b/daemons/cmirrord/cluster.c
@@ -25,7 +25,6 @@
#if CMIRROR_HAS_CHECKPOINT
#include <openais/saAis.h>
#include <openais/saCkpt.h>
-#endif
/* Open AIS error codes */
#define str_ais_error(x) \
@@ -57,6 +56,40 @@
((x) == SA_AIS_ERR_TOO_BIG) ? "SA_AIS_ERR_TOO_BIG" : \
((x) == SA_AIS_ERR_NO_SECTIONS) ? "SA_AIS_ERR_NO_SECTIONS" : \
"ais_error_unknown"
+#else
+#define str_ais_error(x) \
+ ((x) == CS_OK) ? "CS_OK" : \
+ ((x) == CS_ERR_LIBRARY) ? "CS_ERR_LIBRARY" : \
+ ((x) == CS_ERR_VERSION) ? "CS_ERR_VERSION" : \
+ ((x) == CS_ERR_INIT) ? "CS_ERR_INIT" : \
+ ((x) == CS_ERR_TIMEOUT) ? "CS_ERR_TIMEOUT" : \
+ ((x) == CS_ERR_TRY_AGAIN) ? "CS_ERR_TRY_AGAIN" : \
+ ((x) == CS_ERR_INVALID_PARAM) ? "CS_ERR_INVALID_PARAM" : \
+ ((x) == CS_ERR_NO_MEMORY) ? "CS_ERR_NO_MEMORY" : \
+ ((x) == CS_ERR_BAD_HANDLE) ? "CS_ERR_BAD_HANDLE" : \
+ ((x) == CS_ERR_BUSY) ? "CS_ERR_BUSY" : \
+ ((x) == CS_ERR_ACCESS) ? "CS_ERR_ACCESS" : \
+ ((x) == CS_ERR_NOT_EXIST) ? "CS_ERR_NOT_EXIST" : \
+ ((x) == CS_ERR_NAME_TOO_LONG) ? "CS_ERR_NAME_TOO_LONG" : \
+ ((x) == CS_ERR_EXIST) ? "CS_ERR_EXIST" : \
+ ((x) == CS_ERR_NO_SPACE) ? "CS_ERR_NO_SPACE" : \
+ ((x) == CS_ERR_INTERRUPT) ? "CS_ERR_INTERRUPT" : \
+ ((x) == CS_ERR_NAME_NOT_FOUND) ? "CS_ERR_NAME_NOT_FOUND" : \
+ ((x) == CS_ERR_NO_RESOURCES) ? "CS_ERR_NO_RESOURCES" : \
+ ((x) == CS_ERR_NOT_SUPPORTED) ? "CS_ERR_NOT_SUPPORTED" : \
+ ((x) == CS_ERR_BAD_OPERATION) ? "CS_ERR_BAD_OPERATION" : \
+ ((x) == CS_ERR_FAILED_OPERATION) ? "CS_ERR_FAILED_OPERATION" : \
+ ((x) == CS_ERR_MESSAGE_ERROR) ? "CS_ERR_MESSAGE_ERROR" : \
+ ((x) == CS_ERR_QUEUE_FULL) ? "CS_ERR_QUEUE_FULL" : \
+ ((x) == CS_ERR_QUEUE_NOT_AVAILABLE) ? "CS_ERR_QUEUE_NOT_AVAILABLE" : \
+ ((x) == CS_ERR_BAD_FLAGS) ? "CS_ERR_BAD_FLAGS" : \
+ ((x) == CS_ERR_TOO_BIG) ? "CS_ERR_TOO_BIG" : \
+ ((x) == CS_ERR_NO_SECTIONS) ? "CS_ERR_NO_SECTIONS" : \
+ ((x) == CS_ERR_CONTEXT_NOT_FOUND) ? "CS_ERR_CONTEXT_NOT_FOUND" : \
+ ((x) == CS_ERR_TOO_MANY_GROUPS) ? "CS_ERR_TOO_MANY_GROUPS" : \
+ ((x) == CS_ERR_SECURITY) ? "CS_ERR_SECURITY" : \
+ "cs_error_unknown"
+#endif
#define _RQ_TYPE(x) \
((x) == DM_ULOG_CHECKPOINT_READY) ? "DM_ULOG_CHECKPOINT_READY": \
@@ -803,6 +836,11 @@ static int import_checkpoint(struct clog_cpg *entry, int no_read,
{
int bitmap_size;
+ if (no_read) {
+ LOG_DBG("Checkpoint for this log already received");
+ return 0;
+ }
+
bitmap_size = (rq->u_rq.data_size - RECOVERING_REGION_SECTION_SIZE) / 2;
if (bitmap_size < 0) {
LOG_ERROR("Checkpoint has invalid payload size.");
@@ -947,7 +985,8 @@ static int do_cluster_work(void *data __attribute__((unused)))
dm_list_iterate_items_safe(entry, tmp, &clog_cpg_list) {
r = cpg_dispatch(entry->handle, CS_DISPATCH_ALL);
if (r != CS_OK)
- LOG_ERROR("cpg_dispatch failed: %d", r);
+ LOG_ERROR("cpg_dispatch failed: %s",
+ str_ais_error(r));
if (entry->free_me) {
free(entry);
10 years, 8 months
master - dumpconfig: also mention profilable type if giving hint about known types
by Peter Rajnoha
Gitweb: http://git.fedorahosted.org/git/?p=lvm2.git;a=commitdiff;h=99fd710cfd8beb...
Commit: 99fd710cfd8beb88eb860e16007209d0acb1c440
Parent: d8b781e8ab9be0e54fa68834398bc42ce9465ba0
Author: Peter Rajnoha <prajnoha(a)redhat.com>
AuthorDate: Mon Aug 19 08:32:03 2013 +0200
Committer: Peter Rajnoha <prajnoha(a)redhat.com>
CommitterDate: Mon Aug 19 08:32:03 2013 +0200
dumpconfig: also mention profilable type if giving hint about known types
---
tools/dumpconfig.c | 2 +-
1 files changed, 1 insertions(+), 1 deletions(-)
diff --git a/tools/dumpconfig.c b/tools/dumpconfig.c
index 0887297..18fba34 100644
--- a/tools/dumpconfig.c
+++ b/tools/dumpconfig.c
@@ -188,7 +188,7 @@ int dumpconfig(struct cmd_context *cmd, int argc, char **argv)
}
else {
log_error("Incorrect type of configuration specified. "
- "Expected one of: current, default, missing, new.");
+ "Expected one of: current, default, missing, new, profilable.");
r = EINVALID_CMD_LINE;
goto out;
}
10 years, 8 months
master - dmsetup: display any message output from kernel
by Alasdair Kergon
Gitweb: http://git.fedorahosted.org/git/?p=lvm2.git;a=commitdiff;h=d8b781e8ab9be0...
Commit: d8b781e8ab9be0e54fa68834398bc42ce9465ba0
Parent: cac49725c9a2a1f5c0e48235a07f168d98458ace
Author: Alasdair G Kergon <agk(a)redhat.com>
AuthorDate: Fri Aug 16 15:25:39 2013 +0100
Committer: Alasdair G Kergon <agk(a)redhat.com>
CommitterDate: Fri Aug 16 15:25:39 2013 +0100
dmsetup: display any message output from kernel
Recent kernels allow messages to respond with a string.
Add dm_task_get_message_response() to libdevmapper to perform some
basic sanity checks and return this.
Have 'dmsetup message' display any response.
DM statistics will make extensive use of this.
(From Mikulas.)
---
WHATS_NEW_DM | 2 ++
libdm/ioctl/libdm-iface.c | 26 +++++++++++++++++++++++++-
libdm/libdevmapper.h | 1 +
tools/dmsetup.c | 8 ++++++++
4 files changed, 36 insertions(+), 1 deletions(-)
diff --git a/WHATS_NEW_DM b/WHATS_NEW_DM
index 67b7d46..3995187 100644
--- a/WHATS_NEW_DM
+++ b/WHATS_NEW_DM
@@ -1,5 +1,7 @@
Version 1.02.80 -
==================================
+ Display any output returned by 'dmsetup message'.
+ Add dm_task_get_message_response to libdevmapper.
Version 1.02.79 - 13th August 2013
==================================
diff --git a/libdm/ioctl/libdm-iface.c b/libdm/ioctl/libdm-iface.c
index b6f9d09..b0a2228 100644
--- a/libdm/ioctl/libdm-iface.c
+++ b/libdm/ioctl/libdm-iface.c
@@ -1,6 +1,6 @@
/*
* Copyright (C) 2001-2004 Sistina Software, Inc. All rights reserved.
- * Copyright (C) 2004-2012 Red Hat, Inc. All rights reserved.
+ * Copyright (C) 2004-2013 Red Hat, Inc. All rights reserved.
*
* This file is part of the device-mapper userspace tools.
*
@@ -700,6 +700,29 @@ struct dm_versions *dm_task_get_versions(struct dm_task *dmt)
dmt->dmi.v4->data_start);
}
+const char *dm_task_get_message_response(struct dm_task *dmt)
+{
+ const char *start, *end;
+
+ if (!(dmt->dmi.v4->flags & DM_DATA_OUT_FLAG))
+ return NULL;
+
+ start = (const char *) dmt->dmi.v4 + dmt->dmi.v4->data_start;
+ end = (const char *) dmt->dmi.v4 + dmt->dmi.v4->data_size;
+
+ if (end < start) {
+ log_error(INTERNAL_ERROR "Corrupted message structure returned: start %d > end %d", (int)dmt->dmi.v4->data_start, (int)dmt->dmi.v4->data_size);
+ return NULL;
+ }
+
+ if (!memchr(start, 0, end - start)) {
+ log_error(INTERNAL_ERROR "Message response doesn't contain terminating NUL character");
+ return NULL;
+ }
+
+ return start;
+}
+
int dm_task_set_ro(struct dm_task *dmt)
{
dmt->read_only = 1;
@@ -1867,6 +1890,7 @@ repeat_ioctl:
case DM_DEVICE_STATUS:
case DM_DEVICE_TABLE:
case DM_DEVICE_WAITEVENT:
+ case DM_DEVICE_TARGET_MSG:
_ioctl_buffer_double_factor++;
_dm_zfree_dmi(dmi);
goto repeat_ioctl;
diff --git a/libdm/libdevmapper.h b/libdm/libdevmapper.h
index 0b03eaf..b287eef 100644
--- a/libdm/libdevmapper.h
+++ b/libdm/libdevmapper.h
@@ -187,6 +187,7 @@ const char *dm_task_get_uuid(const struct dm_task *dmt);
struct dm_deps *dm_task_get_deps(struct dm_task *dmt);
struct dm_versions *dm_task_get_versions(struct dm_task *dmt);
+const char *dm_task_get_message_response(struct dm_task *dmt);
/*
* These functions return device-mapper names based on the value
diff --git a/tools/dmsetup.c b/tools/dmsetup.c
index 8f6b340..01f49c3 100644
--- a/tools/dmsetup.c
+++ b/tools/dmsetup.c
@@ -770,6 +770,7 @@ static int _message(CMD_ARGS)
size_t sz = 1;
struct dm_task *dmt;
char *str;
+ const char *response;
if (!(dmt = dm_task_create(DM_DEVICE_TARGET_MSG)))
return 0;
@@ -826,6 +827,13 @@ static int _message(CMD_ARGS)
if (!dm_task_run(dmt))
goto out;
+ if ((response = dm_task_get_message_response(dmt))) {
+ if (!*response || response[strlen(response) - 1] == '\n')
+ fputs(response, stdout);
+ else
+ puts(response);
+ }
+
r = 1;
out:
10 years, 8 months
master - udev: fix lvmetad rules to not ignore loop device configuration
by Peter Rajnoha
Gitweb: http://git.fedorahosted.org/git/?p=lvm2.git;a=commitdiff;h=cac49725c9a2a1...
Commit: cac49725c9a2a1f5c0e48235a07f168d98458ace
Parent: f1dc4d3d81456d506b2c56fb2e8b12106cbd9e16
Author: Peter Rajnoha <prajnoha(a)redhat.com>
AuthorDate: Fri Aug 16 15:45:00 2013 +0200
Committer: Peter Rajnoha <prajnoha(a)redhat.com>
CommitterDate: Fri Aug 16 15:45:00 2013 +0200
udev: fix lvmetad rules to not ignore loop device configuration
If loop device is first configured on systems where /dev/loop-control
is used to dynamically create the loop device itself, there's an
ADD+CHANGE even generated. But next time the existing /dev/loop[0-9]*
is reused, there's only a CHANGE event since the device representing
it is already present in kernel (so no ADD event in this case).
We can't ignore this CHANGE event for loop devices! This is a regression
caused by 756bcabbfe297688ba240a880bc2b55265ad33f0. We already had
a similar problem with MD devices which was fixed by
2ac217d408470dcecb69b83d9cbf7a254747fa5b (but that one was
only an intra-release fix).
---
WHATS_NEW | 1 +
udev/69-dm-lvm-metad.rules.in | 2 +-
2 files changed, 2 insertions(+), 1 deletions(-)
diff --git a/WHATS_NEW b/WHATS_NEW
index a4df6c9..3cf3e47 100644
--- a/WHATS_NEW
+++ b/WHATS_NEW
@@ -1,5 +1,6 @@
Version 2.02.101 -
===================================
+ Fix ignored lvmetad update on loop device configuration (2.02.99).
Use LVM_PATH instead of hardcoded value in lvm2 activation systemd generator.
Refresh existing VG before autoactivation (event retrigger/device reappeared).
Fix vgck to notice on-disk corruption even if lvmetad is used.
diff --git a/udev/69-dm-lvm-metad.rules.in b/udev/69-dm-lvm-metad.rules.in
index a0e48a1..d5087e3 100644
--- a/udev/69-dm-lvm-metad.rules.in
+++ b/udev/69-dm-lvm-metad.rules.in
@@ -21,7 +21,7 @@ SUBSYSTEM!="block", GOTO="lvm_end"
ENV{ID_FS_TYPE}!="LVM2_member|LVM1_member", GOTO="lvm_end"
ACTION=="remove", GOTO="lvm_scan"
-ACTION=="change", KERNEL=="md[0-9]*", GOTO="lvm_scan"
+ACTION=="change", KERNEL=="md[0-9]*|loop[0-9]*", GOTO="lvm_scan"
# If the PV is not a dm device, scan only after device addition (ADD event)
KERNEL!="dm-[0-9]*", ACTION!="add", GOTO="lvm_end"
10 years, 8 months
master - fix: ambiguity in log_sys_error call from previous commit
by Peter Rajnoha
Gitweb: http://git.fedorahosted.org/git/?p=lvm2.git;a=commitdiff;h=f1dc4d3d81456d...
Commit: f1dc4d3d81456d506b2c56fb2e8b12106cbd9e16
Parent: 0563bd0037610397c5838d0172fd1c913c62c187
Author: Peter Rajnoha <prajnoha(a)redhat.com>
AuthorDate: Thu Aug 15 12:40:47 2013 +0200
Committer: Peter Rajnoha <prajnoha(a)redhat.com>
CommitterDate: Thu Aug 15 12:50:58 2013 +0200
fix: ambiguity in log_sys_error call from previous commit
libdm-common.c:883:42: warning: pointer/integer type mismatch in conditional expression
define log_sys_error(x, y) log_err("%s%s%s failed: %s", y, *y ? ": " : "", x, strerror(errno))
So the "y" which was 'path ? : "SELinux context reset"' from
previous commit did not quite fit the other "? :" in the log_sys_macro.
---
libdm/libdm-common.c | 2 +-
1 files changed, 1 insertions(+), 1 deletions(-)
diff --git a/libdm/libdm-common.c b/libdm/libdm-common.c
index 4f398f1..9043352 100644
--- a/libdm/libdm-common.c
+++ b/libdm/libdm-common.c
@@ -880,7 +880,7 @@ int dm_prepare_selinux_context(const char *path, mode_t mode)
log_debug_activation("Resetting SELinux context to default value.");
if (setfscreatecon(scontext) < 0) {
- log_sys_error("setfscreatecon", path ? : "SELinux context reset");
+ log_sys_error("setfscreatecon", (path ? : "SELinux context reset"));
freecon(scontext);
return 0;
}
10 years, 8 months
master - fix: some issues reported by coverity
by Peter Rajnoha
Gitweb: http://git.fedorahosted.org/git/?p=lvm2.git;a=commitdiff;h=0563bd00376103...
Commit: 0563bd0037610397c5838d0172fd1c913c62c187
Parent: 8cbbe851a80e8d99dc886ce9b44834137731d8ce
Author: Peter Rajnoha <prajnoha(a)redhat.com>
AuthorDate: Thu Aug 15 12:23:49 2013 +0200
Committer: Peter Rajnoha <prajnoha(a)redhat.com>
CommitterDate: Thu Aug 15 12:23:49 2013 +0200
fix: some issues reported by coverity
- null_fd resource leak on error path in _reopen_fd_null fn
- dead code in verify_message in clvmd code
- dead code in _init_filter_components in toolcontext code
- null dereference in dm_prepare_selinux_context on error path if
setfscreatecon fails while resetting SELinux context
---
daemons/clvmd/clvmd.c | 5 -----
lib/commands/toolcontext.c | 4 ----
lib/misc/lvm-exec.c | 9 ++++++---
libdm/libdm-common.c | 2 +-
4 files changed, 7 insertions(+), 13 deletions(-)
diff --git a/daemons/clvmd/clvmd.c b/daemons/clvmd/clvmd.c
index eaa75ca..a52b39d 100644
--- a/daemons/clvmd/clvmd.c
+++ b/daemons/clvmd/clvmd.c
@@ -1133,11 +1133,6 @@ static int verify_message(char *buf, int len)
return -1;
}
- if (h->clientid < 0) {
- log_error("verify_message bad clientid %x", h->clientid);
- return -1;
- }
-
if (h->arglen > max_cluster_message) {
log_error("verify_message bad arglen %x max %d", h->arglen, max_cluster_message);
return -1;
diff --git a/lib/commands/toolcontext.c b/lib/commands/toolcontext.c
index 65371b1..702a2d8 100644
--- a/lib/commands/toolcontext.c
+++ b/lib/commands/toolcontext.c
@@ -879,10 +879,6 @@ static struct dev_filter *_init_filter_components(struct cmd_context *cmd)
nr_filt++;
}
- /* Only build a composite filter if we really need it. */
- if (nr_filt == 1)
- return filters[0];
-
if (!(composite = composite_filter_create(nr_filt, filters)))
goto_bad;
diff --git a/lib/misc/lvm-exec.c b/lib/misc/lvm-exec.c
index 4cecfa3..01704ad 100644
--- a/lib/misc/lvm-exec.c
+++ b/lib/misc/lvm-exec.c
@@ -111,6 +111,7 @@ int exec_cmd(struct cmd_context *cmd, const char *const argv[],
static int _reopen_fd_to_null(int fd)
{
int null_fd;
+ int r = 0;
if ((null_fd = open("/dev/null", O_RDWR)) == -1) {
log_sys_error("open", "/dev/null");
@@ -119,20 +120,22 @@ static int _reopen_fd_to_null(int fd)
if (close(fd)) {
log_sys_error("close", "");
- return 0;
+ goto out;
}
if (dup2(null_fd, fd) == -1) {
log_sys_error("dup2", "");
- return 0;
+ goto out;
}
+ r = 1;
+out:
if (close(null_fd)) {
log_sys_error("dup2", "");
return 0;
}
- return 1;
+ return r;
}
FILE *pipe_open(struct cmd_context *cmd, const char *const argv[],
diff --git a/libdm/libdm-common.c b/libdm/libdm-common.c
index 2e068dc..4f398f1 100644
--- a/libdm/libdm-common.c
+++ b/libdm/libdm-common.c
@@ -880,7 +880,7 @@ int dm_prepare_selinux_context(const char *path, mode_t mode)
log_debug_activation("Resetting SELinux context to default value.");
if (setfscreatecon(scontext) < 0) {
- log_sys_error("setfscreatecon", path);
+ log_sys_error("setfscreatecon", path ? : "SELinux context reset");
freecon(scontext);
return 0;
}
10 years, 8 months
master - systemd: use LVM_PATH instead of hardcoded value in activation generator
by Peter Rajnoha
Gitweb: http://git.fedorahosted.org/git/?p=lvm2.git;a=commitdiff;h=8cbbe851a80e8d...
Commit: 8cbbe851a80e8d99dc886ce9b44834137731d8ce
Parent: c29c64f20dadbd9076d8729bd3d0cb724c4b39b0
Author: Michael Stapelberg <stapelberg(a)debian.org>
AuthorDate: Thu Aug 15 09:57:30 2013 +0200
Committer: Peter Rajnoha <prajnoha(a)redhat.com>
CommitterDate: Thu Aug 15 09:59:19 2013 +0200
systemd: use LVM_PATH instead of hardcoded value in activation generator
---
WHATS_NEW | 1 +
.../lvm2_activation_generator_systemd_red_hat.c | 3 ++-
2 files changed, 3 insertions(+), 1 deletions(-)
diff --git a/WHATS_NEW b/WHATS_NEW
index 903b28d..a4df6c9 100644
--- a/WHATS_NEW
+++ b/WHATS_NEW
@@ -1,5 +1,6 @@
Version 2.02.101 -
===================================
+ Use LVM_PATH instead of hardcoded value in lvm2 activation systemd generator.
Refresh existing VG before autoactivation (event retrigger/device reappeared).
Fix vgck to notice on-disk corruption even if lvmetad is used.
Move mpath device filter before partitioned filter (which opens devices).
diff --git a/scripts/lvm2_activation_generator_systemd_red_hat.c b/scripts/lvm2_activation_generator_systemd_red_hat.c
index 17bc71a..9d4b581 100644
--- a/scripts/lvm2_activation_generator_systemd_red_hat.c
+++ b/scripts/lvm2_activation_generator_systemd_red_hat.c
@@ -22,6 +22,7 @@
#include <fcntl.h>
#include <limits.h> /* For PATH_MAX for musl libc */
#include "lvm2app.h"
+#include "configure.h" /* for LVM_PATH */
#define KMSG_DEV_PATH "/dev/kmsg"
#define LVM_CONF_USE_LVMETAD "global/use_lvmetad"
@@ -150,7 +151,7 @@ static int generate_unit(const char *dir, int unit)
"[Service]\n", f);
}
- fputs("ExecStart=/usr/sbin/lvm vgchange -aay --sysinit\n"
+ fputs("ExecStart=" LVM_PATH " vgchange -aay --sysinit\n"
"Type=oneshot\n", f);
if (fclose(f) < 0) {
10 years, 8 months
master - lvm2app: lvm_list_pvs_free seg. fault when no PVs
by tasleson
Gitweb: http://git.fedorahosted.org/git/?p=lvm2.git;a=commitdiff;h=c29c64f20dadbd...
Commit: c29c64f20dadbd9076d8729bd3d0cb724c4b39b0
Parent: 732e609fe2e337fa7f4c2b3308d0bc6187269947
Author: Tony Asleson <tasleson(a)redhat.com>
AuthorDate: Wed Aug 14 15:14:42 2013 -0500
Committer: Tony Asleson <tasleson(a)redhat.com>
CommitterDate: Wed Aug 14 15:17:39 2013 -0500
lvm2app: lvm_list_pvs_free seg. fault when no PVs
When the system has no PVs we don't have access to
the cmd pointer and it remains NULL which causes
a seg. fault when we try to free the VG lock.
Signed-off-by: Tony Asleson <tasleson(a)redhat.com>
---
liblvm/lvm_pv.c | 19 +++++++++++++------
1 files changed, 13 insertions(+), 6 deletions(-)
diff --git a/liblvm/lvm_pv.c b/liblvm/lvm_pv.c
index 2bd0ac0..e67e1eb 100644
--- a/liblvm/lvm_pv.c
+++ b/liblvm/lvm_pv.c
@@ -65,6 +65,7 @@ struct lvm_property_value lvm_pvseg_get_property(const pvseg_t pvseg,
struct lvm_list_wrapper
{
unsigned long magic;
+ struct cmd_context *cmd;
struct dm_list pvslist;
struct dm_list vgslist;
};
@@ -84,6 +85,11 @@ struct dm_list *lvm_list_pvs(lvm_t libh)
struct lvm_list_wrapper *rc = NULL;
struct cmd_context *cmd = (struct cmd_context *)libh;
+ /*
+ * This memory will get cleared when the library handle
+ * gets closed, don't try to free is as it doesn't work
+ * like malloc/free do.
+ */
if (!(rc = dm_pool_zalloc(cmd->mem, sizeof(*rc)))) {
log_errno(ENOMEM, "Memory allocation fail for pv list.");
return NULL;
@@ -95,9 +101,14 @@ struct dm_list *lvm_list_pvs(lvm_t libh)
dm_list_init(&rc->pvslist);
dm_list_init(&rc->vgslist);
if( !get_pvs_perserve_vg(cmd, &rc->pvslist, &rc->vgslist) ) {
- dm_pool_free(cmd->mem, rc);
return NULL;
}
+
+ /*
+ * If we have no PVs we still need to have access to cmd
+ * pointer in the free call.
+ */
+ rc->cmd = cmd;
rc->magic = 0xF005BA11;
}
@@ -109,7 +120,6 @@ int lvm_list_pvs_free(struct dm_list *pvlist)
struct lvm_list_wrapper *to_delete;
struct vg_list *vgl;
struct pv_list *pvl;
- struct cmd_context *cmd = NULL;
if (pvlist) {
to_delete = dm_list_struct_base(pvlist, struct lvm_list_wrapper, pvslist);
@@ -119,17 +129,14 @@ int lvm_list_pvs_free(struct dm_list *pvlist)
}
dm_list_iterate_items(vgl, &to_delete->vgslist) {
- cmd = vgl->vg->cmd;
release_vg(vgl->vg);
}
dm_list_iterate_items(pvl, &to_delete->pvslist)
free_pv_fid(pvl->pv);
- unlock_vg(cmd, VG_GLOBAL);
-
+ unlock_vg(to_delete->cmd, VG_GLOBAL);
to_delete->magic = 0xA5A5A5A5;
- dm_pool_free(cmd->mem, to_delete);
}
return 0;
10 years, 8 months
master - test: Fix false positives due to open devices
by Marian Csontos
Gitweb: http://git.fedorahosted.org/git/?p=lvm2.git;a=commitdiff;h=732e609fe2e337...
Commit: 732e609fe2e337fa7f4c2b3308d0bc6187269947
Parent: 82d83a01ce2cac77fec2e9b763061fbfb5f01ce8
Author: Marian Csontos <mcsontos(a)redhat.com>
AuthorDate: Wed Aug 14 15:57:52 2013 +0200
Committer: Marian Csontos <mcsontos(a)redhat.com>
CommitterDate: Wed Aug 14 16:04:01 2013 +0200
test: Fix false positives due to open devices
Something is rather randomly keeping devices open. As it is a known udev
feature, waiting for transaction may (or may not) help.
---
test/lib/aux.sh | 1 +
1 files changed, 1 insertions(+), 0 deletions(-)
diff --git a/test/lib/aux.sh b/test/lib/aux.sh
index d61f17d..36de6e5 100644
--- a/test/lib/aux.sh
+++ b/test/lib/aux.sh
@@ -345,6 +345,7 @@ prepare_devs() {
disable_dev() {
local dev
+ udev_wait
init_udev_transaction
for dev in "$@"; do
maj=$(($(stat --printf=0x%t "$dev")))
10 years, 8 months
master - autoactivation: refresh existing VG before autoactivation
by Peter Rajnoha
Gitweb: http://git.fedorahosted.org/git/?p=lvm2.git;a=commitdiff;h=82d83a01ce2cac...
Commit: 82d83a01ce2cac77fec2e9b763061fbfb5f01ce8
Parent: fcbb34bdccb21f0ed4c8fe990fdc68126f1cbf4f
Author: Peter Rajnoha <prajnoha(a)redhat.com>
AuthorDate: Wed Aug 14 14:04:58 2013 +0200
Committer: Peter Rajnoha <prajnoha(a)redhat.com>
CommitterDate: Wed Aug 14 14:04:58 2013 +0200
autoactivation: refresh existing VG before autoactivation
When autoactivating a VG, there could be an existing VG with exactly
the same PV UUIDs. The PVs could be reappeared after previous
loss/disconnect (for example disconnecting and reconnecting iscsi).
Since there's no "autodeactivation" yet, the mappings for the LVs
from the VG were left in the system even if the device was disconnected.
These mappings also hold the major:minor of the underlying device.
So if the device reappears, it is assigned a different major:minor
pair (...and kernel name). We need to cope with this during
autoactivation so any existing mappings are corrected for any changes.
The VG refresh does that (the vgchange --refresh functionality) -
call this before VG autoactivation.
(If the VG does not exist yet, the VG refresh is NOP)
---
WHATS_NEW | 1 +
tools/pvscan.c | 20 +++++++++++++-------
2 files changed, 14 insertions(+), 7 deletions(-)
diff --git a/WHATS_NEW b/WHATS_NEW
index c7fda19..903b28d 100644
--- a/WHATS_NEW
+++ b/WHATS_NEW
@@ -1,5 +1,6 @@
Version 2.02.101 -
===================================
+ Refresh existing VG before autoactivation (event retrigger/device reappeared).
Fix vgck to notice on-disk corruption even if lvmetad is used.
Move mpath device filter before partitioned filter (which opens devices).
Split partitioned filter out of lvm_type filter.
diff --git a/tools/pvscan.c b/tools/pvscan.c
index 96bbf6b..3f16b05 100644
--- a/tools/pvscan.c
+++ b/tools/pvscan.c
@@ -98,6 +98,7 @@ static int _auto_activation_handler(struct cmd_context *cmd,
struct volume_group *vg;
int consistent = 0;
struct id vgid_raw;
+ int r = 0;
/* TODO: add support for partial and clustered VGs */
if (partial)
@@ -106,24 +107,29 @@ static int _auto_activation_handler(struct cmd_context *cmd,
if (!id_read_format(&vgid_raw, vgid))
return_0;
- /* NB. This is safe because we know lvmetad is running and we won't hit
- * disk. */
+ /* NB. This is safe because we know lvmetad is running and we won't hit disk. */
if (!(vg = vg_read_internal(cmd, NULL, (const char *) &vgid_raw, 0, &consistent)))
return 1;
if (vg_is_clustered(vg)) {
- release_vg(vg);
- return 1;
+ r = 1; goto out;
+ }
+
+ if (!vg_refresh_visible(vg->cmd, vg)) {
+ 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);
- release_vg(vg);
- return 0;
+ goto out;
}
+ r = 1;
+
+out:
release_vg(vg);
- return 1;
+ return r;
}
static int _pvscan_lvmetad(struct cmd_context *cmd, int argc, char **argv)
10 years, 8 months