master - Remove vgconvert
by David Teigland
Gitweb: https://sourceware.org/git/?p=lvm2.git;a=commitdiff;h=5fca75877d8af5fe6f2...
Commit: 5fca75877d8af5fe6f277159490eda4817740060
Parent: 22c5467add88268554a7d163a26892166dbc3104
Author: David Teigland <teigland(a)redhat.com>
AuthorDate: Wed Jun 13 14:12:46 2018 -0500
Committer: David Teigland <teigland(a)redhat.com>
CommitterDate: Wed Jun 13 14:14:03 2018 -0500
Remove vgconvert
it has no use without lvm1
---
man/vgconvert.8_des | 6 +-
tools/Makefile.in | 1 -
tools/command-lines.in | 15 ++---
tools/stub.h | 9 +++
tools/vgconvert.c | 151 ------------------------------------------------
5 files changed, 19 insertions(+), 163 deletions(-)
diff --git a/man/vgconvert.8_des b/man/vgconvert.8_des
index 8519063..eb5a006 100644
--- a/man/vgconvert.8_des
+++ b/man/vgconvert.8_des
@@ -1,3 +1,3 @@
-vgconvert converts VG metadata from one format to another. This command
-is no longer used because this version of lvm no longer supports the LVM1
-format.
+vgconvert is no longer a part of LVM. It was removed along with
+support for the LVM1 format. Use an older version of LVM to
+convert VGs from the LVM1 format to LVM2.
diff --git a/tools/Makefile.in b/tools/Makefile.in
index 9742842..3785b50 100644
--- a/tools/Makefile.in
+++ b/tools/Makefile.in
@@ -52,7 +52,6 @@ SOURCES =\
vgchange.c \
vgck.c \
vgcreate.c \
- vgconvert.c \
vgdisplay.c \
vgexport.c \
vgextend.c \
diff --git a/tools/command-lines.in b/tools/command-lines.in
index ad710a4..0f9ed47 100644
--- a/tools/command-lines.in
+++ b/tools/command-lines.in
@@ -1548,14 +1548,6 @@ ID: vgck_general
---
-vgconvert VG ...
-OO: --force, --labelsector Number, --bootloaderareasize SizeMB,
---metadatatype MetadataType, --pvmetadatacopies MetadataCopiesPV,
---metadatasize SizeMB, --reportformat ReportFmt
-ID: vgconvert_general
-
----
-
vgcreate VG_new PV ...
OO: --addtag Tag, --alloc Alloc, --autobackup Bool, --clustered Bool, --maxlogicalvolumes Uint32,
--maxphysicalvolumes Uint32, --metadataprofile String, --metadatatype MetadataType,
@@ -1783,3 +1775,10 @@ lvmsar
OO: --full, --stdin
ID: lvmsar_general
+# deprecated
+vgconvert VG ...
+OO: --force, --labelsector Number, --bootloaderareasize SizeMB,
+--metadatatype MetadataType, --pvmetadatacopies MetadataCopiesPV,
+--metadatasize SizeMB, --reportformat ReportFmt
+ID: vgconvert_general
+
diff --git a/tools/stub.h b/tools/stub.h
index 1d58387..fcfc189 100644
--- a/tools/stub.h
+++ b/tools/stub.h
@@ -48,3 +48,12 @@ int lvmchange(struct cmd_context *cmd __attribute__((unused)),
log_error("Use 'dmsetup' commands to reset the kernel device-mapper driver.");
return ECMD_FAILED;
}
+
+int vgconvert(struct cmd_context *cmd __attribute__((unused)),
+ int argc __attribute__((unused)),
+ char **argv __attribute__((unused)))
+{
+ log_error("The vgconvert command has been removed along with the lvm1 format.");
+ log_error("Use a previous version of lvm to convert the lvm1 format to lvm2.");
+ return ECMD_FAILED;
+}
diff --git a/tools/vgconvert.c b/tools/vgconvert.c
deleted file mode 100644
index ca9615c..0000000
--- a/tools/vgconvert.c
+++ /dev/null
@@ -1,151 +0,0 @@
-/*
- * Copyright (C) 2001-2004 Sistina Software, Inc. All rights reserved.
- * Copyright (C) 2004-2007 Red Hat, Inc. All rights reserved.
- *
- * This file is part of LVM2.
- *
- * 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 Lesser General Public License v.2.1.
- *
- * You should have received a copy of the GNU Lesser General Public License
- * along with this program; if not, write to the Free Software Foundation,
- * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
- */
-
-#include "tools.h"
-
-static int _vgconvert_single(struct cmd_context *cmd, const char *vg_name,
- struct volume_group *vg,
- struct processing_handle *handle __attribute__((unused)))
-{
- struct pv_create_args pva = { 0 };
- struct logical_volume *lv;
- struct lv_list *lvl;
- struct lvinfo info;
- int active = 0;
-
- if (!vg_check_status(vg, LVM_WRITE | EXPORTED_VG))
- return_ECMD_FAILED;
-
- if (vg->fid->fmt == cmd->fmt) {
- log_error("Volume group \"%s\" already uses format %s",
- vg_name, cmd->fmt->name);
- return ECMD_FAILED;
- }
-
- if (arg_sign_value(cmd, metadatasize_ARG, SIGN_NONE) == SIGN_MINUS) {
- log_error("Metadata size may not be negative");
- return EINVALID_CMD_LINE;
- }
-
- pva.pvmetadatasize = arg_uint64_value(cmd, metadatasize_ARG, UINT64_C(0));
- if (!pva.pvmetadatasize)
- pva.pvmetadatasize = find_config_tree_int(cmd, metadata_pvmetadatasize_CFG, NULL);
-
- pva.pvmetadatacopies = arg_int_value(cmd, pvmetadatacopies_ARG, -1);
- if (pva.pvmetadatacopies < 0)
- pva.pvmetadatacopies = find_config_tree_int(cmd, metadata_pvmetadatacopies_CFG, NULL);
-
- if (arg_sign_value(cmd, bootloaderareasize_ARG, SIGN_NONE) == SIGN_MINUS) {
- log_error("Bootloader area size may not be negative");
- return EINVALID_CMD_LINE;
- }
-
- pva.ba_size = arg_uint64_value(cmd, bootloaderareasize_ARG, UINT64_C(0));
-
- if (!vg_check_new_extent_size(cmd->fmt, vg->extent_size))
- return_ECMD_FAILED;
-
- if (!archive(vg)) {
- log_error("Archive of \"%s\" metadata failed.", vg_name);
- return ECMD_FAILED;
- }
-
- /* Set PV/LV limit if converting from unlimited metadata format */
- if (vg->fid->fmt->features & FMT_UNLIMITED_VOLS &&
- !(cmd->fmt->features & FMT_UNLIMITED_VOLS)) {
- if (!vg->max_lv)
- vg->max_lv = 255;
- if (!vg->max_pv)
- vg->max_pv = 255;
- }
-
- /* If converting to restricted lvid, check if lvid is compatible */
- if (!(vg->fid->fmt->features & FMT_RESTRICTED_LVIDS) &&
- cmd->fmt->features & FMT_RESTRICTED_LVIDS)
- dm_list_iterate_items(lvl, &vg->lvs)
- if (!lvid_in_restricted_range(&lvl->lv->lvid)) {
- log_error("Logical volume %s lvid format is"
- " incompatible with requested"
- " metadata format.", lvl->lv->name);
- return ECMD_FAILED;
- }
-
- /* Attempt to change any LVIDs that are too big */
- if (cmd->fmt->features & FMT_RESTRICTED_LVIDS) {
- dm_list_iterate_items(lvl, &vg->lvs) {
- lv = lvl->lv;
- if (lv_is_snapshot(lv))
- continue;
- if (lvnum_from_lvid(&lv->lvid) < MAX_RESTRICTED_LVS)
- continue;
- if (lv_info(cmd, lv, 0, &info, 0, 0) && info.exists) {
- log_error("Logical volume %s must be "
- "deactivated before conversion.",
- lv->name);
- active++;
- continue;
- }
- lvid_from_lvnum(&lv->lvid, &lv->vg->id, find_free_lvnum(lv));
-
- }
- }
-
- if (active)
- return_ECMD_FAILED;
-
- /* FIXME Cache the label format change so we don't have to skip this */
- if (test_mode()) {
- log_verbose("Test mode: Skipping metadata writing for VG %s in"
- " format %s", vg_name, cmd->fmt->name);
- return ECMD_PROCESSED;
- }
-
- log_verbose("Writing metadata for VG %s using format %s", vg_name,
- cmd->fmt->name);
-
- if (!backup_restore_vg(cmd, vg, 1, &pva)) {
- log_error("Conversion failed for volume group %s.", vg_name);
- log_error("Use pvcreate and vgcfgrestore to repair from "
- "archived metadata.");
- return ECMD_FAILED;
- }
- log_print_unless_silent("Volume group %s successfully converted", vg_name);
-
- backup(vg);
-
- return ECMD_PROCESSED;
-}
-
-int vgconvert(struct cmd_context *cmd, int argc, char **argv)
-{
- if (!argc) {
- log_error("Please enter volume group(s)");
- return EINVALID_CMD_LINE;
- }
-
- if (arg_is_set(cmd, metadatatype_ARG) && lvmetad_used()) {
- log_error("lvmetad must be disabled to change metadata types.");
- return EINVALID_CMD_LINE;
- }
-
- if (arg_int_value(cmd, labelsector_ARG, 0) >= LABEL_SCAN_SECTORS) {
- log_error("labelsector must be less than %lu",
- LABEL_SCAN_SECTORS);
- return EINVALID_CMD_LINE;
- }
-
- return process_each_vg(cmd, argc, argv, NULL, NULL, READ_FOR_UPDATE, 0, NULL,
- &_vgconvert_single);
-}
6 years
master - filters: remove cache file in persistent filter
by David Teigland
Gitweb: https://sourceware.org/git/?p=lvm2.git;a=commitdiff;h=22c5467add88268554a...
Commit: 22c5467add88268554a7d163a26892166dbc3104
Parent: 17f5572bc972c932bcf62fc2bff3029268ae0109
Author: David Teigland <teigland(a)redhat.com>
AuthorDate: Wed Jun 13 14:00:47 2018 -0500
Committer: David Teigland <teigland(a)redhat.com>
CommitterDate: Wed Jun 13 14:00:47 2018 -0500
filters: remove cache file in persistent filter
It creates problems because it's not always correct,
and it doesn't actually help much.
---
lib/commands/toolcontext.c | 37 +------
lib/commands/toolcontext.h | 1 -
lib/config/config_settings.h | 17 +--
lib/filters/filter-composite.c | 13 --
lib/filters/filter-persistent.c | 233 +--------------------------------------
lib/filters/filter.h | 6 +-
6 files changed, 8 insertions(+), 299 deletions(-)
diff --git a/lib/commands/toolcontext.c b/lib/commands/toolcontext.c
index 8c18fc6..a76c68d 100644
--- a/lib/commands/toolcontext.c
+++ b/lib/commands/toolcontext.c
@@ -1195,20 +1195,15 @@ bad:
*/
int init_filters(struct cmd_context *cmd, unsigned load_persistent_cache)
{
- const char *dev_cache;
struct dev_filter *filter = NULL, *filter_components[2] = {0};
int nr_filt;
- struct stat st;
const struct dm_config_node *cn;
- struct timespec ts, cts;
if (!cmd->initialized.connections) {
log_error(INTERNAL_ERROR "connections must be initialized before filters");
return 0;
}
- cmd->dump_filter = 0;
-
cmd->lvmetad_filter = _init_lvmetad_filter_chain(cmd);
if (!cmd->lvmetad_filter)
goto_bad;
@@ -1246,10 +1241,7 @@ int init_filters(struct cmd_context *cmd, unsigned load_persistent_cache)
cmd->lvmetad_filter = NULL;
}
- if (!(dev_cache = find_config_tree_str(cmd, devices_cache_CFG, NULL)))
- goto_bad;
-
- if (!(filter = persistent_filter_create(cmd->dev_types, filter, dev_cache))) {
+ if (!(filter = persistent_filter_create(cmd->dev_types, filter))) {
log_verbose("Failed to create persistent device filter.");
goto bad;
}
@@ -1267,29 +1259,6 @@ int init_filters(struct cmd_context *cmd, unsigned load_persistent_cache)
} else
cmd->full_filter = filter;
- /* Should we ever dump persistent filter state? */
- if (find_config_tree_bool(cmd, devices_write_cache_state_CFG, NULL))
- cmd->dump_filter = 1;
-
- if (!*cmd->system_dir)
- cmd->dump_filter = 0;
-
- /*
- * Only load persistent filter device cache on startup if it is newer
- * than the config file and this is not a long-lived process. Also avoid
- * it when lvmetad is enabled.
- */
- if (!find_config_tree_bool(cmd, global_use_lvmetad_CFG, NULL) &&
- load_persistent_cache && !cmd->is_long_lived &&
- !stat(dev_cache, &st)) {
- lvm_stat_ctim(&ts, &st);
- cts = config_file_timestamp(cmd->cft);
- if (timespeccmp(&ts, &cts, >) &&
- !persistent_filter_load(cmd->filter, NULL))
- log_verbose("Failed to load existing device cache from %s",
- dev_cache);
- }
-
cmd->initialized.filters = 1;
return 1;
bad:
@@ -2166,10 +2135,6 @@ void destroy_toolcontext(struct cmd_context *cmd)
struct dm_config_tree *cft_cmdline;
int flags;
- if (cmd->dump_filter && cmd->filter && cmd->filter->dump &&
- !cmd->filter->dump(cmd->filter, 1))
- stack;
-
archive_exit(cmd);
backup_exit(cmd);
lvmcache_destroy(cmd, 0, 0);
diff --git a/lib/commands/toolcontext.h b/lib/commands/toolcontext.h
index 18e1b7d..baecfbd 100644
--- a/lib/commands/toolcontext.h
+++ b/lib/commands/toolcontext.h
@@ -179,7 +179,6 @@ struct cmd_context {
struct dev_filter *lvmetad_filter; /* pre-lvmetad filter chain */
struct dev_filter *filter; /* post-lvmetad filter chain */
struct dev_filter *full_filter; /* lvmetad_filter + filter */
- int dump_filter; /* Dump filter when exiting? */
/*
* Configuration.
diff --git a/lib/config/config_settings.h b/lib/config/config_settings.h
index 8aa4879..a730afb 100644
--- a/lib/config/config_settings.h
+++ b/lib/config/config_settings.h
@@ -312,24 +312,17 @@ cfg_array(devices_global_filter_CFG, "global_filter", devices_CFG_SECTION, CFG_D
"The syntax is the same as devices/filter. Devices rejected by\n"
"global_filter are not opened by LVM.\n")
-cfg_runtime(devices_cache_CFG, "cache", devices_CFG_SECTION, 0, CFG_TYPE_STRING, vsn(1, 0, 0), vsn(1, 2, 19),
- "This has been replaced by the devices/cache_dir setting.\n",
- "Cache file path.\n")
+cfg_runtime(devices_cache_CFG, "cache", devices_CFG_SECTION, 0, CFG_TYPE_STRING, vsn(1, 0, 0), vsn(1, 2, 19), NULL,
+ "This setting is no longer used.\n")
cfg_runtime(devices_cache_dir_CFG, "cache_dir", devices_CFG_SECTION, 0, CFG_TYPE_STRING, vsn(1, 2, 19), 0, NULL,
- "Directory in which to store the device cache file.\n"
- "The results of filtering are cached on disk to avoid rescanning dud\n"
- "devices (which can take a very long time). By default this cache is\n"
- "stored in a file named .cache. It is safe to delete this file; the\n"
- "tools regenerate it. If obtain_device_list_from_udev is enabled, the\n"
- "list of devices is obtained from udev and any existing .cache file\n"
- "is removed.\n")
+ "This setting is no longer used.\n")
cfg(devices_cache_file_prefix_CFG, "cache_file_prefix", devices_CFG_SECTION, CFG_ALLOW_EMPTY, CFG_TYPE_STRING, DEFAULT_CACHE_FILE_PREFIX, vsn(1, 2, 19), NULL, 0, NULL,
- "A prefix used before the .cache file name. See devices/cache_dir.\n")
+ "This setting is no longer used.\n")
cfg(devices_write_cache_state_CFG, "write_cache_state", devices_CFG_SECTION, 0, CFG_TYPE_BOOL, 1, vsn(1, 0, 0), NULL, 0, NULL,
- "Enable/disable writing the cache file. See devices/cache_dir.\n")
+ "This setting is no longer used.\n")
cfg_array(devices_types_CFG, "types", devices_CFG_SECTION, CFG_DEFAULT_UNDEFINED | CFG_ADVANCED, CFG_TYPE_INT | CFG_TYPE_STRING, NULL, vsn(1, 0, 0), NULL, 0, NULL,
"List of additional acceptable block device types.\n"
diff --git a/lib/filters/filter-composite.c b/lib/filters/filter-composite.c
index 8691aeb..ba837af 100644
--- a/lib/filters/filter-composite.c
+++ b/lib/filters/filter-composite.c
@@ -58,18 +58,6 @@ static void _composite_destroy(struct dev_filter *f)
free(f);
}
-static int _dump(struct dev_filter *f, int merge_existing)
-{
- struct dev_filter **filters;
-
- for (filters = (struct dev_filter **) f->private; *filters; ++filters)
- if ((*filters)->dump &&
- !(*filters)->dump(*filters, merge_existing))
- return_0;
-
- return 1;
-}
-
static void _wipe(struct dev_filter *f)
{
struct dev_filter **filters;
@@ -102,7 +90,6 @@ struct dev_filter *composite_filter_create(int n, int use_dev_ext_info, struct d
cft->passes_filter = use_dev_ext_info ? _and_p_with_dev_ext_info : _and_p;
cft->destroy = _composite_destroy;
- cft->dump = _dump;
cft->wipe = _wipe;
cft->use_count = 0;
cft->private = filters_copy;
diff --git a/lib/filters/filter-persistent.c b/lib/filters/filter-persistent.c
index 643c349..9ee3957 100644
--- a/lib/filters/filter-persistent.c
+++ b/lib/filters/filter-persistent.c
@@ -17,13 +17,10 @@
#include "lib/misc/lib.h"
#include "lib/filters/filter.h"
#include "lib/config/config.h"
-#include "lib/misc/lvm-file.h"
struct pfilter {
- char *file;
struct dm_hash_table *devices;
struct dev_filter *real;
- struct timespec ctime;
struct dev_types *dt;
};
@@ -44,11 +41,6 @@ struct pfilter {
* times. A device should be checked against the filter once, and then not
* need to be checked again. With scanning now controlled, we could probably
* do this.
- *
- * FIXME: "persistent" isn't a great name for this caching filter. This filter
- * at one time saved its cache results to a file, which is how it got the name.
- * That .cache file does not work well, causes problems, and is no longer used
- * by default. The old code for it should be removed.
*/
/*
@@ -76,214 +68,6 @@ static void _persistent_filter_wipe(struct dev_filter *f)
dm_hash_wipe(pf->devices);
}
-static int _read_array(struct pfilter *pf, struct dm_config_tree *cft,
- const char *path, void *data)
-{
- const struct dm_config_node *cn;
- const struct dm_config_value *cv;
-
- if (!(cn = dm_config_find_node(cft->root, path))) {
- log_very_verbose("Couldn't find %s array in '%s'",
- path, pf->file);
- return 0;
- }
-
- /*
- * iterate through the array, adding
- * devices as we go.
- */
- for (cv = cn->v; cv; cv = cv->next) {
- if (cv->type != DM_CFG_STRING) {
- log_verbose("Devices array contains a value "
- "which is not a string ... ignoring");
- continue;
- }
-
- if (!dm_hash_insert(pf->devices, cv->v.str, data))
- log_verbose("Couldn't add '%s' to filter ... ignoring",
- cv->v.str);
- /* Populate dev_cache ourselves */
- dev_cache_get(cv->v.str, NULL);
- }
- return 1;
-}
-
-int persistent_filter_load(struct dev_filter *f, struct dm_config_tree **cft_out)
-{
- struct pfilter *pf = (struct pfilter *) f->private;
- struct dm_config_tree *cft;
- struct stat info;
- int r = 0;
-
- if (obtain_device_list_from_udev()) {
- if (!stat(pf->file, &info)) {
- log_very_verbose("Obtaining device list from udev. "
- "Removing obsolete %s.",
- pf->file);
- if (unlink(pf->file) < 0 && errno != EROFS)
- log_sys_error("unlink", pf->file);
- }
- return 1;
- }
-
- if (!stat(pf->file, &info))
- lvm_stat_ctim(&pf->ctime, &info);
- else {
- log_very_verbose("%s: stat failed: %s", pf->file,
- strerror(errno));
- return_0;
- }
-
- if (!(cft = config_open(CONFIG_FILE_SPECIAL, pf->file, 1)))
- return_0;
-
- if (!config_file_read(cft))
- goto_out;
-
- log_debug_devs("Loading persistent filter cache from %s", pf->file);
- _read_array(pf, cft, "persistent_filter_cache/valid_devices",
- PF_GOOD_DEVICE);
- /* We don't gain anything by holding invalid devices */
- /* _read_array(pf, cft, "persistent_filter_cache/invalid_devices",
- PF_BAD_DEVICE); */
-
- log_very_verbose("Loaded persistent filter cache from %s", pf->file);
-
- out:
- if (r && cft_out)
- *cft_out = cft;
- else
- config_destroy(cft);
- return r;
-}
-
-static void _write_array(struct pfilter *pf, FILE *fp, const char *path,
- void *data)
-{
- void *d;
- int first = 1;
- char buf[2 * PATH_MAX];
- struct dm_hash_node *n;
-
- for (n = dm_hash_get_first(pf->devices); n;
- n = dm_hash_get_next(pf->devices, n)) {
- d = dm_hash_get_data(pf->devices, n);
-
- if (d != data)
- continue;
-
- if (!first)
- fprintf(fp, ",\n");
- else {
- fprintf(fp, "\t%s=[\n", path);
- first = 0;
- }
-
- dm_escape_double_quotes(buf, dm_hash_get_key(pf->devices, n));
- fprintf(fp, "\t\t\"%s\"", buf);
- }
-
- if (!first)
- fprintf(fp, "\n\t]\n");
-}
-
-static int _persistent_filter_dump(struct dev_filter *f, int merge_existing)
-{
- struct pfilter *pf;
- char *tmp_file;
- struct stat info, info2;
- struct timespec ts;
- struct dm_config_tree *cft = NULL;
- FILE *fp;
- int lockfd;
- int r = 0;
-
- if (obtain_device_list_from_udev())
- return 1;
-
- if (!f)
- return_0;
- pf = (struct pfilter *) f->private;
-
- if (!dm_hash_get_num_entries(pf->devices)) {
- log_very_verbose("Internal persistent device cache empty "
- "- not writing to %s", pf->file);
- return 1;
- }
- if (!dev_cache_has_scanned()) {
- log_very_verbose("Device cache incomplete - not writing "
- "to %s", pf->file);
- return 0;
- }
-
- log_very_verbose("Dumping persistent device cache to %s", pf->file);
-
- while (1) {
- if ((lockfd = fcntl_lock_file(pf->file, F_WRLCK, 0)) < 0)
- return_0;
-
- /*
- * Ensure we locked the file we expected
- */
- if (fstat(lockfd, &info)) {
- log_sys_error("fstat", pf->file);
- goto out;
- }
- if (stat(pf->file, &info2)) {
- log_sys_error("stat", pf->file);
- goto out;
- }
-
- if (is_same_inode(info, info2))
- break;
-
- fcntl_unlock_file(lockfd);
- }
-
- /*
- * If file contents changed since we loaded it, merge new contents
- */
- lvm_stat_ctim(&ts, &info);
- if (merge_existing && timespeccmp(&ts, &pf->ctime, !=))
- /* Keep cft open to avoid losing lock */
- persistent_filter_load(f, &cft);
-
- tmp_file = alloca(strlen(pf->file) + 5);
- sprintf(tmp_file, "%s.tmp", pf->file);
-
- if (!(fp = fopen(tmp_file, "w"))) {
- /* EACCES has been reported over NFS */
- if (errno != EROFS && errno != EACCES)
- log_sys_error("fopen", tmp_file);
- goto out;
- }
-
- fprintf(fp, "# This file is automatically maintained by lvm.\n\n");
- fprintf(fp, "persistent_filter_cache {\n");
-
- _write_array(pf, fp, "valid_devices", PF_GOOD_DEVICE);
- /* We don't gain anything by remembering invalid devices */
- /* _write_array(pf, fp, "invalid_devices", PF_BAD_DEVICE); */
-
- fprintf(fp, "}\n");
- if (lvm_fclose(fp, tmp_file))
- goto_out;
-
- if (rename(tmp_file, pf->file))
- log_error("%s: rename to %s failed: %s", tmp_file, pf->file,
- strerror(errno));
-
- r = 1;
-
-out:
- fcntl_unlock_file(lockfd);
-
- if (cft)
- config_destroy(cft);
-
- return r;
-}
-
static int _lookup_p(struct dev_filter *f, struct device *dev)
{
struct pfilter *pf = (struct pfilter *) f->private;
@@ -361,19 +145,15 @@ static void _persistent_destroy(struct dev_filter *f)
log_error(INTERNAL_ERROR "Destroying persistent filter while in use %u times.", f->use_count);
dm_hash_destroy(pf->devices);
- free(pf->file);
pf->real->destroy(pf->real);
free(pf);
free(f);
}
-struct dev_filter *persistent_filter_create(struct dev_types *dt,
- struct dev_filter *real,
- const char *file)
+struct dev_filter *persistent_filter_create(struct dev_types *dt, struct dev_filter *real)
{
struct pfilter *pf;
struct dev_filter *f = NULL;
- struct stat info;
if (!(pf = zalloc(sizeof(*pf)))) {
log_error("Allocation of persistent filter failed.");
@@ -382,11 +162,6 @@ struct dev_filter *persistent_filter_create(struct dev_types *dt,
pf->dt = dt;
- if (!(pf->file = strdup(file))) {
- log_error("Filename duplication for persistent filter failed.");
- goto bad;
- }
-
pf->real = real;
if (!(_init_hash(pf))) {
@@ -399,23 +174,17 @@ struct dev_filter *persistent_filter_create(struct dev_types *dt,
goto bad;
}
- /* Only merge cache file before dumping it if it changed externally. */
- if (!stat(pf->file, &info))
- lvm_stat_ctim(&pf->ctime, &info);
-
f->passes_filter = _lookup_p;
f->destroy = _persistent_destroy;
f->use_count = 0;
f->private = pf;
f->wipe = _persistent_filter_wipe;
- f->dump = _persistent_filter_dump;
log_debug_devs("Persistent filter initialised.");
return f;
bad:
- free(pf->file);
if (pf->devices)
dm_hash_destroy(pf->devices);
free(pf);
diff --git a/lib/filters/filter.h b/lib/filters/filter.h
index ff9cc1b..cdd5a14 100644
--- a/lib/filters/filter.h
+++ b/lib/filters/filter.h
@@ -27,9 +27,7 @@ struct dev_filter *md_filter_create(struct cmd_context *cmd, struct dev_types *d
struct dev_filter *fwraid_filter_create(struct dev_types *dt);
struct dev_filter *mpath_filter_create(struct dev_types *dt);
struct dev_filter *partitioned_filter_create(struct dev_types *dt);
-struct dev_filter *persistent_filter_create(struct dev_types *dt,
- struct dev_filter *f,
- const char *file);
+struct dev_filter *persistent_filter_create(struct dev_types *dt, struct dev_filter *f);
struct dev_filter *sysfs_filter_create(void);
struct dev_filter *signature_filter_create(struct dev_types *dt);
@@ -54,6 +52,4 @@ typedef enum {
} filter_mode_t;
struct dev_filter *usable_filter_create(struct dev_types *dt, filter_mode_t mode);
-int persistent_filter_load(struct dev_filter *f, struct dm_config_tree **cft_out);
-
#endif /* _LVM_FILTER_H */
6 years
master - Remove independent metadata areas
by David Teigland
Gitweb: https://sourceware.org/git/?p=lvm2.git;a=commitdiff;h=17f5572bc972c932bcf...
Commit: 17f5572bc972c932bcf62fc2bff3029268ae0109
Parent: 9df6f601e019d0e5b052d9e6aa0bd9dc732e411d
Author: David Teigland <teigland(a)redhat.com>
AuthorDate: Wed Jun 13 12:25:19 2018 -0500
Committer: David Teigland <teigland(a)redhat.com>
CommitterDate: Wed Jun 13 12:25:19 2018 -0500
Remove independent metadata areas
in which metadata is stored in files on the local fs
instead of on PVs.
---
lib/cache/lvmcache.c | 36 -----
lib/commands/toolcontext.c | 3 -
lib/commands/toolcontext.h | 1 -
lib/config/config_settings.h | 15 +--
lib/format_text/format-text.c | 340 +----------------------------------------
lib/format_text/layout.h | 2 -
lib/metadata/metadata.c | 12 --
7 files changed, 2 insertions(+), 407 deletions(-)
diff --git a/lib/cache/lvmcache.c b/lib/cache/lvmcache.c
index 8db964c..c7e3903 100644
--- a/lib/cache/lvmcache.c
+++ b/lib/cache/lvmcache.c
@@ -60,7 +60,6 @@ struct lvmcache_vginfo {
uint32_t mda_checksum;
size_t mda_size;
int seqno;
- int independent_metadata_location; /* metadata read from independent areas */
int scan_summary_mismatch; /* vgsummary from devs had mismatching seqno or checksum */
};
@@ -794,16 +793,6 @@ next:
* VG metadata to figure out that a dev with no metadata belongs
* to a particular VG, so a device with no mdas will not be linked
* to that VG after a scan.
- *
- * (In the special case where VG metadata is stored in files on the
- * file system (configured in lvm.conf), the
- * vginfo->independent_metadata_location flag is set during label scan.
- * When we get here to rescan, we are revalidating the device to VG
- * mapping from label scan by repeating the label scan on a subset of
- * devices. If we see independent_metadata_location is set from the
- * initial label scan, we know that there is nothing to do because
- * there is no device to VG mapping to revalidate, since the VG metadata
- * comes directly from files.)
*/
int lvmcache_label_rescan_vg(struct cmd_context *cmd, const char *vgname, const char *vgid)
@@ -821,16 +810,6 @@ int lvmcache_label_rescan_vg(struct cmd_context *cmd, const char *vgname, const
if (!(vginfo = lvmcache_vginfo_from_vgname(vgname, vgid)))
return_0;
- /*
- * When the VG metadata is from an independent location,
- * then rescanning the devices in the VG won't find the
- * metadata, and will destroy the vginfo/info associations
- * that were created during label scan when the
- * independent locations were read.
- */
- if (vginfo->independent_metadata_location)
- return 1;
-
dm_list_iterate_items(info, &vginfo->infos) {
if (!(devl = malloc(sizeof(*devl)))) {
log_error("device_list element allocation failed");
@@ -897,7 +876,6 @@ int lvmcache_label_scan(struct cmd_context *cmd)
struct lvmcache_info *info;
struct lvmcache_vginfo *vginfo;
struct device_list *devl;
- struct format_type *fmt;
int vginfo_count = 0;
int r = 0;
@@ -998,12 +976,6 @@ int lvmcache_label_scan(struct cmd_context *cmd)
}
}
- /* Perform any format-specific scanning e.g. text files */
- if (cmd->independent_metadata_areas)
- dm_list_iterate_items(fmt, &cmd->formats)
- if (fmt->ops->scan && !fmt->ops->scan(fmt, NULL))
- goto out;
-
r = 1;
out:
@@ -2234,14 +2206,6 @@ int lvmcache_vgid_is_cached(const char *vgid) {
return 1;
}
-void lvmcache_set_independent_location(const char *vgname)
-{
- struct lvmcache_vginfo *vginfo;
-
- if ((vginfo = lvmcache_vginfo_from_vgname(vgname, NULL)))
- vginfo->independent_metadata_location = 1;
-}
-
uint64_t lvmcache_smallest_mda_size(struct lvmcache_info *info)
{
if (!info)
diff --git a/lib/commands/toolcontext.c b/lib/commands/toolcontext.c
index aca93f9..8c18fc6 100644
--- a/lib/commands/toolcontext.c
+++ b/lib/commands/toolcontext.c
@@ -1796,7 +1796,6 @@ struct cmd_context *create_toolcontext(unsigned is_clvmd,
cmd->threaded = threaded ? 1 : 0;
cmd->handles_missing_pvs = 0;
cmd->handles_unknown_segments = 0;
- cmd->independent_metadata_areas = 0;
cmd->ignore_clustered_vgs = 0;
cmd->hosttags = 0;
dm_list_init(&cmd->arg_value_groups);
@@ -1968,8 +1967,6 @@ static void _destroy_formats(struct cmd_context *cmd, struct dm_list *formats)
dm_list_del(&fmt->list);
fmt->ops->destroy(fmt);
}
-
- cmd->independent_metadata_areas = 0;
}
static void _destroy_segtypes(struct dm_list *segtypes)
diff --git a/lib/commands/toolcontext.h b/lib/commands/toolcontext.h
index fee35d4..18e1b7d 100644
--- a/lib/commands/toolcontext.h
+++ b/lib/commands/toolcontext.h
@@ -146,7 +146,6 @@ struct cmd_context {
unsigned metadata_read_only:1;
unsigned ignore_clustered_vgs:1;
unsigned threaded:1; /* set if running within a thread e.g. clvmd */
- unsigned independent_metadata_areas:1; /* active formats have MDAs outside PVs */
unsigned unknown_system_id:1;
unsigned include_historical_lvs:1; /* also process/report/display historical LVs */
unsigned record_historical_lvs:1; /* record historical LVs */
diff --git a/lib/config/config_settings.h b/lib/config/config_settings.h
index 32a6476..8aa4879 100644
--- a/lib/config/config_settings.h
+++ b/lib/config/config_settings.h
@@ -1509,20 +1509,7 @@ cfg(metadata_pvmetadataignore_CFG, "pvmetadataignore", metadata_CFG_SECTION, CFG
cfg(metadata_stripesize_CFG, "stripesize", metadata_CFG_SECTION, CFG_ADVANCED | CFG_DEFAULT_COMMENTED, CFG_TYPE_INT, DEFAULT_STRIPESIZE, vsn(1, 0, 0), NULL, 0, NULL, NULL)
cfg_array(metadata_dirs_CFG, "dirs", metadata_CFG_SECTION, CFG_ADVANCED | CFG_DEFAULT_UNDEFINED, CFG_TYPE_STRING, NULL, vsn(1, 0, 0), NULL, 0, NULL,
- "Directories holding live copies of text format metadata.\n"
- "These directories must not be on logical volumes!\n"
- "It's possible to use LVM with a couple of directories here,\n"
- "preferably on different (non-LV) filesystems, and with no other\n"
- "on-disk metadata (pvmetadatacopies = 0). Or this can be in addition\n"
- "to on-disk metadata areas. The feature was originally added to\n"
- "simplify testing and is not supported under low memory situations -\n"
- "the machine could lock up. Never edit any files in these directories\n"
- "by hand unless you are absolutely sure you know what you are doing!\n"
- "Use the supplied toolset to make changes (e.g. vgcfgrestore).\n"
- "#\n"
- "Example\n"
- "dirs = [ \"/etc/lvm/metadata\", \"/mnt/disk2/lvm/metadata2\" ]\n"
- "#\n")
+ "This setting is no longer used.\n")
cfg_section(metadata_disk_areas_CFG_SUBSECTION, "disk_areas", metadata_CFG_SECTION, CFG_UNSUPPORTED | CFG_DEFAULT_COMMENTED, vsn(1, 0, 0), 0, NULL, NULL)
cfg_section(disk_area_CFG_SUBSECTION, "disk_area", metadata_disk_areas_CFG_SUBSECTION, CFG_NAME_VARIABLE | CFG_UNSUPPORTED | CFG_DEFAULT_COMMENTED, vsn(1, 0, 0), 0, NULL, NULL)
diff --git a/lib/format_text/format-text.c b/lib/format_text/format-text.c
index 907944a..a1fce86 100644
--- a/lib/format_text/format-text.c
+++ b/lib/format_text/format-text.c
@@ -45,16 +45,6 @@ struct text_fid_context {
uint32_t raw_metadata_buf_size;
};
-struct dir_list {
- struct dm_list list;
- char dir[0];
-};
-
-struct raw_list {
- struct dm_list list;
- struct device_area dev_area;
-};
-
int rlocn_is_ignored(const struct raw_locn *rlocn)
{
return (rlocn->flags & RAW_LOCN_IGNORED ? 1 : 0);
@@ -505,22 +495,6 @@ static uint64_t _next_rlocn_offset(struct raw_locn *rlocn, struct mda_header *md
return new_start_offset;
}
-static int _raw_holds_vgname(struct format_instance *fid,
- struct device_area *dev_area, const char *vgname)
-{
- int r = 0;
- int noprecommit = 0;
- struct mda_header *mdah;
-
- if (!(mdah = raw_read_mda_header(fid->fmt, dev_area, 0)))
- return_0;
-
- if (_read_metadata_location_vg(dev_area, mdah, 0, vgname, &noprecommit))
- r = 1;
-
- return r;
-}
-
static struct volume_group *_vg_read_raw_area(struct format_instance *fid,
const char *vgname,
struct device_area *area,
@@ -1118,75 +1092,6 @@ static int _vg_remove_file(struct format_instance *fid __attribute__((unused)),
return 1;
}
-static int _scan_file(const struct format_type *fmt, const char *vgname)
-{
- struct dirent *dirent;
- struct dir_list *dl;
- struct dm_list *dir_list;
- char *tmp;
- DIR *d;
- struct volume_group *vg;
- struct format_instance *fid;
- struct format_instance_ctx fic;
- char path[PATH_MAX];
- char *scanned_vgname;
-
- dir_list = &((struct mda_lists *) fmt->private)->dirs;
-
- if (!dm_list_empty(dir_list))
- log_debug_metadata("Scanning independent files for %s", vgname ? vgname : "VGs");
-
- dm_list_iterate_items(dl, dir_list) {
- if (!(d = opendir(dl->dir))) {
- log_sys_error("opendir", dl->dir);
- continue;
- }
- while ((dirent = readdir(d)))
- if (strcmp(dirent->d_name, ".") &&
- strcmp(dirent->d_name, "..") &&
- (!(tmp = strstr(dirent->d_name, ".tmp")) ||
- tmp != dirent->d_name + strlen(dirent->d_name)
- - 4)) {
- scanned_vgname = dirent->d_name;
-
- /* If vgname supplied, only scan that one VG */
- if (vgname && strcmp(vgname, scanned_vgname))
- continue;
-
- if (dm_snprintf(path, PATH_MAX, "%s/%s",
- dl->dir, scanned_vgname) < 0) {
- log_error("Name too long %s/%s",
- dl->dir, scanned_vgname);
- break;
- }
-
- /* FIXME stat file to see if it's changed */
- /* FIXME: Check this fid is OK! */
- fic.type = FMT_INSTANCE_PRIVATE_MDAS;
- fic.context.private = NULL;
- if (!(fid = _text_create_text_instance(fmt, &fic))) {
- stack;
- break;
- }
-
- log_debug_metadata("Scanning independent file %s for VG %s", path, scanned_vgname);
-
- if ((vg = _vg_read_file_name(fid, scanned_vgname,
- path))) {
- /* FIXME Store creation host in vg */
- lvmcache_update_vg(vg, 0);
- lvmcache_set_independent_location(vg->name);
- release_vg(vg);
- }
- }
-
- if (closedir(d))
- log_sys_error("closedir", dl->dir);
- }
-
- return 1;
-}
-
int read_metadata_location_summary(const struct format_type *fmt,
struct mda_header *mdah, int primary_mda, struct device_area *dev_area,
struct lvmcache_vgsummary *vgsummary, uint64_t *mda_free_sectors)
@@ -1326,55 +1231,6 @@ int read_metadata_location_summary(const struct format_type *fmt,
return 1;
}
-/* used for independent_metadata_areas */
-
-static int _scan_raw(const struct format_type *fmt, const char *vgname __attribute__((unused)))
-{
- struct raw_list *rl;
- struct dm_list *raw_list;
- struct volume_group *vg;
- struct format_instance fid;
- struct lvmcache_vgsummary vgsummary = { 0 };
- struct mda_header *mdah;
-
- raw_list = &((struct mda_lists *) fmt->private)->raws;
-
- if (!dm_list_empty(raw_list))
- log_debug_metadata("Scanning independent raw locations for %s", vgname ? vgname : "VGs");
-
- fid.fmt = fmt;
- dm_list_init(&fid.metadata_areas_in_use);
- dm_list_init(&fid.metadata_areas_ignored);
-
- dm_list_iterate_items(rl, raw_list) {
- log_debug_metadata("Scanning independent dev %s", dev_name(rl->dev_area.dev));
-
- if (!(mdah = raw_read_mda_header(fmt, &rl->dev_area, 0))) {
- stack;
- continue;
- }
-
- if (read_metadata_location_summary(fmt, mdah, 0, &rl->dev_area, &vgsummary, NULL)) {
- vg = _vg_read_raw_area(&fid, vgsummary.vgname, &rl->dev_area, NULL, NULL, 0, 0);
- if (vg) {
- lvmcache_update_vg(vg, 0);
- lvmcache_set_independent_location(vg->name);
- }
- }
- }
-
- return 1;
-}
-
-/* used for independent_metadata_areas */
-
-static int _text_scan(const struct format_type *fmt, const char *vgname)
-{
- _scan_file(fmt, vgname);
- _scan_raw(fmt, vgname);
- return 1;
-}
-
struct _write_single_mda_baton {
const struct format_type *fmt;
struct physical_volume *pv;
@@ -1535,28 +1391,6 @@ static int _text_pv_needs_rewrite(const struct format_type *fmt, struct physical
return 1;
}
-static int _add_raw(struct dm_list *raw_list, struct device_area *dev_area)
-{
- struct raw_list *rl;
-
- /* Already present? */
- dm_list_iterate_items(rl, raw_list) {
- /* FIXME Check size/overlap consistency too */
- if (rl->dev_area.dev == dev_area->dev &&
- rl->dev_area.start == dev_area->start)
- return 1;
- }
-
- if (!(rl = malloc(sizeof(struct raw_list)))) {
- log_error("_add_raw allocation failed");
- return 0;
- }
- memcpy(&rl->dev_area, dev_area, sizeof(*dev_area));
- dm_list_add(raw_list, &rl->list);
-
- return 1;
-}
-
/*
* Copy constructor for a metadata_locn.
*/
@@ -1709,36 +1543,13 @@ static void _text_destroy_instance(struct format_instance *fid)
}
}
-static void _free_dirs(struct dm_list *dir_list)
-{
- struct dm_list *dl, *tmp;
-
- dm_list_iterate_safe(dl, tmp, dir_list) {
- dm_list_del(dl);
- free(dl);
- }
-}
-
-static void _free_raws(struct dm_list *raw_list)
-{
- struct dm_list *rl, *tmp;
-
- dm_list_iterate_safe(rl, tmp, raw_list) {
- dm_list_del(rl);
- free(rl);
- }
-}
-
static void _text_destroy(struct format_type *fmt)
{
if (fmt->orphan_vg)
free_orphan_vg(fmt->orphan_vg);
- if (fmt->private) {
- _free_dirs(&((struct mda_lists *) fmt->private)->dirs);
- _free_raws(&((struct mda_lists *) fmt->private)->raws);
+ if (fmt->private)
free(fmt->private);
- }
free(fmt);
}
@@ -1963,15 +1774,9 @@ static void *_create_text_context(struct dm_pool *mem, struct text_context *tc)
static int _create_vg_text_instance(struct format_instance *fid,
const struct format_instance_ctx *fic)
{
- static char path[PATH_MAX];
uint32_t type = fic->type;
struct text_fid_context *fidtc;
struct metadata_area *mda;
- struct mda_context *mdac;
- struct dir_list *dl;
- struct raw_list *rl;
- struct dm_list *dir_list, *raw_list;
- struct text_context tc;
struct lvmcache_vginfo *vginfo;
const char *vg_name, *vg_id;
@@ -2001,53 +1806,12 @@ static int _create_vg_text_instance(struct format_instance *fid,
return 0;
}
- if (type & FMT_INSTANCE_AUX_MDAS) {
- dir_list = &((struct mda_lists *) fid->fmt->private)->dirs;
- dm_list_iterate_items(dl, dir_list) {
- if (dm_snprintf(path, PATH_MAX, "%s/%s", dl->dir, vg_name) < 0) {
- log_error("Name too long %s/%s", dl->dir, vg_name);
- return 0;
- }
-
- if (!(mda = dm_pool_zalloc(fid->mem, sizeof(*mda))))
- return_0;
- mda->ops = &_metadata_text_file_ops;
- tc.path_live = path;
- tc.path_edit = tc.desc = NULL;
- mda->metadata_locn = _create_text_context(fid->mem, &tc);
- mda->status = 0;
- fid_add_mda(fid, mda, NULL, 0, 0);
- }
-
- raw_list = &((struct mda_lists *) fid->fmt->private)->raws;
- dm_list_iterate_items(rl, raw_list) {
- /* FIXME Cache this; rescan below if some missing */
- if (!_raw_holds_vgname(fid, &rl->dev_area, vg_name))
- continue;
-
- if (!(mda = dm_pool_zalloc(fid->mem, sizeof(*mda))))
- return_0;
-
- if (!(mdac = dm_pool_zalloc(fid->mem, sizeof(*mdac))))
- return_0;
- mda->metadata_locn = mdac;
- /* FIXME Allow multiple dev_areas inside area */
- memcpy(&mdac->area, &rl->dev_area, sizeof(mdac->area));
- mda->ops = &_metadata_text_raw_ops;
- mda->status = 0;
- /* FIXME MISTAKE? mda->metadata_locn = context; */
- fid_add_mda(fid, mda, NULL, 0, 0);
- }
- }
-
if (type & FMT_INSTANCE_MDAS) {
if (!(vginfo = lvmcache_vginfo_from_vgname(vg_name, vg_id)))
goto_out;
if (!lvmcache_fid_add_mdas_vg(vginfo, fid))
goto_out;
}
-
- /* FIXME If PV list or raw metadata area count are not as expected rescan */
}
out:
@@ -2440,7 +2204,6 @@ static struct format_instance *_text_create_text_instance(const struct format_ty
}
static struct format_handler _text_handler = {
- .scan = _text_scan,
.pv_initialise = _text_pv_initialise,
.pv_setup = _text_pv_setup,
.pv_add_metadata_area = _text_pv_add_metadata_area,
@@ -2455,84 +2218,11 @@ static struct format_handler _text_handler = {
.destroy = _text_destroy
};
-static int _add_dir(const char *dir, struct dm_list *dir_list)
-{
- struct dir_list *dl;
-
- if (dm_create_dir(dir)) {
- if (!(dl = malloc(sizeof(struct dm_list) + strlen(dir) + 1))) {
- log_error("_add_dir allocation failed");
- return 0;
- }
- log_very_verbose("Adding text format metadata dir: %s", dir);
- strcpy(dl->dir, dir);
- dm_list_add(dir_list, &dl->list);
- return 1;
- }
-
- return 0;
-}
-
-static int _get_config_disk_area(struct cmd_context *cmd,
- const struct dm_config_node *cn, struct dm_list *raw_list)
-{
- struct device_area dev_area;
- const char *id_str;
- struct id id;
-
- if (!(cn = cn->child)) {
- log_error("Empty metadata disk_area section of config file");
- return 0;
- }
-
- if (!dm_config_get_uint64(cn, "start_sector", &dev_area.start)) {
- log_error("Missing start_sector in metadata disk_area section "
- "of config file");
- return 0;
- }
- dev_area.start <<= SECTOR_SHIFT;
-
- if (!dm_config_get_uint64(cn, "size", &dev_area.size)) {
- log_error("Missing size in metadata disk_area section "
- "of config file");
- return 0;
- }
- dev_area.size <<= SECTOR_SHIFT;
-
- if (!dm_config_get_str(cn, "id", &id_str)) {
- log_error("Missing uuid in metadata disk_area section "
- "of config file");
- return 0;
- }
-
- if (!id_read_format(&id, id_str)) {
- log_error("Invalid uuid in metadata disk_area section "
- "of config file: %s", id_str);
- return 0;
- }
-
- if (!(dev_area.dev = lvmcache_device_from_pvid(cmd, &id, NULL))) {
- char buffer[64] __attribute__((aligned(8)));
-
- if (!id_write_format(&id, buffer, sizeof(buffer)))
- log_error("Couldn't find device.");
- else
- log_error("Couldn't find device with uuid '%s'.",
- buffer);
-
- return 0;
- }
-
- return _add_raw(raw_list, &dev_area);
-}
-
struct format_type *create_text_format(struct cmd_context *cmd)
{
struct format_instance_ctx fic;
struct format_instance *fid;
struct format_type *fmt;
- const struct dm_config_node *cn;
- const struct dm_config_value *cv;
struct mda_lists *mda_lists;
if (!(fmt = malloc(sizeof(*fmt)))) {
@@ -2556,8 +2246,6 @@ struct format_type *create_text_format(struct cmd_context *cmd)
return NULL;
}
- dm_list_init(&mda_lists->dirs);
- dm_list_init(&mda_lists->raws);
mda_lists->file_ops = &_metadata_text_file_ops;
mda_lists->raw_ops = &_metadata_text_raw_ops;
fmt->private = (void *) mda_lists;
@@ -2576,32 +2264,6 @@ struct format_type *create_text_format(struct cmd_context *cmd)
goto bad;
}
- if ((cn = find_config_tree_array(cmd, metadata_dirs_CFG, NULL))) {
- for (cv = cn->v; cv; cv = cv->next) {
- if (cv->type != DM_CFG_STRING) {
- log_error("Invalid string in config file: "
- "metadata/dirs");
- goto bad;
- }
-
- if (!_add_dir(cv->v.str, &mda_lists->dirs)) {
- log_error("Failed to add %s to text format "
- "metadata directory list ", cv->v.str);
- goto bad;
- }
- cmd->independent_metadata_areas = 1;
- }
- }
-
- if ((cn = find_config_tree_node(cmd, metadata_disk_areas_CFG_SUBSECTION, NULL))) {
- /* FIXME: disk_areas do not work with lvmetad - the "id" can't be found. */
- for (cn = cn->child; cn; cn = cn->sib) {
- if (!_get_config_disk_area(cmd, cn, &mda_lists->raws))
- goto_bad;
- cmd->independent_metadata_areas = 1;
- }
- }
-
if (!(fmt->orphan_vg = alloc_vg("text_orphan", cmd, fmt->orphan_vg_name)))
goto_bad;
diff --git a/lib/format_text/layout.h b/lib/format_text/layout.h
index 0a63708..e1462f1 100644
--- a/lib/format_text/layout.h
+++ b/lib/format_text/layout.h
@@ -84,8 +84,6 @@ struct mda_header *raw_read_mda_header(const struct format_type *fmt,
struct device_area *dev_area, int primary_mda);
struct mda_lists {
- struct dm_list dirs;
- struct dm_list raws;
struct metadata_area_ops *file_ops;
struct metadata_area_ops *raw_ops;
};
diff --git a/lib/metadata/metadata.c b/lib/metadata/metadata.c
index a4308bc..40854de 100644
--- a/lib/metadata/metadata.c
+++ b/lib/metadata/metadata.c
@@ -4026,9 +4026,6 @@ static struct volume_group *_vg_read(struct cmd_context *cmd,
inconsistent = 0;
- /* Independent MDAs aren't supported under low memory */
- if (!cmd->independent_metadata_areas && prioritized_section())
- return_NULL;
if (!(fmt = lvmcache_fmt_from_vgname(cmd, vgname, vgid, 0)))
return_NULL;
@@ -5211,15 +5208,6 @@ uint32_t vg_lock_newname(struct cmd_context *cmd, const char *vgname)
if (!lvmcache_fmt_from_vgname(cmd, vgname, NULL, 1)) {
lvmcache_label_scan(cmd);
if (!lvmcache_fmt_from_vgname(cmd, vgname, NULL, 1)) {
- /* Independent MDAs aren't supported under low memory */
- if (!cmd->independent_metadata_areas && critical_section()) {
- /*
- * FIXME: Disallow calling this function if
- * critical_section() is true.
- */
- unlock_vg(cmd, NULL, vgname);
- return FAILED_LOCKING;
- }
lvmcache_label_scan(cmd);
if (!lvmcache_fmt_from_vgname(cmd, vgname, NULL, 0))
return SUCCESS; /* vgname not found after scanning */
6 years
master - Remove code for loading other metadata formats
by David Teigland
Gitweb: https://sourceware.org/git/?p=lvm2.git;a=commitdiff;h=9df6f601e019d0e5b05...
Commit: 9df6f601e019d0e5b052d9e6aa0bd9dc732e411d
Parent: 885e57cb2723b8f58e8bced534b81d536a1a16a4
Author: David Teigland <teigland(a)redhat.com>
AuthorDate: Wed Jun 13 11:32:29 2018 -0500
Committer: David Teigland <teigland(a)redhat.com>
CommitterDate: Wed Jun 13 12:03:42 2018 -0500
Remove code for loading other metadata formats
other formats are not used.
---
lib/commands/toolcontext.c | 70 ++++----------------------------------------
1 files changed, 6 insertions(+), 64 deletions(-)
diff --git a/lib/commands/toolcontext.c b/lib/commands/toolcontext.c
index 20a73b7..aca93f9 100644
--- a/lib/commands/toolcontext.c
+++ b/lib/commands/toolcontext.c
@@ -1331,73 +1331,21 @@ struct format_type *get_format_by_name(struct cmd_context *cmd, const char *form
return NULL;
}
+/* FIXME: there's only one format, get rid of the list of formats */
+
static int _init_formats(struct cmd_context *cmd)
{
- const char *format;
-
struct format_type *fmt;
-#ifdef HAVE_LIBDL
- const struct dm_config_node *cn;
-#endif
-
-#ifdef HAVE_LIBDL
- /* Load any formats in shared libs if not static */
- if (!is_static() &&
- (cn = find_config_tree_array(cmd, global_format_libraries_CFG, NULL))) {
-
- const struct dm_config_value *cv;
- struct format_type *(*init_format_fn) (struct cmd_context *);
- void *lib;
-
- for (cv = cn->v; cv; cv = cv->next) {
- if (cv->type != DM_CFG_STRING) {
- log_error("Invalid string in config file: "
- "global/format_libraries");
- return 0;
- }
- if (!(lib = load_shared_library(cmd, cv->v.str,
- "format", 0)))
- return_0;
-
- if (!(init_format_fn = dlsym(lib, "init_format"))) {
- log_error("Shared library %s does not contain "
- "format functions", cv->v.str);
- dlclose(lib);
- return 0;
- }
-
- if (!(fmt = init_format_fn(cmd))) {
- dlclose(lib);
- return_0;
- }
-
- fmt->library = lib;
- dm_list_add(&cmd->formats, &fmt->list);
- }
- }
-#endif
-
if (!(fmt = create_text_format(cmd)))
return 0;
- fmt->library = NULL;
- dm_list_add(&cmd->formats, &fmt->list);
+ dm_list_add(&cmd->formats, &fmt->list);
cmd->fmt_backup = fmt;
+ cmd->default_settings.fmt_name = fmt->name;
+ cmd->fmt = fmt;
- format = find_config_tree_str(cmd, global_format_CFG, NULL);
-
- dm_list_iterate_items(fmt, &cmd->formats) {
- if (!strcasecmp(fmt->name, format) ||
- (fmt->alias && !strcasecmp(fmt->alias, format))) {
- cmd->default_settings.fmt_name = fmt->name;
- cmd->fmt = fmt;
- return 1;
- }
- }
-
- log_error("_init_formats: Default format (%s) not found", format);
- return 0;
+ return 1;
}
int init_lvmcache_orphans(struct cmd_context *cmd)
@@ -2014,17 +1962,11 @@ static void _destroy_formats(struct cmd_context *cmd, struct dm_list *formats)
{
struct dm_list *fmtl, *tmp;
struct format_type *fmt;
- void *lib;
dm_list_iterate_safe(fmtl, tmp, formats) {
fmt = dm_list_item(fmtl, struct format_type);
dm_list_del(&fmt->list);
- lib = fmt->library;
fmt->ops->destroy(fmt);
-#ifdef HAVE_LIBDL
- if (lib)
- dlclose(lib);
-#endif
}
cmd->independent_metadata_areas = 0;
6 years
v2_02_178 annotated tag has been created
by Marian Csontos
Gitweb: https://sourceware.org/git/?p=lvm2.git;a=commitdiff;h=97926eae03282419984...
Commit: 97926eae03282419984fe3264dea6108d55df019
Parent: 0000000000000000000000000000000000000000
Author: Marian Csontos <mcsontos(a)redhat.com>
AuthorDate: 2018-06-13 12:16 +0000
Committer: Marian Csontos <mcsontos(a)redhat.com>
CommitterDate: 2018-06-13 12:16 +0000
annotated tag: v2_02_178 has been created
at 97926eae03282419984fe3264dea6108d55df019 (tag)
tagging 06accf13953d0bc3a5ffef918e562bad1d802249 (commit)
replaces v2_02_178-rc1
Release 2.02.178
Major changes:
Remove support for historical lvm1 and GFS pool formats.
Major changes in label scanning.
Use libaio.
See doc/release-notes/2.02.178 for details.
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v2.0.22 (GNU/Linux)
iQIcBAABAgAGBQJbIQszAAoJELkRJDHlCQOft38P/3iW0pILWiZudLTPvNmUEQUa
6lY8v8jmWVbWUhvKFYFq3hDTkeS1cz5wem1AfmUJxE+A6Av26ESje5efBPpVCM8d
x4OTh1azEHjD2y42tN+pdsJT40ka56XCxPDYSssbv8DMWXjk322orv7zCAAfM9yH
ly9KF84mcko09vx5cVBrJiJPGNykdYY+fPuAl7nS1GPf2fWg4yeHHv68ghZ3gh6j
To5d2YsflhJIecmUsOI3+MucdPjfxFUjQmTOuaio7UwlXAMNq7wlqdD24zxzkmVg
qk0NrvX0SHjh/RF9VhmjF06TCPJdcINf6odJ1sOMYa9HsXyBBZSqdyCNnYbv+IDD
6cT6DranKVaeVC/TMKKWFiw0eaONQ+wvgPdFKmSjsTbiRhtPEEyGQkmL2MguSfoF
30ilB6codzK7A/aH4Lgj/Kd3aV934Ia1Tk0UlQCsNrDMhU/6e3FeoDBfWhJ/zB+5
JTC7dKcCr8JydZJx85Bsls6ak0HmeGMMMYoOJW40RQrUrI3cq6qFD7qWM5h/tI5d
EjeP1qIMjAIgob8usHPFQNZh9HiFi2Z6O/UB97AyMIgJ4kMl+ZxbCLvcLzDlOcSn
6z/JpJpzPsrLsZpFFFjlzExioYw7bZKsFQye7FU7J2MpeRHKWxP+ciOop6hh4Cak
rhzJRZs2SFt1no/T/cWY
=3FED
-----END PGP SIGNATURE-----
Marian Csontos (1):
pre-release
6 years
master - tests: lvmetad-pvscan-cache expect command to fail
by David Teigland
Gitweb: https://sourceware.org/git/?p=lvm2.git;a=commitdiff;h=885e57cb2723b8f58e8...
Commit: 885e57cb2723b8f58e8bced534b81d536a1a16a4
Parent: 7824bb710d376804a7b821730aaa8ff1a65cae21
Author: David Teigland <teigland(a)redhat.com>
AuthorDate: Tue Jun 12 12:44:23 2018 -0500
Committer: David Teigland <teigland(a)redhat.com>
CommitterDate: Tue Jun 12 12:44:23 2018 -0500
tests: lvmetad-pvscan-cache expect command to fail
---
test/shell/lvmetad-pvscan-cache.sh | 4 ++--
1 files changed, 2 insertions(+), 2 deletions(-)
diff --git a/test/shell/lvmetad-pvscan-cache.sh b/test/shell/lvmetad-pvscan-cache.sh
index e57030d..367220e 100644
--- a/test/shell/lvmetad-pvscan-cache.sh
+++ b/test/shell/lvmetad-pvscan-cache.sh
@@ -37,8 +37,8 @@ check lv_field $vg1/$lv1 lv_active ""
# Check that an LV cannot be activated by pvscan while VG is exported
vgexport $vg1
-pvscan --cache -aay "$dev1"
-pvscan --cache -aay "$dev2"
+not pvscan --cache -aay "$dev1"
+not pvscan --cache -aay "$dev2"
vgimport $vg1
check lv_exists $vg1
check lv_field $vg1/$lv1 lv_active ""
6 years
master - tests: lvconvert-repair remove cluster test
by David Teigland
Gitweb: https://sourceware.org/git/?p=lvm2.git;a=commitdiff;h=7824bb710d376804a7b...
Commit: 7824bb710d376804a7b821730aaa8ff1a65cae21
Parent: be3af7f93ef0ca7d65b07863c876a7cbb1e7a239
Author: David Teigland <teigland(a)redhat.com>
AuthorDate: Tue Jun 12 11:35:45 2018 -0500
Committer: David Teigland <teigland(a)redhat.com>
CommitterDate: Tue Jun 12 11:35:45 2018 -0500
tests: lvconvert-repair remove cluster test
---
test/shell/lvconvert-repair.sh | 4 ----
1 files changed, 0 insertions(+), 4 deletions(-)
diff --git a/test/shell/lvconvert-repair.sh b/test/shell/lvconvert-repair.sh
index 9ee7980..5f7b851 100644
--- a/test/shell/lvconvert-repair.sh
+++ b/test/shell/lvconvert-repair.sh
@@ -68,11 +68,7 @@ vgreduce --removemissing $vg
aux enable_dev "$dev4"
# 3-way, mirrored log => 3-way, core log
-if test -n "$LVM_TEST_LVMLOCKD"; then
recreate_vg_
-else
-recreate_vg_ -c n
-fi
lvcreate -aey --type mirror -m 2 --mirrorlog mirrored --ignoremonitoring -L 1 -n 3way $vg \
"$dev1" "$dev2" "$dev3" "$dev4":0 "$dev5":0
aux disable_dev "$dev4" "$dev5"
6 years
master - Remove the unused lock_hash in lvmcache
by David Teigland
Gitweb: https://sourceware.org/git/?p=lvm2.git;a=commitdiff;h=be3af7f93ef0ca7d65b...
Commit: be3af7f93ef0ca7d65b07863c876a7cbb1e7a239
Parent: 981a3ba98ed6815a8b761261ed5652ec81294938
Author: David Teigland <teigland(a)redhat.com>
AuthorDate: Tue Jun 12 11:29:56 2018 -0500
Committer: David Teigland <teigland(a)redhat.com>
CommitterDate: Tue Jun 12 11:29:56 2018 -0500
Remove the unused lock_hash in lvmcache
It kept track of which VGs were locked, but is
no longer used, so remove it.
---
lib/cache/lvmcache.c | 56 --------------------------------------------------
1 files changed, 0 insertions(+), 56 deletions(-)
diff --git a/lib/cache/lvmcache.c b/lib/cache/lvmcache.c
index 757ed88..8db964c 100644
--- a/lib/cache/lvmcache.c
+++ b/lib/cache/lvmcache.c
@@ -67,14 +67,12 @@ struct lvmcache_vginfo {
static struct dm_hash_table *_pvid_hash = NULL;
static struct dm_hash_table *_vgid_hash = NULL;
static struct dm_hash_table *_vgname_hash = NULL;
-static struct dm_hash_table *_lock_hash = NULL;
static DM_LIST_INIT(_vginfos);
static DM_LIST_INIT(_found_duplicate_devs);
static DM_LIST_INIT(_unused_duplicate_devs);
static int _scanning_in_progress = 0;
static int _has_scanned = 0;
static int _vgs_locked = 0;
-static int _vg_global_lock_held = 0; /* Global lock held when cache wiped? */
static int _found_duplicate_pvs = 0; /* If we never see a duplicate PV we can skip checking for them later. */
int lvmcache_init(struct cmd_context *cmd)
@@ -98,19 +96,6 @@ int lvmcache_init(struct cmd_context *cmd)
if (!(_pvid_hash = dm_hash_create(128)))
return 0;
- if (!(_lock_hash = dm_hash_create(128)))
- return 0;
-
- /*
- * Reinitialising the cache clears the internal record of
- * which locks are held. The global lock can be held during
- * this operation so its state must be restored afterwards.
- */
- if (_vg_global_lock_held) {
- lvmcache_lock_vgname(VG_GLOBAL, 0);
- _vg_global_lock_held = 0;
- }
-
return 1;
}
@@ -131,25 +116,12 @@ void lvmcache_seed_infos_from_lvmetad(struct cmd_context *cmd)
void lvmcache_lock_vgname(const char *vgname, int read_only __attribute__((unused)))
{
- if (dm_hash_lookup(_lock_hash, vgname))
- log_error(INTERNAL_ERROR "Nested locking attempted on VG %s.",
- vgname);
-
- if (!dm_hash_insert(_lock_hash, vgname, (void *) 1))
- log_error("Cache locking failure for %s", vgname);
-
if (strcmp(vgname, VG_GLOBAL))
_vgs_locked++;
}
void lvmcache_unlock_vgname(const char *vgname)
{
- if (!dm_hash_lookup(_lock_hash, vgname))
- log_error(INTERNAL_ERROR "Attempt to unlock unlocked VG %s.",
- vgname);
-
- dm_hash_remove(_lock_hash, vgname);
-
/* FIXME Do this per-VG */
if (strcmp(vgname, VG_GLOBAL) && !--_vgs_locked) {
dev_size_seqno_inc(); /* invalidate all cached dev sizes */
@@ -1912,26 +1884,8 @@ static void _lvmcache_destroy_vgnamelist(struct lvmcache_vginfo *vginfo)
} while ((vginfo = next));
}
-static void _lvmcache_destroy_lockname(struct dm_hash_node *n)
-{
- char *vgname;
-
- if (!dm_hash_get_data(_lock_hash, n))
- return;
-
- vgname = dm_hash_get_key(_lock_hash, n);
-
- if (!strcmp(vgname, VG_GLOBAL))
- _vg_global_lock_held = 1;
- else
- log_error(INTERNAL_ERROR "Volume Group %s was not unlocked",
- dm_hash_get_key(_lock_hash, n));
-}
-
void lvmcache_destroy(struct cmd_context *cmd, int retain_orphans, int reset)
{
- struct dm_hash_node *n;
-
log_debug_cache("Dropping VG info");
_has_scanned = 0;
@@ -1954,16 +1908,6 @@ void lvmcache_destroy(struct cmd_context *cmd, int retain_orphans, int reset)
_vgname_hash = NULL;
}
- if (_lock_hash) {
- if (reset)
- _vg_global_lock_held = 0;
- else
- dm_hash_iterate(n, _lock_hash)
- _lvmcache_destroy_lockname(n);
- dm_hash_destroy(_lock_hash);
- _lock_hash = NULL;
- }
-
if (!dm_list_empty(&_vginfos))
log_error(INTERNAL_ERROR "_vginfos list should be empty");
dm_list_init(&_vginfos);
6 years
master - Clean up repair and result values in vg_read
by David Teigland
Gitweb: https://sourceware.org/git/?p=lvm2.git;a=commitdiff;h=981a3ba98ed6815a8b7...
Commit: 981a3ba98ed6815a8b761261ed5652ec81294938
Parent: 9a8c36b8917edf00ea875e727b0b775ca5a87a43
Author: David Teigland <teigland(a)redhat.com>
AuthorDate: Tue Jun 12 09:44:37 2018 -0500
Committer: David Teigland <teigland(a)redhat.com>
CommitterDate: Tue Jun 12 11:08:26 2018 -0500
Clean up repair and result values in vg_read
Fix the confusing mix of input and output values
in the single variable.
---
lib/metadata/metadata-exported.h | 11 ++--
lib/metadata/metadata.c | 104 +++++++++++++++++++-------------------
lib/metadata/vg.c | 3 +-
tools/toollib.c | 3 +-
4 files changed, 60 insertions(+), 61 deletions(-)
diff --git a/lib/metadata/metadata-exported.h b/lib/metadata/metadata-exported.h
index 36a87b5..501d0fa 100644
--- a/lib/metadata/metadata-exported.h
+++ b/lib/metadata/metadata-exported.h
@@ -653,8 +653,6 @@ void pvcreate_params_set_defaults(struct pvcreate_params *pp);
int vg_write(struct volume_group *vg);
int vg_commit(struct volume_group *vg);
void vg_revert(struct volume_group *vg);
-struct volume_group *vg_read_internal(struct cmd_context *cmd, const char *vg_name,
- const char *vgid, uint32_t lockd_state, uint32_t warn_flags, int *consistent);
/*
* Add/remove LV to/from volume group
@@ -689,15 +687,18 @@ int lv_resize(struct logical_volume *lv,
/*
* Return a handle to VG metadata.
*/
+struct volume_group *vg_read_internal(struct cmd_context *cmd,
+ const char *vgname, const char *vgid,
+ uint32_t lockd_state, uint32_t warn_flags,
+ int enable_repair,
+ int *mdas_consistent);
struct volume_group *vg_read(struct cmd_context *cmd, const char *vg_name,
const char *vgid, uint32_t read_flags, uint32_t lockd_state);
struct volume_group *vg_read_for_update(struct cmd_context *cmd, const char *vg_name,
const char *vgid, uint32_t read_flags, uint32_t lockd_state);
struct volume_group *vg_read_orphans(struct cmd_context *cmd,
uint32_t warn_flags,
- const char *orphan_vgname,
- int *consistent);
-
+ const char *orphan_vgname);
/*
* Test validity of a VG handle.
*/
diff --git a/lib/metadata/metadata.c b/lib/metadata/metadata.c
index 9dc5627..a4308bc 100644
--- a/lib/metadata/metadata.c
+++ b/lib/metadata/metadata.c
@@ -3276,8 +3276,7 @@ static int _vg_read_orphan_pv(struct lvmcache_info *info, void *baton)
/* Make orphan PVs look like a VG. */
struct volume_group *vg_read_orphans(struct cmd_context *cmd,
uint32_t warn_flags,
- const char *orphan_vgname,
- int *consistent)
+ const char *orphan_vgname)
{
const struct format_type *fmt;
struct lvmcache_vginfo *vginfo;
@@ -3624,7 +3623,9 @@ static struct volume_group *_vg_read(struct cmd_context *cmd,
const char *vgid,
uint32_t lockd_state,
uint32_t warn_flags,
- int *consistent, unsigned precommitted)
+ int enable_repair,
+ int *mdas_consistent,
+ unsigned precommitted)
{
struct format_instance *fid = NULL;
struct format_instance_ctx fic;
@@ -3637,19 +3638,20 @@ static struct volume_group *_vg_read(struct cmd_context *cmd,
int inconsistent_pvs = 0;
int inconsistent_mdas = 0;
int inconsistent_mda_count = 0;
- int strip_historical_lvs = *consistent;
- int update_old_pv_ext = *consistent;
+ int strip_historical_lvs = enable_repair;
+ int update_old_pv_ext = enable_repair;
unsigned use_precommitted = precommitted;
struct dm_list *pvids;
struct pv_list *pvl;
struct dm_list all_pvs;
char uuid[64] __attribute__((aligned(8)));
int skipped_rescan = 0;
-
int reappeared = 0;
struct cached_vg_fmtdata *vg_fmtdata = NULL; /* Additional format-specific data about the vg */
unsigned use_previous_vg;
+ *mdas_consistent = 1;
+
if (is_orphan_vg(vgname)) {
log_very_verbose("Reading VG %s", vgname);
@@ -3658,7 +3660,7 @@ static struct volume_group *_vg_read(struct cmd_context *cmd,
"with pre-commit.");
return NULL;
}
- return vg_read_orphans(cmd, warn_flags, vgname, consistent);
+ return vg_read_orphans(cmd, warn_flags, vgname);
}
uuid[0] = '\0';
@@ -3670,11 +3672,11 @@ static struct volume_group *_vg_read(struct cmd_context *cmd,
if (lvmetad_used() && !use_precommitted) {
if ((correct_vg = lvmetad_vg_lookup(cmd, vgname, vgid))) {
dm_list_iterate_items(pvl, &correct_vg->pvs)
- reappeared += _check_reappeared_pv(correct_vg, pvl->pv, *consistent);
- if (reappeared && *consistent)
- *consistent = _repair_inconsistent_vg(correct_vg, lockd_state);
+ reappeared += _check_reappeared_pv(correct_vg, pvl->pv, enable_repair);
+ if (reappeared && enable_repair)
+ *mdas_consistent = _repair_inconsistent_vg(correct_vg, lockd_state);
else
- *consistent = !reappeared;
+ *mdas_consistent = !reappeared;
if (_wipe_outdated_pvs(cmd, correct_vg, &correct_vg->pvs_outdated, lockd_state)) {
/* clear the list */
dm_list_init(&correct_vg->pvs_outdated);
@@ -4153,7 +4155,6 @@ static struct volume_group *_vg_read(struct cmd_context *cmd,
log_error(INTERNAL_ERROR "Too many inconsistent MDAs.");
if (!inconsistent_mda_count) {
- *consistent = 0;
_free_pv_list(&all_pvs);
return correct_vg;
}
@@ -4162,13 +4163,9 @@ static struct volume_group *_vg_read(struct cmd_context *cmd,
return NULL;
}
- if (!*consistent) {
- _free_pv_list(&all_pvs);
- return correct_vg;
- }
-
- if (cmd->is_clvmd) {
+ if (!enable_repair) {
_free_pv_list(&all_pvs);
+ *mdas_consistent = 0;
return correct_vg;
}
@@ -4181,10 +4178,9 @@ static struct volume_group *_vg_read(struct cmd_context *cmd,
/* Don't touch if vgids didn't match */
if (inconsistent_vgid) {
- log_warn("WARNING: Inconsistent metadata UUIDs found for "
- "volume group %s.", vgname);
- *consistent = 0;
+ log_warn("WARNING: Inconsistent metadata UUIDs found for volume group %s.", vgname);
_free_pv_list(&all_pvs);
+ *mdas_consistent = 0;
return correct_vg;
}
@@ -4225,16 +4221,13 @@ static struct volume_group *_vg_read(struct cmd_context *cmd,
}
/* We have the VG now finally, check if PV ext info is in sync with VG metadata. */
- if (!cmd->is_clvmd && !_check_or_repair_pv_ext(cmd, correct_vg, lockd_state,
- skipped_rescan ? 0 : *consistent,
+ if (!_check_or_repair_pv_ext(cmd, correct_vg, lockd_state, skipped_rescan ? 0 : enable_repair,
&inconsistent_pvs)) {
release_vg(correct_vg);
return_NULL;
}
- *consistent = !inconsistent_pvs;
-
- if (!cmd->is_clvmd && correct_vg && *consistent && !skipped_rescan) {
+ if (correct_vg && enable_repair && !skipped_rescan) {
if (update_old_pv_ext && !_vg_update_old_pv_ext_if_needed(correct_vg)) {
release_vg(correct_vg);
return_NULL;
@@ -4246,6 +4239,9 @@ static struct volume_group *_vg_read(struct cmd_context *cmd,
}
}
+ if (inconsistent_pvs)
+ *mdas_consistent = 0;
+
return correct_vg;
}
@@ -4390,12 +4386,14 @@ static int _check_devs_used_correspond_with_vg(struct volume_group *vg)
struct volume_group *vg_read_internal(struct cmd_context *cmd,
const char *vgname, const char *vgid,
uint32_t lockd_state, uint32_t warn_flags,
- int *consistent)
+ int enable_repair,
+ int *mdas_consistent)
{
struct volume_group *vg;
struct lv_list *lvl;
- if (!(vg = _vg_read(cmd, vgname, vgid, lockd_state, warn_flags, consistent, 0)))
+ if (!(vg = _vg_read(cmd, vgname, vgid, lockd_state,
+ warn_flags, enable_repair, mdas_consistent, 0)))
goto_out;
if (!check_pv_dev_sizes(vg))
@@ -4435,7 +4433,7 @@ struct volume_group *vg_read_internal(struct cmd_context *cmd,
(void) _check_devs_used_correspond_with_vg(vg);
out:
- if (!*consistent && (warn_flags & WARN_INCONSISTENT)) {
+ if (!*mdas_consistent && (warn_flags & WARN_INCONSISTENT)) {
if (is_orphan_vg(vgname))
log_warn("WARNING: Found inconsistent standalone Physical Volumes.");
else
@@ -4756,7 +4754,7 @@ static struct volume_group *_recover_vg(struct cmd_context *cmd,
const char *vg_name, const char *vgid,
int is_shared, uint32_t lockd_state)
{
- int consistent = 1;
+ int mdas_consistent = 0;
struct volume_group *vg;
uint32_t state = 0;
@@ -4777,12 +4775,12 @@ static struct volume_group *_recover_vg(struct cmd_context *cmd,
lockd_state |= LDST_EX;
}
- if (!(vg = vg_read_internal(cmd, vg_name, vgid, lockd_state, WARN_PV_READ, &consistent))) {
+ if (!(vg = vg_read_internal(cmd, vg_name, vgid, lockd_state, 0, 1, &mdas_consistent))) {
unlock_vg(cmd, NULL, vg_name);
return_NULL;
}
- if (!consistent) {
+ if (!mdas_consistent) {
release_vg(vg);
unlock_vg(cmd, NULL, vg_name);
return_NULL;
@@ -5015,15 +5013,17 @@ static struct volume_group *_vg_lock_and_read(struct cmd_context *cmd, const cha
uint32_t lockd_state)
{
struct volume_group *vg = NULL;
- int consistent = 1;
- int consistent_in;
uint32_t failure = 0;
uint32_t warn_flags = 0;
+ int mdas_consistent = 1;
+ int enable_repair = 1;
int is_shared = 0;
int skip_lock = is_orphan_vg(vg_name) && (read_flags & PROCESS_SKIP_ORPHAN_LOCK);
- if ((read_flags & READ_ALLOW_INCONSISTENT) || (lock_flags != LCK_VG_WRITE))
- consistent = 0;
+ if ((read_flags & READ_ALLOW_INCONSISTENT) || (lock_flags != LCK_VG_WRITE)) {
+ enable_repair = 0;
+ warn_flags |= WARN_INCONSISTENT;
+ }
if (!validate_name(vg_name) && !is_orphan_vg(vg_name)) {
log_error("Volume group name \"%s\" has invalid characters.",
@@ -5043,18 +5043,7 @@ static struct volume_group *_vg_lock_and_read(struct cmd_context *cmd, const cha
if (is_orphan_vg(vg_name))
status_flags &= ~LVM_WRITE;
- consistent_in = consistent;
-
- warn_flags = WARN_PV_READ;
- if (consistent || (read_flags & READ_WARN_INCONSISTENT))
- warn_flags |= WARN_INCONSISTENT;
-
- /* If consistent == 1, we get NULL here if correction fails. */
- if (!(vg = vg_read_internal(cmd, vg_name, vgid, lockd_state, warn_flags, &consistent))) {
- if (consistent_in && !consistent) {
- failure |= FAILED_INCONSISTENT;
- goto bad;
- }
+ if (!(vg = vg_read_internal(cmd, vg_name, vgid, lockd_state, warn_flags, enable_repair, &mdas_consistent))) {
if (!(read_flags & READ_OK_NOTFOUND))
log_error("Volume group \"%s\" not found", vg_name);
failure |= FAILED_NOTFOUND;
@@ -5064,16 +5053,27 @@ static struct volume_group *_vg_lock_and_read(struct cmd_context *cmd, const cha
if (!_vg_access_permitted(cmd, vg, lockd_state, &failure))
goto bad;
- /* consistent == 0 when VG is not found, but failed == FAILED_NOTFOUND */
- if (!consistent && !failure) {
+ /*
+ * If we called vg_read_internal above without repair enabled,
+ * and the read found inconsistent mdas, then then get a write/ex
+ * lock and call it again with repair enabled so it will fix
+ * the inconsistent mdas.
+ *
+ * FIXME: factor vg repair out of vg_read. The vg_read caller
+ * should get an error about the vg have problems and then call
+ * a repair-specific function if it wants to. (NB there are
+ * other kinds of repairs hidden in _vg_read that should be
+ * pulled out in addition to _recover_vg).
+ */
+ if (!mdas_consistent && !enable_repair) {
is_shared = vg_is_shared(vg);
release_vg(vg);
+
if (!(vg = _recover_vg(cmd, vg_name, vgid, is_shared, lockd_state))) {
if (is_orphan_vg(vg_name))
log_error("Recovery of standalone physical volumes failed.");
else
- log_error("Recovery of volume group \"%s\" failed.",
- vg_name);
+ log_error("Recovery of volume group \"%s\" failed.", vg_name);
failure |= FAILED_RECOVERY;
goto bad_no_unlock;
}
diff --git a/lib/metadata/vg.c b/lib/metadata/vg.c
index d837a55..75a054f 100644
--- a/lib/metadata/vg.c
+++ b/lib/metadata/vg.c
@@ -671,7 +671,6 @@ int vgreduce_single(struct cmd_context *cmd, struct volume_group *vg,
{
struct pv_list *pvl;
struct volume_group *orphan_vg = NULL;
- int consistent;
int r = 0;
const char *name = pv_dev_name(pv);
@@ -715,7 +714,7 @@ int vgreduce_single(struct cmd_context *cmd, struct volume_group *vg,
vg->extent_count -= pv_pe_count(pv);
/* FIXME: we don't need to vg_read the orphan vg here */
- orphan_vg = vg_read_orphans(cmd, 0, vg->fid->fmt->orphan_vg_name, &consistent);
+ orphan_vg = vg_read_orphans(cmd, 0, vg->fid->fmt->orphan_vg_name);
if (vg_read_error(orphan_vg))
goto bad;
diff --git a/tools/toollib.c b/tools/toollib.c
index fb37d07..7caab45 100644
--- a/tools/toollib.c
+++ b/tools/toollib.c
@@ -5348,7 +5348,6 @@ int pvcreate_each_device(struct cmd_context *cmd,
struct pv_list *vgpvl;
struct device_list *devl;
const char *pv_name;
- int consistent = 0;
int must_use_all = (cmd->cname->flags & MUST_USE_ALL_ARGS);
int found;
unsigned i;
@@ -5639,7 +5638,7 @@ do_command:
if (pp->preserve_existing && pp->orphan_vg_name) {
log_debug("Using existing orphan PVs in %s.", pp->orphan_vg_name);
- if (!(orphan_vg = vg_read_internal(cmd, pp->orphan_vg_name, NULL, 0, 0, &consistent))) {
+ if (!(orphan_vg = vg_read_orphans(cmd, 0, pp->orphan_vg_name))) {
log_error("Cannot read orphans VG %s.", pp->orphan_vg_name);
goto bad;
}
6 years
master - Fix use of orphan lock in commands
by David Teigland
Gitweb: https://sourceware.org/git/?p=lvm2.git;a=commitdiff;h=9a8c36b8917edf00ea8...
Commit: 9a8c36b8917edf00ea875e727b0b775ca5a87a43
Parent: c4153a8dfca9defcea645818dcd547388858c51e
Author: David Teigland <teigland(a)redhat.com>
AuthorDate: Mon Jun 11 15:08:23 2018 -0500
Committer: David Teigland <teigland(a)redhat.com>
CommitterDate: Tue Jun 12 09:46:11 2018 -0500
Fix use of orphan lock in commands
vgreduce, vgremove and vgcfgrestore were acquiring
the orphan lock in the midst of command processing
instead of at the start of the command. (The orphan
lock moved to being acquired at the start of the
command back when pvcreate/vgcreate/vgextend were
reworked based on pvcreate_each_device.)
vgsplit also needed a small update to avoid reacquiring
a VG lock that it already held (for the new VG name).
---
lib/metadata/metadata-exported.h | 4 ++++
lib/metadata/metadata.c | 10 ++--------
lib/metadata/vg.c | 14 ++++++--------
tools/vgcfgrestore.c | 12 ++++++------
tools/vgreduce.c | 13 ++++++++++++-
tools/vgremove.c | 7 +++++++
tools/vgsplit.c | 2 ++
7 files changed, 39 insertions(+), 23 deletions(-)
diff --git a/lib/metadata/metadata-exported.h b/lib/metadata/metadata-exported.h
index 641bf49..36a87b5 100644
--- a/lib/metadata/metadata-exported.h
+++ b/lib/metadata/metadata-exported.h
@@ -693,6 +693,10 @@ struct volume_group *vg_read(struct cmd_context *cmd, const char *vg_name,
const char *vgid, uint32_t read_flags, uint32_t lockd_state);
struct volume_group *vg_read_for_update(struct cmd_context *cmd, const char *vg_name,
const char *vgid, uint32_t read_flags, uint32_t lockd_state);
+struct volume_group *vg_read_orphans(struct cmd_context *cmd,
+ uint32_t warn_flags,
+ const char *orphan_vgname,
+ int *consistent);
/*
* Test validity of a VG handle.
diff --git a/lib/metadata/metadata.c b/lib/metadata/metadata.c
index 30b22c0..9dc5627 100644
--- a/lib/metadata/metadata.c
+++ b/lib/metadata/metadata.c
@@ -600,14 +600,8 @@ int vg_remove(struct volume_group *vg)
{
int ret;
- if (!lock_vol(vg->cmd, VG_ORPHANS, LCK_VG_WRITE, NULL)) {
- log_error("Can't get lock for orphan PVs");
- return 0;
- }
-
ret = vg_remove_direct(vg);
- unlock_vg(vg->cmd, vg, VG_ORPHANS);
return ret;
}
@@ -3280,7 +3274,7 @@ static int _vg_read_orphan_pv(struct lvmcache_info *info, void *baton)
}
/* Make orphan PVs look like a VG. */
-static struct volume_group *_vg_read_orphans(struct cmd_context *cmd,
+struct volume_group *vg_read_orphans(struct cmd_context *cmd,
uint32_t warn_flags,
const char *orphan_vgname,
int *consistent)
@@ -3664,7 +3658,7 @@ static struct volume_group *_vg_read(struct cmd_context *cmd,
"with pre-commit.");
return NULL;
}
- return _vg_read_orphans(cmd, warn_flags, vgname, consistent);
+ return vg_read_orphans(cmd, warn_flags, vgname, consistent);
}
uuid[0] = '\0';
diff --git a/lib/metadata/vg.c b/lib/metadata/vg.c
index 400af8d..d837a55 100644
--- a/lib/metadata/vg.c
+++ b/lib/metadata/vg.c
@@ -671,6 +671,7 @@ int vgreduce_single(struct cmd_context *cmd, struct volume_group *vg,
{
struct pv_list *pvl;
struct volume_group *orphan_vg = NULL;
+ int consistent;
int r = 0;
const char *name = pv_dev_name(pv);
@@ -679,6 +680,8 @@ int vgreduce_single(struct cmd_context *cmd, struct volume_group *vg,
return r;
}
+ log_debug("vgreduce_single VG %s PV %s", vg->name, pv_dev_name(pv));
+
if (pv_pe_alloc_count(pv)) {
log_error("Physical volume \"%s\" still in use", name);
return r;
@@ -690,11 +693,6 @@ int vgreduce_single(struct cmd_context *cmd, struct volume_group *vg,
return r;
}
- if (!lock_vol(cmd, VG_ORPHANS, LCK_VG_WRITE, NULL)) {
- log_error("Can't get lock for orphan PVs");
- return r;
- }
-
pvl = find_pv_in_vg(vg, name);
if (!archive(vg))
@@ -716,8 +714,8 @@ int vgreduce_single(struct cmd_context *cmd, struct volume_group *vg,
vg->free_count -= pv_pe_count(pv) - pv_pe_alloc_count(pv);
vg->extent_count -= pv_pe_count(pv);
- orphan_vg = vg_read_for_update(cmd, vg->fid->fmt->orphan_vg_name,
- NULL, 0, 0);
+ /* FIXME: we don't need to vg_read the orphan vg here */
+ orphan_vg = vg_read_orphans(cmd, 0, vg->fid->fmt->orphan_vg_name, &consistent);
if (vg_read_error(orphan_vg))
goto bad;
@@ -755,6 +753,6 @@ bad:
/* If we are committing here or we had an error then we will free fid */
if (pvl && (commit || r != 1))
free_pv_fid(pvl->pv);
- unlock_and_release_vg(cmd, orphan_vg, VG_ORPHANS);
+ release_vg(orphan_vg);
return r;
}
diff --git a/tools/vgcfgrestore.c b/tools/vgcfgrestore.c
index ec2c240..0b03687 100644
--- a/tools/vgcfgrestore.c
+++ b/tools/vgcfgrestore.c
@@ -63,14 +63,14 @@ int vgcfgrestore(struct cmd_context *cmd, int argc, char **argv)
lvmetad_rescan = 1;
}
- if (!lock_vol(cmd, vg_name, LCK_VG_WRITE, NULL)) {
- log_error("Unable to lock volume group %s.", vg_name);
+ if (!lock_vol(cmd, VG_ORPHANS, LCK_VG_WRITE, NULL)) {
+ log_error("Unable to lock orphans.");
return ECMD_FAILED;
}
- if (!lock_vol(cmd, VG_ORPHANS, LCK_VG_WRITE, NULL)) {
- log_error("Unable to lock orphans.");
- unlock_vg(cmd, NULL, vg_name);
+ if (!lock_vol(cmd, vg_name, LCK_VG_WRITE, NULL)) {
+ log_error("Unable to lock volume group %s.", vg_name);
+ unlock_vg(cmd, NULL, VG_ORPHANS);
return ECMD_FAILED;
}
@@ -83,8 +83,8 @@ int vgcfgrestore(struct cmd_context *cmd, int argc, char **argv)
arg_str_value(cmd, file_ARG, ""),
arg_count(cmd, force_long_ARG)) :
backup_restore(cmd, vg_name, arg_count(cmd, force_long_ARG)))) {
- unlock_vg(cmd, NULL, VG_ORPHANS);
unlock_vg(cmd, NULL, vg_name);
+ unlock_vg(cmd, NULL, VG_ORPHANS);
log_error("Restore failed.");
ret = ECMD_FAILED;
goto rescan;
diff --git a/tools/vgreduce.c b/tools/vgreduce.c
index e8479a8..ce3d155 100644
--- a/tools/vgreduce.c
+++ b/tools/vgreduce.c
@@ -231,9 +231,20 @@ int vgreduce(struct cmd_context *cmd, int argc, char **argv)
handle->custom_handle = &vp;
if (!repairing) {
+ if (!lock_vol(cmd, VG_ORPHANS, LCK_VG_WRITE, NULL)) {
+ log_error("Can't get lock for orphan PVs");
+ ret = ECMD_FAILED;
+ goto out;
+ }
+
/* FIXME: Pass private struct through to all these functions */
/* and update in batch afterwards? */
- ret = process_each_pv(cmd, argc, argv, vg_name, 0, READ_FOR_UPDATE, handle, _vgreduce_single);
+
+ ret = process_each_pv(cmd, argc, argv, vg_name, 0,
+ READ_FOR_UPDATE | PROCESS_SKIP_ORPHAN_LOCK,
+ handle, _vgreduce_single);
+
+ unlock_vg(cmd, NULL, VG_ORPHANS);
goto out;
}
diff --git a/tools/vgremove.c b/tools/vgremove.c
index 8bf3841..5010e7d 100644
--- a/tools/vgremove.c
+++ b/tools/vgremove.c
@@ -108,10 +108,17 @@ int vgremove(struct cmd_context *cmd, int argc, char **argv)
*/
cmd->lockd_gl_disable = 1;
+ if (!lock_vol(cmd, VG_ORPHANS, LCK_VG_WRITE, NULL)) {
+ log_error("Can't get lock for orphan PVs");
+ return ECMD_FAILED;
+ }
+
cmd->handles_missing_pvs = 1;
ret = process_each_vg(cmd, argc, argv, NULL, NULL,
READ_FOR_UPDATE, 0,
NULL, &_vgremove_single);
+ unlock_vg(cmd, NULL, VG_ORPHANS);
+
return ret;
}
diff --git a/tools/vgsplit.c b/tools/vgsplit.c
index 1e46e7e..7ec00f8 100644
--- a/tools/vgsplit.c
+++ b/tools/vgsplit.c
@@ -748,8 +748,10 @@ int vgsplit(struct cmd_context *cmd, int argc, char **argv)
/*
* Finally, remove the EXPORTED flag from the new VG and write it out.
+ * We need to unlock vg_to because vg_read_for_update wants to lock it.
*/
if (!test_mode()) {
+ unlock_vg(cmd, NULL, vg_name_to);
release_vg(vg_to);
vg_to = vg_read_for_update(cmd, vg_name_to, NULL,
READ_ALLOW_EXPORTED, 0);
6 years