master - TEST: Check that LVM1 VGs work when using lvmetad (BZ 863401).
by Petr Rockai
Gitweb: http://git.fedorahosted.org/git/?p=lvm2.git;a=commitdiff;h=9ff2f1a3dbaa6f...
Commit: 9ff2f1a3dbaa6f77b1693b7a9cf540a902cf618d
Parent: 06243be91b12a7bb249d2b18cf5eeb0492ccfa4f
Author: Petr Rockai <prockai(a)redhat.com>
AuthorDate: Tue Oct 9 07:59:53 2012 +0200
Committer: Petr Rockai <prockai(a)redhat.com>
CommitterDate: Tue Oct 9 07:59:53 2012 +0200
TEST: Check that LVM1 VGs work when using lvmetad (BZ 863401).
---
test/shell/lvmetad-lvm1.sh | 21 +++++++++++++++++++++
1 files changed, 21 insertions(+), 0 deletions(-)
diff --git a/test/shell/lvmetad-lvm1.sh b/test/shell/lvmetad-lvm1.sh
new file mode 100644
index 0000000..c183fec
--- /dev/null
+++ b/test/shell/lvmetad-lvm1.sh
@@ -0,0 +1,21 @@
+#!/bin/sh
+# Copyright (C) 2012 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
+
+. lib/test
+
+test -e LOCAL_LVMETAD || skip
+aux prepare_devs 2
+pvcreate --metadatatype 1 $dev1
+vgscan --cache
+pvs | grep $dev1
+vgcreate --metadatatype 1 $vg1 $dev1
+vgs | grep $vg1
+pvs | grep $dev1
11 years, 6 months
master - lvmetad: Fix a leak on duplicated PVs (same PVID, different device).
by Petr Rockai
Gitweb: http://git.fedorahosted.org/git/?p=lvm2.git;a=commitdiff;h=06243be91b12a7...
Commit: 06243be91b12a7bb249d2b18cf5eeb0492ccfa4f
Parent: 665b6b308e4482a33fc5dd67e1e12066515e1424
Author: Petr Rockai <prockai(a)redhat.com>
AuthorDate: Mon Oct 8 20:31:12 2012 +0200
Committer: Petr Rockai <prockai(a)redhat.com>
CommitterDate: Tue Oct 9 01:38:58 2012 +0200
lvmetad: Fix a leak on duplicated PVs (same PVID, different device).
---
daemons/lvmetad/lvmetad-core.c | 33 +++++++++++++++++++++++++--------
1 files changed, 25 insertions(+), 8 deletions(-)
diff --git a/daemons/lvmetad/lvmetad-core.c b/daemons/lvmetad/lvmetad-core.c
index 466042b..4741649 100644
--- a/daemons/lvmetad/lvmetad-core.c
+++ b/daemons/lvmetad/lvmetad-core.c
@@ -66,6 +66,13 @@ static void destroy_metadata_hashes(lvmetad_state *s)
dm_hash_destroy(s->vgid_to_metadata);
dm_hash_destroy(s->vgid_to_vgname);
dm_hash_destroy(s->vgname_to_vgid);
+
+ n = dm_hash_get_first(s->device_to_pvid);
+ while (n) {
+ dm_free(dm_hash_get_data(s->device_to_pvid, n));
+ n = dm_hash_get_next(s->device_to_pvid, n);
+ }
+
dm_hash_destroy(s->device_to_pvid);
dm_hash_destroy(s->pvid_to_vgid);
}
@@ -748,6 +755,7 @@ static response pv_gone(lvmetad_state *s, request r)
const char *pvid = daemon_request_str(r, "uuid", NULL);
int64_t device = daemon_request_int(r, "device", 0);
struct dm_config_tree *pvmeta;
+ char *pvid_old;
DEBUG(s, "pv_gone: %s / %" PRIu64, pvid, device);
@@ -762,11 +770,15 @@ static response pv_gone(lvmetad_state *s, request r)
DEBUG(s, "pv_gone (updated): %s / %" PRIu64, pvid, device);
pvmeta = dm_hash_lookup(s->pvid_to_pvmeta, pvid);
+ pvid_old = dm_hash_lookup_binary(s->device_to_pvid, &device, sizeof(device));
dm_hash_remove_binary(s->device_to_pvid, &device, sizeof(device));
dm_hash_remove(s->pvid_to_pvmeta, pvid);
vg_remove_if_missing(s, dm_hash_lookup(s->pvid_to_vgid, pvid));
unlock_pvid_to_pvmeta(s);
+ if (pvid_old)
+ dm_free(pvid_old);
+
if (pvmeta) {
dm_config_destroy(pvmeta);
return daemon_reply_simple("OK", NULL);
@@ -800,8 +812,8 @@ static response pv_found(lvmetad_state *s, request r)
const char *vgid = daemon_request_str(r, "metadata/id", NULL);
struct dm_config_node *pvmeta = dm_config_find_node(r.cft->root, "pvmeta");
uint64_t device;
- struct dm_config_tree *cft, *pvmeta_old = NULL;
- const char *old;
+ struct dm_config_tree *cft, *pvmeta_old_dev = NULL, *pvmeta_old_pvid = NULL;
+ char *old;
const char *pvid_dup;
int complete = 0, orphan = 0;
int64_t seqno = -1, seqno_old = -1;
@@ -814,14 +826,17 @@ static response pv_found(lvmetad_state *s, request r)
if (!dm_config_get_uint64(pvmeta, "pvmeta/device", &device))
return reply_fail("need PV device number");
- DEBUG(s, "pv_found %s, vgid = %s, device = %" PRIu64, pvid, vgid, device);
-
lock_pvid_to_pvmeta(s);
if ((old = dm_hash_lookup_binary(s->device_to_pvid, &device, sizeof(device)))) {
- pvmeta_old = dm_hash_lookup(s->pvid_to_pvmeta, old);
+ pvmeta_old_dev = dm_hash_lookup(s->pvid_to_pvmeta, old);
dm_hash_remove(s->pvid_to_pvmeta, old);
}
+ pvmeta_old_pvid = dm_hash_lookup(s->pvid_to_pvmeta, pvid);
+
+ DEBUG(s, "pv_found %s, vgid = %s, device = %" PRIu64 ", old = %s", pvid, vgid, device, old);
+
+ dm_free(old);
if (!(cft = dm_config_create()) ||
!(cft->root = dm_config_clone_node(cft, pvmeta, 0))) {
@@ -829,14 +844,16 @@ static response pv_found(lvmetad_state *s, request r)
return reply_fail("out of memory");
}
- pvid_dup = dm_config_find_str(cft->root, "pvmeta/id", NULL);
+ pvid_dup = dm_strdup(pvid);
if (!dm_hash_insert(s->pvid_to_pvmeta, pvid, cft) ||
!dm_hash_insert_binary(s->device_to_pvid, &device, sizeof(device), (void*)pvid_dup)) {
unlock_pvid_to_pvmeta(s);
return reply_fail("out of memory");
}
- if (pvmeta_old)
- dm_config_destroy(pvmeta_old);
+ if (pvmeta_old_pvid)
+ dm_config_destroy(pvmeta_old_pvid);
+ if (pvmeta_old_dev && pvmeta_old_dev != pvmeta_old_pvid)
+ dm_config_destroy(pvmeta_old_dev);
unlock_pvid_to_pvmeta(s);
11 years, 6 months
master - lvmetad: Fix a leak in an error path in update_metadata.
by Petr Rockai
Gitweb: http://git.fedorahosted.org/git/?p=lvm2.git;a=commitdiff;h=665b6b308e4482...
Commit: 665b6b308e4482a33fc5dd67e1e12066515e1424
Parent: 556d2c920aacb857377c6cfdb0fa3f6c50f6721b
Author: Petr Rockai <prockai(a)redhat.com>
AuthorDate: Mon Oct 8 20:33:03 2012 +0200
Committer: Petr Rockai <prockai(a)redhat.com>
CommitterDate: Mon Oct 8 23:52:44 2012 +0200
lvmetad: Fix a leak in an error path in update_metadata.
---
daemons/lvmetad/lvmetad-core.c | 2 ++
1 files changed, 2 insertions(+), 0 deletions(-)
diff --git a/daemons/lvmetad/lvmetad-core.c b/daemons/lvmetad/lvmetad-core.c
index 1dc05d6..466042b 100644
--- a/daemons/lvmetad/lvmetad-core.c
+++ b/daemons/lvmetad/lvmetad-core.c
@@ -737,6 +737,8 @@ static int update_metadata(lvmetad_state *s, const char *name, const char *_vgid
unlock_pvid_to_vgid(s);
out:
+ if (!retval && cft)
+ dm_config_destroy(cft);
unlock_vg(s, _vgid);
return retval;
}
11 years, 6 months
master - TEST: Give lvmetad a chance to exit gracefully upon teardown.
by Petr Rockai
Gitweb: http://git.fedorahosted.org/git/?p=lvm2.git;a=commitdiff;h=556d2c920aacb8...
Commit: 556d2c920aacb857377c6cfdb0fa3f6c50f6721b
Parent: 39468b73a33853c2e532375762a2bbf1e76ea406
Author: Petr Rockai <prockai(a)redhat.com>
AuthorDate: Mon Oct 8 20:25:51 2012 +0200
Committer: Petr Rockai <prockai(a)redhat.com>
CommitterDate: Mon Oct 8 20:35:29 2012 +0200
TEST: Give lvmetad a chance to exit gracefully upon teardown.
---
test/lib/aux.sh | 4 +++-
1 files changed, 3 insertions(+), 1 deletions(-)
diff --git a/test/lib/aux.sh b/test/lib/aux.sh
index 37e7f69..107afc1 100644
--- a/test/lib/aux.sh
+++ b/test/lib/aux.sh
@@ -167,7 +167,9 @@ teardown_devs() {
teardown() {
echo -n "## teardown..."
- test ! -s LOCAL_LVMETAD || kill -9 "$(cat LOCAL_LVMETAD)" || true
+ test ! -s LOCAL_LVMETAD || \
+ (kill -TERM "$(cat LOCAL_LVMETAD)" && sleep 1 &&
+ kill -KILL "$(cat LOCAL_LVMETAD)" 2> /dev/null) || true
dm_table | not egrep -q "$vg|$vg1|$vg2|$vg3|$vg4" || {
# Avoid activation of dmeventd if there is no pid
11 years, 6 months
master - TEST: Wait for lvmetad socket to appear in "aux prepare_lvmetad".
by Petr Rockai
Gitweb: http://git.fedorahosted.org/git/?p=lvm2.git;a=commitdiff;h=39468b73a33853...
Commit: 39468b73a33853c2e532375762a2bbf1e76ea406
Parent: d5f2e6223f90b56fb173997bc2932bc361f54475
Author: Petr Rockai <prockai(a)redhat.com>
AuthorDate: Mon Oct 8 20:25:14 2012 +0200
Committer: Petr Rockai <prockai(a)redhat.com>
CommitterDate: Mon Oct 8 20:35:29 2012 +0200
TEST: Wait for lvmetad socket to appear in "aux prepare_lvmetad".
---
test/lib/aux.sh | 4 ++--
1 files changed, 2 insertions(+), 2 deletions(-)
diff --git a/test/lib/aux.sh b/test/lib/aux.sh
index d1d5e10..37e7f69 100644
--- a/test/lib/aux.sh
+++ b/test/lib/aux.sh
@@ -79,8 +79,8 @@ prepare_lvmetad() {
echo "preparing lvmetad..."
$run_valgrind lvmetad -f "$@" -s "$TESTDIR/lvmetad.socket" -d wire,debug &
echo $! > LOCAL_LVMETAD
-
- sleep .3
+ while ! test -e "$TESTDIR/lvmetad.socket"; do echo -n .; sleep .1; done # wait for the socket
+ echo ok
}
notify_lvmetad() {
11 years, 6 months
master - TEST: When INTERACTIVE=1, allow scripts to control a TTY.
by Petr Rockai
Gitweb: http://git.fedorahosted.org/git/?p=lvm2.git;a=commitdiff;h=d5f2e6223f90b5...
Commit: d5f2e6223f90b56fb173997bc2932bc361f54475
Parent: 138b4e1719324139426d894f666d00b8f5b86965
Author: Petr Rockai <prockai(a)redhat.com>
AuthorDate: Mon Oct 8 20:15:55 2012 +0200
Committer: Petr Rockai <prockai(a)redhat.com>
CommitterDate: Mon Oct 8 20:35:29 2012 +0200
TEST: When INTERACTIVE=1, allow scripts to control a TTY.
---
test/lib/harness.c | 19 +++++++++++++------
1 files changed, 13 insertions(+), 6 deletions(-)
diff --git a/test/lib/harness.c b/test/lib/harness.c
index c1d6774..929bfc8 100644
--- a/test/lib/harness.c
+++ b/test/lib/harness.c
@@ -44,6 +44,7 @@ static int readbuf_sz = 0, readbuf_used = 0;
static int die = 0;
static int verbose = 0; /* >1 with timestamps */
+static int interactive = 0; /* disable all redirections */
struct subst {
const char *key;
@@ -278,11 +279,13 @@ static void run(int i, char *f) {
perror("Fork failed.");
exit(201);
} else if (pid == 0) {
- close(0);
- dup2(fds[0], 1);
- dup2(fds[0], 2);
- close(fds[0]);
- close(fds[1]);
+ if (!interactive) {
+ close(0);
+ dup2(fds[0], 1);
+ dup2(fds[0], 2);
+ close(fds[0]);
+ close(fds[1]);
+ }
execlp("bash", "bash", f, NULL);
perror("execlp");
fflush(stderr);
@@ -320,7 +323,8 @@ static void run(int i, char *f) {
}
int main(int argc, char **argv) {
- const char *be_verbose = getenv("VERBOSE");
+ const char *be_verbose = getenv("VERBOSE"),
+ *be_interactive = getenv("INTERACTIVE");
time_t start = time(NULL);
int i;
@@ -332,6 +336,9 @@ int main(int argc, char **argv) {
if (be_verbose)
verbose = atoi(be_verbose);
+ if (be_interactive)
+ interactive = atoi(be_interactive);
+
if (socketpair(PF_UNIX, SOCK_STREAM, 0, fds)) {
perror("socketpair");
return 201;
11 years, 6 months
master - lvmetad: Fix a typo-induced leak in destroy_metadata_hashes.
by Petr Rockai
Gitweb: http://git.fedorahosted.org/git/?p=lvm2.git;a=commitdiff;h=138b4e17193241...
Commit: 138b4e1719324139426d894f666d00b8f5b86965
Parent: a19a5953433c86811df80c59de7ec6346c62be32
Author: Petr Rockai <prockai(a)redhat.com>
AuthorDate: Mon Oct 8 20:15:09 2012 +0200
Committer: Petr Rockai <prockai(a)redhat.com>
CommitterDate: Mon Oct 8 20:35:29 2012 +0200
lvmetad: Fix a typo-induced leak in destroy_metadata_hashes.
---
daemons/lvmetad/lvmetad-core.c | 1 +
1 files changed, 1 insertions(+), 0 deletions(-)
diff --git a/daemons/lvmetad/lvmetad-core.c b/daemons/lvmetad/lvmetad-core.c
index dce7535..1dc05d6 100644
--- a/daemons/lvmetad/lvmetad-core.c
+++ b/daemons/lvmetad/lvmetad-core.c
@@ -51,6 +51,7 @@ static void destroy_metadata_hashes(lvmetad_state *s)
{
struct dm_hash_node *n = NULL;
+ n = dm_hash_get_first(s->vgid_to_metadata);
while (n) {
dm_config_destroy(dm_hash_get_data(s->vgid_to_metadata, n));
n = dm_hash_get_next(s->vgid_to_metadata, n);
11 years, 6 months
master - libdaemon-client: Fix a memory leak in daemon_send.
by Petr Rockai
Gitweb: http://git.fedorahosted.org/git/?p=lvm2.git;a=commitdiff;h=a19a5953433c86...
Commit: a19a5953433c86811df80c59de7ec6346c62be32
Parent: 4b4c2833d984f6b6a8dde394168b4653cdd47863
Author: Petr Rockai <prockai(a)redhat.com>
AuthorDate: Mon Oct 8 18:35:30 2012 +0200
Committer: Petr Rockai <prockai(a)redhat.com>
CommitterDate: Mon Oct 8 20:35:29 2012 +0200
libdaemon-client: Fix a memory leak in daemon_send.
---
libdaemon/client/daemon-client.c | 12 ++++++++----
1 files changed, 8 insertions(+), 4 deletions(-)
diff --git a/libdaemon/client/daemon-client.c b/libdaemon/client/daemon-client.c
index e34a2a0..c87856c 100644
--- a/libdaemon/client/daemon-client.c
+++ b/libdaemon/client/daemon-client.c
@@ -73,12 +73,13 @@ daemon_reply daemon_send(daemon_handle h, daemon_request rq)
{
daemon_reply reply = { .cft = NULL, .error = 0 };
assert(h.socket_fd >= 0);
+ char *buffer = rq.buffer;
- if (!rq.buffer)
- dm_config_write_node(rq.cft->root, buffer_line, &rq.buffer);
+ if (!buffer)
+ dm_config_write_node(rq.cft->root, buffer_line, &buffer);
- assert(rq.buffer);
- if (!write_buffer(h.socket_fd, rq.buffer, strlen(rq.buffer)))
+ assert(buffer);
+ if (!write_buffer(h.socket_fd, buffer, strlen(buffer)))
reply.error = errno;
if (read_buffer(h.socket_fd, &reply.buffer)) {
@@ -88,6 +89,9 @@ daemon_reply daemon_send(daemon_handle h, daemon_request rq)
} else
reply.error = errno;
+ if (buffer != rq.buffer)
+ dm_free(buffer);
+
return reply;
}
11 years, 6 months
master - libdaemon-server: Optimize logging for a fast no-output path.
by Petr Rockai
Gitweb: http://git.fedorahosted.org/git/?p=lvm2.git;a=commitdiff;h=4b4c2833d984f6...
Commit: 4b4c2833d984f6b6a8dde394168b4653cdd47863
Parent: cc9c02fe68f6ee8f5f6bcf885c1ed41387778bb7
Author: Petr Rockai <prockai(a)redhat.com>
AuthorDate: Mon Oct 8 18:34:33 2012 +0200
Committer: Petr Rockai <prockai(a)redhat.com>
CommitterDate: Mon Oct 8 20:35:29 2012 +0200
libdaemon-server: Optimize logging for a fast no-output path.
---
libdaemon/server/daemon-log.c | 16 ++++++++++++++++
1 files changed, 16 insertions(+), 0 deletions(-)
diff --git a/libdaemon/server/daemon-log.c b/libdaemon/server/daemon-log.c
index 837fffd..b31bb4e 100644
--- a/libdaemon/server/daemon-log.c
+++ b/libdaemon/server/daemon-log.c
@@ -52,6 +52,16 @@ void daemon_log(log_state *s, int type, const char *message) {
}
}
+static int _type_interesting(log_state *s, int type) {
+ int i = 0;
+ while ( backend[i].id ) {
+ if ( (s->log_config[type] & backend[i].id) == backend[i].id )
+ return 1;
+ ++ i;
+ }
+ return 0;
+}
+
void daemon_logf(log_state *s, int type, const char *fmt, ...) {
char *buf;
va_list ap;
@@ -78,12 +88,18 @@ static int _log_line(const char *line, void *baton) {
void daemon_log_cft(log_state *s, int type, const char *prefix, const struct dm_config_node *n)
{
+ if (!_type_interesting(s, type))
+ return;
+
struct log_line_baton b = { .s = s, .type = type, .prefix = prefix };
dm_config_write_node(n, &_log_line, &b);
}
void daemon_log_multi(log_state *s, int type, const char *prefix, const char *msg)
{
+ if (!_type_interesting(s, type))
+ return;
+
struct log_line_baton b = { .s = s, .type = type, .prefix = prefix };
char *buf = dm_strdup(msg);
char *pos = buf;
11 years, 6 months
master - libdaemon-server: Fix a memory leak in daemon_log_multi.
by Petr Rockai
Gitweb: http://git.fedorahosted.org/git/?p=lvm2.git;a=commitdiff;h=cc9c02fe68f6ee...
Commit: cc9c02fe68f6ee8f5f6bcf885c1ed41387778bb7
Parent: 7a64fff948278604d287ac96d9783a6b896de99b
Author: Petr Rockai <prockai(a)redhat.com>
AuthorDate: Mon Oct 8 17:11:43 2012 +0200
Committer: Petr Rockai <prockai(a)redhat.com>
CommitterDate: Mon Oct 8 20:35:29 2012 +0200
libdaemon-server: Fix a memory leak in daemon_log_multi.
---
libdaemon/server/daemon-log.c | 1 +
1 files changed, 1 insertions(+), 0 deletions(-)
diff --git a/libdaemon/server/daemon-log.c b/libdaemon/server/daemon-log.c
index b18e70c..837fffd 100644
--- a/libdaemon/server/daemon-log.c
+++ b/libdaemon/server/daemon-log.c
@@ -98,6 +98,7 @@ void daemon_log_multi(log_state *s, int type, const char *prefix, const char *ms
_log_line(pos, &b);
pos = next ? next + 1 : 0;
}
+ dm_free(buf);
}
void daemon_log_enable(log_state *s, int outlet, int type, int enable)
11 years, 6 months