summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDavid Teigland <teigland@redhat.com>2019-02-06 14:56:27 -0600
committerDavid Teigland <teigland@redhat.com>2019-04-09 15:18:06 -0500
commitf279f85d2404ef619b06b3880de0895e7b959b67 (patch)
tree2b8ada8c403d1d692b9b4e522c41822857309b2d
parent441ef658641f279cac7d8afbd41d451ef1f8fcd7 (diff)
downloadlvm2-dev-dct-read-13.tar.gz
remove unused or moved codedev-dct-read-13
this would have been done as part of the prior commit, but 'diff' was becoming confused and made as mess.
-rw-r--r--lib/metadata/metadata.c377
1 files changed, 2 insertions, 375 deletions
diff --git a/lib/metadata/metadata.c b/lib/metadata/metadata.c
index fb59a5cec..88fa9b481 100644
--- a/lib/metadata/metadata.c
+++ b/lib/metadata/metadata.c
@@ -3138,6 +3138,7 @@ void vg_revert(struct volume_group *vg)
}
}
+#if 0
static int _check_mda_in_use(struct metadata_area *mda, void *_in_use)
{
int *in_use = _in_use;
@@ -3145,6 +3146,7 @@ static int _check_mda_in_use(struct metadata_area *mda, void *_in_use)
*in_use = 1;
return 1;
}
+#endif
struct _vg_read_orphan_baton {
struct cmd_context *cmd;
@@ -3389,186 +3391,6 @@ int vg_missing_pv_count(const struct volume_group *vg)
return ret;
}
-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
- * PVs, especially since the resulting messages can be pretty
- * confusing.
- */
- if (correct_vg->cmd->handles_missing_pvs)
- return rv;
-
- /*
- * Skip this if there is no underlying device present for this PV.
- */
- if (!pv->dev)
- return rv;
-
- dm_list_iterate_items(pvl, &correct_vg->pvs)
- if (pv->dev == pvl->pv->dev && is_missing_pv(pvl->pv)) {
- if (act)
- log_warn("WARNING: 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) {
- if (act) {
- pv->status &= ~MISSING_PV;
- pvl->pv->status &= ~MISSING_PV;
- }
- ++ rv;
- } else if (act)
- log_warn("WARNING: Device %s still marked missing because of allocated data "
- "on it, remove volumes and consider vgreduce --removemissing.",
- pv_dev_name(pvl->pv));
- }
-
- return rv;
-}
-
-#define DEV_LIST_DELIM ", "
-
-static int _check_devs_used_correspond_with_lv(struct dm_pool *mem, struct dm_list *list, struct logical_volume *lv)
-{
- struct device_list *dl;
- int found_inconsistent = 0;
- struct device *dev;
- struct lv_segment *seg;
- uint32_t s;
- int warned_about_no_dev = 0;
- char *used_devnames = NULL, *assumed_devnames = NULL;
-
- if (!(list = dev_cache_get_dev_list_for_lvid(lv->lvid.s + ID_LEN)))
- return 1;
-
- dm_list_iterate_items(dl, list) {
- dev = dl->dev;
- if (!(dev->flags & DEV_ASSUMED_FOR_LV)) {
- if (!found_inconsistent) {
- if (!dm_pool_begin_object(mem, 32))
- return_0;
- found_inconsistent = 1;
- } else {
- if (!dm_pool_grow_object(mem, DEV_LIST_DELIM, sizeof(DEV_LIST_DELIM) - 1))
- return_0;
- }
- if (!dm_pool_grow_object(mem, dev_name(dev), 0))
- return_0;
- }
- }
-
- if (!found_inconsistent)
- return 1;
-
- if (!dm_pool_grow_object(mem, "\0", 1))
- return_0;
- used_devnames = dm_pool_end_object(mem);
-
- found_inconsistent = 0;
- dm_list_iterate_items(seg, &lv->segments) {
- for (s = 0; s < seg->area_count; s++) {
- if (seg_type(seg, s) == AREA_PV) {
- if (!(dev = seg_dev(seg, s))) {
- if (!warned_about_no_dev) {
- log_warn("WARNING: Couldn't find all devices for LV %s "
- "while checking used and assumed devices.",
- display_lvname(lv));
- warned_about_no_dev = 1;
- }
- continue;
- }
- if (!(dev->flags & DEV_USED_FOR_LV)) {
- if (!found_inconsistent) {
- if (!dm_pool_begin_object(mem, 32))
- return_0;
- found_inconsistent = 1;
- } else {
- if (!dm_pool_grow_object(mem, DEV_LIST_DELIM, sizeof(DEV_LIST_DELIM) - 1))
- return_0;
- }
- if (!dm_pool_grow_object(mem, dev_name(dev), 0))
- return_0;
- }
- }
- }
- }
-
- if (found_inconsistent) {
- if (!dm_pool_grow_object(mem, "\0", 1))
- return_0;
- assumed_devnames = dm_pool_end_object(mem);
- log_warn("WARNING: Device mismatch detected for %s which is accessing %s instead of %s.",
- display_lvname(lv), used_devnames, assumed_devnames);
- }
-
- return 1;
-}
-
-static int _check_devs_used_correspond_with_vg(struct volume_group *vg)
-{
- struct dm_pool *mem;
- char vgid[ID_LEN + 1];
- struct pv_list *pvl;
- struct lv_list *lvl;
- struct dm_list *list;
- struct device_list *dl;
- int found_inconsistent = 0;
-
- if (is_orphan_vg(vg->name))
- return 1;
-
- strncpy(vgid, (const char *) vg->id.uuid, sizeof(vgid));
- vgid[ID_LEN] = '\0';
-
- /* Mark all PVs in VG as used. */
- dm_list_iterate_items(pvl, &vg->pvs) {
- /*
- * FIXME: It's not clear if the meaning
- * of "missing" should always include the
- * !pv->dev case, or if "missing" is the
- * more narrow case where VG metadata has
- * been written with the MISSING flag.
- */
- if (!pvl->pv->dev)
- continue;
- if (is_missing_pv(pvl->pv))
- continue;
- pvl->pv->dev->flags |= DEV_ASSUMED_FOR_LV;
- }
-
- if (!(list = dev_cache_get_dev_list_for_vgid(vgid)))
- return 1;
-
- dm_list_iterate_items(dl, list) {
- if (!(dl->dev->flags & DEV_OPEN_FAILURE) &&
- !(dl->dev->flags & DEV_ASSUMED_FOR_LV)) {
- found_inconsistent = 1;
- break;
- }
- }
-
- if (found_inconsistent) {
- if (!(mem = dm_pool_create("vg_devs_check", 1024)))
- return_0;
-
- dm_list_iterate_items(lvl, &vg->lvs) {
- if (!_check_devs_used_correspond_with_lv(mem, list, lvl->lv)) {
- dm_pool_destroy(mem);
- return_0;
- }
- }
-
- dm_pool_destroy(mem);
- }
-
- return 1;
-}
-
void free_pv_fid(struct physical_volume *pv)
{
if (!pv)
@@ -3855,25 +3677,6 @@ int vg_flag_write_locked(struct volume_group *vg)
return 0;
}
-static int _access_vg_clustered(struct cmd_context *cmd, const struct volume_group *vg)
-{
- if (vg_is_clustered(vg)) {
- /*
- * force_access_clustered is only set when forcibly
- * converting a clustered vg to lock type none.
- */
- if (cmd->force_access_clustered) {
- log_debug("Allowing forced access to clustered vg %s", vg->name);
- return 1;
- }
-
- log_verbose("Skipping clustered VG %s.", vg->name);
- return 0;
- }
-
- return 1;
-}
-
/*
* Performs a set of checks against a VG according to bits set in status
* and returns FAILED_* bits for those that aren't acceptable.
@@ -3915,182 +3718,6 @@ int vg_check_status(const struct volume_group *vg, uint64_t status)
return !vg_bad_status_bits(vg, status);
}
-static int _allow_extra_system_id(struct cmd_context *cmd, const char *system_id)
-{
- const struct dm_config_node *cn;
- const struct dm_config_value *cv;
- const char *str;
-
- if (!(cn = find_config_tree_array(cmd, local_extra_system_ids_CFG, NULL)))
- return 0;
-
- for (cv = cn->v; cv; cv = cv->next) {
- if (cv->type == DM_CFG_EMPTY_ARRAY)
- break;
- /* Ignore invalid data: Warning message already issued by config.c */
- if (cv->type != DM_CFG_STRING)
- continue;
- str = cv->v.str;
- if (!*str)
- continue;
-
- if (!strcmp(str, system_id))
- return 1;
- }
-
- return 0;
-}
-
-static int _access_vg_lock_type(struct cmd_context *cmd, struct volume_group *vg,
- uint32_t lockd_state, uint32_t *failure)
-{
- if (!is_real_vg(vg->name))
- return 1;
-
- if (cmd->lockd_vg_disable)
- return 1;
-
- /*
- * Local VG requires no lock from lvmlockd.
- */
- if (!vg_is_shared(vg))
- return 1;
-
- /*
- * When lvmlockd is not used, lockd VGs are ignored by lvm
- * and cannot be used, with two exceptions:
- *
- * . The --shared option allows them to be revealed with
- * reporting/display commands.
- *
- * . If a command asks to operate on one specifically
- * by name, then an error is printed.
- */
- if (!lvmlockd_use()) {
- /*
- * Some reporting/display commands have the --shared option
- * (like --foreign) to allow them to reveal lockd VGs that
- * are otherwise ignored. The --shared option must only be
- * permitted in commands that read the VG for report or display,
- * not any that write the VG or activate LVs.
- */
- if (cmd->include_shared_vgs)
- return 1;
-
- /*
- * Some commands want the error printed by vg_read, others by ignore_vg.
- * Those using ignore_vg may choose to skip the error.
- */
- if (cmd->vg_read_print_access_error) {
- log_error("Cannot access VG %s with lock type %s that requires lvmlockd.",
- vg->name, vg->lock_type);
- }
-
- *failure |= FAILED_LOCK_TYPE;
- return 0;
- }
-
- /*
- * The lock request from lvmlockd failed. If the lock was ex,
- * we cannot continue. If the lock was sh, we could also fail
- * to continue but since the lock was sh, it means the VG is
- * only being read, and it doesn't hurt to allow reading with
- * no lock.
- */
- if (lockd_state & LDST_FAIL) {
- if ((lockd_state & LDST_EX) || cmd->lockd_vg_enforce_sh) {
- log_error("Cannot access VG %s due to failed lock.", vg->name);
- *failure |= FAILED_LOCK_MODE;
- return 0;
- }
-
- log_warn("Reading VG %s without a lock.", vg->name);
- return 1;
- }
-
- if (test_mode()) {
- log_error("Test mode is not yet supported with lock type %s.", vg->lock_type);
- return 0;
- }
-
- return 1;
-}
-
-static int _access_vg_systemid(struct cmd_context *cmd, struct volume_group *vg)
-{
- /*
- * A few commands allow read-only access to foreign VGs.
- */
- if (cmd->include_foreign_vgs)
- return 1;
-
- if (is_system_id_allowed(cmd, vg->system_id))
- return 1;
-
- /*
- * Allow VG access if the local host has active LVs in it.
- */
- if (lvs_in_vg_activated(vg)) {
- log_warn("WARNING: Found LVs active in VG %s with foreign system ID %s. Possible data corruption.",
- vg->name, vg->system_id);
- if (cmd->include_active_foreign_vgs)
- return 1;
- return 0;
- }
-
- /*
- * Print an error when reading a VG that has a system_id
- * and the host system_id is unknown.
- */
- if (!cmd->system_id || cmd->unknown_system_id) {
- log_error("Cannot access VG %s with system ID %s with unknown local system ID.",
- vg->name, vg->system_id);
- return 0;
- }
-
- /*
- * Some commands want the error printed by vg_read, others by ignore_vg.
- * Those using ignore_vg may choose to skip the error.
- */
- if (cmd->vg_read_print_access_error) {
- log_error("Cannot access VG %s with system ID %s with local system ID %s.",
- vg->name, vg->system_id, cmd->system_id);
- return 0;
- }
-
- /* Silently ignore foreign vgs. */
-
- return 0;
-}
-
-/*
- * FIXME: move vg_bad_status_bits() checks in here.
- */
-static int _vg_access_permitted(struct cmd_context *cmd, struct volume_group *vg,
- uint32_t lockd_state, uint32_t *failure)
-{
- if (!is_real_vg(vg->name)) {
- return 1;
- }
-
- if (!_access_vg_clustered(cmd, vg)) {
- *failure |= FAILED_CLUSTERED;
- return 0;
- }
-
- if (!_access_vg_lock_type(cmd, vg, lockd_state, failure)) {
- /* Either FAILED_LOCK_TYPE or FAILED_LOCK_MODE were set. */
- return 0;
- }
-
- if (!_access_vg_systemid(cmd, vg)) {
- *failure |= FAILED_SYSTEMID;
- return 0;
- }
-
- return 1;
-}
-
/*
* Test the validity of a VG handle returned by vg_read() or vg_read_for_update().
* FIXME: drop this function