From 6222635b38dd6c8c68cecef3679fa73e96e92411 Mon Sep 17 00:00:00 2001 From: Zdenek Kabelac Date: Fri, 21 May 2010 12:55:25 +0000 Subject: [PATCH] Replicator: add find_replicator_vgs Adding find_replicator_vgs() function to find all needed VGs for replicator-dev LV. This function is later called before taking lock_vol(). --- WHATS_NEW | 1 + lib/metadata/metadata-exported.h | 2 ++ lib/metadata/replicator_manip.c | 32 ++++++++++++++++++++++++++++++++ 3 files changed, 35 insertions(+) diff --git a/WHATS_NEW b/WHATS_NEW index d0539c462..0b8d7fb44 100644 --- a/WHATS_NEW +++ b/WHATS_NEW @@ -1,5 +1,6 @@ Version 2.02.67 - =============================== + Add find_replicator_vgs() to discover all needed VGs for replicator-dev LV. Add functions for handling cmd_vg structure. Extend _lv_each_dependency() with Replicator dependencies. Add check_replicator_segment() for catching internal Replicator errors. diff --git a/lib/metadata/metadata-exported.h b/lib/metadata/metadata-exported.h index 37732a58d..5fde3835a 100644 --- a/lib/metadata/metadata-exported.h +++ b/lib/metadata/metadata-exported.h @@ -815,6 +815,8 @@ struct cmd_vg *cmd_vg_lookup(struct dm_list *cmd_vgs, int cmd_vg_read(struct cmd_context *cmd, struct dm_list *cmd_vgs); void cmd_vg_release(struct dm_list *cmd_vgs); +int find_replicator_vgs(struct logical_volume *lv); + struct logical_volume *find_pvmove_lv(struct volume_group *vg, struct device *dev, uint32_t lv_type); struct logical_volume *find_pvmove_lv_from_pvname(struct cmd_context *cmd, diff --git a/lib/metadata/replicator_manip.c b/lib/metadata/replicator_manip.c index 9bab6385c..dc14755e2 100644 --- a/lib/metadata/replicator_manip.c +++ b/lib/metadata/replicator_manip.c @@ -602,3 +602,35 @@ void cmd_vg_release(struct dm_list *cmd_vgs) cvl->vg = NULL; } } + +/** + * Find all needed remote VGs for processing given LV. + * Missing VGs are added to VG's cmd_vg list and flag cmd_missing_vgs is set. + */ +int find_replicator_vgs(struct logical_volume *lv) +{ + struct replicator_site *rsite; + int ret = 1; + + if (!lv_is_replicator_dev(lv)) + return 1; + + dm_list_iterate_items(rsite, &first_seg(lv)->replicator->rsites) { + if (!rsite->vg_name || !lv->vg->cmd_vgs || + cmd_vg_lookup(lv->vg->cmd_vgs, rsite->vg_name, NULL)) + continue; + ret = 0; + /* Using cmd memory pool for cmd_vg list allocation */ + if (!cmd_vg_add(lv->vg->cmd->mem, lv->vg->cmd_vgs, + rsite->vg_name, NULL, 0)) { + lv->vg->cmd_missing_vgs = 0; /* do not retry */ + stack; + break; + } + + log_debug("VG: %s added as missing.", rsite->vg_name); + lv->vg->cmd_missing_vgs++; + } + + return ret; +}