summaryrefslogtreecommitdiff
path: root/tools
diff options
context:
space:
mode:
Diffstat (limited to 'tools')
-rw-r--r--tools/Makefile.in4
-rw-r--r--tools/args.h7
-rw-r--r--tools/command-lines.in17
-rw-r--r--tools/command.c1
-rw-r--r--tools/commands.h11
-rw-r--r--tools/lvchange.c14
-rw-r--r--tools/lvmcmdline.c56
-rw-r--r--tools/lvscan.c62
-rw-r--r--tools/polldaemon.c22
-rw-r--r--tools/pvcreate.c11
-rw-r--r--tools/pvdisplay.c17
-rw-r--r--tools/pvscan.c567
-rw-r--r--tools/reporter.c5
-rw-r--r--tools/toollib.c24
-rw-r--r--tools/tools.h6
-rw-r--r--tools/vgcfgrestore.c35
-rw-r--r--tools/vgchange.c14
-rw-r--r--tools/vgck.c1
-rw-r--r--tools/vgcreate.c3
-rw-r--r--tools/vgimport.c20
-rw-r--r--tools/vgimportclone.c25
-rw-r--r--tools/vgmerge.c1
-rw-r--r--tools/vgrename.c4
-rw-r--r--tools/vgscan.c66
-rw-r--r--tools/vgsplit.c7
25 files changed, 47 insertions, 953 deletions
diff --git a/tools/Makefile.in b/tools/Makefile.in
index 7d9dd93da..e21ca6313 100644
--- a/tools/Makefile.in
+++ b/tools/Makefile.in
@@ -135,10 +135,6 @@ man-generator: man-generator.o
@echo " [CC] $@"
$(CC) $(CFLAGS) -o $@ $<
-ifeq ("@BUILD_LVMETAD@", "yes")
-lvm: $(top_builddir)/libdaemon/client/libdaemonclient.a
-endif
-
lvm.static: $(OBJECTS) lvm-static.o $(top_builddir)/lib/liblvm-internal.a $(INTERNAL_LIBS)
@echo " [CC] $@"
$(Q) $(CC) $(CFLAGS) $(LDFLAGS) -static -L$(interfacebuilddir) -o $@ \
diff --git a/tools/args.h b/tools/args.h
index 0d4d3bc87..9e83b125a 100644
--- a/tools/args.h
+++ b/tools/args.h
@@ -96,11 +96,11 @@ arg(bootloaderareasize_ARG, '\0', "bootloaderareasize", sizemb_VAL, 0, 0,
arg(cache_long_ARG, '\0', "cache", 0, 0, 0,
"#pvscan\n"
- "Scan one or more devices and send the metadata to lvmetad.\n"
+ "Scan one or more devices and record that they are online.\n"
"#vgscan\n"
- "Scan all devices and send the metadata to lvmetad.\n"
+ "This option is no longer used.\n"
"#lvscan\n"
- "Scan the devices used by an LV and send the metadata to lvmetad.\n")
+ "This option is no longer used.\n")
arg(cachemetadataformat_ARG, '\0', "cachemetadataformat", cachemetadataformat_VAL, 0, 0,
"Specifies the cache metadata format used by cache target.\n")
@@ -674,7 +674,6 @@ arg(sysinit_ARG, '\0', "sysinit", 0, 0, 0,
"acts as a shortcut which selects an appropriate set of options. Currently,\n"
"this is equivalent to using --ignorelockingfailure, --ignoremonitoring,\n"
"--poll n, and setting env var LVM_SUPPRESS_LOCKING_FAILURE_MESSAGES.\n"
- "When used in conjunction with lvmetad enabled and running,\n"
"vgchange/lvchange skip autoactivation, and defer to pvscan autoactivation.\n")
arg(systemid_ARG, '\0', "systemid", string_VAL, 0, 0,
diff --git a/tools/command-lines.in b/tools/command-lines.in
index bf36738d5..6192b0313 100644
--- a/tools/command-lines.in
+++ b/tools/command-lines.in
@@ -1373,16 +1373,9 @@ ID: lvs_general
lvscan
OO: --all, --blockdevice, --ignorelockingfailure,
--readonly, --reportformat ReportFmt
-IO: --partial
+IO: --partial, --cache_long
ID: lvscan_general
-lvscan --cache_long
-OO: --blockdevice, --ignorelockingfailure,
---readonly, --reportformat ReportFmt
-OP: LV ...
-IO: --partial
-ID: lvscan_cache
-
---
# None of these can function as a required option for pvchange.
@@ -1476,7 +1469,7 @@ ID: pvs_general
pvscan
OO: --ignorelockingfailure, --reportformat ReportFmt, --exported, --novolumegroup,
--short, --uuid
-ID: pvscan_show
+ID: pvscan_display
DESC: Display PV information.
pvscan --cache_long
@@ -1484,7 +1477,7 @@ OO: --ignorelockingfailure, --reportformat ReportFmt, --background,
--activate ay, --major Number, --minor Number
OP: PV|String ...
ID: pvscan_cache
-DESC: Populate the lvmetad cache by scanning PVs.
+DESC: Autoactivate a VG when all PVs are online.
---
@@ -1734,9 +1727,9 @@ ID: vgs_general
---
vgscan
-OO: --cache_long, --ignorelockingfailure, --mknodes, --notifydbus,
+OO: --ignorelockingfailure, --mknodes, --notifydbus,
--reportformat ReportFmt
-IO: --partial
+IO: --partial, --cache_long
ID: vgscan_general
---
diff --git a/tools/command.c b/tools/command.c
index eefc12483..42f9aa3c9 100644
--- a/tools/command.c
+++ b/tools/command.c
@@ -133,7 +133,6 @@ static inline int configtype_arg(struct cmd_context *cmd __attribute__((unused))
#define NO_METADATA_PROCESSING 0x00000040
#define IGNORE_PERSISTENT_FILTER 0x00000080
#define MUST_USE_ALL_ARGS 0x00000100
-#define NO_LVMETAD_AUTOSCAN 0x00000200
#define ENABLE_DUPLICATE_DEVS 0x00000400
#define DISALLOW_TAG_ARGS 0x00000800
#define GET_VGNAME_FROM_OPTIONS 0x00001000
diff --git a/tools/commands.h b/tools/commands.h
index 4af92c87f..ef5763bd5 100644
--- a/tools/commands.h
+++ b/tools/commands.h
@@ -103,7 +103,7 @@ xx(lvs,
xx(lvscan,
"List all logical volumes in all volume groups",
- PERMITTED_READ_ONLY | ALL_VGS_IS_DEFAULT | LOCKD_VG_SH | NO_LVMETAD_AUTOSCAN)
+ PERMITTED_READ_ONLY | ALL_VGS_IS_DEFAULT | LOCKD_VG_SH)
xx(pvchange,
"Change attributes of physical volume(s)",
@@ -149,7 +149,7 @@ xx(pvs,
xx(pvscan,
"List all physical volumes",
- PERMITTED_READ_ONLY | LOCKD_VG_SH | NO_LVMETAD_AUTOSCAN | IGNORE_PERSISTENT_FILTER)
+ PERMITTED_READ_ONLY | LOCKD_VG_SH | IGNORE_PERSISTENT_FILTER)
xx(segtypes,
"List available segment types",
@@ -201,11 +201,10 @@ xx(vgextend,
xx(vgimport,
"Register exported volume group with system",
- ALL_VGS_IS_DEFAULT | NO_LVMETAD_AUTOSCAN)
+ ALL_VGS_IS_DEFAULT)
xx(vgimportclone,
- "Import a VG from cloned PVs",
- NO_LVMETAD_AUTOSCAN)
+ "Import a VG from cloned PVs", 0)
xx(vgmerge,
"Merge volume groups",
@@ -233,7 +232,7 @@ xx(vgs,
xx(vgscan,
"Search for all volume groups",
- PERMITTED_READ_ONLY | ALL_VGS_IS_DEFAULT | LOCKD_VG_SH | NO_LVMETAD_AUTOSCAN | IGNORE_PERSISTENT_FILTER)
+ PERMITTED_READ_ONLY | ALL_VGS_IS_DEFAULT | LOCKD_VG_SH | IGNORE_PERSISTENT_FILTER)
xx(vgsplit,
"Move physical volumes into a new or existing volume group",
diff --git a/tools/lvchange.c b/tools/lvchange.c
index 6282a6f31..07a578b86 100644
--- a/tools/lvchange.c
+++ b/tools/lvchange.c
@@ -1380,20 +1380,6 @@ static int _lvchange_activate_single(struct cmd_context *cmd,
}
}
- /*
- * If --sysinit -aay is used and at the same time lvmetad is used,
- * we want to rely on autoactivation to take place. Also, we
- * need to take special care here as lvmetad service does
- * not neet to be running at this moment yet - it could be
- * just too early during system initialization time.
- */
- if (arg_is_set(cmd, sysinit_ARG) && (arg_uint_value(cmd, activate_ARG, 0) == CHANGE_AAY)) {
- if (lvmetad_used()) {
- log_warn("WARNING: lvmetad is active, skipping direct activation during sysinit.");
- return ECMD_PROCESSED;
- }
- }
-
if (!_lvchange_activate(cmd, lv))
return_ECMD_FAILED;
diff --git a/tools/lvmcmdline.c b/tools/lvmcmdline.c
index 1146e7c38..cb1753d70 100644
--- a/tools/lvmcmdline.c
+++ b/tools/lvmcmdline.c
@@ -19,7 +19,6 @@
#include "lib/label/label.h"
#include "lvm-version.h"
#include "lib/locking/lvmlockd.h"
-#include "daemons/lvmetad/lvmetad-client.h"
#include "stub.h"
#include "lib/misc/last-path-component.h"
@@ -147,6 +146,8 @@ static const struct command_function _command_functions[CMD_COUNT] = {
{ lvconvert_to_vdopool_CMD, lvconvert_to_vdopool_cmd },
{ lvconvert_to_vdopool_param_CMD, lvconvert_to_vdopool_param_cmd },
+ { pvscan_display_CMD, pvscan_display_cmd },
+ { pvscan_cache_CMD, pvscan_cache_cmd },
};
@@ -2716,11 +2717,6 @@ static int _cmd_no_meta_proc(struct cmd_context *cmd)
return cmd->cname->flags & NO_METADATA_PROCESSING;
}
-static int _cmd_no_lvmetad_autoscan(struct cmd_context *cmd)
-{
- return cmd->cname->flags & NO_LVMETAD_AUTOSCAN;
-}
-
static int _cmd_ignores_persistent_filter(struct cmd_context *cmd)
{
return cmd->cname->flags & IGNORE_PERSISTENT_FILTER;
@@ -2729,7 +2725,6 @@ static int _cmd_ignores_persistent_filter(struct cmd_context *cmd)
int lvm_run_command(struct cmd_context *cmd, int argc, char **argv)
{
struct dm_config_tree *config_string_cft, *config_profile_command_cft, *config_profile_metadata_cft;
- const char *reason = NULL;
int ret = 0;
int locking_type;
int nolocking = 0;
@@ -2898,13 +2893,6 @@ int lvm_run_command(struct cmd_context *cmd, int argc, char **argv)
goto out;
}
- if (cmd->command->command_enum == lvconvert_repair_CMD) {
- log_warn("WARNING: Disabling lvmetad cache for repair command.");
- lvmetad_set_disabled(cmd, LVMETAD_DISABLE_REASON_REPAIR);
- log_warn("WARNING: Not using lvmetad because of repair.");
- lvmetad_make_unused(cmd);
- }
-
if (cmd->metadata_read_only &&
!(cmd->cname->flags & PERMITTED_READ_ONLY)) {
log_error("%s: Command not permitted while global/metadata_read_only "
@@ -2951,46 +2939,6 @@ int lvm_run_command(struct cmd_context *cmd, int argc, char **argv)
goto_out;
}
- /*
- * pvscan/vgscan/lvscan/vgimport want their own control over rescanning
- * to populate lvmetad and have similar code of their own.
- * Other commands use this general policy for using lvmetad.
- *
- * The lvmetad cache may need to be repopulated before we use it because:
- * - We are reading foreign VGs which others hosts may have changed
- * which our lvmetad would not have seen.
- * - lvmetad may have just been started and no command has been run
- * to populate it yet (e.g. no pvscan --cache was run).
- * - Another local command may have run with a different global filter
- * which changed the content of lvmetad from what we want (recognized
- * by different token values.)
- *
- * lvmetad may have been previously disabled (or disabled during the
- * rescan done here) because duplicate devices were seen.
- * In this case, disable the *use* of lvmetad by this command, reverting to
- * disk scanning.
- */
- if (lvmetad_used() && !_cmd_no_lvmetad_autoscan(cmd)) {
- if (cmd->include_foreign_vgs || !lvmetad_token_matches(cmd)) {
- if (lvmetad_used() && !lvmetad_pvscan_all_devs(cmd, cmd->include_foreign_vgs ? 1 : 0)) {
- log_warn("WARNING: Not using lvmetad because cache update failed.");
- lvmetad_make_unused(cmd);
- }
- }
-
- if (lvmetad_used() && lvmetad_is_disabled(cmd, &reason)) {
- log_warn("WARNING: Not using lvmetad because %s.", reason);
- lvmetad_make_unused(cmd);
-
- if (strstr(reason, "duplicate")) {
- log_warn("WARNING: Use multipath or vgimportclone to resolve duplicate PVs?");
- if (!find_config_tree_bool(cmd, devices_multipath_component_detection_CFG, NULL))
- log_warn("WARNING: Set multipath_component_detection=1 to hide multipath duplicates.");
- log_warn("WARNING: After duplicates are resolved, run \"pvscan --cache\" to enable lvmetad.");
- }
- }
- }
-
if (cmd->command->functions)
/* A command-line-specific function is used */
ret = cmd->command->functions->fn(cmd, argc, argv);
diff --git a/tools/lvscan.c b/tools/lvscan.c
index c38208ab0..cba4d616e 100644
--- a/tools/lvscan.c
+++ b/tools/lvscan.c
@@ -15,36 +15,6 @@
#include "tools.h"
-static int _lvscan_single_lvmetad(struct cmd_context *cmd, struct logical_volume *lv)
-{
- struct pv_list *pvl;
- struct dm_list all_pvs;
- char pvid_s[64] __attribute__((aligned(8)));
-
- if (!lvmetad_used())
- return ECMD_PROCESSED;
-
- dm_list_init(&all_pvs);
-
- if (!get_pv_list_for_lv(lv->vg->vgmem, lv, &all_pvs))
- return ECMD_FAILED;
-
- dm_list_iterate_items(pvl, &all_pvs) {
- if (!pvl->pv->dev) {
- if (!id_write_format(&pvl->pv->id, pvid_s, sizeof(pvid_s)))
- stack;
- else
- log_warn("WARNING: Device for PV %s already missing, skipping.",
- pvid_s);
- continue;
- }
- if (!lvmetad_pvscan_single(cmd, pvl->pv->dev, NULL, NULL))
- return ECMD_FAILED;
- }
-
- return ECMD_PROCESSED;
-}
-
static int _lvscan_single(struct cmd_context *cmd, struct logical_volume *lv,
struct processing_handle *handle __attribute__((unused)))
{
@@ -54,9 +24,6 @@ static int _lvscan_single(struct cmd_context *cmd, struct logical_volume *lv,
const char *active_str, *snapshot_str;
- if (arg_is_set(cmd, cache_long_ARG))
- return _lvscan_single_lvmetad(cmd, lv);
-
if (!arg_is_set(cmd, all_ARG) && !lv_is_visible(lv))
return ECMD_PROCESSED;
@@ -91,32 +58,9 @@ static int _lvscan_single(struct cmd_context *cmd, struct logical_volume *lv,
int lvscan(struct cmd_context *cmd, int argc, char **argv)
{
- const char *reason = NULL;
-
- if (argc && !arg_is_set(cmd, cache_long_ARG)) {
- log_error("No additional command line arguments allowed");
- return EINVALID_CMD_LINE;
- }
-
- if (!lvmetad_used() && arg_is_set(cmd, cache_long_ARG))
- log_verbose("Ignoring lvscan --cache because lvmetad is not in use.");
-
- /* Needed because this command has NO_LVMETAD_AUTOSCAN. */
- if (lvmetad_used() && (!lvmetad_token_matches(cmd) || lvmetad_is_disabled(cmd, &reason))) {
- if (lvmetad_used() && !lvmetad_pvscan_all_devs(cmd, 0)) {
- log_warn("WARNING: Not using lvmetad because cache update failed.");
- lvmetad_make_unused(cmd);
- }
-
- if (lvmetad_used() && lvmetad_is_disabled(cmd, &reason)) {
- log_warn("WARNING: Not using lvmetad because %s.", reason);
- lvmetad_make_unused(cmd);
- }
-
- /*
- * FIXME: doing lvscan --cache after a full scan is pointless.
- * Should the cache case just exit here?
- */
+ if (arg_is_set(cmd, cache_long_ARG)) {
+ log_warn("Ignoring lvscan --cache because lvmetad is no longer used.");
+ return ECMD_PROCESSED;
}
return process_each_lv(cmd, argc, argv, NULL, NULL, 0, NULL, NULL, &_lvscan_single);
diff --git a/tools/polldaemon.c b/tools/polldaemon.c
index 7ad45ca29..877247671 100644
--- a/tools/polldaemon.c
+++ b/tools/polldaemon.c
@@ -397,16 +397,13 @@ static int _report_progress(struct cmd_context *cmd, struct poll_operation_id *i
int ret;
/*
- * It's reasonable to expect a lockd_vg("sh") here, but it should
- * not actually be needed, because we only report the progress on
- * the same host where the pvmove/lvconvert is happening. This means
- * that the local pvmove/lvconvert/lvpoll commands are updating the
- * local lvmetad with the latest info they have, and we just need to
- * read the latest info that they have put into lvmetad about their
- * progress. No VG lock is needed to protect anything here (we're
- * just reading the VG), and no VG lock is needed to force a VG read
- * from disk to get changes from other hosts, because the only change
- * to the VG we're interested in is the change done locally.
+ * It's reasonable to expect a lockd_vg("sh") here, but it should not
+ * actually be needed, because we only report the progress on the same
+ * host where the pvmove/lvconvert is happening. No VG lock is needed
+ * to protect anything here (we're just reading the VG), and no VG lock
+ * is needed to force a VG read from disk to get changes from other
+ * hosts, because the only change to the VG we're interested in is the
+ * change done locally.
*/
vg = vg_read(cmd, id->vg_name, NULL, 0, lockd_state);
@@ -602,11 +599,6 @@ static int _poll_daemon(struct cmd_context *cmd, struct poll_operation_id *id,
parms->progress_display = 0; /* Child */
/* FIXME Use wait_event (i.e. interval = 0) and */
/* fork one daemon per copy? */
-
- if ((daemon_mode == 1) && find_config_tree_bool(cmd, global_use_lvmetad_CFG, NULL)) {
- if (!lvmetad_connect(cmd))
- log_warn("WARNING: lvm polling process %d cannot connect to lvmetad.", getpid());
- }
}
/*
diff --git a/tools/pvcreate.c b/tools/pvcreate.c
index 0af9d494c..4ffb12fb7 100644
--- a/tools/pvcreate.c
+++ b/tools/pvcreate.c
@@ -103,17 +103,6 @@ int pvcreate(struct cmd_context *cmd, int argc, char **argv)
struct pvcreate_params pp;
int ret;
- if (!argc) {
- log_error("Please enter a physical volume path.");
- return 0;
- }
-
- /*
- * Device info needs to be available for reading the VG backup file in
- * _pvcreate_restore_params_from_backup.
- */
- lvmcache_seed_infos_from_lvmetad(cmd);
-
/*
* Five kinds of pvcreate param values:
* 1. defaults
diff --git a/tools/pvdisplay.c b/tools/pvdisplay.c
index 5f033f3f0..3c97a7f29 100644
--- a/tools/pvdisplay.c
+++ b/tools/pvdisplay.c
@@ -60,7 +60,6 @@ out:
int pvdisplay(struct cmd_context *cmd, int argc, char **argv)
{
- int lock_global = 0;
int ret;
if (arg_is_set(cmd, columns_ARG)) {
@@ -94,25 +93,9 @@ int pvdisplay(struct cmd_context *cmd, int argc, char **argv)
return EINVALID_CMD_LINE;
}
- /*
- * If the lock_type is LCK_VG_READ (used only in reporting commands),
- * we lock VG_GLOBAL to enable use of metadata cache.
- * This can pause alongide pvscan or vgscan process for a while.
- */
- if (!lvmetad_used()) {
- lock_global = 1;
- if (!lock_vol(cmd, VG_GLOBAL, LCK_VG_READ, NULL)) {
- log_error("Unable to obtain global lock.");
- return ECMD_FAILED;
- }
- }
-
ret = process_each_pv(cmd, argc, argv, NULL,
arg_is_set(cmd, all_ARG), 0,
NULL, _pvdisplay_single);
- if (lock_global)
- unlock_vg(cmd, NULL, VG_GLOBAL);
-
return ret;
}
diff --git a/tools/pvscan.c b/tools/pvscan.c
index 393edb50a..a4c0244eb 100644
--- a/tools/pvscan.c
+++ b/tools/pvscan.c
@@ -15,14 +15,11 @@
#include "tools.h"
-#include "lib/cache/lvmetad.h"
#include "lib/cache/lvmcache.h"
#include "lib/metadata/metadata.h"
#include <dirent.h>
-static int _pvscan_online_aa(struct cmd_context *cmd, int argc, char **argv);
-
struct pvscan_params {
int new_pvs_found;
int pvs_found;
@@ -37,7 +34,6 @@ struct pvscan_params {
struct pvscan_aa_params {
int refresh_all;
unsigned int activate_errors;
- struct dm_list changed_vgnames;
};
static int _pvscan_display_pv(struct cmd_context *cmd,
@@ -131,551 +127,12 @@ static int _pvscan_display_single(struct cmd_context *cmd, struct volume_group *
return ECMD_PROCESSED;
}
-static int _lvmetad_clear_dev(dev_t devno, int32_t major, int32_t minor)
-{
- char buf[24];
-
- (void) dm_snprintf(buf, sizeof(buf), FMTd32 ":" FMTd32, major, minor);
-
- if (!lvmetad_pv_gone(devno, buf))
- return_0;
-
- log_print_unless_silent("Device %s not found. Cleared from lvmetad cache.", buf);
-
- return 1;
-}
-
-/*
- * pvscan --cache does not perform any lvmlockd locking, and
- * pvscan --cache -aay skips autoactivation in lockd VGs.
- *
- * pvscan --cache populates lvmetad with VG metadata from disk.
- * No lvmlockd locking is needed. It is expected that lockd VG
- * metadata that is read by pvscan and populated in lvmetad may
- * be immediately stale due to changes to the VG from other hosts
- * during or after this pvscan. This is normal and not a problem.
- * When a subsequent lvm command uses the VG, it will lock the VG
- * with lvmlockd, read the VG from lvmetad, and update the cached
- * copy from disk if necessary.
- *
- * pvscan --cache -aay does not activate LVs in lockd VGs because
- * activation requires locking, and a lock-start operation is needed
- * on a lockd VG before any locking can be performed in it.
- *
- * An equivalent of pvscan --cache -aay for lockd VGs is:
- * 1. pvscan --cache
- * 2. vgchange --lock-start
- * 3. vgchange -aay -S 'locktype=sanlock || locktype=dlm'
- *
- * [We could eventually add support for autoactivating lockd VGs
- * using pvscan by incorporating the lock start step (which can
- * take a long time), but there may be a better option than
- * continuing to overload pvscan.]
- *
- * Stages of starting a lockd VG:
- *
- * . pvscan --cache populates lockd VGs in lvmetad without locks,
- * and this initial cached copy may quickly become stale.
- *
- * . vgchange --lock-start VG reads the VG without the VG lock
- * because no locks are available until the locking is started.
- * It only uses the VG name and lock_type from the VG metadata,
- * and then only uses it to start the VG lockspace in lvmlockd.
- *
- * . Further lvm commands, e.g. activation, can then lock the VG
- * with lvmlockd and use current VG metdata.
- */
-
-#define REFRESH_BEFORE_AUTOACTIVATION_RETRIES 5
-#define REFRESH_BEFORE_AUTOACTIVATION_RETRY_USLEEP_DELAY 100000
-
-static int _pvscan_autoactivate_single(struct cmd_context *cmd, const char *vg_name,
- struct volume_group *vg, struct processing_handle *handle)
-{
- struct pvscan_aa_params *pp = (struct pvscan_aa_params *)handle->custom_handle;
- unsigned int refresh_retries = REFRESH_BEFORE_AUTOACTIVATION_RETRIES;
- int refresh_done = 0;
-
- if (vg_is_clustered(vg))
- return ECMD_PROCESSED;
-
- if (vg_is_exported(vg))
- return ECMD_PROCESSED;
-
- if (vg_is_shared(vg))
- return ECMD_PROCESSED;
-
- log_debug("pvscan autoactivating VG %s.", vg_name);
-
- /*
- * Refresh LVs in a VG that has "changed" from finding a PV.
- * The meaning of "changed" is determined in lvmetad, and is
- * returned to the command as a flag.
- *
- * FIXME: There's a tiny race when suspending the device which is part
- * of the refresh because when suspend ioctl is performed, the dm
- * kernel driver executes (do_suspend and dm_suspend kernel fn):
- *
- * step 1: a check whether the dev is already suspended and
- * if yes it returns success immediately as there's
- * nothing to do
- * step 2: it grabs the suspend lock
- * step 3: another check whether the dev is already suspended
- * and if found suspended, it exits with -EINVAL now
- *
- * The race can occur in between step 1 and step 2. To prevent premature
- * autoactivation failure, we're using a simple retry logic here before
- * we fail completely. For a complete solution, we need to fix the
- * locking so there's no possibility for suspend calls to interleave
- * each other to cause this kind of race.
- *
- * Remove this workaround with "refresh_retries" once we have proper locking in!
- */
- if (pp->refresh_all || str_list_match_item(&pp->changed_vgnames, vg_name)) {
- while (refresh_retries--) {
- log_debug_activation("Refreshing VG %s before autoactivation.", vg_name);
- if (vg_refresh_visible(cmd, vg)) {
- refresh_done = 1;
- break;
- }
- usleep(REFRESH_BEFORE_AUTOACTIVATION_RETRY_USLEEP_DELAY);
- }
-
- if (!refresh_done)
- log_warn("%s: refresh before autoactivation failed.", vg->name);
- }
-
- log_debug_activation("Autoactivating VG %s.", vg_name);
-
- if (!vgchange_activate(cmd, vg, CHANGE_AAY)) {
- log_error("%s: autoactivation failed.", vg->name);
- pp->activate_errors++;
- goto out;
- }
-
-out:
- return ECMD_PROCESSED;
-}
-
-static int _pvscan_autoactivate(struct cmd_context *cmd, struct pvscan_aa_params *pp,
- int all_vgs, struct dm_list *vgnames)
-{
- struct processing_handle *handle = NULL;
- int ret;
-
- if (!all_vgs && dm_list_empty(vgnames)) {
- log_debug("No VGs to autoactivate.");
- return ECMD_PROCESSED;
- }
-
- if (!lvmetad_used())
- log_warn("WARNING: Autoactivation reading from disk instead of lvmetad.");
-
- if (!(handle = init_processing_handle(cmd, NULL))) {
- log_error("Failed to initialize processing handle.");
- return ECMD_FAILED;
- }
-
- handle->custom_handle = pp;
-
- if (all_vgs) {
- cmd->cname->flags |= ALL_VGS_IS_DEFAULT;
- pp->refresh_all = 1;
- }
-
- ret = process_each_vg(cmd, 0, NULL, NULL, vgnames, READ_FOR_UPDATE, 0, handle, _pvscan_autoactivate_single);
-
- destroy_processing_handle(cmd, handle);
-
- return ret;
-}
-
-static int _pvscan_cache(struct cmd_context *cmd, int argc, char **argv)
-{
- struct pvscan_aa_params pp = { 0 };
- struct dm_list single_devs;
- struct dm_list found_vgnames;
- struct device *dev;
- struct device_list *devl;
- const char *pv_name;
- const char *reason = NULL;
- int32_t major = -1;
- int32_t minor = -1;
- int devno_args = 0;
- struct arg_value_group_list *current_group;
- dev_t devno;
- int do_activate;
- int all_vgs = 0;
- int remove_errors = 0;
- int add_errors = 0;
- int ret = ECMD_PROCESSED;
-
- dm_list_init(&found_vgnames);
- dm_list_init(&pp.changed_vgnames);
-
- if ((do_activate = arg_is_set(cmd, activate_ARG))) {
- if (arg_uint_value(cmd, activate_ARG, 0) != CHANGE_AAY) {
- log_error("Only --activate ay allowed with pvscan.");
- return EINVALID_CMD_LINE;
- }
-
- if (!lvmetad_used() &&
- !find_config_tree_bool(cmd, global_use_lvmetad_CFG, NULL)) {
- log_verbose("Ignoring pvscan --cache -aay because lvmetad is not in use.");
- return ret;
- }
- } else {
- if (!lvmetad_used()) {
- log_verbose("Ignoring pvscan --cache because lvmetad is not in use.");
- return ret;
- }
- }
-
- if (arg_is_set(cmd, major_ARG) + arg_is_set(cmd, minor_ARG))
- devno_args = 1;
-
- if (devno_args && (!arg_is_set(cmd, major_ARG) || !arg_is_set(cmd, minor_ARG))) {
- log_error("Both --major and --minor required to identify devices.");
- return EINVALID_CMD_LINE;
- }
-
- if (!lock_vol(cmd, VG_GLOBAL, LCK_VG_READ, NULL)) {
- log_error("Unable to obtain global lock.");
- return ECMD_FAILED;
- }
-
- /*
- * This a special case where use_lvmetad=1 in lvm.conf but pvscan
- * cannot use lvmetad for some reason. In this case pvscan should
- * still activate LVs even though it's not updating the cache.
- */
- if (do_activate && !lvmetad_used()) {
- log_verbose("Activating all VGs without lvmetad.");
- all_vgs = 1;
- devno_args = 0;
- goto activate;
- }
-
- /*
- * Scan all devices when no args are given.
- */
- if (!argc && !devno_args) {
- log_verbose("Scanning all devices.");
-
- if (!lvmetad_pvscan_all_devs(cmd, 1)) {
- log_warn("WARNING: Not using lvmetad because cache update failed.");
- lvmetad_make_unused(cmd);
- }
- if (lvmetad_used() && lvmetad_is_disabled(cmd, &reason)) {
- log_warn("WARNING: Not using lvmetad because %s.", reason);
- lvmetad_make_unused(cmd);
- }
- all_vgs = 1;
- goto activate;
- }
-
- /*
- * FIXME: when specific devs are named, we generally don't want to scan
- * any other devs, but if lvmetad is not yet populated, the first
- * 'pvscan --cache dev' does need to do a full scan. We want to remove
- * the need for this case so that 'pvscan --cache dev' is guaranteed to
- * never scan any devices other than those specified.
- */
- if (!lvmetad_token_matches(cmd)) {
- log_verbose("Scanning all devices to initialize lvmetad.");
-
- if (lvmetad_used() && !lvmetad_pvscan_all_devs(cmd, 0)) {
- log_warn("WARNING: Not using lvmetad because cache update failed.");
- lvmetad_make_unused(cmd);
- }
- if (lvmetad_used() && lvmetad_is_disabled(cmd, &reason)) {
- log_warn("WARNING: Not using lvmetad because %s.", reason);
- lvmetad_make_unused(cmd);
- }
- all_vgs = 1;
- goto activate;
- }
-
- /*
- * When args are given, scan only those devices. If lvmetad is already
- * disabled, a full scan is required to reenable it, so there's no
- * point in doing individual device scans, so go directly to
- * autoactivation. (FIXME: Should we also skip autoactivation in this
- * case since that will read disks with lvmetad disabled?
- * i.e. avoid disk access and not activate LVs, or or read from disk
- * and activate LVs?)
- */
- if (lvmetad_is_disabled(cmd, &reason)) {
- log_warn("WARNING: Not using lvmetad because %s.", reason);
- lvmetad_make_unused(cmd);
- all_vgs = 1;
- goto activate;
- }
-
- /*
- * Step 1: for each device, if it's no longer found, then tell lvmetad
- * to drop it. If the device exists, read metadata from it and send
- * that to lvmetad.
- *
- * When given a device name, check if the device is not visible to
- * lvmetad, but still visible to the system, and if so, tell lvmetad to
- * drop it (using the major:minor from the system).
- *
- * When given a major:minor which is not visible to the system, just
- * tell lvmetad to drop it directly using that major:minor.
- *
- * When a device has left the system, it must be dropped using
- * --major/--minor because we cannot map the device name to major:minor
- * after the device has left. (A full rescan could of course be used
- * to drop any devices that have left.)
- */
-
- if (argc || devno_args) {
- log_verbose("Scanning devices on command line.");
- cmd->pvscan_cache_single = 1;
- }
-
- /* Creates a list of dev names from /dev, sysfs, etc; does not read any. */
- dev_cache_scan();
-
- dm_list_init(&single_devs);
-
- while (argc--) {
- pv_name = *argv++;
- if (pv_name[0] == '/') {
- if (!(dev = dev_cache_get(cmd, pv_name, cmd->lvmetad_filter))) {
- /* Remove device path from lvmetad. */
- log_debug("Removing dev %s from lvmetad cache.", pv_name);
- if ((dev = dev_cache_get(cmd, pv_name, NULL))) {
- if (!_lvmetad_clear_dev(dev->dev, MAJOR(dev->dev), MINOR(dev->dev)))
- remove_errors++;
- } else {
- log_error("Physical Volume %s not found.", pv_name);
- ret = ECMD_FAILED;
- }
- } else {
- /*
- * Scan device. This dev could still be
- * removed from lvmetad below if it doesn't
- * pass other filters.
- */
- log_debug("Scanning dev %s for lvmetad cache.", pv_name);
-
- if (!(devl = dm_pool_zalloc(cmd->mem, sizeof(*devl))))
- return_0;
- devl->dev = dev;
- dm_list_add(&single_devs, &devl->list);
- }
- } else {
- if (sscanf(pv_name, "%d:%d", &major, &minor) != 2) {
- log_warn("WARNING: Failed to parse major:minor from %s, skipping.", pv_name);
- continue;
- }
- devno = MKDEV((dev_t)major, (dev_t)minor);
-
- if (!(dev = dev_cache_get_by_devt(cmd, devno, cmd->lvmetad_filter))) {
- /* Remove major:minor from lvmetad. */
- log_debug("Removing dev %d:%d from lvmetad cache.", major, minor);
- if (!_lvmetad_clear_dev(devno, major, minor))
- remove_errors++;
- } else {
- /*
- * Scan device. This dev could still be
- * removed from lvmetad below if it doesn't
- * pass other filters.
- */
- log_debug("Scanning dev %d:%d for lvmetad cache.", major, minor);
-
- if (!(devl = dm_pool_zalloc(cmd->mem, sizeof(*devl))))
- return_0;
- devl->dev = dev;
- dm_list_add(&single_devs, &devl->list);
- }
- }
-
- if (sigint_caught()) {
- ret = ECMD_FAILED;
- goto_out;
- }
- }
-
- if (!dm_list_empty(&single_devs)) {
- label_scan_devs(cmd, cmd->lvmetad_filter, &single_devs);
-
- dm_list_iterate_items(devl, &single_devs) {
- dev = devl->dev;
-
- if (dev->flags & DEV_FILTER_OUT_SCAN) {
- log_debug("Removing dev %s from lvmetad cache after scan.", dev_name(dev));
- if (!_lvmetad_clear_dev(dev->dev, MAJOR(dev->dev), MINOR(dev->dev)))
- remove_errors++;
- continue;
- }
-
- /*
- * Devices that exist and pass the lvmetad filter
- * are added to lvmetad.
- */
- if (!lvmetad_pvscan_single(cmd, dev, &found_vgnames, &pp.changed_vgnames))
- add_errors++;
- }
- }
-
- if (!devno_args)
- goto activate;
-
- dm_list_init(&single_devs);
-
- /* Process any grouped --major --minor args */
- dm_list_iterate_items(current_group, &cmd->arg_value_groups) {
- major = grouped_arg_int_value(current_group->arg_values, major_ARG, major);
- minor = grouped_arg_int_value(current_group->arg_values, minor_ARG, minor);
-
- if (major < 0 || minor < 0)
- continue;
-
- devno = MKDEV((dev_t)major, (dev_t)minor);
-
- if (!(dev = dev_cache_get_by_devt(cmd, devno, cmd->lvmetad_filter))) {
- /* Remove major:minor from lvmetad. */
- log_debug("Removing dev %d:%d from lvmetad cache.", major, minor);
- if (!_lvmetad_clear_dev(devno, major, minor))
- remove_errors++;
- } else {
- /* Add major:minor to lvmetad. */
- log_debug("Scanning dev %d:%d for lvmetad cache.", major, minor);
-
- if (!(devl = dm_pool_zalloc(cmd->mem, sizeof(*devl))))
- return_0;
- devl->dev = dev;
- dm_list_add(&single_devs, &devl->list);
- }
-
- if (sigint_caught()) {
- ret = ECMD_FAILED;
- goto_out;
- }
- }
-
- if (!dm_list_empty(&single_devs)) {
- label_scan_devs(cmd, cmd->lvmetad_filter, &single_devs);
-
- dm_list_iterate_items(devl, &single_devs) {
- dev = devl->dev;
-
- if (dev->flags & DEV_FILTER_OUT_SCAN) {
- log_debug("Removing dev %s from lvmetad cache after scan.", dev_name(dev));
- if (!_lvmetad_clear_dev(dev->dev, MAJOR(dev->dev), MINOR(dev->dev)))
- remove_errors++;
- continue;
- }
-
- /*
- * Devices that exist and pass the lvmetad filter
- * are added to lvmetad.
- */
- if (!lvmetad_pvscan_single(cmd, devl->dev, &found_vgnames, &pp.changed_vgnames))
- add_errors++;
- }
- }
-
- /*
- * In the process of scanning devices, lvmetad may have become
- * disabled. If so, revert to scanning for the autoactivation step.
- * Only autoactivate the VGs that were found during the dev scans.
- */
- if (lvmetad_used() && lvmetad_is_disabled(cmd, &reason)) {
- log_warn("WARNING: Not using lvmetad because %s.", reason);
- lvmetad_make_unused(cmd);
- }
-
-activate:
- /*
- * Step 2: when the PV was sent to lvmetad, the lvmetad reply
- * indicated if all the PVs for the VG are now found. If so,
- * the vgname was added to the list, and we can attempt to
- * autoactivate LVs in the VG.
- */
- if (do_activate)
- ret = _pvscan_autoactivate(cmd, &pp, all_vgs, &found_vgnames);
-
-out:
- if (remove_errors || add_errors || pp.activate_errors)
- ret = ECMD_FAILED;
-
- if (!sync_local_dev_names(cmd))
- stack;
- unlock_vg(cmd, NULL, VG_GLOBAL);
- return ret;
-}
-
-/*
- * Three main pvscan cases related to lvmetad usage:
- * 1. pvscan
- * 2. pvscan --cache
- * 3. pvscan --cache <dev>
- *
- * 1. The 'pvscan' command (without --cache) may or may not attempt to
- * repopulate the lvmetad cache, and may or may not use the lvmetad
- * cache to display PV info:
- *
- * i. If lvmetad is being used and is in a normal state, then 'pvscan'
- * will simply read and display PV info from the lvmetad cache.
- *
- * ii. If lvmetad is not being used, 'pvscan' will read all devices to
- * display the PV info.
- *
- * iii. If lvmetad is being used, but has been disabled (because of
- * duplicate devs), or has a non-matching token
- * (because the device filter is different from the device filter last
- * used to populate lvmetad), then 'pvscan' will begin by rescanning
- * devices to repopulate lvmetad. If lvmetad is enabled after the
- * rescan, then 'pvscan' will simply read and display PV info from the
- * lvmetad cache (like case i). If lvmetad is disabled after the
- * rescan, then 'pvscan' will read all devices to display PV info
- * (like case ii).
- *
- * 2. The 'pvscan --cache' command (without named devs) will always
- * attempt to repopulate the lvmetad cache by rescanning all devs
- * (regardless of whether lvmetad was previously disabled or had an
- * unmatching token.) lvmetad may be enabled or disabled after the
- * rescan (depending on whether duplicate devs).
- *
- * 3. The 'pvscan --cache <dev>' command will attempt to repopulate the
- * lvmetad cache by rescanning all devs if lvmetad has a non-matching
- * token (e.g. because it has not yet been populated, see FIXME above).
- * Otherwise, the command will only rescan the named <dev> and send
- * their metadata to lvmetad.
- */
-
-int pvscan(struct cmd_context *cmd, int argc, char **argv)
+int pvscan_display_cmd(struct cmd_context *cmd, int argc, char **argv)
{
struct pvscan_params params = { 0 };
struct processing_handle *handle = NULL;
- const char *reason = NULL;
int ret;
- if (arg_is_set(cmd, cache_long_ARG) && !lvmetad_used())
- return _pvscan_online_aa(cmd, argc, argv);
-
- if (arg_is_set(cmd, cache_long_ARG))
- return _pvscan_cache(cmd, argc, argv);
-
- if (argc) {
- log_error("Too many parameters on command line.");
- return EINVALID_CMD_LINE;
- }
-
- if (arg_is_set(cmd, activate_ARG)) {
- log_error("--activate is only valid with --cache.");
- return EINVALID_CMD_LINE;
- }
-
- if (arg_is_set(cmd, major_ARG) || arg_is_set(cmd, minor_ARG)) {
- log_error("--major and --minor are only valid with --cache.");
- return EINVALID_CMD_LINE;
- }
-
if (arg_is_set(cmd, novolumegroup_ARG) && arg_is_set(cmd, exported_ARG)) {
log_error("Options -e and -n are incompatible");
return EINVALID_CMD_LINE;
@@ -686,19 +143,6 @@ int pvscan(struct cmd_context *cmd, int argc, char **argv)
arg_is_set(cmd, exported_ARG) ?
"of exported volume group(s)" : "in no volume group");
- /* Needed because this command has NO_LVMETAD_AUTOSCAN. */
- if (lvmetad_used() && (!lvmetad_token_matches(cmd) || lvmetad_is_disabled(cmd, &reason))) {
- if (lvmetad_used() && !lvmetad_pvscan_all_devs(cmd, 0)) {
- log_warn("WARNING: Not using lvmetad because cache update failed.");
- lvmetad_make_unused(cmd);
- }
-
- if (lvmetad_used() && lvmetad_is_disabled(cmd, &reason)) {
- log_warn("WARNING: Not using lvmetad because %s.", reason);
- lvmetad_make_unused(cmd);
- }
- }
-
if (!lock_vol(cmd, VG_GLOBAL, LCK_VG_WRITE, NULL)) {
log_error("Unable to obtain global lock.");
return ECMD_FAILED;
@@ -1148,7 +592,7 @@ static int _pvscan_aa(struct cmd_context *cmd, struct pvscan_aa_params *pp,
return ret;
}
-static int _pvscan_online_aa(struct cmd_context *cmd, int argc, char **argv)
+int pvscan_cache_cmd(struct cmd_context *cmd, int argc, char **argv)
{
struct pvscan_aa_params pp = { 0 };
struct dm_list single_devs;
@@ -1369,3 +813,10 @@ out:
return ret;
}
+int pvscan(struct cmd_context *cmd, int argc, char **argv)
+{
+ log_error(INTERNAL_ERROR "Missing function for command definition %d:%s.",
+ cmd->command->command_index, cmd->command->command_id);
+ return ECMD_FAILED;
+}
+
diff --git a/tools/reporter.c b/tools/reporter.c
index faaff3741..cd2a41e38 100644
--- a/tools/reporter.c
+++ b/tools/reporter.c
@@ -1104,8 +1104,7 @@ static int _do_report(struct cmd_context *cmd, struct processing_handle *handle,
* We lock VG_GLOBAL to enable use of metadata cache.
* This can pause alongide pvscan or vgscan process for a while.
*/
- if (single_args->args_are_pvs && (report_type == PVS || report_type == PVSEGS) &&
- !lvmetad_used()) {
+ if (single_args->args_are_pvs && (report_type == PVS || report_type == PVSEGS)) {
lock_global = 1;
if (!lock_vol(cmd, VG_GLOBAL, LCK_VG_READ, NULL)) {
log_error("Unable to obtain global lock.");
@@ -1421,8 +1420,6 @@ static int _report(struct cmd_context *cmd, int argc, char **argv, report_type_t
return ECMD_FAILED;
}
- lvmcache_seed_infos_from_lvmetad(cmd);
-
if (single_args->report_type == FULL) {
handle->custom_handle = &args;
r = process_each_vg(cmd, argc, argv, NULL, NULL, 0, 1, handle, &_full_report_single);
diff --git a/tools/toollib.c b/tools/toollib.c
index 62e1ecfd3..36ae12550 100644
--- a/tools/toollib.c
+++ b/tools/toollib.c
@@ -106,8 +106,6 @@ int become_daemon(struct cmd_context *cmd, int skip_lvm)
strncpy(*cmd->argv, "(lvm2)", strlen(*cmd->argv));
- lvmetad_disconnect();
-
if (!skip_lvm) {
reset_locking();
lvmcache_destroy(cmd, 1, 1);
@@ -1475,7 +1473,6 @@ int process_each_label(struct cmd_context *cmd, int argc, char **argv,
log_set_report_object_type(LOG_REPORT_OBJECT_TYPE_LABEL);
lvmcache_label_scan(cmd);
- lvmcache_seed_infos_from_lvmetad(cmd);
if (argc) {
for (; opt < argc; opt++) {
@@ -2064,10 +2061,8 @@ static int _resolve_duplicate_vgnames(struct cmd_context *cmd,
continue;
/*
- * Without lvmetad, a label scan has already populated
- * lvmcache vginfo with this information.
- * With lvmetad, this function does vg_lookup on this
- * name/vgid and checks system_id in the metadata.
+ * label scan has already populated lvmcache vginfo with
+ * this information.
*/
if (lvmcache_vg_is_foreign(cmd, vgnl->vg_name, vgnl->vgid)) {
if (!id_write_format((const struct id*)vgnl->vgid, uuid, sizeof(uuid)))
@@ -3912,8 +3907,6 @@ static int _get_all_devices(struct cmd_context *cmd, struct dm_list *all_devices
log_debug("Getting list of all devices");
- lvmcache_seed_infos_from_lvmetad(cmd);
-
if (!(iter = dev_iter_create(cmd->full_filter, 1))) {
log_error("dev_iter creation failed.");
return ECMD_FAILED;
@@ -4574,7 +4567,6 @@ int process_each_pv(struct cmd_context *cmd,
log_verbose("Some PVs were not found in first search, retrying.");
lvmcache_label_scan(cmd);
- lvmcache_seed_infos_from_lvmetad(cmd);
ret = _process_pvs_in_vgs(cmd, read_flags, &all_vgnameids, &all_devices,
&arg_missed, &arg_tags, 0, 0,
@@ -5770,12 +5762,6 @@ do_command:
continue;
}
- if (!lvmetad_pv_gone_by_dev(pd->dev)) {
- log_error("Failed to remove PV %s from lvmetad.", pd->name);
- dm_list_move(&pp->arg_fail, &pd->list);
- continue;
- }
-
log_print_unless_silent("Labels on physical volume \"%s\" successfully wiped.",
pd->name);
}
@@ -5790,12 +5776,6 @@ do_command:
continue;
}
- if (!lvmetad_pv_gone_by_dev(pd->dev)) {
- log_error("Failed to remove PV %s from lvmetad.", pd->name);
- dm_list_move(&pp->arg_fail, &pd->list);
- continue;
- }
-
lvmcache_remove_unchosen_duplicate(pd->dev);
log_print_unless_silent("Labels on physical volume \"%s\" successfully wiped.",
diff --git a/tools/tools.h b/tools/tools.h
index d60576845..405910fc7 100644
--- a/tools/tools.h
+++ b/tools/tools.h
@@ -23,7 +23,6 @@
#include "lib/activate/activate.h"
#include "lib/format_text/archiver.h"
#include "lib/cache/lvmcache.h"
-#include "lib/cache/lvmetad.h"
#include "lib/locking/lvmlockd.h"
#include "lvm-version.h"
#include "lib/config/config.h"
@@ -128,8 +127,6 @@ struct arg_value_group_list {
#define IGNORE_PERSISTENT_FILTER 0x00000080
/* Command must use all specified arg names and fail if all cannot be used. */
#define MUST_USE_ALL_ARGS 0x00000100
-/* Command wants to control the device scan for lvmetad itself. */
-#define NO_LVMETAD_AUTOSCAN 0x00000200
/* Command should process unused duplicate devices. */
#define ENABLE_DUPLICATE_DEVS 0x00000400
/* Command does not accept tags as args. */
@@ -270,4 +267,7 @@ int lvconvert_merge_cmd(struct cmd_context *cmd, int argc, char **argv);
int lvconvert_to_vdopool_cmd(struct cmd_context *cmd, int argc, char **argv);
int lvconvert_to_vdopool_param_cmd(struct cmd_context *cmd, int argc, char **argv);
+int pvscan_display_cmd(struct cmd_context *cmd, int argc, char **argv);
+int pvscan_cache_cmd(struct cmd_context *cmd, int argc, char **argv);
+
#endif
diff --git a/tools/vgcfgrestore.c b/tools/vgcfgrestore.c
index 0dd7d4d77..84032f133 100644
--- a/tools/vgcfgrestore.c
+++ b/tools/vgcfgrestore.c
@@ -14,7 +14,6 @@
*/
#include "tools.h"
-#include "daemons/lvmetad/lvmetad-client.h"
#include "device_mapper/all.h"
#include "device_mapper/misc/dm-ioctl.h"
@@ -77,7 +76,6 @@ out:
int vgcfgrestore(struct cmd_context *cmd, int argc, char **argv)
{
const char *vg_name = NULL;
- int lvmetad_rescan = 0;
unsigned found = 0;
int ret;
@@ -121,22 +119,6 @@ int vgcfgrestore(struct cmd_context *cmd, int argc, char **argv)
}
}
- /*
- * lvmetad does not handle a VG being restored, which would require
- * vg_remove of the existing VG, then vg_update of the restored VG. A
- * command failure after removing the existing VG from lvmetad would
- * not be easily recovered from. So, disable the lvmetad cache before
- * doing the restore. After the VG is restored on disk, rescan
- * metadata from disk to populate lvmetad from scratch which will pick
- * up the VG that was restored on disk.
- */
-
- if (lvmetad_used()) {
- lvmetad_set_disabled(cmd, LVMETAD_DISABLE_REASON_VGRESTORE);
- lvmetad_disconnect();
- lvmetad_rescan = 1;
- }
-
if (!lock_vol(cmd, VG_ORPHANS, LCK_VG_WRITE, NULL)) {
log_error("Unable to lock orphans.");
return ECMD_FAILED;
@@ -161,7 +143,7 @@ int vgcfgrestore(struct cmd_context *cmd, int argc, char **argv)
unlock_vg(cmd, NULL, VG_ORPHANS);
log_error("Restore failed.");
ret = ECMD_FAILED;
- goto rescan;
+ goto out;
}
ret = ECMD_PROCESSED;
@@ -169,21 +151,6 @@ int vgcfgrestore(struct cmd_context *cmd, int argc, char **argv)
unlock_vg(cmd, NULL, VG_ORPHANS);
unlock_vg(cmd, NULL, vg_name);
-rescan:
- if (lvmetad_rescan) {
- if (!lvmetad_connect(cmd)) {
- log_warn("WARNING: Failed to connect to lvmetad.");
- log_warn("WARNING: Update lvmetad with pvscan --cache.");
- goto out;
- }
- if (!refresh_filters(cmd))
- stack;
- if (!lvmetad_pvscan_all_devs(cmd, 1)) {
- log_warn("WARNING: Failed to scan devices.");
- log_warn("WARNING: Update lvmetad with pvscan --cache.");
- goto out;
- }
- }
out:
return ret;
}
diff --git a/tools/vgchange.c b/tools/vgchange.c
index fa0fd5365..c8f894d49 100644
--- a/tools/vgchange.c
+++ b/tools/vgchange.c
@@ -769,20 +769,6 @@ int vgchange(struct cmd_context *cmd, int argc, char **argv)
return EINVALID_CMD_LINE;
}
- /*
- * If --sysinit -aay is used and at the same time lvmetad is used,
- * we want to rely on autoactivation to take place. Also, we
- * need to take special care here as lvmetad service does
- * not neet to be running at this moment yet - it could be
- * just too early during system initialization time.
- */
- if (arg_is_set(cmd, sysinit_ARG) && (arg_uint_value(cmd, activate_ARG, 0) == CHANGE_AAY)) {
- if (lvmetad_used()) {
- log_warn("WARNING: lvmetad is active, skipping direct activation during sysinit");
- return ECMD_PROCESSED;
- }
- }
-
if (arg_is_set(cmd, clustered_ARG) && !argc && !arg_is_set(cmd, yes_ARG) &&
(yes_no_prompt("Change clustered property of all volumes groups? [y/n]: ") == 'n')) {
log_error("No volume groups changed.");
diff --git a/tools/vgck.c b/tools/vgck.c
index 54bc9d649..a126c2924 100644
--- a/tools/vgck.c
+++ b/tools/vgck.c
@@ -37,7 +37,6 @@ static int vgck_single(struct cmd_context *cmd __attribute__((unused)),
int vgck(struct cmd_context *cmd, int argc, char **argv)
{
- lvmetad_make_unused(cmd);
return process_each_vg(cmd, argc, argv, NULL, NULL, 0, 0, NULL,
&vgck_single);
}
diff --git a/tools/vgcreate.c b/tools/vgcreate.c
index 94f95ec0c..2a40bc718 100644
--- a/tools/vgcreate.c
+++ b/tools/vgcreate.c
@@ -84,8 +84,7 @@ int vgcreate(struct cmd_context *cmd, int argc, char **argv)
return ECMD_FAILED;
}
- lvmcache_label_scan(cmd); /* Does nothing when using lvmetad. */
- lvmcache_seed_infos_from_lvmetad(cmd); /* Does nothing unless using lvmetad. */
+ lvmcache_label_scan(cmd);
if (lvmcache_fmt_from_vgname(cmd, vp_new.vg_name, NULL, 0)) {
unlock_vg(cmd, NULL, vp_new.vg_name);
diff --git a/tools/vgimport.c b/tools/vgimport.c
index 8ef870967..26c63630a 100644
--- a/tools/vgimport.c
+++ b/tools/vgimport.c
@@ -61,8 +61,6 @@ bad:
int vgimport(struct cmd_context *cmd, int argc, char **argv)
{
- const char *reason = NULL;
-
if (!argc && !arg_is_set(cmd, all_ARG) && !arg_is_set(cmd, select_ARG)) {
log_error("Please supply volume groups or -S for selection or use -a for all.");
return EINVALID_CMD_LINE;
@@ -89,24 +87,6 @@ int vgimport(struct cmd_context *cmd, int argc, char **argv)
cmd->handles_missing_pvs = 1;
}
- /*
- * Rescan devices and update lvmetad. lvmetad may hold a copy of the
- * VG from before it was exported, if it was exported by another host.
- * We need to reread it to see that it's been exported before we can
- * import it.
- */
- if (lvmetad_used()) {
- if (!lvmetad_pvscan_all_devs(cmd, 1)) {
- log_warn("WARNING: Not using lvmetad because cache update failed.");
- lvmetad_make_unused(cmd);
- }
-
- if (lvmetad_used() && lvmetad_is_disabled(cmd, &reason)) {
- log_warn("WARNING: Not using lvmetad because %s.", reason);
- lvmetad_make_unused(cmd);
- }
- }
-
return process_each_vg(cmd, argc, argv, NULL, NULL,
READ_FOR_UPDATE | READ_ALLOW_EXPORTED,
0, NULL,
diff --git a/tools/vgimportclone.c b/tools/vgimportclone.c
index e37b89772..b7fae61fa 100644
--- a/tools/vgimportclone.c
+++ b/tools/vgimportclone.c
@@ -14,7 +14,6 @@
#include "tools.h"
#include "lib/cache/lvmcache.h"
-#include "daemons/lvmetad/lvmetad-client.h"
#include "lib/filters/filter.h"
struct vgimportclone_params {
@@ -204,7 +203,6 @@ int vgimportclone(struct cmd_context *cmd, int argc, char **argv)
char base_vgname[NAME_LEN] = { 0 };
char tmp_vgname[NAME_LEN] = { 0 };
unsigned int vgname_count;
- int lvmetad_rescan = 0;
int ret = ECMD_FAILED;
if (!argc) {
@@ -219,12 +217,6 @@ int vgimportclone(struct cmd_context *cmd, int argc, char **argv)
vp.import_vg = arg_is_set(cmd, import_ARG);
- if (lvmetad_used()) {
- lvmetad_set_disabled(cmd, LVMETAD_DISABLE_REASON_DUPLICATES);
- lvmetad_disconnect();
- lvmetad_rescan = 1;
- }
-
if (!(handle = init_processing_handle(cmd, NULL))) {
log_error("Failed to initialize processing handle.");
return ECMD_FAILED;
@@ -362,22 +354,5 @@ out:
init_internal_filtering(0);
destroy_processing_handle(cmd, handle);
- /* Enable lvmetad again if no duplicates are left. */
- if (lvmetad_rescan) {
- if (!lvmetad_connect(cmd)) {
- log_warn("WARNING: Failed to connect to lvmetad.");
- log_warn("WARNING: Update lvmetad with pvscan --cache.");
- return ret;
- }
-
- if (!refresh_filters(cmd))
- stack;
-
- if (!lvmetad_pvscan_all_devs(cmd, 1)) {
- log_warn("WARNING: Failed to scan devices.");
- log_warn("WARNING: Update lvmetad with pvscan --cache.");
- }
- }
-
return ret;
}
diff --git a/tools/vgmerge.c b/tools/vgmerge.c
index eab3d56f6..f2c785ba7 100644
--- a/tools/vgmerge.c
+++ b/tools/vgmerge.c
@@ -73,7 +73,6 @@ static int _vgmerge_single(struct cmd_context *cmd, const char *vg_name_to,
}
lvmcache_label_scan(cmd);
- lvmcache_seed_infos_from_lvmetad(cmd);
if (strcmp(vg_name_to, vg_name_from) > 0)
lock_vg_from_first = 1;
diff --git a/tools/vgrename.c b/tools/vgrename.c
index 2e6157f37..5e386cc74 100644
--- a/tools/vgrename.c
+++ b/tools/vgrename.c
@@ -61,10 +61,8 @@ static int _vgrename_single(struct cmd_context *cmd, const char *vg_name,
*
* (FIXME: We could look for the new name in the list of all
* VGs that process_each_vg created, but we don't have access
- * to that list here, so we have to look in lvmcache.
- * This requires populating lvmcache when using lvmetad.)
+ * to that list here, so we have to look in lvmcache.)
*/
- lvmcache_seed_infos_from_lvmetad(cmd);
if (lvmcache_vginfo_from_vgname(vp->vg_name_new, NULL)) {
log_error("New VG name \"%s\" already exists", vp->vg_name_new);
diff --git a/tools/vgscan.c b/tools/vgscan.c
index f9fa3821c..470e3d85f 100644
--- a/tools/vgscan.c
+++ b/tools/vgscan.c
@@ -28,51 +28,10 @@ static int _vgscan_single(struct cmd_context *cmd, const char *vg_name,
return ECMD_PROCESSED;
}
-/*
- * Two main vgscan cases related to lvmetad usage:
- * 1. vgscan
- * 2. vgscan --cache
- *
- * 1. The 'vgscan' command (without --cache) may or may not attempt to
- * repopulate the lvmetad cache, and may or may not use the lvmetad
- * cache to display VG info:
- *
- * i. If lvmetad is being used and is in a normal state, then 'vgscan'
- * will simply read and display VG info from the lvmetad cache.
- *
- * ii. If lvmetad is not being used, 'vgscan' will read all devices to
- * display the VG info.
- *
- * iii. If lvmetad is being used, but has been disabled (because of
- * duplicate devs), or has a non-matching token
- * (because the device filter is different from the device filter last
- * used to populate lvmetad), then 'vgscan' will begin by rescanning
- * devices to repopulate lvmetad. If lvmetad is enabled after the
- * rescan, then 'vgscan' will simply read and display VG info from the
- * lvmetad cache (like case i). If lvmetad is disabled after the
- * rescan, then 'vgscan' will read all devices to display VG info
- * (like case ii).
- *
- * 2. The 'vgscan --cache' command will always attempt to repopulate
- * the lvmetad cache by rescanning all devs (regardless of whether
- * lvmetad was previously disabled or had an unmatching token.)
- * lvmetad may be enabled or disabled after the rescan (depending
- * on whether duplicate devs were found).
- * If enabled, then it will simply read and display VG info from the
- * lvmetad cache (like case 1.i.). If disabled, then it will
- * read all devices to display VG info (like case 1.ii.)
- */
-
int vgscan(struct cmd_context *cmd, int argc, char **argv)
{
- const char *reason = NULL;
int maxret, ret;
- if (argc) {
- log_error("Too many parameters on command line");
- return EINVALID_CMD_LINE;
- }
-
if (arg_is_set(cmd, notifydbus_ARG)) {
if (!lvmnotify_is_supported()) {
log_error("Cannot notify dbus: lvm is not built with dbus support.");
@@ -93,29 +52,12 @@ int vgscan(struct cmd_context *cmd, int argc, char **argv)
return ECMD_FAILED;
}
- if (cmd->filter->wipe)
- cmd->filter->wipe(cmd->filter);
- lvmcache_destroy(cmd, 1, 0);
-
- if (!lvmetad_used() && arg_is_set(cmd, cache_long_ARG))
- log_verbose("Ignoring vgscan --cache command because lvmetad is not in use.");
-
- if (lvmetad_used() && (arg_is_set(cmd, cache_long_ARG) || !lvmetad_token_matches(cmd) || lvmetad_is_disabled(cmd, &reason))) {
- if (lvmetad_used() && !lvmetad_pvscan_all_devs(cmd, arg_is_set(cmd, cache_long_ARG))) {
- log_warn("WARNING: Not using lvmetad because cache update failed.");
- lvmetad_make_unused(cmd);
- }
-
- if (lvmetad_used() && lvmetad_is_disabled(cmd, &reason)) {
- log_warn("WARNING: Not using lvmetad because %s.", reason);
- lvmetad_make_unused(cmd);
- }
+ if (arg_is_set(cmd, cache_long_ARG)) {
+ log_warn("Ignoring vgscan --cache command because lvmetad is no longer used.");
+ return ECMD_PROCESSED;
}
- if (!lvmetad_used())
- log_print_unless_silent("Reading all physical volumes. This may take a while...");
- else
- log_print_unless_silent("Reading volume groups from cache.");
+ log_print_unless_silent("Reading all physical volumes. This may take a while...");
maxret = process_each_vg(cmd, argc, argv, NULL, NULL, 0, 0, NULL, &_vgscan_single);
diff --git a/tools/vgsplit.c b/tools/vgsplit.c
index 7ec00f8a2..5824c82ce 100644
--- a/tools/vgsplit.c
+++ b/tools/vgsplit.c
@@ -582,7 +582,6 @@ int vgsplit(struct cmd_context *cmd, int argc, char **argv)
}
lvmcache_label_scan(cmd);
- lvmcache_seed_infos_from_lvmetad(cmd);
if (strcmp(vg_name_to, vg_name_from) < 0)
lock_vg_from_first = 0;
@@ -728,8 +727,6 @@ int vgsplit(struct cmd_context *cmd, int argc, char **argv)
if (!vg_write(vg_to) || !vg_commit(vg_to))
goto_bad;
- lvmetad_vg_update_finish(vg_to);
-
backup(vg_to);
/*
@@ -741,8 +738,6 @@ int vgsplit(struct cmd_context *cmd, int argc, char **argv)
if (!vg_write(vg_from) || !vg_commit(vg_from))
goto_bad;
- lvmetad_vg_update_finish(vg_from);
-
backup(vg_from);
}
@@ -767,8 +762,6 @@ int vgsplit(struct cmd_context *cmd, int argc, char **argv)
if (!vg_write(vg_to) || !vg_commit(vg_to))
goto_bad;
- lvmetad_vg_update_finish(vg_to);
-
backup(vg_to);
log_print_unless_silent("%s volume group \"%s\" successfully split from \"%s\"",