master - test: Correctly trigger inconsistent metadata repair in lvmcache-exercise.
by Petr Rockai
Gitweb: http://git.fedorahosted.org/git/?p=lvm2.git;a=commitdiff;h=17f3b8280b8ade...
Commit: 17f3b8280b8ade397a6a4a8fd82ba7dd7d0e1d1b
Parent: 0decd7553ac9dcf4a7d81f5b10b1f4ca053ae9a5
Author: Petr Rockai <prockai(a)redhat.com>
AuthorDate: Wed Oct 9 14:44:15 2013 +0200
Committer: Petr Rockai <prockai(a)redhat.com>
CommitterDate: Wed Oct 9 14:44:15 2013 +0200
test: Correctly trigger inconsistent metadata repair in lvmcache-exercise.
Since lvconvert --repair sets handles_missing_pvs, it will not repair
inconsistent metadata automatically. Calling lvs instead should do the trick.
---
test/shell/lvmcache-exercise.sh | 2 +-
1 files changed, 1 insertions(+), 1 deletions(-)
diff --git a/test/shell/lvmcache-exercise.sh b/test/shell/lvmcache-exercise.sh
index 5ea6381..6e8efda 100644
--- a/test/shell/lvmcache-exercise.sh
+++ b/test/shell/lvmcache-exercise.sh
@@ -30,7 +30,7 @@ lvconvert --yes --repair $vg2/$lv1
aux enable_dev "$dev3"
# here it should fix any reappeared devices
-lvconvert --yes --repair $vg2/$lv1
+lvs
lvs -a $vg2 -o+devices 2>&1 | tee out
not grep reappeared out
10 years, 7 months
master - metadata: Fix metadata repair paths when lvmetad is used.
by Petr Rockai
Gitweb: http://git.fedorahosted.org/git/?p=lvm2.git;a=commitdiff;h=0decd7553ac9dc...
Commit: 0decd7553ac9dcf4a7d81f5b10b1f4ca053ae9a5
Parent: fbb6de845e857cfb4144c40dca36456d27abdbe9
Author: Petr Rockai <prockai(a)redhat.com>
AuthorDate: Wed Oct 9 14:04:47 2013 +0200
Committer: Petr Rockai <prockai(a)redhat.com>
CommitterDate: Wed Oct 9 14:44:01 2013 +0200
metadata: Fix metadata repair paths when lvmetad is used.
---
lib/cache/lvmetad.c | 2 -
lib/metadata/metadata.c | 76 +++++++++++++++++++++++++++++++----------------
lib/metadata/metadata.h | 3 --
3 files changed, 50 insertions(+), 31 deletions(-)
diff --git a/lib/cache/lvmetad.c b/lib/cache/lvmetad.c
index f43283f..8940704 100644
--- a/lib/cache/lvmetad.c
+++ b/lib/cache/lvmetad.c
@@ -392,8 +392,6 @@ struct volume_group *lvmetad_vg_lookup(struct cmd_context *cmd, const char *vgna
pvl->pv->dev = lvmcache_device(info);
if (!pvl->pv->dev)
pvl->pv->status |= MISSING_PV;
- else
- check_reappeared_pv(vg, pvl->pv);
if (!lvmcache_fid_add_mdas_pv(info, fid)) {
vg = NULL;
goto_out; /* FIXME error path */
diff --git a/lib/metadata/metadata.c b/lib/metadata/metadata.c
index 4ffd502..8571e0a 100644
--- a/lib/metadata/metadata.c
+++ b/lib/metadata/metadata.c
@@ -2883,10 +2883,11 @@ int vg_missing_pv_count(const struct volume_group *vg)
return ret;
}
-void check_reappeared_pv(struct volume_group *correct_vg,
- struct physical_volume *pv)
+static int _check_reappeared_pv(struct volume_group *correct_vg,
+ struct physical_volume *pv, int act)
{
struct pv_list *pvl;
+ int rv = 0;
/*
* Skip these checks in case the tool is going to deal with missing
@@ -2894,21 +2895,47 @@ void check_reappeared_pv(struct volume_group *correct_vg,
* confusing.
*/
if (correct_vg->cmd->handles_missing_pvs)
- return;
+ return rv;
dm_list_iterate_items(pvl, &correct_vg->pvs)
if (pv->dev == pvl->pv->dev && is_missing_pv(pvl->pv)) {
- log_warn("Missing device %s reappeared, updating "
- "metadata for VG %s to version %u.",
- pv_dev_name(pvl->pv), pv_vg_name(pvl->pv),
- correct_vg->seqno);
+ if (act)
+ log_warn("Missing device %s reappeared, updating "
+ "metadata for VG %s to version %u.",
+ pv_dev_name(pvl->pv), pv_vg_name(pvl->pv),
+ correct_vg->seqno);
if (pvl->pv->pe_alloc_count == 0) {
- pv->status &= ~MISSING_PV;
- pvl->pv->status &= ~MISSING_PV;
- } else
+ if (act) {
+ pv->status &= ~MISSING_PV;
+ pvl->pv->status &= ~MISSING_PV;
+ }
+ ++ rv;
+ } else if (act)
log_warn("Device still marked missing because of allocated data "
"on it, remove volumes and consider vgreduce --removemissing.");
}
+ return rv;
+}
+
+static int _repair_inconsistent_vg(struct volume_group *vg)
+{
+ unsigned saved_handles_missing_pvs = vg->cmd->handles_missing_pvs;
+
+ vg->cmd->handles_missing_pvs = 1;
+ if (!vg_write(vg)) {
+ log_error("Automatic metadata correction failed");
+ vg->cmd->handles_missing_pvs = saved_handles_missing_pvs;
+ return 0;
+ }
+
+ vg->cmd->handles_missing_pvs = saved_handles_missing_pvs;
+
+ if (!vg_commit(vg)) {
+ log_error("Automatic metadata correction commit failed");
+ return 0;
+ }
+
+ return 1;
}
static int _check_mda_in_use(struct metadata_area *mda, void *_in_use)
@@ -2951,12 +2978,12 @@ static struct volume_group *_vg_read(struct cmd_context *cmd,
int inconsistent_mdas = 0;
int inconsistent_mda_count = 0;
unsigned use_precommitted = precommitted;
- unsigned saved_handles_missing_pvs = cmd->handles_missing_pvs;
struct dm_list *pvids;
struct pv_list *pvl, *pvl2;
struct dm_list all_pvs;
char uuid[64] __attribute__((aligned(8)));
unsigned seqno = 0;
+ int reappeared = 0;
if (is_orphan_vg(vgname)) {
if (use_precommitted) {
@@ -2969,8 +2996,16 @@ static struct volume_group *_vg_read(struct cmd_context *cmd,
}
if (lvmetad_active() && !use_precommitted) {
- *consistent = 1;
- return lvmcache_get_vg(cmd, vgname, vgid, precommitted);
+ if ((correct_vg = lvmcache_get_vg(cmd, vgname, vgid, precommitted))) {
+ dm_list_iterate_items(pvl, &correct_vg->pvs)
+ if (pvl->pv->dev)
+ reappeared += _check_reappeared_pv(correct_vg, pvl->pv, *consistent);
+ if (reappeared && *consistent)
+ *consistent = _repair_inconsistent_vg(correct_vg);
+ else
+ *consistent = !reappeared;
+ }
+ return correct_vg;
}
/*
@@ -3339,22 +3374,11 @@ static struct volume_group *_vg_read(struct cmd_context *cmd,
* update metadata and remove MISSING flag
*/
dm_list_iterate_items(pvl, &all_pvs)
- check_reappeared_pv(correct_vg, pvl->pv);
+ _check_reappeared_pv(correct_vg, pvl->pv, 1);
- cmd->handles_missing_pvs = 1;
- if (!vg_write(correct_vg)) {
- log_error("Automatic metadata correction failed");
+ if (!_repair_inconsistent_vg(correct_vg)) {
_free_pv_list(&all_pvs);
release_vg(correct_vg);
- cmd->handles_missing_pvs = saved_handles_missing_pvs;
- return NULL;
- }
- cmd->handles_missing_pvs = saved_handles_missing_pvs;
-
- if (!vg_commit(correct_vg)) {
- log_error("Automatic metadata correction commit "
- "failed");
- release_vg(correct_vg);
return NULL;
}
diff --git a/lib/metadata/metadata.h b/lib/metadata/metadata.h
index 2408c23..21ac204 100644
--- a/lib/metadata/metadata.h
+++ b/lib/metadata/metadata.h
@@ -486,7 +486,4 @@ int add_pv_to_vg(struct volume_group *vg, const char *pv_name,
uint64_t find_min_mda_size(struct dm_list *mdas);
char *tags_format_and_copy(struct dm_pool *mem, const struct dm_list *tags);
-void check_reappeared_pv(struct volume_group *correct_vg,
- struct physical_volume *pv);
-
#endif
10 years, 7 months
master - test: Make comma a separator as in make check T=lvconvert, lvcreate
by Petr Rockai
Gitweb: http://git.fedorahosted.org/git/?p=lvm2.git;a=commitdiff;h=fbb6de845e857c...
Commit: fbb6de845e857cfb4144c40dca36456d27abdbe9
Parent: 863be9d9c6dbe84f072b77d37a64de601bd2f76b
Author: Petr Rockai <prockai(a)redhat.com>
AuthorDate: Wed Oct 9 14:02:34 2013 +0200
Committer: Petr Rockai <prockai(a)redhat.com>
CommitterDate: Wed Oct 9 14:02:34 2013 +0200
test: Make comma a separator as in make check T=lvconvert,lvcreate
---
test/Makefile.in | 3 ++-
1 files changed, 2 insertions(+), 1 deletions(-)
diff --git a/test/Makefile.in b/test/Makefile.in
index 1b9789f..5685544 100644
--- a/test/Makefile.in
+++ b/test/Makefile.in
@@ -34,7 +34,8 @@ T ?= .
S ?= @ # never match anything by default
VERBOSE ?= 0
ALL = $(shell find $(srcdir) \( -path \*/shell/\*.sh -or -path \*/api/\*.sh \) | sort)
-RUN = $(shell find $(srcdir) -regextype posix-egrep \( -path \*/shell/\*.sh -or -path \*/api/\*.sh \) -and -regex "$(srcdir)/.*($(T)).*" -and -not -regex "$(srcdir)/.*($(S)).*" | sort)
+comma = ,
+RUN = $(shell find $(srcdir) -regextype posix-egrep \( -path \*/shell/\*.sh -or -path \*/api/\*.sh \) -and -regex "$(srcdir)/.*($(subst $(comma),|,$(T))).*" -and -not -regex "$(srcdir)/.*($(subst $(comma),|,$(S))).*" | sort)
RUN_BASE = $(subst $(srcdir)/,,$(RUN))
# Shell quote;
10 years, 7 months
master - WHATS_NEW: commit d888a05 and 808a5d9
by Peter Rajnoha
Gitweb: http://git.fedorahosted.org/git/?p=lvm2.git;a=commitdiff;h=863be9d9c6dbe8...
Commit: 863be9d9c6dbe84f072b77d37a64de601bd2f76b
Parent: a7c73154ea4f751cfd7e72162d355844993d72fa
Author: Peter Rajnoha <prajnoha(a)redhat.com>
AuthorDate: Wed Oct 9 12:11:12 2013 +0200
Committer: Peter Rajnoha <prajnoha(a)redhat.com>
CommitterDate: Wed Oct 9 12:11:12 2013 +0200
WHATS_NEW: commit d888a05 and 808a5d9
---
WHATS_NEW | 2 ++
1 files changed, 2 insertions(+), 0 deletions(-)
diff --git a/WHATS_NEW b/WHATS_NEW
index 7450f04..39c5b05 100644
--- a/WHATS_NEW
+++ b/WHATS_NEW
@@ -1,5 +1,7 @@
Version 2.02.104
===================================
+ Fix incorrect memory handling when reading messages from lvmetad.
+ Fix locking in lvmetad when handling the PV which is gone.
Recognize new flag to skip udev scanning in udev rules and act appropriately.
Add support for flagging an LV to skip udev scanning during activation.
Improve message when unable to change discards setting on active thin pool.
10 years, 7 months
master - cleanup: remove 'discards 'const' qualifier' compilation warning
by Peter Rajnoha
Gitweb: http://git.fedorahosted.org/git/?p=lvm2.git;a=commitdiff;h=a7c73154ea4f75...
Commit: a7c73154ea4f751cfd7e72162d355844993d72fa
Parent: 808a5d945e3af27c7e79093f38d2dbe8370fee39
Author: Peter Rajnoha <prajnoha(a)redhat.com>
AuthorDate: Wed Oct 9 10:05:02 2013 +0200
Committer: Peter Rajnoha <prajnoha(a)redhat.com>
CommitterDate: Wed Oct 9 10:05:02 2013 +0200
cleanup: remove 'discards 'const' qualifier' compilation warning
---
daemons/lvmetad/lvmetad-core.c | 2 +-
1 files changed, 1 insertions(+), 1 deletions(-)
diff --git a/daemons/lvmetad/lvmetad-core.c b/daemons/lvmetad/lvmetad-core.c
index cfbf279..b7a3023 100644
--- a/daemons/lvmetad/lvmetad-core.c
+++ b/daemons/lvmetad/lvmetad-core.c
@@ -796,7 +796,7 @@ static response pv_gone(lvmetad_state *s, request r)
pvmeta = dm_hash_lookup(s->pvid_to_pvmeta, pvid);
pvid_old = dm_hash_lookup_binary(s->device_to_pvid, &device, sizeof(device));
- const char *vgid = dm_strdup(dm_hash_lookup(s->pvid_to_vgid, pvid));
+ char *vgid = dm_strdup(dm_hash_lookup(s->pvid_to_vgid, pvid));
if (!vgid) {
unlock_pvid_to_pvmeta(s);
10 years, 7 months
master - libdaemon: Fix an invalid memory read.
by Petr Rockai
Gitweb: http://git.fedorahosted.org/git/?p=lvm2.git;a=commitdiff;h=808a5d945e3af2...
Commit: 808a5d945e3af27c7e79093f38d2dbe8370fee39
Parent: d888a0557efc173336582ca94055e0630d5ceca8
Author: Petr Rockai <prockai(a)redhat.com>
AuthorDate: Tue Oct 8 23:19:11 2013 +0200
Committer: Petr Rockai <prockai(a)redhat.com>
CommitterDate: Tue Oct 8 23:21:09 2013 +0200
libdaemon: Fix an invalid memory read.
---
libdaemon/client/daemon-io.c | 2 +-
1 files changed, 1 insertions(+), 1 deletions(-)
diff --git a/libdaemon/client/daemon-io.c b/libdaemon/client/daemon-io.c
index 906f375..e2c5180 100644
--- a/libdaemon/client/daemon-io.c
+++ b/libdaemon/client/daemon-io.c
@@ -38,7 +38,7 @@ int buffer_read(int fd, struct buffer *buffer) {
result = read(fd, buffer->mem + buffer->used, buffer->allocated - buffer->used);
if (result > 0) {
buffer->used += result;
- if (!strncmp((buffer->mem) + buffer->used - 4, "\n##\n", 4)) {
+ if (buffer->used >= 4 && !strncmp((buffer->mem) + buffer->used - 4, "\n##\n", 4)) {
buffer->used -= 4;
buffer->mem[buffer->used] = 0;
break; /* success, we have the full message now */
10 years, 7 months
master - lvmetad: Properly grab locks in pv_gone.
by Petr Rockai
Gitweb: http://git.fedorahosted.org/git/?p=lvm2.git;a=commitdiff;h=d888a0557efc17...
Commit: d888a0557efc173336582ca94055e0630d5ceca8
Parent: 805f7e404202300422b9533453ab722d0503fb69
Author: Petr Rockai <prockai(a)redhat.com>
AuthorDate: Tue Oct 8 23:16:41 2013 +0200
Committer: Petr Rockai <prockai(a)redhat.com>
CommitterDate: Tue Oct 8 23:21:09 2013 +0200
lvmetad: Properly grab locks in pv_gone.
---
daemons/lvmetad/lvmetad-core.c | 14 +++++++++++++-
1 files changed, 13 insertions(+), 1 deletions(-)
diff --git a/daemons/lvmetad/lvmetad-core.c b/daemons/lvmetad/lvmetad-core.c
index 1593bf7..cfbf279 100644
--- a/daemons/lvmetad/lvmetad-core.c
+++ b/daemons/lvmetad/lvmetad-core.c
@@ -796,11 +796,23 @@ static response pv_gone(lvmetad_state *s, request r)
pvmeta = dm_hash_lookup(s->pvid_to_pvmeta, pvid);
pvid_old = dm_hash_lookup_binary(s->device_to_pvid, &device, sizeof(device));
+ const char *vgid = dm_strdup(dm_hash_lookup(s->pvid_to_vgid, pvid));
+
+ if (!vgid) {
+ unlock_pvid_to_pvmeta(s);
+ return reply_fail("out of memory");
+ }
+
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), 1);
unlock_pvid_to_pvmeta(s);
+ lock_vg(s, vgid);
+ vg_remove_if_missing(s, vgid, 1);
+ unlock_vg(s, vgid);
+
+ dm_free(vgid);
+
if (pvid_old)
dm_free(pvid_old);
10 years, 7 months
master - lvmetad: Clean up pvid->vgid map when last PV in a VG disappears.
by Petr Rockai
Gitweb: http://git.fedorahosted.org/git/?p=lvm2.git;a=commitdiff;h=805f7e40420230...
Commit: 805f7e404202300422b9533453ab722d0503fb69
Parent: 830d233b1750d3fa885f75e488f18c91e98d61e5
Author: Petr Rockai <prockai(a)redhat.com>
AuthorDate: Tue Oct 8 23:14:55 2013 +0200
Committer: Petr Rockai <prockai(a)redhat.com>
CommitterDate: Tue Oct 8 23:21:09 2013 +0200
lvmetad: Clean up pvid->vgid map when last PV in a VG disappears.
---
daemons/lvmetad/lvmetad-core.c | 10 +++++-----
1 files changed, 5 insertions(+), 5 deletions(-)
diff --git a/daemons/lvmetad/lvmetad-core.c b/daemons/lvmetad/lvmetad-core.c
index e1ec5a8..1593bf7 100644
--- a/daemons/lvmetad/lvmetad-core.c
+++ b/daemons/lvmetad/lvmetad-core.c
@@ -551,7 +551,7 @@ static int compare_config(struct dm_config_node *a, struct dm_config_node *b)
return result;
}
-static int vg_remove_if_missing(lvmetad_state *s, const char *vgid);
+static int vg_remove_if_missing(lvmetad_state *s, const char *vgid, int update_pvids);
/* You need to be holding the pvid_to_vgid lock already to call this. */
static int update_pvid_to_vgid(lvmetad_state *s, struct dm_config_tree *vg,
@@ -590,7 +590,7 @@ static int update_pvid_to_vgid(lvmetad_state *s, struct dm_config_tree *vg,
n = dm_hash_get_next(to_check, n)) {
check_vgid = dm_hash_get_key(to_check, n);
lock_vg(s, check_vgid);
- vg_remove_if_missing(s, check_vgid);
+ vg_remove_if_missing(s, check_vgid, 0);
unlock_vg(s, check_vgid);
}
@@ -631,7 +631,7 @@ static int remove_metadata(lvmetad_state *s, const char *vgid, int update_pvids)
}
/* The VG must be locked. */
-static int vg_remove_if_missing(lvmetad_state *s, const char *vgid)
+static int vg_remove_if_missing(lvmetad_state *s, const char *vgid, int update_pvids)
{
struct dm_config_tree *vg;
struct dm_config_node *pv;
@@ -658,7 +658,7 @@ static int vg_remove_if_missing(lvmetad_state *s, const char *vgid)
if (missing) {
DEBUGLOG(s, "removing empty VG %s", vgid);
- remove_metadata(s, vgid, 0);
+ remove_metadata(s, vgid, update_pvids);
}
unlock_pvid_to_pvmeta(s);
@@ -798,7 +798,7 @@ static response pv_gone(lvmetad_state *s, request r)
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));
+ vg_remove_if_missing(s, dm_hash_lookup(s->pvid_to_vgid, pvid), 1);
unlock_pvid_to_pvmeta(s);
if (pvid_old)
10 years, 7 months
master - tests: needed --type mirror
by Zdenek Kabelac
Gitweb: http://git.fedorahosted.org/git/?p=lvm2.git;a=commitdiff;h=830d233b1750d3...
Commit: 830d233b1750d3fa885f75e488f18c91e98d61e5
Parent: 2ee969e8514d7d7310990308a242b210e55a9113
Author: Zdenek Kabelac <zkabelac(a)redhat.com>
AuthorDate: Tue Oct 8 16:56:09 2013 +0200
Committer: Zdenek Kabelac <zkabelac(a)redhat.com>
CommitterDate: Tue Oct 8 16:56:09 2013 +0200
tests: needed --type mirror
Avoid testing raids here (would need kernel module)
---
test/shell/lvcreate-usage.sh | 2 +-
1 files changed, 1 insertions(+), 1 deletions(-)
diff --git a/test/shell/lvcreate-usage.sh b/test/shell/lvcreate-usage.sh
index 68a15a9..7f32bbc 100644
--- a/test/shell/lvcreate-usage.sh
+++ b/test/shell/lvcreate-usage.sh
@@ -77,7 +77,7 @@ not lvcreate -l1 -n $lv4 $vg
not lvcreate -l1 --type mirror -m1 -n $lv4 $vg
lvconvert -m0 $vg/$lv3
-lvconvert -m2 -i 1 $vg/$lv3
+lvconvert -m2 --type mirror -i 1 $vg/$lv3
lvconvert -m1 $vg/$lv3
not vgchange -l 2
10 years, 7 months
master - tests: reappering device
by Zdenek Kabelac
Gitweb: http://git.fedorahosted.org/git/?p=lvm2.git;a=commitdiff;h=2ee969e8514d7d...
Commit: 2ee969e8514d7d7310990308a242b210e55a9113
Parent: 2f5ddfbadea5dae6b2fc236d4f243bd88d955aa8
Author: Zdenek Kabelac <zkabelac(a)redhat.com>
AuthorDate: Tue Oct 8 16:19:14 2013 +0200
Committer: Zdenek Kabelac <zkabelac(a)redhat.com>
CommitterDate: Tue Oct 8 16:19:14 2013 +0200
tests: reappering device
Simulation of problem for:
https://bugzilla.redhat.com/show_bug.cgi?id=995440
---
test/shell/lvmcache-exercise.sh | 17 +++++++++++++++--
1 files changed, 15 insertions(+), 2 deletions(-)
diff --git a/test/shell/lvmcache-exercise.sh b/test/shell/lvmcache-exercise.sh
index b1e2b92..5ea6381 100644
--- a/test/shell/lvmcache-exercise.sh
+++ b/test/shell/lvmcache-exercise.sh
@@ -1,5 +1,5 @@
#!/bin/sh
-# Copyright (C) 2008 Red Hat, Inc. All rights reserved.
+# Copyright (C) 2008-2013 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
@@ -14,10 +14,23 @@
aux prepare_pvs 5
vgcreate $vg1 "$dev1"
-vgcreate $vg2 "$dev3"
+vgcreate $vg2 "$dev3" "$dev4" "$dev5"
aux disable_dev "$dev1"
pvscan
vgcreate $vg1 "$dev2"
aux enable_dev "$dev1"
pvs
+
+# reappearing device (rhbz 995440)
+lvcreate -aey -m2 --type mirror -l4 --alloc anywhere --corelog -n $lv1 $vg2
+
+aux disable_dev "$dev3"
+lvconvert --yes --repair $vg2/$lv1
+aux enable_dev "$dev3"
+
+# here it should fix any reappeared devices
+lvconvert --yes --repair $vg2/$lv1
+
+lvs -a $vg2 -o+devices 2>&1 | tee out
+not grep reappeared out
10 years, 7 months