master - polldaemon.c: modify log levels in report_progress
by okozina
Gitweb: http://git.fedorahosted.org/git/?p=lvm2.git;a=commitdiff;h=01b06cb71b2511...
Commit: 01b06cb71b25111c9d0ddaccca97e788f2dedf9d
Parent: 43224f22e460eddd3d4ee993d4585b4c8f421357
Author: Ondrej Kozina <okozina(a)redhat.com>
AuthorDate: Thu May 21 10:17:29 2015 +0200
Committer: Ondrej Kozina <okozina(a)redhat.com>
CommitterDate: Thu May 21 11:20:11 2015 +0200
polldaemon.c: modify log levels in report_progress
There's a race when asking lvmpolld about progress_status and
actually reading the progress info from kernel:
Even with lvmpolld being used we read status info from
LVM2 command issued by a user (client side from lvmpolld perspective).
The whole cycle may look like following:
1) set up an operation that requires polling (i.e. pvmove /dev/sda)
2) notify lvmpolld about such operation (lvmpolld_poll_init())
3) in case 1) was not called with --background it would continue with:
4) Ask lvmpolld about progress status. it may respond with one of:
a) in_progress
b) not_found
c) finished
d) any low level error
5) provided the answer was 4a) try to read progress info from polling LV
(i.e. vg00/pvmove1). Repeat steps 4) and 5) until the answer is != 4a).
And now we got into racy configuration: lvmpolld answered with in_progress
but it may be the that in_between 4) and 5) the operation has already
finished and polling LV is already gone or there's nothing to ask for.
Up to now, 5) would report warning and it could print such warning many
times if --interval was set to 0.
We don't want to scary users by warnings in such situation so let's just
print these messages in verbose mode. Error messages due to error while
reading kernel status info (on existing, active and locked LV) remained
the same.
---
tools/polldaemon.c | 24 ++++++++++--------------
1 files changed, 10 insertions(+), 14 deletions(-)
diff --git a/tools/polldaemon.c b/tools/polldaemon.c
index fe2e7fd..2e86cb1 100644
--- a/tools/polldaemon.c
+++ b/tools/polldaemon.c
@@ -375,24 +375,19 @@ static int report_progress(struct cmd_context *cmd, struct poll_operation_id *id
if (lv && parms->lv_type && !(lv->status & parms->lv_type))
lv = NULL;
- if (!lv && parms->lv_type == PVMOVE) {
- log_print_unless_silent("%s: No pvmove in progress - already finished or aborted.",
- id->display_name);
- unlock_and_release_vg(cmd, vg, vg->name);
- return 1;
- }
-
if (!lv) {
- log_warn("Can't find LV in %s for %s. Already finished or removed.",
- vg->name, id->display_name);
- unlock_and_release_vg(cmd, vg, vg->name);
- return 1;
+ if (parms->lv_type == PVMOVE)
+ log_verbose("%s: No pvmove in progress - already finished or aborted.",
+ id->display_name);
+ else
+ log_verbose("Can't find LV in %s for %s. Already finished or removed.",
+ vg->name, id->display_name);
+ goto out;
}
if (!lv_is_active_locally(lv)) {
- log_print_unless_silent("%s: Interrupted: No longer active.", id->display_name);
- unlock_and_release_vg(cmd, vg, vg->name);
- return 1;
+ log_verbose("%s: Interrupted: No longer active.", id->display_name);
+ goto out;
}
if (parms->poll_fns->poll_progress(cmd, lv, id->display_name, parms) == PROGRESS_CHECK_FAILED) {
@@ -400,6 +395,7 @@ static int report_progress(struct cmd_context *cmd, struct poll_operation_id *id
return_0;
}
+out:
unlock_and_release_vg(cmd, vg, vg->name);
return 1;
8 years, 11 months
master - format_text: Parse (optional) outdated_pvs section in VG metadata.
by Petr Rockai
Gitweb: http://git.fedorahosted.org/git/?p=lvm2.git;a=commitdiff;h=43224f22e460ed...
Commit: 43224f22e460eddd3d4ee993d4585b4c8f421357
Parent: e8d00e068762d0ebd7dd489d45c43927b7ffdc58
Author: Petr Rockai <prockai(a)redhat.com>
AuthorDate: Wed Apr 29 15:02:26 2015 +0200
Committer: Petr Rockai <prockai(a)redhat.com>
CommitterDate: Wed May 20 19:46:14 2015 +0200
format_text: Parse (optional) outdated_pvs section in VG metadata.
---
lib/format_text/import_vsn1.c | 16 ++++++++++++----
1 files changed, 12 insertions(+), 4 deletions(-)
diff --git a/lib/format_text/import_vsn1.c b/lib/format_text/import_vsn1.c
index 3030bad..2d62905 100644
--- a/lib/format_text/import_vsn1.c
+++ b/lib/format_text/import_vsn1.c
@@ -167,6 +167,8 @@ static int _read_pv(struct format_instance *fid,
const struct dm_config_value *cv;
uint64_t size, ba_start;
+ int outdated = !strcmp(pvn->parent->key, "outdated_pvs");
+
if (!(pvl = dm_pool_zalloc(mem, sizeof(*pvl))) ||
!(pvl->pv = dm_pool_zalloc(mem, sizeof(*pvl->pv))))
return_0;
@@ -212,7 +214,7 @@ static int _read_pv(struct format_instance *fid,
memcpy(&pv->vgid, &vg->id, sizeof(vg->id));
- if (!_read_flag_config(pvn, &pv->status, PV_FLAGS)) {
+ if (!outdated && !_read_flag_config(pvn, &pv->status, PV_FLAGS)) {
log_error("Couldn't read status flags for physical volume.");
return 0;
}
@@ -234,13 +236,13 @@ static int _read_pv(struct format_instance *fid,
return 0;
}
- if (!_read_uint64(pvn, "pe_start", &pv->pe_start)) {
+ if (!outdated && !_read_uint64(pvn, "pe_start", &pv->pe_start)) {
log_error("Couldn't read extent start value (pe_start) "
"for physical volume.");
return 0;
}
- if (!_read_int32(pvn, "pe_count", &pv->pe_count)) {
+ if (!outdated && !_read_int32(pvn, "pe_count", &pv->pe_count)) {
log_error("Couldn't find extent count (pe_count) for "
"physical volume.");
return 0;
@@ -299,7 +301,10 @@ static int _read_pv(struct format_instance *fid,
vg->extent_count += pv->pe_count;
vg->free_count += pv->pe_count;
- add_pvl_to_vgs(vg, pvl);
+ if (outdated)
+ dm_list_add(&vg->pvs_outdated, &pvl->list);
+ else
+ add_pvl_to_vgs(vg, pvl);
return 1;
}
@@ -877,6 +882,9 @@ static struct volume_group *_read_vg(struct format_instance *fid,
goto bad;
}
+ _read_sections(fid, "outdated_pvs", _read_pv, vg,
+ vgn, pv_hash, lv_hash, 1, &scan_done_once);
+
/* Optional tags */
if (dm_config_get_list(vgn, "tags", &cv) &&
!(read_tags(vg->vgmem, &vg->tags, cv))) {
8 years, 11 months
master - lvmetad: Set up lvmcache & PV structs for outdated_pvs.
by Petr Rockai
Gitweb: http://git.fedorahosted.org/git/?p=lvm2.git;a=commitdiff;h=e8d00e068762d0...
Commit: e8d00e068762d0ebd7dd489d45c43927b7ffdc58
Parent: 55f33696928728e60f15dc7a557e55bf910dabdd
Author: Petr Rockai <prockai(a)redhat.com>
AuthorDate: Wed Apr 29 15:01:20 2015 +0200
Committer: Petr Rockai <prockai(a)redhat.com>
CommitterDate: Wed May 20 19:46:14 2015 +0200
lvmetad: Set up lvmcache & PV structs for outdated_pvs.
---
lib/cache/lvmetad.c | 43 +++++++++++++++++++++++++++++++------------
1 files changed, 31 insertions(+), 12 deletions(-)
diff --git a/lib/cache/lvmetad.c b/lib/cache/lvmetad.c
index a66f915..68162b6 100644
--- a/lib/cache/lvmetad.c
+++ b/lib/cache/lvmetad.c
@@ -395,6 +395,22 @@ static int _pv_populate_lvmcache(struct cmd_context *cmd,
return 1;
}
+static int _pv_update_struct_pv(struct physical_volume *pv, struct format_instance *fid)
+{
+ struct lvmcache_info *info;
+ if ((info = lvmcache_info_from_pvid((const char *)&pv->id, 0))) {
+ pv->label_sector = lvmcache_get_label(info)->sector;
+ pv->dev = lvmcache_device(info);
+ if (!pv->dev)
+ pv->status |= MISSING_PV;
+ if (!lvmcache_fid_add_mdas_pv(info, fid))
+ return_0;
+ pv->fid = fid;
+ } else
+ pv->status |= MISSING_PV; /* probably missing */
+ return 1;
+}
+
struct volume_group *lvmetad_vg_lookup(struct cmd_context *cmd, const char *vgname, const char *vgid)
{
struct volume_group *vg = NULL;
@@ -409,7 +425,6 @@ struct volume_group *lvmetad_vg_lookup(struct cmd_context *cmd, const char *vgna
struct format_type *fmt;
struct dm_config_node *pvcn;
struct pv_list *pvl;
- struct lvmcache_info *info;
if (!lvmetad_active())
return NULL;
@@ -460,22 +475,26 @@ struct volume_group *lvmetad_vg_lookup(struct cmd_context *cmd, const char *vgna
for (pvcn = pvcn->child; pvcn; pvcn = pvcn->sib)
_pv_populate_lvmcache(cmd, pvcn, fmt, 0);
+ if ((pvcn = dm_config_find_node(top, "metadata/outdated_pvs")))
+ for (pvcn = pvcn->child; pvcn; pvcn = pvcn->sib)
+ _pv_populate_lvmcache(cmd, pvcn, fmt, 0);
+
top->key = name;
if (!(vg = import_vg_from_config_tree(reply.cft, fid)))
goto_out;
dm_list_iterate_items(pvl, &vg->pvs) {
- if ((info = lvmcache_info_from_pvid((const char *)&pvl->pv->id, 0))) {
- pvl->pv->label_sector = lvmcache_get_label(info)->sector;
- pvl->pv->dev = lvmcache_device(info);
- if (!pvl->pv->dev)
- pvl->pv->status |= MISSING_PV;
- if (!lvmcache_fid_add_mdas_pv(info, fid)) {
- vg = NULL;
- goto_out; /* FIXME error path */
- }
- } else
- pvl->pv->status |= MISSING_PV; /* probably missing */
+ if (!_pv_update_struct_pv(pvl->pv, fid)) {
+ vg = NULL;
+ goto_out; /* FIXME error path */
+ }
+ }
+
+ dm_list_iterate_items(pvl, &vg->pvs_outdated) {
+ if (!_pv_update_struct_pv(pvl->pv, fid)) {
+ vg = NULL;
+ goto_out; /* FIXME error path */
+ }
}
lvmcache_update_vg(vg, 0);
8 years, 11 months
master - lvmetad: Provide entire pvmeta sections for outdated_pvs.
by Petr Rockai
Gitweb: http://git.fedorahosted.org/git/?p=lvm2.git;a=commitdiff;h=55f33696928728...
Commit: 55f33696928728e60f15dc7a557e55bf910dabdd
Parent: 611c8b6d29ca164a22270cb9b3dcf7958063c712
Author: Petr Rockai <prockai(a)redhat.com>
AuthorDate: Wed Apr 29 15:00:28 2015 +0200
Committer: Petr Rockai <prockai(a)redhat.com>
CommitterDate: Wed May 20 19:46:14 2015 +0200
lvmetad: Provide entire pvmeta sections for outdated_pvs.
---
daemons/lvmetad/lvmetad-core.c | 28 ++++++++++++++++++++++------
1 files changed, 22 insertions(+), 6 deletions(-)
diff --git a/daemons/lvmetad/lvmetad-core.c b/daemons/lvmetad/lvmetad-core.c
index 40cf7d4..449e332 100644
--- a/daemons/lvmetad/lvmetad-core.c
+++ b/daemons/lvmetad/lvmetad-core.c
@@ -470,13 +470,29 @@ static void mark_outdated_pv(lvmetad_state *s, const char *vgid, const char *pvi
list->v = v;
}
-static void chain_outdated_pvs(lvmetad_state *s, const char *vgid, struct dm_config_tree *metadata, struct dm_config_node *last)
+static void chain_outdated_pvs(lvmetad_state *s, const char *vgid, struct dm_config_tree *metadata_cft, struct dm_config_node *metadata)
{
- struct dm_config_tree *cft = dm_hash_lookup(s->vgid_to_outdated_pvs, vgid);
- if (!cft)
- return; /* nothing to chain in */
- last->sib = dm_config_clone_node(metadata, dm_config_find_node(cft->root, "outdated_pvs/pv_list"), 0);
- last->sib->key = "outdated_pvs";
+ struct dm_config_tree *cft = dm_hash_lookup(s->vgid_to_outdated_pvs, vgid), *pvmeta;
+ struct dm_config_node *pv, *res, *pvs = cft ? dm_config_find_node(cft->root, "outdated_pvs/pv_list") : NULL;
+ struct dm_config_value *pvs_v = pvs ? pvs->v : NULL;
+ if (!pvs_v)
+ return;
+ if (!(res = make_config_node(metadata_cft, "outdated_pvs", metadata_cft->root, 0)))
+ return; /* oops */
+ res->sib = metadata->child;
+ metadata->child = res;
+ for (; pvs_v && pvs_v->type != DM_CFG_EMPTY_ARRAY; pvs_v = pvs_v->next) {
+ pvmeta = dm_hash_lookup(s->pvid_to_pvmeta, pvs_v->v.str);
+ if (!pvmeta) {
+ WARN(s, "metadata for PV %s not found", pvs_v->v.str);
+ continue;
+ }
+ if (!(pv = dm_config_clone_node(metadata_cft, pvmeta->root, 0)))
+ continue;
+ pv->key = dm_config_find_str(pv, "pvmeta/id", NULL);
+ pv->sib = res->child;
+ res->child = pv;
+ }
}
static response vg_lookup(lvmetad_state *s, request r)
8 years, 11 months
master - metadata: Add pvs_outdated to struct volume_group.
by Petr Rockai
Gitweb: http://git.fedorahosted.org/git/?p=lvm2.git;a=commitdiff;h=611c8b6d29ca16...
Commit: 611c8b6d29ca164a22270cb9b3dcf7958063c712
Parent: 5435346052f491333b79da48bec5ef160cd118d5
Author: Petr Rockai <prockai(a)redhat.com>
AuthorDate: Wed Apr 15 16:41:09 2015 +0200
Committer: Petr Rockai <prockai(a)redhat.com>
CommitterDate: Wed May 20 19:46:14 2015 +0200
metadata: Add pvs_outdated to struct volume_group.
This is a list of PVs that should have their MDAs wiped because they carry
outdated metadata (that used to belong to the VG they are attached to).
---
lib/metadata/metadata.c | 3 +++
lib/metadata/vg.c | 1 +
lib/metadata/vg.h | 7 +++++++
3 files changed, 11 insertions(+), 0 deletions(-)
diff --git a/lib/metadata/metadata.c b/lib/metadata/metadata.c
index 5456c4e..8300eb6 100644
--- a/lib/metadata/metadata.c
+++ b/lib/metadata/metadata.c
@@ -3307,6 +3307,9 @@ static struct volume_group *_vg_read(struct cmd_context *cmd,
*consistent = _repair_inconsistent_vg(correct_vg);
else
*consistent = !reappeared;
+ if (_wipe_outdated_pvs(cmd, correct_vg, &correct_vg->pvs_outdated))
+ /* clear the list */
+ dm_list_init(&correct_vg->pvs_outdated);
}
return correct_vg;
}
diff --git a/lib/metadata/vg.c b/lib/metadata/vg.c
index c9a7e9e..1db8e75 100644
--- a/lib/metadata/vg.c
+++ b/lib/metadata/vg.c
@@ -61,6 +61,7 @@ struct volume_group *alloc_vg(const char *pool_name, struct cmd_context *cmd,
dm_list_init(&vg->pvs);
dm_list_init(&vg->pvs_to_create);
+ dm_list_init(&vg->pvs_outdated);
dm_list_init(&vg->lvs);
dm_list_init(&vg->tags);
dm_list_init(&vg->removed_lvs);
diff --git a/lib/metadata/vg.h b/lib/metadata/vg.h
index b0ab122..bb21f34 100644
--- a/lib/metadata/vg.h
+++ b/lib/metadata/vg.h
@@ -91,6 +91,13 @@ struct volume_group {
struct dm_list pvs_to_create;
/*
+ * List of physical volumes that carry outdated metadata that belongs
+ * to this VG. Currently only populated when lvmetad is in use.
+ */
+
+ struct dm_list pvs_outdated;
+
+ /*
* logical volumes
* The following relationship should always hold:
* dm_list_size(lvs) = user visible lv_count + snapshot_count + other invisible LVs
8 years, 11 months
master - metadata: Factor _wipe_outdated_pvs() PVs out of _vg_read().
by Petr Rockai
Gitweb: http://git.fedorahosted.org/git/?p=lvm2.git;a=commitdiff;h=5435346052f491...
Commit: 5435346052f491333b79da48bec5ef160cd118d5
Parent: 1562cd732060f995663a586566b15bc129e62b64
Author: Petr Rockai <prockai(a)redhat.com>
AuthorDate: Wed Apr 15 16:40:26 2015 +0200
Committer: Petr Rockai <prockai(a)redhat.com>
CommitterDate: Wed May 20 19:46:13 2015 +0200
metadata: Factor _wipe_outdated_pvs() PVs out of _vg_read().
---
lib/metadata/metadata.c | 53 +++++++++++++++++++++++++---------------------
1 files changed, 29 insertions(+), 24 deletions(-)
diff --git a/lib/metadata/metadata.c b/lib/metadata/metadata.c
index 19741ba..5456c4e 100644
--- a/lib/metadata/metadata.c
+++ b/lib/metadata/metadata.c
@@ -3224,6 +3224,30 @@ static int _check_mda_in_use(struct metadata_area *mda, void *_in_use)
return 1;
}
+static int _wipe_outdated_pvs(struct cmd_context *cmd, struct volume_group *vg, struct dm_list *to_check)
+{
+ struct pv_list *pvl, *pvl2;
+ char uuid[64] __attribute__((aligned(8)));
+ dm_list_iterate_items(pvl, to_check) {
+ dm_list_iterate_items(pvl2, &vg->pvs) {
+ if (pvl->pv->dev == pvl2->pv->dev)
+ goto next_pv;
+ }
+ if (!id_write_format(&pvl->pv->id, uuid, sizeof(uuid)))
+ return_0;
+ log_warn("WARNING: Removing PV %s (%s) that no longer belongs to VG %s",
+ pv_dev_name(pvl->pv), uuid, vg->name);
+ if (!pv_write_orphan(cmd, pvl->pv))
+ return_0;
+
+ /* Refresh metadata after orphan write */
+ drop_cached_metadata(vg);
+next_pv:
+ ;
+ }
+ return 1;
+}
+
/* Caller sets consistent to 1 if it's safe for vg_read_internal to correct
* inconsistent metadata on disk (i.e. the VG write lock is held).
* This guarantees only consistent metadata is returned.
@@ -3257,9 +3281,8 @@ static struct volume_group *_vg_read(struct cmd_context *cmd,
int inconsistent_mda_count = 0;
unsigned use_precommitted = precommitted;
struct dm_list *pvids;
- struct pv_list *pvl, *pvl2;
+ struct pv_list *pvl;
struct dm_list all_pvs;
- char uuid[64] __attribute__((aligned(8)));
unsigned seqno = 0;
int reappeared = 0;
struct cached_vg_fmtdata *vg_fmtdata = NULL; /* Additional format-specific data about the vg */
@@ -3684,28 +3707,10 @@ static struct volume_group *_vg_read(struct cmd_context *cmd,
return NULL;
}
- dm_list_iterate_items(pvl, &all_pvs) {
- dm_list_iterate_items(pvl2, &correct_vg->pvs) {
- if (pvl->pv->dev == pvl2->pv->dev)
- goto next_pv;
- }
- if (!id_write_format(&pvl->pv->id, uuid, sizeof(uuid))) {
- _free_pv_list(&all_pvs);
- release_vg(correct_vg);
- return_NULL;
- }
- log_warn("WARNING: Removing PV %s (%s) that no longer belongs to VG %s",
- pv_dev_name(pvl->pv), uuid, correct_vg->name);
- if (!pv_write_orphan(cmd, pvl->pv)) {
- _free_pv_list(&all_pvs);
- release_vg(correct_vg);
- return_NULL;
- }
-
- /* Refresh metadata after orphan write */
- drop_cached_metadata(correct_vg);
- next_pv:
- ;
+ if (!_wipe_outdated_pvs(cmd, correct_vg, &all_pvs)) {
+ _free_pv_list(&all_pvs);
+ release_vg(correct_vg);
+ return_NULL;
}
}
8 years, 11 months
master - lvmetad: Attach an outdated_pvs list to vg_lookup replies.
by Petr Rockai
Gitweb: http://git.fedorahosted.org/git/?p=lvm2.git;a=commitdiff;h=1562cd732060f9...
Commit: 1562cd732060f995663a586566b15bc129e62b64
Parent: da1527d65dbe474fe4c9e620ad028a9a09213ac8
Author: Petr Rockai <prockai(a)redhat.com>
AuthorDate: Wed Apr 15 16:39:32 2015 +0200
Committer: Petr Rockai <prockai(a)redhat.com>
CommitterDate: Wed May 20 19:46:13 2015 +0200
lvmetad: Attach an outdated_pvs list to vg_lookup replies.
---
daemons/lvmetad/lvmetad-core.c | 9 +++++++--
1 files changed, 7 insertions(+), 2 deletions(-)
diff --git a/daemons/lvmetad/lvmetad-core.c b/daemons/lvmetad/lvmetad-core.c
index d14bac2..40cf7d4 100644
--- a/daemons/lvmetad/lvmetad-core.c
+++ b/daemons/lvmetad/lvmetad-core.c
@@ -470,8 +470,13 @@ static void mark_outdated_pv(lvmetad_state *s, const char *vgid, const char *pvi
list->v = v;
}
-static void chain_outdated_pvs(lvmetad_state *s, const char *vgid, struct dm_config_tree *metadata)
+static void chain_outdated_pvs(lvmetad_state *s, const char *vgid, struct dm_config_tree *metadata, struct dm_config_node *last)
{
+ struct dm_config_tree *cft = dm_hash_lookup(s->vgid_to_outdated_pvs, vgid);
+ if (!cft)
+ return; /* nothing to chain in */
+ last->sib = dm_config_clone_node(metadata, dm_config_find_node(cft->root, "outdated_pvs/pv_list"), 0);
+ last->sib->key = "outdated_pvs";
}
static response vg_lookup(lvmetad_state *s, request r)
@@ -540,7 +545,7 @@ static response vg_lookup(lvmetad_state *s, request r)
unlock_vg(s, uuid);
update_pv_status(s, res.cft, n, 1); /* FIXME report errors */
- chain_outdated_pvs(s, uuid, res.cft);
+ chain_outdated_pvs(s, uuid, res.cft, n);
return res;
bad:
8 years, 11 months
master - lvmetad: Clear the vgid_to_outdated_pvs hash on shutdown.
by Petr Rockai
Gitweb: http://git.fedorahosted.org/git/?p=lvm2.git;a=commitdiff;h=da1527d65dbe47...
Commit: da1527d65dbe474fe4c9e620ad028a9a09213ac8
Parent: 925268794f4c97091674d99d98e3d73349a75502
Author: Petr Rockai <prockai(a)redhat.com>
AuthorDate: Wed Apr 15 16:38:57 2015 +0200
Committer: Petr Rockai <prockai(a)redhat.com>
CommitterDate: Wed May 20 19:46:13 2015 +0200
lvmetad: Clear the vgid_to_outdated_pvs hash on shutdown.
---
daemons/lvmetad/lvmetad-core.c | 3 +++
1 files changed, 3 insertions(+), 0 deletions(-)
diff --git a/daemons/lvmetad/lvmetad-core.c b/daemons/lvmetad/lvmetad-core.c
index 7e30add..d14bac2 100644
--- a/daemons/lvmetad/lvmetad-core.c
+++ b/daemons/lvmetad/lvmetad-core.c
@@ -61,6 +61,9 @@ static void destroy_metadata_hashes(lvmetad_state *s)
dm_hash_iterate(n, s->vgid_to_metadata)
dm_config_destroy(dm_hash_get_data(s->vgid_to_metadata, n));
+ dm_hash_iterate(n, s->vgid_to_outdated_pvs)
+ dm_config_destroy(dm_hash_get_data(s->vgid_to_outdated_pvs, n));
+
dm_hash_iterate(n, s->pvid_to_pvmeta)
dm_config_destroy(dm_hash_get_data(s->pvid_to_pvmeta, n));
8 years, 11 months
master - lvmetad: Maintain info about outdated PVs.
by Petr Rockai
Gitweb: http://git.fedorahosted.org/git/?p=lvm2.git;a=commitdiff;h=925268794f4c97...
Commit: 925268794f4c97091674d99d98e3d73349a75502
Parent: f3c7bd4004a64b6ce2c9e0f0069eedb050420c62
Author: Petr Rockai <prockai(a)redhat.com>
AuthorDate: Wed Apr 15 13:00:35 2015 +0200
Committer: Petr Rockai <prockai(a)redhat.com>
CommitterDate: Wed May 20 19:46:13 2015 +0200
lvmetad: Maintain info about outdated PVs.
---
daemons/lvmetad/lvmetad-core.c | 82 +++++++++++++++++++++++++++++++++++++---
1 files changed, 76 insertions(+), 6 deletions(-)
diff --git a/daemons/lvmetad/lvmetad-core.c b/daemons/lvmetad/lvmetad-core.c
index 398ef38..7e30add 100644
--- a/daemons/lvmetad/lvmetad-core.c
+++ b/daemons/lvmetad/lvmetad-core.c
@@ -40,6 +40,7 @@ typedef struct {
struct dm_hash_table *vgid_to_metadata;
struct dm_hash_table *vgid_to_vgname;
+ struct dm_hash_table *vgid_to_outdated_pvs;
struct dm_hash_table *vgname_to_vgid;
struct dm_hash_table *pvid_to_vgid;
struct {
@@ -66,6 +67,7 @@ static void destroy_metadata_hashes(lvmetad_state *s)
dm_hash_destroy(s->pvid_to_pvmeta);
dm_hash_destroy(s->vgid_to_metadata);
dm_hash_destroy(s->vgid_to_vgname);
+ dm_hash_destroy(s->vgid_to_outdated_pvs);
dm_hash_destroy(s->vgname_to_vgid);
dm_hash_destroy(s->device_to_pvid);
@@ -78,6 +80,7 @@ static void create_metadata_hashes(lvmetad_state *s)
s->device_to_pvid = dm_hash_create(32);
s->vgid_to_metadata = dm_hash_create(32);
s->vgid_to_vgname = dm_hash_create(32);
+ s->vgid_to_outdated_pvs = dm_hash_create(32);
s->pvid_to_vgid = dm_hash_create(32);
s->vgname_to_vgid = dm_hash_create(32);
}
@@ -420,6 +423,54 @@ bad:
return res;
}
+static void mark_outdated_pv(lvmetad_state *s, const char *vgid, const char *pvid)
+{
+ struct dm_config_tree *pvmeta, *outdated_pvs;
+ struct dm_config_node *list, *cft_vgid;
+ struct dm_config_value *v;
+
+ lock_pvid_to_pvmeta(s);
+ pvmeta = dm_hash_lookup(s->pvid_to_pvmeta, pvid);
+ unlock_pvid_to_pvmeta(s);
+
+ /* if the MDA exists and is used, it will have ignore=0 set */
+ if (!pvmeta ||
+ (dm_config_find_int64(pvmeta->root, "pvmeta/mda0/ignore", 1) &&
+ dm_config_find_int64(pvmeta->root, "pvmeta/mda1/ignore", 1)))
+ return;
+
+ WARN(s, "PV %s has outdated metadata", pvid);
+
+ outdated_pvs = dm_hash_lookup(s->vgid_to_outdated_pvs, vgid);
+ if (!outdated_pvs) {
+ if (!(outdated_pvs = dm_config_from_string("outdated_pvs/pv_list = []")) ||
+ !(cft_vgid = make_text_node(outdated_pvs, "vgid", dm_pool_strdup(outdated_pvs->mem, vgid),
+ outdated_pvs->root, NULL)))
+ abort();
+ if(!dm_hash_insert(s->vgid_to_outdated_pvs, cft_vgid->v->v.str, outdated_pvs))
+ abort();
+ DEBUGLOG(s, "created outdated_pvs list for VG %s", vgid);
+ }
+
+ list = dm_config_find_node(outdated_pvs->root, "outdated_pvs/pv_list");
+ v = list->v;
+ while (v) {
+ if (v->type != DM_CFG_EMPTY_ARRAY && !strcmp(v->v.str, pvid))
+ return;
+ v = v->next;
+ }
+ if (!(v = dm_config_create_value(outdated_pvs)))
+ abort();
+ v->type = DM_CFG_STRING;
+ v->v.str = dm_pool_strdup(outdated_pvs->mem, pvid);
+ v->next = list->v;
+ list->v = v;
+}
+
+static void chain_outdated_pvs(lvmetad_state *s, const char *vgid, struct dm_config_tree *metadata)
+{
+}
+
static response vg_lookup(lvmetad_state *s, request r)
{
struct dm_config_tree *cft;
@@ -486,6 +537,7 @@ static response vg_lookup(lvmetad_state *s, request r)
unlock_vg(s, uuid);
update_pv_status(s, res.cft, n, 1); /* FIXME report errors */
+ chain_outdated_pvs(s, uuid, res.cft);
return res;
bad:
@@ -549,9 +601,11 @@ static int compare_config(struct dm_config_node *a, struct dm_config_node *b)
static int vg_remove_if_missing(lvmetad_state *s, const char *vgid, int update_pvids);
+enum update_pvid_mode { UPDATE_ONLY, REMOVE_EMPTY, MARK_OUTDATED };
+
/* 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,
- const char *vgid, int nuke_empty)
+ const char *vgid, int mode)
{
struct dm_config_node *pv;
struct dm_hash_table *to_check;
@@ -571,11 +625,14 @@ static int update_pvid_to_vgid(lvmetad_state *s, struct dm_config_tree *vg,
if (!(pvid = dm_config_find_str(pv->child, "id", NULL)))
continue;
- if (nuke_empty &&
+ if (mode == REMOVE_EMPTY &&
(vgid_old = dm_hash_lookup(s->pvid_to_vgid, pvid)) &&
!dm_hash_insert(to_check, vgid_old, (void*) 1))
goto out;
+ if (mode == MARK_OUTDATED)
+ mark_outdated_pv(s, vgid, pvid);
+
if (!dm_hash_insert(s->pvid_to_vgid, pvid, (void*) vgid))
goto out;
@@ -599,10 +656,11 @@ static int update_pvid_to_vgid(lvmetad_state *s, struct dm_config_tree *vg,
/* A pvid map lock needs to be held if update_pvids = 1. */
static int remove_metadata(lvmetad_state *s, const char *vgid, int update_pvids)
{
- struct dm_config_tree *old;
+ struct dm_config_tree *old, *outdated_pvs;
const char *oldname;
lock_vgid_to_metadata(s);
old = dm_hash_lookup(s->vgid_to_metadata, vgid);
+ outdated_pvs = dm_hash_lookup(s->vgid_to_outdated_pvs, vgid);
oldname = dm_hash_lookup(s->vgid_to_vgname, vgid);
if (!old) {
@@ -616,12 +674,15 @@ static int remove_metadata(lvmetad_state *s, const char *vgid, int update_pvids)
dm_hash_remove(s->vgid_to_metadata, vgid);
dm_hash_remove(s->vgid_to_vgname, vgid);
dm_hash_remove(s->vgname_to_vgid, oldname);
+ dm_hash_remove(s->vgid_to_outdated_pvs, vgid);
unlock_vgid_to_metadata(s);
if (update_pvids)
/* FIXME: What should happen when update fails */
update_pvid_to_vgid(s, old, "#orphan", 0);
dm_config_destroy(old);
+ if (outdated_pvs)
+ dm_config_destroy(outdated_pvs);
return 1;
}
@@ -665,7 +726,7 @@ static int vg_remove_if_missing(lvmetad_state *s, const char *vgid, int update_p
* this function, so they can be safely destroyed after update_metadata returns
* (anything that might have been retained is copied). */
static int update_metadata(lvmetad_state *s, const char *name, const char *_vgid,
- struct dm_config_node *metadata, int64_t *oldseq)
+ struct dm_config_node *metadata, int64_t *oldseq, const char *pvid)
{
struct dm_config_tree *cft = NULL;
struct dm_config_tree *old;
@@ -714,6 +775,10 @@ static int update_metadata(lvmetad_state *s, const char *name, const char *_vgid
if (seq < haveseq) {
DEBUGLOG(s, "Refusing to update metadata for %s (at %d) to %d", _vgid, haveseq, seq);
+
+ if (pvid)
+ mark_outdated_pv(s, dm_config_find_str(old->root, "metadata/id", NULL), pvid);
+
/* TODO: notify the client that their metadata is out of date? */
retval = 1;
goto out;
@@ -736,6 +801,8 @@ static int update_metadata(lvmetad_state *s, const char *name, const char *_vgid
if (haveseq >= 0 && haveseq < seq) {
INFO(s, "Updating metadata for %s at %d to %d", _vgid, haveseq, seq);
+ if (oldseq)
+ update_pvid_to_vgid(s, old, vgid, MARK_OUTDATED);
/* temporarily orphan all of our PVs */
update_pvid_to_vgid(s, old, "#orphan", 0);
}
@@ -992,7 +1059,7 @@ out_of_mem:
if (daemon_request_int(r, "metadata/seqno", -1) < 0)
return reply_fail("need VG seqno");
- if (!update_metadata(s, vgname, vgid, metadata, &seqno_old))
+ if (!update_metadata(s, vgname, vgid, metadata, &seqno_old, pvid))
return reply_fail("metadata update failed");
changed |= (seqno_old != dm_config_find_int(metadata, "metadata/seqno", -1));
} else {
@@ -1055,7 +1122,7 @@ static response vg_update(lvmetad_state *s, request r)
/* TODO defer metadata update here; add a separate vg_commit
* call; if client does not commit, die */
- if (!update_metadata(s, vgname, vgid, metadata, NULL))
+ if (!update_metadata(s, vgname, vgid, metadata, NULL, NULL))
return reply_fail("metadata update failed");
}
return daemon_reply_simple("OK", NULL);
@@ -1136,6 +1203,9 @@ static response dump(lvmetad_state *s)
buffer_append(b, "\n# VGID to VGNAME mapping\n\n");
_dump_pairs(b, s->vgid_to_vgname, "vgid_to_vgname", 0);
+ buffer_append(b, "\n# VGID to outdated PVs mapping\n\n");
+ _dump_cft(b, s->vgid_to_outdated_pvs, "outdated_pvs/vgid");
+
buffer_append(b, "\n# VGNAME to VGID mapping\n\n");
_dump_pairs(b, s->vgname_to_vgid, "vgname_to_vgid", 0);
8 years, 11 months
master - makefiles: use bash subshell
by Zdenek Kabelac
Gitweb: http://git.fedorahosted.org/git/?p=lvm2.git;a=commitdiff;h=f3c7bd4004a64b...
Commit: f3c7bd4004a64b6ce2c9e0f0069eedb050420c62
Parent: 682e0c898e7fd96ff936b7113738f773335e0fff
Author: Zdenek Kabelac <zkabelac(a)redhat.com>
AuthorDate: Wed May 20 09:25:50 2015 +0200
Committer: Zdenek Kabelac <zkabelac(a)redhat.com>
CommitterDate: Wed May 20 09:33:51 2015 +0200
makefiles: use bash subshell
Avoid using make's $(shell invocation since the eval order is
then somewhat different and use $$( subshell.
This also fixes a problem when more then one symbol is found,
since target shell has been given separate word list
so the 'R' assignment would need "" around it.
---
make.tmpl.in | 2 +-
1 files changed, 1 insertions(+), 1 deletions(-)
diff --git a/make.tmpl.in b/make.tmpl.in
index 806bde4..731dab7 100644
--- a/make.tmpl.in
+++ b/make.tmpl.in
@@ -499,7 +499,7 @@ ifeq (,$(firstword $(EXPORTED_SYMBOLS)))
echo " local:"; echo " *;"; echo "};") > $@
else
set -e;\
- R=$(shell sort $^ | uniq -u);\
+ R=$$(sort $^ | uniq -u);\
test -z "$$R" || { echo "Mismatch between symbols in shared library and lists in .exported_symbols.* files: $$R"; false; } ;\
for i in $(EXPORTED_SYMBOLS); do\
echo "$${i##*.} {"; echo " global:";\
8 years, 11 months