1
0
mirror of git://sourceware.org/git/lvm2.git synced 2025-03-22 06:50:52 +03:00

Remove lvmetad

Native disk scanning is now both reduced and
async/parallel, which makes it comparable in
performance (and often faster) when compared
to lvm using lvmetad.

Autoactivation now uses local temp files to record
online PVs, and no longer requires lvmetad.

There should be no apparent command-level change
in behavior.
This commit is contained in:
David Teigland 2018-07-10 13:39:29 -05:00
parent edf3f86184
commit 117160b27e
55 changed files with 101 additions and 8496 deletions

View File

@ -83,7 +83,7 @@ endif
DISTCLEAN_TARGETS += cscope.out
CLEAN_DIRS += autom4te.cache
check check_system check_cluster check_local check_lvmetad check_lvmpolld check_lvmlockd_test check_lvmlockd_dlm check_lvmlockd_sanlock: test
check check_system check_cluster check_local check_lvmpolld check_lvmlockd_test check_lvmlockd_dlm check_lvmlockd_sanlock: test
$(MAKE) -C test $(@)
conf.generate man.generate: tools
@ -153,7 +153,6 @@ LCOV_TRACES = libdm.info lib.info tools.info \
test/unit.info \
daemons/clvmd.info \
daemons/dmeventd.info \
daemons/lvmetad.info \
daemons/lvmlockd.info \
daemons/lvmpolld.info

View File

@ -39,7 +39,6 @@ case "$host_os" in
LDDEPS="$LDDEPS .export.sym"
LIB_SUFFIX=so
DEVMAPPER=yes
BUILD_LVMETAD=no
BUILD_LVMPOLLD=no
LOCKDSANLOCK=no
LOCKDDLM=no
@ -843,16 +842,6 @@ if test "$DEVMAPPER" = yes; then
AC_DEFINE([DEVMAPPER_SUPPORT], 1, [Define to 1 to enable LVM2 device-mapper interaction.])
fi
################################################################################
dnl -- Build lvmetad
AC_MSG_CHECKING(whether to build LVMetaD)
AC_ARG_ENABLE(lvmetad,
AC_HELP_STRING([--enable-lvmetad],
[enable the LVM Metadata Daemon]),
LVMETAD=$enableval)
test -n "$LVMETAD" && BUILD_LVMETAD=$LVMETAD
AC_MSG_RESULT($BUILD_LVMETAD)
################################################################################
dnl -- Build lvmpolld
AC_MSG_CHECKING(whether to build lvmpolld)
@ -908,9 +897,7 @@ AC_MSG_RESULT($BUILD_LVMLOCKD)
if test "$BUILD_LVMLOCKD" = yes; then
AS_IF([test "$LVMPOLLD" = no], [AC_MSG_ERROR([cannot build lvmlockd with --disable-lvmpolld.])])
AS_IF([test "$LVMETAD" = no], [AC_MSG_ERROR([cannot build lvmlockd with --disable-lvmetad.])])
AS_IF([test "$BUILD_LVMPOLLD" = no], [BUILD_LVMPOLLD=yes; AC_MSG_WARN([Enabling lvmpolld - required by lvmlockd.])])
AS_IF([test "$BUILD_LVMETAD" = no], [BUILD_LVMETAD=yes; AC_MSG_WARN([Enabling lvmetad - required by lvmlockd.])])
AC_MSG_CHECKING([defaults for use_lvmlockd])
AC_ARG_ENABLE(use_lvmlockd,
AC_HELP_STRING([--disable-use-lvmlockd],
@ -935,33 +922,6 @@ fi
AC_DEFINE_UNQUOTED(DEFAULT_USE_LVMLOCKD, [$DEFAULT_USE_LVMLOCKD],
[Use lvmlockd by default.])
################################################################################
dnl -- Check lvmetad
if test "$BUILD_LVMETAD" = yes; then
AC_MSG_CHECKING([defaults for use_lvmetad])
AC_ARG_ENABLE(use_lvmetad,
AC_HELP_STRING([--disable-use-lvmetad],
[disable usage of LVM Metadata Daemon]),
[case ${enableval} in
yes) DEFAULT_USE_LVMETAD=1 ;;
*) DEFAULT_USE_LVMETAD=0 ;;
esac], DEFAULT_USE_LVMETAD=1)
AC_MSG_RESULT($DEFAULT_USE_LVMETAD)
AC_DEFINE([LVMETAD_SUPPORT], 1, [Define to 1 to include code that uses lvmetad.])
AC_ARG_WITH(lvmetad-pidfile,
AC_HELP_STRING([--with-lvmetad-pidfile=PATH],
[lvmetad pidfile [PID_DIR/lvmetad.pid]]),
LVMETAD_PIDFILE=$withval,
LVMETAD_PIDFILE="$DEFAULT_PID_DIR/lvmetad.pid")
AC_DEFINE_UNQUOTED(LVMETAD_PIDFILE, ["$LVMETAD_PIDFILE"],
[Path to lvmetad pidfile.])
else
DEFAULT_USE_LVMETAD=0
fi
AC_DEFINE_UNQUOTED(DEFAULT_USE_LVMETAD, [$DEFAULT_USE_LVMETAD],
[Use lvmetad by default.])
################################################################################
dnl -- Check lvmpolld
if test "$BUILD_LVMPOLLD" = yes; then
@ -1662,7 +1622,6 @@ AC_SUBST(BLKID_PC)
AC_SUBST(BUILD_CMIRRORD)
AC_SUBST(BUILD_DMEVENTD)
AC_SUBST(BUILD_LVMDBUSD)
AC_SUBST(BUILD_LVMETAD)
AC_SUBST(BUILD_LVMPOLLD)
AC_SUBST(BUILD_LVMLOCKD)
AC_SUBST(BUILD_LOCKDSANLOCK)
@ -1699,7 +1658,6 @@ AC_SUBST(DEFAULT_SPARSE_SEGTYPE)
AC_SUBST(DEFAULT_SYS_DIR)
AC_SUBST(DEFAULT_SYS_LOCK_DIR)
AC_SUBST(DEFAULT_USE_BLKID_WIPING)
AC_SUBST(DEFAULT_USE_LVMETAD)
AC_SUBST(DEFAULT_USE_LVMPOLLD)
AC_SUBST(DEFAULT_USE_LVMLOCKD)
AC_SUBST(DEVMAPPER)
@ -1792,7 +1750,6 @@ AC_SUBST(VDO_INCLUDE)
AC_SUBST(VDO_LIB)
AC_SUBST(WRITE_INSTALL)
AC_SUBST(DMEVENTD_PIDFILE)
AC_SUBST(LVMETAD_PIDFILE)
AC_SUBST(LVMPOLLD_PIDFILE)
AC_SUBST(LVMLOCKD_PIDFILE)
AC_SUBST(CMIRRORD_PIDFILE)
@ -1832,7 +1789,6 @@ daemons/lvmdbusd/lvmdbusd
daemons/lvmdbusd/lvmdb.py
daemons/lvmdbusd/lvm_shell_proxy.py
daemons/lvmdbusd/path.py
daemons/lvmetad/Makefile
daemons/lvmpolld/Makefile
daemons/lvmlockd/Makefile
conf/Makefile
@ -1860,9 +1816,6 @@ scripts/dm_event_systemd_red_hat.service
scripts/dm_event_systemd_red_hat.socket
scripts/lvm2_cmirrord_systemd_red_hat.service
scripts/lvm2_lvmdbusd_systemd_red_hat.service
scripts/lvm2_lvmetad_init_red_hat
scripts/lvm2_lvmetad_systemd_red_hat.service
scripts/lvm2_lvmetad_systemd_red_hat.socket
scripts/lvm2_lvmpolld_init_red_hat
scripts/lvm2_lvmpolld_systemd_red_hat.service
scripts/lvm2_lvmpolld_systemd_red_hat.socket

View File

@ -1,2 +0,0 @@
lvmetad
lvmetactl

View File

@ -1,64 +0,0 @@
#
# Copyright (C) 2011-2012 Red Hat, Inc.
#
# 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
srcdir = @srcdir@
top_srcdir = @top_srcdir@
top_builddir = @top_builddir@
SOURCES = lvmetad-core.c
SOURCES2 = lvmetactl.c
TARGETS = lvmetad lvmetactl
.PHONY: install_lvmetad
CFLOW_LIST = $(SOURCES)
CFLOW_LIST_TARGET = $(LIB_NAME).cflow
CFLOW_TARGET = lvmetad
include $(top_builddir)/make.tmpl
CFLAGS_lvmetactl.o += $(EXTRA_EXEC_CFLAGS)
CFLAGS_lvmetad-core.o += $(EXTRA_EXEC_CFLAGS)
INCLUDES += -I$(top_srcdir)/libdaemon/server
LDFLAGS += -L$(top_builddir)/libdaemon/server $(EXTRA_EXEC_LDFLAGS) $(ELDFLAGS)
LIBS += $(RT_LIBS) $(DAEMON_LIBS) $(PTHREAD_LIBS) -lm
lvmetad: $(OBJECTS) $(top_builddir)/libdaemon/client/libdaemonclient.a \
$(top_builddir)/libdaemon/server/libdaemonserver.a \
$(INTERNAL_LIBS)
$(CC) $(CFLAGS) $(LDFLAGS) -o $@ $(OBJECTS) -ldaemonserver $(INTERNAL_LIBS) $(LIBS)
lvmetactl: lvmetactl.o $(top_builddir)/libdaemon/client/libdaemonclient.a \
$(top_builddir)/libdaemon/server/libdaemonserver.a \
$(INTERNAL_LIBS)
$(CC) $(CFLAGS) $(LDFLAGS) -o $@ lvmetactl.o $(INTERNAL_LIBS) $(LIBS)
CLEAN_TARGETS += lvmetactl.o
# TODO: No idea. No idea how to test either.
#ifneq ("$(CFLOW_CMD)", "")
#CFLOW_SOURCES = $(addprefix $(srcdir)/, $(SOURCES))
#-include $(top_builddir)/libdm/libdevmapper.cflow
#-include $(top_builddir)/lib/liblvm-internal.cflow
#-include $(top_builddir)/lib/liblvm2cmd.cflow
#-include $(top_builddir)/daemons/dmeventd/$(LIB_NAME).cflow
#-include $(top_builddir)/daemons/dmeventd/plugins/mirror/$(LIB_NAME)-lvm2mirror.cflow
#endif
install_lvmetad: lvmetad
$(INSTALL_PROGRAM) -D $< $(sbindir)/$(<F)
install_lvm2: install_lvmetad
install: install_lvm2

View File

@ -1,249 +0,0 @@
/*
* Copyright (C) 2014 Red Hat, Inc.
*
* 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.
*/
#include "tools/tool.h"
#include "daemons/lvmetad/lvmetad-client.h"
daemon_handle h;
static void print_reply(daemon_reply reply)
{
const char *a = daemon_reply_str(reply, "response", NULL);
const char *b = daemon_reply_str(reply, "status", NULL);
const char *c = daemon_reply_str(reply, "reason", NULL);
printf("response \"%s\" status \"%s\" reason \"%s\"\n",
a ? a : "", b ? b : "", c ? c : "");
}
int main(int argc, char **argv)
{
daemon_reply reply;
char *cmd;
char *uuid;
char *name;
int val;
int ver;
if (argc < 2) {
printf("lvmetactl dump\n");
printf("lvmetactl pv_list\n");
printf("lvmetactl vg_list\n");
printf("lvmetactl get_global_info\n");
printf("lvmetactl vg_lookup_name <name>\n");
printf("lvmetactl vg_lookup_uuid <uuid>\n");
printf("lvmetactl pv_lookup_uuid <uuid>\n");
printf("lvmetactl set_global_invalid 0|1\n");
printf("lvmetactl set_global_disable 0|1\n");
printf("lvmetactl set_vg_version <uuid> <name> <version>\n");
printf("lvmetactl vg_lock_type <uuid>\n");
return -1;
}
cmd = argv[1];
h = lvmetad_open(NULL);
if (!strcmp(cmd, "dump")) {
reply = daemon_send_simple(h, "dump",
"token = %s", "skip",
"pid = " FMTd64, (int64_t)getpid(),
"cmd = %s", "lvmetactl",
NULL);
printf("%s\n", reply.buffer.mem);
} else if (!strcmp(cmd, "pv_list")) {
reply = daemon_send_simple(h, "pv_list",
"token = %s", "skip",
"pid = " FMTd64, (int64_t)getpid(),
"cmd = %s", "lvmetactl",
NULL);
printf("%s\n", reply.buffer.mem);
} else if (!strcmp(cmd, "vg_list")) {
reply = daemon_send_simple(h, "vg_list",
"token = %s", "skip",
"pid = " FMTd64, (int64_t)getpid(),
"cmd = %s", "lvmetactl",
NULL);
printf("%s\n", reply.buffer.mem);
} else if (!strcmp(cmd, "get_global_info")) {
reply = daemon_send_simple(h, "get_global_info",
"token = %s", "skip",
"pid = " FMTd64, (int64_t)getpid(),
"cmd = %s", "lvmetactl",
NULL);
printf("%s\n", reply.buffer.mem);
} else if (!strcmp(cmd, "set_global_invalid")) {
if (argc < 3) {
printf("set_global_invalid 0|1\n");
return -1;
}
val = atoi(argv[2]);
reply = daemon_send_simple(h, "set_global_info",
"global_invalid = " FMTd64, (int64_t) val,
"token = %s", "skip",
"pid = " FMTd64, (int64_t)getpid(),
"cmd = %s", "lvmetactl",
NULL);
print_reply(reply);
} else if (!strcmp(cmd, "set_global_disable")) {
if (argc < 3) {
printf("set_global_disable 0|1\n");
return -1;
}
val = atoi(argv[2]);
reply = daemon_send_simple(h, "set_global_info",
"global_disable = " FMTd64, (int64_t) val,
"disable_reason = %s", LVMETAD_DISABLE_REASON_DIRECT,
"token = %s", "skip",
"pid = " FMTd64, (int64_t)getpid(),
"cmd = %s", "lvmetactl",
NULL);
print_reply(reply);
} else if (!strcmp(cmd, "set_vg_version")) {
if (argc < 5) {
printf("set_vg_version <uuid> <name> <ver>\n");
return -1;
}
uuid = argv[2];
name = argv[3];
ver = atoi(argv[4]);
if ((strlen(uuid) == 1) && (uuid[0] == '-'))
uuid = NULL;
if ((strlen(name) == 1) && (name[0] == '-'))
name = NULL;
if (uuid && name) {
reply = daemon_send_simple(h, "set_vg_info",
"uuid = %s", uuid,
"name = %s", name,
"version = " FMTd64, (int64_t) ver,
"token = %s", "skip",
"pid = " FMTd64, (int64_t)getpid(),
"cmd = %s", "lvmetactl",
NULL);
} else if (uuid) {
reply = daemon_send_simple(h, "set_vg_info",
"uuid = %s", uuid,
"version = " FMTd64, (int64_t) ver,
"token = %s", "skip",
"pid = " FMTd64, (int64_t)getpid(),
"cmd = %s", "lvmetactl",
NULL);
} else if (name) {
reply = daemon_send_simple(h, "set_vg_info",
"name = %s", name,
"version = " FMTd64, (int64_t) ver,
"token = %s", "skip",
"pid = " FMTd64, (int64_t)getpid(),
"cmd = %s", "lvmetactl",
NULL);
} else {
printf("name or uuid required\n");
return -1;
}
print_reply(reply);
} else if (!strcmp(cmd, "vg_lookup_name")) {
if (argc < 3) {
printf("vg_lookup_name <name>\n");
return -1;
}
name = argv[2];
reply = daemon_send_simple(h, "vg_lookup",
"name = %s", name,
"token = %s", "skip",
"pid = " FMTd64, (int64_t)getpid(),
"cmd = %s", "lvmetactl",
NULL);
printf("%s\n", reply.buffer.mem);
} else if (!strcmp(cmd, "vg_lookup_uuid")) {
if (argc < 3) {
printf("vg_lookup_uuid <uuid>\n");
return -1;
}
uuid = argv[2];
reply = daemon_send_simple(h, "vg_lookup",
"uuid = %s", uuid,
"token = %s", "skip",
"pid = " FMTd64, (int64_t)getpid(),
"cmd = %s", "lvmetactl",
NULL);
printf("%s\n", reply.buffer.mem);
} else if (!strcmp(cmd, "vg_lock_type")) {
struct dm_config_node *metadata;
const char *lock_type;
if (argc < 3) {
printf("vg_lock_type <uuid>\n");
return -1;
}
uuid = argv[2];
reply = daemon_send_simple(h, "vg_lookup",
"uuid = %s", uuid,
"token = %s", "skip",
"pid = " FMTd64, (int64_t)getpid(),
"cmd = %s", "lvmetactl",
NULL);
/* printf("%s\n", reply.buffer.mem); */
metadata = dm_config_find_node(reply.cft->root, "metadata");
if (!metadata) {
printf("no metadata\n");
goto out;
}
lock_type = dm_config_find_str(metadata, "metadata/lock_type", NULL);
if (!lock_type) {
printf("no lock_type\n");
goto out;
}
printf("lock_type %s\n", lock_type);
} else if (!strcmp(cmd, "pv_lookup_uuid")) {
if (argc < 3) {
printf("pv_lookup_uuid <uuid>\n");
return -1;
}
uuid = argv[2];
reply = daemon_send_simple(h, "pv_lookup",
"uuid = %s", uuid,
"token = %s", "skip",
"pid = " FMTd64, (int64_t)getpid(),
"cmd = %s", "lvmetactl",
NULL);
printf("%s\n", reply.buffer.mem);
} else {
printf("unknown command\n");
goto out_close;
}
out:
daemon_reply_destroy(reply);
out_close:
daemon_close(h);
return 0;
}

View File

@ -1,90 +0,0 @@
/*
* Copyright (C) 2011-2012 Red Hat, Inc.
*
* 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
*/
#ifndef _LVM_LVMETAD_CLIENT_H
#define _LVM_LVMETAD_CLIENT_H
#include "libdaemon/client/daemon-client.h"
#define LVMETAD_SOCKET DEFAULT_RUN_DIR "/lvmetad.socket"
#define LVMETAD_TOKEN_UPDATE_IN_PROGRESS "update in progress"
#define LVMETAD_DISABLE_REASON_DIRECT "DIRECT"
#define LVMETAD_DISABLE_REASON_DUPLICATES "DUPLICATES"
#define LVMETAD_DISABLE_REASON_VGRESTORE "VGRESTORE"
#define LVMETAD_DISABLE_REASON_REPAIR "REPAIR"
struct volume_group;
/* Different types of replies we may get from lvmetad. */
typedef struct {
daemon_reply r;
const char **uuids; /* NULL terminated array */
} lvmetad_uuidlist;
typedef struct {
daemon_reply r;
struct dm_config_tree *cft;
} lvmetad_vg;
/* Get a list of VG UUIDs that match a given VG name. */
lvmetad_uuidlist lvmetad_lookup_vgname(daemon_handle h, const char *name);
/* Get the metadata of a single VG, identified by UUID. */
lvmetad_vg lvmetad_get_vg(daemon_handle h, const char *uuid);
/*
* Add and remove PVs on demand. Udev-driven systems will use this interface
* instead of scanning.
*/
daemon_reply lvmetad_add_pv(daemon_handle h, const char *pv_uuid, const char *mda_content);
daemon_reply lvmetad_remove_pv(daemon_handle h, const char *pv_uuid);
/* Trigger a full disk scan, throwing away all caches. XXX do we eventually want
* this? Probably not yet, anyway.
* daemon_reply lvmetad_rescan(daemon_handle h);
*/
/*
* Update the version of metadata of a volume group. The VG has to be locked for
* writing for this, and the VG metadata here has to match whatever has been
* written to the disk (under this lock). This initially avoids the requirement
* for lvmetad to write to disk (in later revisions, lvmetad_supersede_vg may
* also do the writing, or we probably add another function to do that).
*/
daemon_reply lvmetad_supersede_vg(daemon_handle h, struct volume_group *vg);
/* Wrappers to open/close connection */
static inline daemon_handle lvmetad_open(const char *socket)
{
daemon_info lvmetad_info = {
.path = "lvmetad",
.socket = socket ?: LVMETAD_SOCKET,
.protocol = "lvmetad",
.protocol_version = 1,
.autostart = 0
};
return daemon_open(lvmetad_info);
}
static inline void lvmetad_close(daemon_handle h)
{
return daemon_close(h);
}
#endif

File diff suppressed because it is too large Load Diff

View File

@ -1,16 +0,0 @@
#!/bin/bash
export LD_LIBRARY_PATH="$1"
test -n "$2" && {
rm -f /var/run/lvmetad.{socket,pid}
chmod +rx lvmetad
valgrind ./lvmetad -f &
PID=$!
sleep 1
./testclient
kill $PID
exit 0
}
sudo ./test.sh "$1" .

View File

@ -1,147 +0,0 @@
/*
* Copyright (C) 2011-2014 Red Hat, Inc.
*
* 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 General Public License v.2.
*
* You should have received a copy of the GNU 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/tool.h"
#include "daemons/lvmetad/lvmetad-client.h"
#include "lib/label/label.h"
#include "lib/cache/lvmcache.h"
#include "lib/metadata/metadata.h"
const char *uuid1 = "abcd-efgh";
const char *uuid2 = "bbcd-efgh";
const char *vgid = "yada-yada";
const char *uuid3 = "cbcd-efgh";
const char *metadata2 = "{\n"
"id = \"yada-yada\"\n"
"seqno = 15\n"
"status = [\"READ\", \"WRITE\"]\n"
"flags = []\n"
"extent_size = 8192\n"
"physical_volumes {\n"
" pv0 {\n"
" id = \"abcd-efgh\"\n"
" }\n"
" pv1 {\n"
" id = \"bbcd-efgh\"\n"
" }\n"
" pv2 {\n"
" id = \"cbcd-efgh\"\n"
" }\n"
"}\n"
"}\n";
void _handle_reply(daemon_reply reply) {
const char *repl = daemon_reply_str(reply, "response", NULL);
const char *status = daemon_reply_str(reply, "status", NULL);
const char *vgid = daemon_reply_str(reply, "vgid", NULL);
fprintf(stderr, "[C] REPLY: %s\n", repl);
if (!strcmp(repl, "failed"))
fprintf(stderr, "[C] REASON: %s\n", daemon_reply_str(reply, "reason", "unknown"));
if (vgid)
fprintf(stderr, "[C] VGID: %s\n", vgid);
if (status)
fprintf(stderr, "[C] STATUS: %s\n", status);
daemon_reply_destroy(reply);
}
void _pv_add(daemon_handle h, const char *uuid, const char *metadata)
{
daemon_reply reply = daemon_send_simple(h, "pv_add", "uuid = %s", uuid,
"metadata = %b", metadata,
NULL);
_handle_reply(reply);
}
int scan(daemon_handle h, char *fn) {
struct device *dev = dev_cache_get(fn, NULL);
struct label *label;
if (!label_read(dev, &label, 0)) {
fprintf(stderr, "[C] no label found on %s\n", fn);
return;
}
char uuid[64];
if (!id_write_format(dev->pvid, uuid, 64)) {
fprintf(stderr, "[C] Failed to format PV UUID for %s", dev_name(dev));
return;
}
fprintf(stderr, "[C] found PV: %s\n", uuid);
struct lvmcache_info *info = (struct lvmcache_info *) label->info;
struct physical_volume pv = { 0, };
if (!(info->fmt->ops->pv_read(info->fmt, dev_name(dev), &pv, 0))) {
fprintf(stderr, "[C] Failed to read PV %s", dev_name(dev));
return;
}
struct format_instance_ctx fic;
struct format_instance *fid = info->fmt->ops->create_instance(info->fmt, &fic);
struct metadata_area *mda;
struct volume_group *vg = NULL;
dm_list_iterate_items(mda, &info->mdas) {
struct volume_group *this = mda->ops->vg_read(fid, "", mda);
if (this && !vg || this->seqno > vg->seqno)
vg = this;
}
if (vg) {
char *buf = NULL;
/* TODO. This is not entirely correct, since export_vg_to_buffer
* adds trailing garbage to the buffer. We may need to use
* export_vg_to_config_tree and format the buffer ourselves. It
* does, however, work for now, since the garbage is well
* formatted and has no conflicting keys with the rest of the
* request. */
export_vg_to_buffer(vg, &buf);
daemon_reply reply =
daemon_send_simple(h, "pv_add", "uuid = %s", uuid,
"metadata = %b", strchr(buf, '{'),
NULL);
_handle_reply(reply);
}
}
void _dump_vg(daemon_handle h, const char *uuid)
{
daemon_reply reply = daemon_send_simple(h, "vg_by_uuid", "uuid = %s", uuid, NULL);
fprintf(stderr, "[C] reply buffer: %s\n", reply.buffer);
daemon_reply_destroy(reply);
}
int main(int argc, char **argv) {
daemon_handle h = lvmetad_open();
/* FIXME Missing error path */
if (argc > 1) {
int i;
struct cmd_context *cmd = create_toolcontext(0, NULL, 0, 0, 1, 1);
for (i = 1; i < argc; ++i) {
const char *uuid = NULL;
scan(h, argv[i]);
}
destroy_toolcontext(cmd);
/* FIXME Missing lvmetad_close() */
return 0;
}
_pv_add(h, uuid1, NULL);
_pv_add(h, uuid2, metadata2);
_dump_vg(h, vgid);
_pv_add(h, uuid3, NULL);
daemon_close(h); /* FIXME lvmetad_close? */
return 0;
}

View File

@ -17,7 +17,6 @@
#include "libdaemon/client/daemon-io.h"
#include "daemon-server.h"
#include "lvm-version.h"
#include "daemons/lvmetad/lvmetad-client.h"
#include "daemons/lvmlockd/lvmlockd-client.h"
#include "device_mapper/misc/dm-ioctl.h"
@ -144,10 +143,6 @@ static const int lvmlockd_protocol_version = 1;
static int daemon_quit;
static int adopt_opt;
static daemon_handle lvmetad_handle;
static pthread_mutex_t lvmetad_mutex;
static int lvmetad_connected;
/*
* We use a separate socket for dumping daemon info.
* This will not interfere with normal operations, and allows
@ -1009,54 +1004,6 @@ static void add_work_action(struct action *act)
pthread_mutex_unlock(&worker_mutex);
}
#define ERR_LVMETAD_NOT_RUNNING -200
static daemon_reply send_lvmetad(const char *id, ...)
{
daemon_reply reply;
va_list ap;
int retries = 0;
int err;
va_start(ap, id);
/*
* mutex is used because all threads share a single
* lvmetad connection/handle.
*/
pthread_mutex_lock(&lvmetad_mutex);
retry:
if (!lvmetad_connected) {
lvmetad_handle = lvmetad_open(NULL);
if (lvmetad_handle.error || lvmetad_handle.socket_fd < 0) {
err = lvmetad_handle.error ?: lvmetad_handle.socket_fd;
pthread_mutex_unlock(&lvmetad_mutex);
log_debug("lvmetad_open reconnect error %d", err);
memset(&reply, 0, sizeof(reply));
reply.error = ERR_LVMETAD_NOT_RUNNING;
va_end(ap);
return reply;
} else {
log_debug("lvmetad reconnected");
lvmetad_connected = 1;
}
}
reply = daemon_send_simple_v(lvmetad_handle, id, ap);
/* lvmetad may have been restarted */
if ((reply.error == ECONNRESET) && (retries < 2)) {
daemon_close(lvmetad_handle);
lvmetad_connected = 0;
retries++;
goto retry;
}
pthread_mutex_unlock(&lvmetad_mutex);
va_end(ap);
return reply;
}
static int res_lock(struct lockspace *ls, struct resource *r, struct action *act, int *retry)
{
struct lock *lk;
@ -1252,6 +1199,18 @@ static int res_lock(struct lockspace *ls, struct resource *r, struct action *act
rv = -EREMOVED;
}
/*
* lvmetad is no longer used, but the infrastructure for
* distributed cache validation remains. The points
* where vg or global cache state would be invalidated
* remain below and log_debug messages point out where
* they would occur.
*
* The comments related to "lvmetad" remain because they
* describe how some other local cache like lvmetad would
* be invalidated here.
*/
/*
* r is vglk: tell lvmetad to set the vg invalid
* flag, and provide the new r_version. If lvmetad finds
@ -1277,47 +1236,12 @@ static int res_lock(struct lockspace *ls, struct resource *r, struct action *act
*/
if (inval_meta && (r->type == LD_RT_VG)) {
daemon_reply reply;
char *uuid;
log_debug("S %s R %s res_lock set lvmetad vg version %u",
log_debug("S %s R %s res_lock invalidate vg state version %u",
ls->name, r->name, new_version);
if (!ls->vg_uuid[0] || !strcmp(ls->vg_uuid, "none"))
uuid = (char *)"none";
else
uuid = ls->vg_uuid;
reply = send_lvmetad("set_vg_info",
"token = %s", "skip",
"uuid = %s", uuid,
"name = %s", ls->vg_name,
"version = " FMTd64, (int64_t)new_version,
NULL);
if (reply.error || strcmp(daemon_reply_str(reply, "response", ""), "OK")) {
if (reply.error != ERR_LVMETAD_NOT_RUNNING)
log_error("set_vg_info in lvmetad failed %d", reply.error);
}
daemon_reply_destroy(reply);
}
if (inval_meta && (r->type == LD_RT_GL)) {
daemon_reply reply;
log_debug("S %s R %s res_lock set lvmetad global invalid",
ls->name, r->name);
reply = send_lvmetad("set_global_info",
"token = %s", "skip",
"global_invalid = " FMTd64, INT64_C(1),
NULL);
if (reply.error || strcmp(daemon_reply_str(reply, "response", ""), "OK")) {
if (reply.error != ERR_LVMETAD_NOT_RUNNING)
log_error("set_global_info in lvmetad failed %d", reply.error);
}
daemon_reply_destroy(reply);
log_debug("S %s R %s res_lock invalidate global state", ls->name, r->name);
}
/*
@ -4827,7 +4751,7 @@ static void close_client_thread(void)
}
/*
* Get a list of all VGs with a lockd type (sanlock|dlm) from lvmetad.
* Get a list of all VGs with a lockd type (sanlock|dlm).
* We'll match this list against a list of existing lockspaces that are
* found in the lock manager.
*
@ -4838,6 +4762,9 @@ static void close_client_thread(void)
static int get_lockd_vgs(struct list_head *vg_lockd)
{
/* FIXME: get VGs some other way */
return -1;
#if 0
struct list_head update_vgs;
daemon_reply reply;
struct dm_config_node *cn;
@ -4994,6 +4921,7 @@ out:
}
return rv;
#endif
}
static char _dm_uuid[DM_UUID_LEN];
@ -5268,7 +5196,7 @@ static void adopt_locks(void)
gl_use_sanlock = 1;
list_for_each_entry(ls, &vg_lockd, list) {
log_debug("adopt lvmetad vg %s lock_type %s lock_args %s",
log_debug("adopt vg %s lock_type %s lock_args %s",
ls->vg_name, lm_str(ls->lm_type), ls->vg_args);
list_for_each_entry(r, &ls->resources, list)
@ -5333,7 +5261,7 @@ static void adopt_locks(void)
/*
* LS in ls_found, not in vg_lockd.
* An lvm lockspace found in the lock manager has no
* corresponding VG in lvmetad. This shouldn't usually
* corresponding VG. This shouldn't usually
* happen, but it's possible the VG could have been removed
* while the orphaned lockspace from it was still around.
* Report an error and leave the ls in the lm alone.
@ -5348,7 +5276,7 @@ static void adopt_locks(void)
/*
* LS in vg_lockd, not in ls_found.
* lockd vgs from lvmetad that do not have an existing lockspace.
* lockd vgs that do not have an existing lockspace.
* This wouldn't be unusual; we just skip the vg.
* But, if the vg has active lvs, then it should have had locks
* and a lockspace. Should we attempt to join the lockspace and
@ -5400,8 +5328,6 @@ static void adopt_locks(void)
memcpy(act->vg_args, ls->vg_args, MAX_ARGS);
act->host_id = ls->host_id;
/* set act->version from lvmetad data? */
log_debug("adopt add %s vg lockspace %s", lm_str(act->lm_type), act->vg_name);
rv = add_lockspace_thread(ls->name, act->vg_name, act->vg_uuid,
@ -5860,24 +5786,12 @@ static int main_loop(daemon_state *ds_arg)
setup_worker_thread();
setup_restart();
pthread_mutex_init(&lvmetad_mutex, NULL);
lvmetad_handle = lvmetad_open(NULL);
if (lvmetad_handle.error || lvmetad_handle.socket_fd < 0)
log_debug("lvmetad_open error %d", lvmetad_handle.error);
else
lvmetad_connected = 1;
/*
* Attempt to rejoin lockspaces and adopt locks from a previous
* instance of lvmlockd that left behind lockspaces/locks.
*/
if (adopt_opt) {
/* FIXME: implement this without lvmetad */
if (!lvmetad_connected)
log_error("Cannot adopt locks without lvmetad running.");
else
adopt_locks();
}
if (adopt_opt)
adopt_locks();
while (1) {
rv = poll(pollfd, pollfd_maxi + 1, -1);
@ -5993,7 +5907,6 @@ static int main_loop(daemon_state *ds_arg)
close_worker_thread();
close_client_thread();
closelog();
daemon_close(lvmetad_handle);
return 1; /* libdaemon uses 1 for success */
}

View File

@ -71,8 +71,6 @@ CLEAN_TARGETS += \
lvm2app.h \
lvm2cmd.h \
lvmcache.h \
lvmetad-client.h \
lvmetad.h \
lvmlockd-client.h \
lvmlockd.h \
lvmnotify.h \

View File

@ -112,11 +112,6 @@ ifeq ("@HAVE_LIBDL@", "yes")
SOURCES += misc/sharedlib.c
endif
ifeq ("@BUILD_LVMETAD@", "yes")
SOURCES +=\
cache/lvmetad.c
endif
ifeq ("@BUILD_LVMPOLLD@", "yes")
SOURCES +=\
lvmpolld/lvmpolld-client.c

68
lib/cache/lvmcache.c vendored
View File

@ -25,9 +25,6 @@
#include "lib/format_text/format-text.h"
#include "lib/config/config.h"
#include "lib/cache/lvmetad.h"
#include "daemons/lvmetad/lvmetad-client.h"
/* One per device */
struct lvmcache_info {
struct dm_list list; /* Join VG members together */
@ -98,21 +95,6 @@ int lvmcache_init(struct cmd_context *cmd)
return 1;
}
void lvmcache_seed_infos_from_lvmetad(struct cmd_context *cmd)
{
if (!lvmetad_used() || _has_scanned)
return;
dev_cache_scan();
if (!lvmetad_pv_list_to_lvmcache(cmd)) {
stack;
return;
}
_has_scanned = 1;
}
void lvmcache_lock_vgname(const char *vgname, int read_only __attribute__((unused)))
{
if (strcmp(vgname, VG_GLOBAL))
@ -249,20 +231,10 @@ const struct format_type *lvmcache_fmt_from_vgname(struct cmd_context *cmd,
struct dm_list *devh, *tmp;
struct dm_list devs;
struct device_list *devl;
struct volume_group *vg;
const struct format_type *fmt;
char vgid_found[ID_LEN + 1] __attribute__((aligned(8)));
if (!(vginfo = lvmcache_vginfo_from_vgname(vgname, vgid))) {
if (!lvmetad_used())
return NULL; /* too bad */
/* If we don't have the info but we have lvmetad, we can ask
* there before failing. */
if ((vg = lvmetad_vg_lookup(cmd, vgname, vgid))) {
fmt = vg->fid->fmt;
release_vg(vg);
return fmt;
}
stack;
return NULL;
}
@ -802,9 +774,6 @@ int lvmcache_label_rescan_vg(struct cmd_context *cmd, const char *vgname, const
struct lvmcache_vginfo *vginfo;
struct lvmcache_info *info;
if (lvmetad_used())
return 1;
dm_list_init(&devs);
if (!(vginfo = lvmcache_vginfo_from_vgname(vgname, vgid)))
@ -880,12 +849,6 @@ int lvmcache_label_scan(struct cmd_context *cmd)
int r = 0;
if (lvmetad_used()) {
if (!label_scan_setup_bcache())
return 0;
return 1;
}
log_debug_cache("Finding VG info");
/* Avoid recursion when a PVID can't be found! */
@ -969,11 +932,6 @@ int lvmcache_label_scan(struct cmd_context *cmd)
* the same device.
*/
_warn_duplicate_devs(cmd);
if (!_found_duplicate_pvs && lvmetad_used()) {
log_warn("WARNING: Disabling lvmetad cache which does not support duplicate PVs.");
lvmetad_set_disabled(cmd, LVMETAD_DISABLE_REASON_DUPLICATES);
}
}
r = 1;
@ -993,14 +951,8 @@ int lvmcache_label_scan(struct cmd_context *cmd)
}
/*
* When not using lvmetad, lvmcache_label_scan() detects duplicates in
* the basic label_scan(), then filters out some dups, and chooses
* preferred duplicates to use.
*
* When using lvmetad, pvscan --cache does not use lvmcache_label_scan(),
* only label_scan() which detects the duplicates. This function is used
* after pvscan's label_scan() to filter out some dups, print any warnings,
* and disable lvmetad if any dups are left.
* lvmcache_label_scan() detects duplicates in the basic label_scan(), then
* filters out some dups, and chooses preferred duplicates to use.
*/
void lvmcache_pvscan_duplicate_check(struct cmd_context *cmd)
@ -1024,19 +976,15 @@ void lvmcache_pvscan_duplicate_check(struct cmd_context *cmd)
_filter_duplicate_devs(cmd);
/*
* If no more dups after ignoring some, then we can use lvmetad.
* no more dups after ignoring some
*/
if (!_found_duplicate_pvs)
return;
/* Duplicates are found where we would have to pick one, so disable lvmetad. */
/* Duplicates are found where we would have to pick one. */
dm_list_iterate_items(devl, &_unused_duplicate_devs)
log_warn("WARNING: found device with duplicate %s", dev_name(devl->dev));
log_warn("WARNING: Disabling lvmetad cache which does not support duplicate PVs.");
lvmetad_set_disabled(cmd, LVMETAD_DISABLE_REASON_DUPLICATES);
lvmetad_make_unused(cmd);
}
int lvmcache_get_vgnameids(struct cmd_context *cmd, int include_internal,
@ -2192,9 +2140,6 @@ int lvmcache_is_orphan(struct lvmcache_info *info) {
int lvmcache_vgid_is_cached(const char *vgid) {
struct lvmcache_vginfo *vginfo;
if (lvmetad_used())
return 1;
vginfo = lvmcache_vginfo_from_vgid(vgid);
if (!vginfo || !vginfo->vgname)
@ -2285,9 +2230,6 @@ int lvmcache_vg_is_foreign(struct cmd_context *cmd, const char *vgname, const ch
struct lvmcache_vginfo *vginfo;
int ret = 0;
if (lvmetad_used())
return lvmetad_vg_is_foreign(cmd, vgname, vgid);
if ((vginfo = lvmcache_vginfo_from_vgid(vgid)))
ret = !is_system_id_allowed(cmd, vginfo->system_id);

View File

@ -64,7 +64,6 @@ struct lvmcache_vgsummary {
};
int lvmcache_init(struct cmd_context *cmd);
void lvmcache_allow_reads_with_lvmetad(void);
void lvmcache_destroy(struct cmd_context *cmd, int retain_orphans, int reset);
@ -106,8 +105,6 @@ const char *lvmcache_vgname_from_info(struct lvmcache_info *info);
const struct format_type *lvmcache_fmt_from_info(struct lvmcache_info *info);
int lvmcache_vgs_locked(void);
void lvmcache_seed_infos_from_lvmetad(struct cmd_context *cmd);
int lvmcache_get_vgnameids(struct cmd_context *cmd, int include_internal,
struct dm_list *vgnameids);

3075
lib/cache/lvmetad.c vendored

File diff suppressed because it is too large Load Diff

213
lib/cache/lvmetad.h vendored
View File

@ -1,213 +0,0 @@
/*
* Copyright (C) 2012 Red Hat, Inc.
*
* 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
*/
#ifndef _LVM_METAD_H
#define _LVM_METAD_H
#include "libdaemon/client/config-util.h"
#include <stdint.h>
struct volume_group;
struct cmd_context;
struct dm_config_tree;
enum activation_change;
typedef int (*activation_handler) (struct cmd_context *cmd,
const char *vgname, const char *vgid,
int partial, int changed,
enum activation_change activate);
#ifdef LVMETAD_SUPPORT
/*
* lvmetad_connect: connect to lvmetad
* lvmetad_disconnect: disconnect from lvmetad
* lvmetad_make_unused: disconnect from lvmetad and refresh cmd filter
* lvmetad_used: check if lvmetad is being used (i.e. is connected)
*/
int lvmetad_connect(struct cmd_context *cmd);
void lvmetad_disconnect(void);
void lvmetad_make_unused(struct cmd_context *cmd);
int lvmetad_used(void);
/*
* Configure the socket that lvmetad_init will use to connect to the daemon.
*/
void lvmetad_set_socket(const char *);
/*
* Check if lvmetad socket is present (either the one set by lvmetad_set_socket
* or the default one if not set).
*/
int lvmetad_socket_present(void);
/*
* Check if lvmetad pidfile is present, indicating that the lvmetad
* process is running or not.
*/
int lvmetad_pidfile_present(void);
/*
* Set the "lvmetad validity token" (currently only consists of the lvmetad
* filter. See lvm.conf.
*/
void lvmetad_set_token(const struct dm_config_value *filter);
/*
* Release allocated token.
*/
void lvmetad_release_token(void);
// FIXME What's described here doesn't appear to be implemented yet.
/*
* Send a new version of VG metadata to lvmetad. This is normally called after
* vg_write but before vg_commit. After vg_commit, lvmetad_vg_commit is called
* to seal the transaction. The result of lvmetad_vg_update is that the new
* metadata is stored tentatively in lvmetad, but it is not used until
* lvmetad_vg_commit. The request is validated immediately and lvmetad_vg_commit
* only constitutes a pointer update.
*/
int lvmetad_vg_update_pending(struct volume_group *vg);
int lvmetad_vg_update_finish(struct volume_group *vg);
/*
* Inform lvmetad that a VG has been removed. This is not entirely safe, but is
* only needed during vgremove, which does not wipe PV labels and therefore
* cannot mark the PVs as gone.
*/
int lvmetad_vg_remove_pending(struct volume_group *vg);
int lvmetad_vg_remove_finish(struct volume_group *vg);
/*
* Notify lvmetad that a PV has been found. It is not an error if the PV is
* already marked as present in lvmetad. If a non-NULL vg pointer is supplied,
* it is taken to represent the metadata read from the MDA(s) present on that
* PV. It *is* an error if: the VG is already known to lvmetad, the sequence
* number on the cached and on the discovered PV match but the metadata content
* does not.
*/
int lvmetad_pv_found(struct cmd_context *cmd, const struct id *pvid, struct device *dev,
const struct format_type *fmt, uint64_t label_sector,
struct volume_group *vg,
struct dm_list *found_vgnames,
struct dm_list *changed_vgnames);
/*
* Inform the daemon that the device no longer exists.
*/
int lvmetad_pv_gone(dev_t devno, const char *pv_name);
int lvmetad_pv_gone_by_dev(struct device *dev);
/*
* Request a list of all PVs available to lvmetad. If requested, this will also
* read labels off all the PVs to populate lvmcache.
*/
int lvmetad_pv_list_to_lvmcache(struct cmd_context *cmd);
/*
* Lookup an individual PV.
* If found is not NULL, it is set according to whether or not the PV is found,
* otherwise if the PV is not found an error is returned.
*/
int lvmetad_pv_lookup(struct cmd_context *cmd, struct id pvid, int *found);
int lvmetad_pv_lookup_by_dev(struct cmd_context *cmd, struct device *dev, int *found);
/*
* Request a list of all VGs available to lvmetad and use it to fill in
* lvmcache..
*/
int lvmetad_vg_list_to_lvmcache(struct cmd_context *cmd);
/*
* Request a list of vgid/vgname pairs for all VGs known to lvmetad.
* Does not do vg_lookup's on each VG, and does not populate lvmcache.
*/
int lvmetad_get_vgnameids(struct cmd_context *cmd, struct dm_list *vgnameids);
/*
* Find a VG by its ID or its name in the lvmetad cache. Gives NULL if the VG is
* not found.
*/
struct volume_group *lvmetad_vg_lookup(struct cmd_context *cmd,
const char *vgname, const char *vgid);
/*
* Scan a single device and update lvmetad with the result(s).
*/
int lvmetad_pvscan_single(struct cmd_context *cmd, struct device *dev,
struct dm_list *found_vgnames,
struct dm_list *changed_vgnames);
int lvmetad_pvscan_all_devs(struct cmd_context *cmd, int do_wait);
int lvmetad_vg_clear_outdated_pvs(struct volume_group *vg);
void lvmetad_validate_global_cache(struct cmd_context *cmd, int force);
int lvmetad_token_matches(struct cmd_context *cmd);
int lvmetad_vg_is_foreign(struct cmd_context *cmd, const char *vgname, const char *vgid);
int lvmetad_is_disabled(struct cmd_context *cmd, const char **reason);
void lvmetad_set_disabled(struct cmd_context *cmd, const char *reason);
void lvmetad_clear_disabled(struct cmd_context *cmd);
# else /* LVMETAD_SUPPORT */
static inline int lvmetad_connect(struct cmd_context *cmd) {return 0;}
static inline void lvmetad_disconnect(void) {}
static inline void lvmetad_make_unused(struct cmd_context *cmd) {}
static inline int lvmetad_used(void) {return 0;}
static inline void lvmetad_set_socket(const char *thing) {}
static inline int lvmetad_socket_present(void) {return 0;}
static inline int lvmetad_pidfile_present(void) {return 0;}
static inline void lvmetad_set_token(const struct dm_config_value *filter) {}
static inline void lvmetad_release_token(void) {}
static inline int lvmetad_vg_update_pending(struct volume_group *vg) {return 1;}
static inline int lvmetad_vg_update_finish(struct volume_group *vg) {return 1;}
static inline int lvmetad_vg_remove_pending(struct volume_group *vg) {return 1;}
static inline int lvmetad_vg_remove_finish(struct volume_group *vg) {return 1;}
static inline int lvmetad_pv_found(struct cmd_context *cmd, const struct id *pvid, struct device *dev,
const struct format_type *fmt, uint64_t label_sector,
struct volume_group *vg,
struct dm_list *found_vgnames,
struct dm_list *changed_vgnames) {return 1;}
static inline int lvmetad_pv_gone(dev_t devno, const char *pv_name) {return 1;}
static inline int lvmetad_pv_gone_by_dev(struct device *dev) {return 1;}
static inline int lvmetad_pv_list_to_lvmcache(struct cmd_context *cmd) {return 1;}
static inline int lvmetad_pv_lookup(struct cmd_context *cmd, struct id pvid, int *found) {return 0;}
static inline int lvmetad_pv_lookup_by_dev(struct cmd_context *cmd, struct device *dev, int *found) {return 0;}
static inline int lvmetad_vg_list_to_lvmcache(struct cmd_context *cmd) {return 1;}
static inline int lvmetad_get_vgnameids(struct cmd_context *cmd, struct dm_list *vgnameids) {return 0;}
static inline struct volume_group *lvmetad_vg_lookup(struct cmd_context *cmd,
const char *vgname, const char *vgid) {return NULL;}
static inline int lvmetad_pvscan_single(struct cmd_context *cmd, struct device *dev,
struct dm_list *found_vgnames,
struct dm_list *changed_vgnames) {return 0;}
static inline int lvmetad_pvscan_all_devs(struct cmd_context *cmd, int do_wait) {return 0;}
static inline int lvmetad_vg_clear_outdated_pvs(struct volume_group *vg) {return 0;}
static inline void lvmetad_validate_global_cache(struct cmd_context *cmd, int force) {}
static inline int lvmetad_token_matches(struct cmd_context *cmd) {return 1;}
static inline int lvmetad_vg_is_foreign(struct cmd_context *cmd, const char *vgname, const char *vgid) {return 0;}
static inline int lvmetad_is_disabled(struct cmd_context *cmd, const char **reason) {return 0;}
static inline void lvmetad_set_disabled(struct cmd_context *cmd, const char *reason) {}
static inline void lvmetad_clear_disabled(struct cmd_context *cmd) {}
# endif /* LVMETAD_SUPPORT */
#endif

View File

@ -29,7 +29,6 @@
#include "lib/datastruct/str_list.h"
#include "lib/metadata/segtype.h"
#include "lib/cache/lvmcache.h"
#include "lib/cache/lvmetad.h"
#include "lib/format_text/archiver.h"
#include "lib/lvmpolld/lvmpolld-client.h"
@ -265,8 +264,6 @@ static int _parse_debug_classes(struct cmd_context *cmd)
debug_classes |= LOG_CLASS_ACTIVATION;
else if (!strcasecmp(cv->v.str, "allocation"))
debug_classes |= LOG_CLASS_ALLOC;
else if (!strcasecmp(cv->v.str, "lvmetad"))
debug_classes |= LOG_CLASS_LVMETAD;
else if (!strcasecmp(cv->v.str, "metadata"))
debug_classes |= LOG_CLASS_METADATA;
else if (!strcasecmp(cv->v.str, "cache"))
@ -1075,14 +1072,12 @@ static struct dev_filter *_init_lvmetad_filter_chain(struct cmd_context *cmd)
}
/* regex filter. Optional. */
if (!lvmetad_used()) {
if ((cn = find_config_tree_node(cmd, devices_filter_CFG, NULL))) {
if (!(filters[nr_filt] = regex_filter_create(cn->v))) {
log_error("Failed to create regex device filter");
goto bad;
}
nr_filt++;
if ((cn = find_config_tree_node(cmd, devices_filter_CFG, NULL))) {
if (!(filters[nr_filt] = regex_filter_create(cn->v))) {
log_error("Failed to create regex device filter");
goto bad;
}
nr_filt++;
}
/* device type filter. Required. */
@ -1093,9 +1088,7 @@ static struct dev_filter *_init_lvmetad_filter_chain(struct cmd_context *cmd)
nr_filt++;
/* usable device filter. Required. */
if (!(filters[nr_filt] = usable_filter_create(cmd->dev_types,
lvmetad_used() ? FILTER_MODE_PRE_LVMETAD
: FILTER_MODE_NO_LVMETAD))) {
if (!(filters[nr_filt] = usable_filter_create(cmd->dev_types, FILTER_MODE_NO_LVMETAD))) {
log_error("Failed to create usabled device filter");
goto bad;
}
@ -1175,8 +1168,6 @@ bad:
int init_filters(struct cmd_context *cmd, unsigned load_persistent_cache)
{
struct dev_filter *filter = NULL, *filter_components[2] = {0};
int nr_filt;
const struct dm_config_node *cn;
if (!cmd->initialized.connections) {
log_error(INTERNAL_ERROR "connections must be initialized before filters");
@ -1198,27 +1189,8 @@ int init_filters(struct cmd_context *cmd, unsigned load_persistent_cache)
* and we use exactly one filter chain during device scanning ("filter"
* that includes also "cmd->lvmetad_filter" chain).
*/
/* filter component 0 */
if (lvmetad_used()) {
nr_filt = 0;
if ((cn = find_config_tree_array(cmd, devices_filter_CFG, NULL))) {
if (!(filter_components[nr_filt] = regex_filter_create(cn->v))) {
log_verbose("Failed to create regex device filter.");
goto bad;
}
nr_filt++;
}
if (!(filter_components[nr_filt] = usable_filter_create(cmd->dev_types, FILTER_MODE_POST_LVMETAD))) {
log_verbose("Failed to create usable device filter.");
goto bad;
}
nr_filt++;
if (!(filter = composite_filter_create(nr_filt, 0, filter_components)))
goto_bad;
} else {
filter = cmd->lvmetad_filter;
cmd->lvmetad_filter = NULL;
}
filter = cmd->lvmetad_filter;
cmd->lvmetad_filter = NULL;
if (!(filter = persistent_filter_create(cmd->dev_types, filter))) {
log_verbose("Failed to create persistent device filter.");
@ -1227,16 +1199,7 @@ int init_filters(struct cmd_context *cmd, unsigned load_persistent_cache)
cmd->filter = filter;
if (lvmetad_used()) {
nr_filt = 0;
filter_components[nr_filt] = cmd->lvmetad_filter;
nr_filt++;
filter_components[nr_filt] = cmd->filter;
nr_filt++;
if (!(cmd->full_filter = composite_filter_create(nr_filt, 0, filter_components)))
goto_bad;
} else
cmd->full_filter = filter;
cmd->full_filter = filter;
cmd->initialized.filters = 1;
return 1;
@ -1539,74 +1502,6 @@ static void _init_globals(struct cmd_context *cmd)
init_mirror_in_sync(0);
}
/*
* init_connections();
* _init_lvmetad();
* lvmetad_disconnect(); (close previous connection)
* lvmetad_set_socket(); (set path from config)
* lvmetad_set_token(); (set token from filter config)
* if (find_config(use_lvmetad))
* lvmetad_connect();
*
* If lvmetad_connect() is successful, lvmetad_used() will
* return 1.
*
* If the config has use_lvmetad=0, then lvmetad_connect()
* will not be called, and lvmetad_used() will return 0.
*
* Other code should use lvmetad_used() to check if the
* command is using lvmetad.
*
*/
static int _init_lvmetad(struct cmd_context *cmd)
{
const struct dm_config_node *cn;
const char *lvmetad_socket;
lvmetad_disconnect();
lvmetad_socket = getenv("LVM_LVMETAD_SOCKET");
if (!lvmetad_socket)
lvmetad_socket = DEFAULT_RUN_DIR "/lvmetad.socket";
/* TODO?
lvmetad_socket = find_config_tree_str(cmd, "lvmetad/socket_path",
DEFAULT_RUN_DIR "/lvmetad.socket");
*/
lvmetad_set_socket(lvmetad_socket);
cn = find_config_tree_array(cmd, devices_global_filter_CFG, NULL);
lvmetad_set_token(cn ? cn->v : NULL);
if (find_config_tree_int(cmd, global_locking_type_CFG, NULL) == 3 &&
find_config_tree_bool(cmd, global_use_lvmetad_CFG, NULL)) {
log_warn("WARNING: Not using lvmetad because locking_type is 3 (clustered).");
return 1;
}
if (!find_config_tree_bool(cmd, global_use_lvmetad_CFG, NULL)) {
if (lvmetad_pidfile_present()) {
log_warn("WARNING: Not using lvmetad because config setting use_lvmetad=0.");
log_warn("WARNING: To avoid corruption, rescan devices to make changes visible (pvscan --cache).");
}
return 1;
}
if (!lvmetad_connect(cmd)) {
log_warn("WARNING: Failed to connect to lvmetad. Falling back to device scanning.");
return 1;
}
if (!lvmetad_used()) {
/* This should never happen. */
log_error(INTERNAL_ERROR "lvmetad setup incorrect");
return 0;
}
return 1;
}
static int _init_lvmpolld(struct cmd_context *cmd)
{
const char *lvmpolld_socket;
@ -1624,12 +1519,6 @@ static int _init_lvmpolld(struct cmd_context *cmd)
int init_connections(struct cmd_context *cmd)
{
if (!_init_lvmetad(cmd)) {
log_error("Failed to initialize lvmetad connection.");
goto bad;
}
if (!_init_lvmpolld(cmd)) {
log_error("Failed to initialize lvmpolld connection.");
goto bad;
@ -2168,8 +2057,6 @@ void destroy_toolcontext(struct cmd_context *cmd)
#endif
free(cmd);
lvmetad_release_token();
lvmetad_disconnect();
lvmpolld_disconnect();
release_log_memory();

View File

@ -157,7 +157,6 @@ struct cmd_context {
unsigned lockd_vg_disable:1;
unsigned lockd_lv_disable:1;
unsigned lockd_gl_removed:1;
unsigned lockd_vg_rescan:1;
unsigned lockd_vg_default_sh:1;
unsigned lockd_vg_enforce_sh:1;
unsigned lockd_lv_sh:1;

View File

@ -289,7 +289,6 @@ cfg_array(devices_filter_CFG, "filter", devices_CFG_SECTION, CFG_DEFAULT_COMMENT
"then the device is accepted. Be careful mixing 'a' and 'r' patterns,\n"
"as the combination might produce unexpected results (test changes.)\n"
"Run vgscan after changing the filter to regenerate the cache.\n"
"See the use_lvmetad comment for a special case regarding filters.\n"
"#\n"
"Example\n"
"Accept every block device:\n"
@ -307,7 +306,7 @@ cfg_array(devices_filter_CFG, "filter", devices_CFG_SECTION, CFG_DEFAULT_COMMENT
cfg_array(devices_global_filter_CFG, "global_filter", devices_CFG_SECTION, CFG_DEFAULT_COMMENTED, CFG_TYPE_STRING, "#Sa|.*/|", vsn(2, 2, 98), NULL, 0, NULL,
"Limit the block devices that are used by LVM system components.\n"
"Because devices/filter may be overridden from the command line, it is\n"
"not suitable for system-wide device filtering, e.g. udev and lvmetad.\n"
"not suitable for system-wide device filtering, e.g. udev.\n"
"Use global_filter to hide devices from these LVM system components.\n"
"The syntax is the same as devices/filter. Devices rejected by\n"
"global_filter are not opened by LVM.\n")
@ -800,11 +799,11 @@ cfg(log_activation_CFG, "activation", log_CFG_SECTION, 0, CFG_TYPE_BOOL, 0, vsn(
cfg(log_activate_file_CFG, "activate_file", log_CFG_SECTION, CFG_DEFAULT_UNDEFINED | CFG_UNSUPPORTED, CFG_TYPE_STRING, NULL, vsn(1, 0, 0), NULL, 0, NULL, NULL)
cfg_array(log_debug_classes_CFG, "debug_classes", log_CFG_SECTION, CFG_ALLOW_EMPTY, CFG_TYPE_STRING, "#Smemory#Sdevices#Sio#Sactivation#Sallocation#Slvmetad#Smetadata#Scache#Slocking#Slvmpolld#Sdbus", vsn(2, 2, 99), NULL, 0, NULL,
cfg_array(log_debug_classes_CFG, "debug_classes", log_CFG_SECTION, CFG_ALLOW_EMPTY, CFG_TYPE_STRING, "#Smemory#Sdevices#Sio#Sactivation#Sallocation#Smetadata#Scache#Slocking#Slvmpolld#Sdbus", vsn(2, 2, 99), NULL, 0, NULL,
"Select log messages by class.\n"
"Some debugging messages are assigned to a class and only appear in\n"
"debug output if the class is listed here. Classes currently\n"
"available: memory, devices, io, activation, allocation, lvmetad,\n"
"available: memory, devices, io, activation, allocation,\n"
"metadata, cache, locking, lvmpolld. Use \"all\" to see everything.\n")
cfg(backup_backup_CFG, "backup", backup_CFG_SECTION, 0, CFG_TYPE_BOOL, DEFAULT_BACKUP_ENABLED, vsn(1, 0, 0), NULL, 0, NULL,
@ -995,38 +994,11 @@ cfg(global_lvdisplay_shows_full_device_path_CFG, "lvdisplay_shows_full_device_pa
"Previously this was always shown as /dev/vgname/lvname even when that\n"
"was never a valid path in the /dev filesystem.\n")
cfg(global_use_lvmetad_CFG, "use_lvmetad", global_CFG_SECTION, 0, CFG_TYPE_BOOL, DEFAULT_USE_LVMETAD, vsn(2, 2, 93), "@DEFAULT_USE_LVMETAD@", 0, NULL,
"Use lvmetad to cache metadata and reduce disk scanning.\n"
"When enabled (and running), lvmetad provides LVM commands with VG\n"
"metadata and PV state. LVM commands then avoid reading this\n"
"information from disks which can be slow. When disabled (or not\n"
"running), LVM commands fall back to scanning disks to obtain VG\n"
"metadata. lvmetad is kept updated via udev rules which must be set\n"
"up for LVM to work correctly. (The udev rules should be installed\n"
"by default.) Without a proper udev setup, changes in the system's\n"
"block device configuration will be unknown to LVM, and ignored\n"
"until a manual 'pvscan --cache' is run. If lvmetad was running\n"
"while use_lvmetad was disabled, it must be stopped, use_lvmetad\n"
"enabled, and then started. When using lvmetad, LV activation is\n"
"switched to an automatic, event-based mode. In this mode, LVs are\n"
"activated based on incoming udev events that inform lvmetad when\n"
"PVs appear on the system. When a VG is complete (all PVs present),\n"
"it is auto-activated. The auto_activation_volume_list setting\n"
"controls which LVs are auto-activated (all by default.)\n"
"When lvmetad is updated (automatically by udev events, or directly\n"
"by pvscan --cache), devices/filter is ignored and all devices are\n"
"scanned by default. lvmetad always keeps unfiltered information\n"
"which is provided to LVM commands. Each LVM command then filters\n"
"based on devices/filter. This does not apply to other, non-regexp,\n"
"filtering settings: component filters such as multipath and MD\n"
"are checked during pvscan --cache. To filter a device and prevent\n"
"scanning from the LVM system entirely, including lvmetad, use\n"
"devices/global_filter.\n")
cfg(global_use_lvmetad_CFG, "use_lvmetad", global_CFG_SECTION, 0, CFG_TYPE_BOOL, 0, vsn(2, 2, 93), 0, vsn(3, 0, 0), NULL,
"This setting is no longer used.\n")
cfg(global_lvmetad_update_wait_time_CFG, "lvmetad_update_wait_time", global_CFG_SECTION, CFG_DEFAULT_COMMENTED, CFG_TYPE_INT, DEFAULT_LVMETAD_UPDATE_WAIT_TIME, vsn(2, 2, 151), NULL, 0, NULL,
"Number of seconds a command will wait for lvmetad update to finish.\n"
"After waiting for this period, a command will not use lvmetad, and\n"
"will revert to disk scanning.\n")
cfg(global_lvmetad_update_wait_time_CFG, "lvmetad_update_wait_time", global_CFG_SECTION, CFG_DEFAULT_COMMENTED, CFG_TYPE_INT, 0, vsn(2, 2, 151), NULL, vsn(3, 0, 0), NULL,
"This setting is no longer used.\n")
cfg(global_use_lvmlockd_CFG, "use_lvmlockd", global_CFG_SECTION, 0, CFG_TYPE_BOOL, 0, vsn(2, 2, 124), NULL, 0, NULL,
"Use lvmlockd for locking among hosts using LVM on shared storage.\n"

View File

@ -18,7 +18,6 @@
#include "lib/format_text/format-text.h"
#include "lib/misc/lvm-string.h"
#include "lib/cache/lvmcache.h"
#include "lib/cache/lvmetad.h"
#include "lib/mm/memlock.h"
#include "lib/commands/toolcontext.h"
#include "lib/locking/locking.h"

View File

@ -28,7 +28,6 @@
#include "lib/mm/xlate.h"
#include "lib/label/label.h"
#include "lib/cache/lvmcache.h"
#include "lib/cache/lvmetad.h"
#include "lib/mm/memlock.h"
#include <unistd.h>
@ -1569,11 +1568,6 @@ static struct metadata_area_ops _metadata_text_file_backup_ops = {
.vg_commit = _vg_commit_file_backup
};
static int _mda_export_text_raw(struct metadata_area *mda,
struct dm_config_tree *cft,
struct dm_config_node *parent);
static int _mda_import_text_raw(struct lvmcache_info *info, const struct dm_config_node *cn);
static struct metadata_area_ops _metadata_text_raw_ops = {
.vg_read = _vg_read_raw,
.vg_read_precommit = _vg_read_precommit_raw,
@ -1591,63 +1585,8 @@ static struct metadata_area_ops _metadata_text_raw_ops = {
.pv_analyze_mda = _pv_analyze_mda_raw,
.mda_locns_match = _mda_locns_match_raw,
.mda_get_device = _mda_get_device_raw,
.mda_export_text = _mda_export_text_raw,
.mda_import_text = _mda_import_text_raw
};
/* used only for sending info to lvmetad */
static int _mda_export_text_raw(struct metadata_area *mda,
struct dm_config_tree *cft,
struct dm_config_node *parent)
{
struct mda_context *mdc = (struct mda_context *) mda->metadata_locn;
char mdah[MDA_HEADER_SIZE]; /* temporary */
if (!mdc) {
log_error(INTERNAL_ERROR "mda_export_text_raw no mdc");
return 1; /* pretend the MDA does not exist */
}
/* FIXME: why aren't ignore,start,size,free_sectors available? */
if (!_raw_read_mda_header((struct mda_header *)mdah, &mdc->area, mda_is_primary(mda)))
return 1; /* pretend the MDA does not exist */
return config_make_nodes(cft, parent, NULL,
"ignore = " FMTd64, (int64_t) mda_is_ignored(mda),
"start = " FMTd64, (int64_t) mdc->area.start,
"size = " FMTd64, (int64_t) mdc->area.size,
"free_sectors = " FMTd64, (int64_t) mdc->free_sectors,
NULL) ? 1 : 0;
}
/* used only for receiving info from lvmetad */
static int _mda_import_text_raw(struct lvmcache_info *info, const struct dm_config_node *cn)
{
struct device *device;
uint64_t offset;
uint64_t size;
int ignore;
if (!cn->child)
return 0;
cn = cn->child;
device = lvmcache_device(info);
size = dm_config_find_int64(cn, "size", 0);
if (!device || !size)
return 0;
offset = dm_config_find_int64(cn, "start", 0);
ignore = dm_config_find_int(cn, "ignore", 0);
lvmcache_add_mda(info, device, offset, size, ignore);
return 1;
}
static int _text_pv_setup(const struct format_type *fmt,
struct physical_volume *pv,
struct volume_group *vg)

View File

@ -246,9 +246,3 @@ struct volume_group *import_vg_from_config_tree(const struct dm_config_tree *cft
{
return _import_vg_from_config_tree(cft, fid, 0);
}
struct volume_group *import_vg_from_lvmetad_config_tree(const struct dm_config_tree *cft,
struct format_instance *fid)
{
return _import_vg_from_config_tree(cft, fid, 1);
}

View File

@ -19,7 +19,6 @@
#include "lib/display/display.h"
#include "lib/commands/toolcontext.h"
#include "lib/cache/lvmcache.h"
#include "lib/cache/lvmetad.h"
#include "lib/locking/lvmlockd.h"
#include "lib/metadata/lv_alloc.h"
#include "lib/metadata/pv_alloc.h"
@ -60,10 +59,6 @@ static int _vsn1_check_version(const struct dm_config_tree *cft)
const struct dm_config_node *cn;
const struct dm_config_value *cv;
// TODO if this is pvscan --cache, we want this check back.
if (lvmetad_used())
return 1;
/*
* Check the contents field.
*/
@ -186,8 +181,6 @@ static int _read_pv(struct format_instance *fid,
const struct dm_config_value *cv;
uint64_t size, ba_start;
int outdated = !strcmp(pvn->parent->key, "outdated_pvs");
if (!(pvl = dm_pool_zalloc(mem, sizeof(*pvl))) ||
!(pvl->pv = dm_pool_zalloc(mem, sizeof(*pvl->pv))))
return_0;
@ -233,13 +226,12 @@ static int _read_pv(struct format_instance *fid,
memcpy(&pv->vgid, &vg->id, sizeof(vg->id));
if (!outdated && !_read_flag_config(pvn, &pv->status, PV_FLAGS)) {
if (!_read_flag_config(pvn, &pv->status, PV_FLAGS)) {
log_error("Couldn't read status flags for physical volume.");
return 0;
}
/* TODO is the !lvmetad_used() too coarse here? */
if (!pv->dev && !lvmetad_used())
if (!pv->dev)
pv->status |= MISSING_PV;
if ((pv->status & MISSING_PV) && pv->dev && pv_mda_used_count(pv) == 0) {
@ -255,13 +247,13 @@ static int _read_pv(struct format_instance *fid,
return 0;
}
if (!outdated && !_read_uint64(pvn, "pe_start", &pv->pe_start)) {
if (!_read_uint64(pvn, "pe_start", &pv->pe_start)) {
log_error("Couldn't read extent start value (pe_start) "
"for physical volume.");
return 0;
}
if (!outdated && !_read_int32(pvn, "pe_count", &pv->pe_count)) {
if (!_read_int32(pvn, "pe_count", &pv->pe_count)) {
log_error("Couldn't find extent count (pe_count) for "
"physical volume.");
return 0;
@ -320,10 +312,7 @@ static int _read_pv(struct format_instance *fid,
vg->extent_count += pv->pe_count;
vg->free_count += pv->pe_count;
if (outdated)
dm_list_add(&vg->pvs_outdated, &pvl->list);
else
add_pvl_to_vgs(vg, pvl);
add_pvl_to_vgs(vg, pvl);
return 1;
}
@ -1148,12 +1137,6 @@ static struct volume_group *_read_vg(struct format_instance *fid,
goto bad;
}
if (allow_lvmetad_extensions)
_read_sections(fid, "outdated_pvs", _read_pv, vg,
vgn, pv_hash, lv_hash, 1);
else if (dm_config_has_node(vgn, "outdated_pvs"))
log_error(INTERNAL_ERROR "Unexpected outdated_pvs section in metadata of VG %s.", vg->name);
/* Optional tags */
if (dm_config_get_list(vgn, "tags", &cv) &&
!(_read_str_list(vg->vgmem, &vg->tags, cv))) {

View File

@ -28,8 +28,6 @@
struct labeller;
void allow_reads_with_lvmetad(void);
/* On disk - 32 bytes */
struct label_header {
int8_t id[8]; /* LABELONE */

View File

@ -60,8 +60,6 @@ int lock_vol(struct cmd_context *cmd, const char *vol, uint32_t flags, const str
#define unlock_vg(cmd, vg, vol) \
do { \
if (vg && !lvmetad_vg_update_finish(vg)) \
stack; \
if (is_real_vg(vol) && !sync_local_dev_names(cmd)) \
stack; \
if (!lock_vol(cmd, vol, LCK_VG_UNLOCK, NULL)) \

View File

@ -13,7 +13,6 @@
#include "lib/metadata/metadata.h"
#include "lib/metadata/segtype.h"
#include "lib/activate/activate.h"
#include "lib/cache/lvmetad.h"
#include "lib/locking/lvmlockd.h"
#include "lib/cache/lvmcache.h"
#include "daemons/lvmlockd/lvmlockd-client.h"
@ -1324,7 +1323,7 @@ int lockd_gl_create(struct cmd_context *cmd, const char *def_mode, const char *v
* lvmlockd to return NO_GL_LS/NO_LOCKSPACES.
*
* 2. No sanlock VGs are seen in lvmcache after the disk
* scan performed in lvmetad_validate_global_cache().
* scan performed.
*
* If both of those are true, we go ahead and create this new
* VG which will have the global lock enabled. However, this
@ -1347,11 +1346,6 @@ int lockd_gl_create(struct cmd_context *cmd, const char *def_mode, const char *v
if ((lockd_flags & LD_RF_NO_GL_LS) &&
(lockd_flags & LD_RF_NO_LOCKSPACES) &&
!strcmp(vg_lock_type, "sanlock")) {
lvmetad_validate_global_cache(cmd, 1);
/*
* lvmcache holds provisional VG lock_type info because
* lvmetad_validate_global_cache did a disk scan.
*/
if (lvmcache_contains_lock_type_sanlock(cmd)) {
/* FIXME: we could check that all are started, and then check that none have gl enabled. */
log_error("Global lock failed: start existing sanlock VGs to access global lock.");
@ -1391,8 +1385,6 @@ int lockd_gl_create(struct cmd_context *cmd, const char *def_mode, const char *v
/* --shared with vgcreate does not mean include_shared_vgs */
cmd->include_shared_vgs = 0;
lvmetad_validate_global_cache(cmd, 1);
return 1;
}
@ -1438,17 +1430,6 @@ int lockd_gl_create(struct cmd_context *cmd, const char *def_mode, const char *v
* will continue running for a long time while not needing the global lock,
* e.g. commands that poll to report progress.
*
* Acquiring the global lock also updates the local lvmetad cache if
* necessary. lockd_gl() first acquires the lock via lvmlockd, then
* before returning to the caller, it checks that the global information
* (e.g. VG namespace, set of orphans) is up to date in lvmetad. If
* not, it scans disks and updates the lvmetad cache before returning
* to the caller. It does this checking using a version number associated
* with the global lock. The version number is incremented each time
* a change is made to the state associated with the global lock, and
* if the local version number is lower than the version number in the
* lock, then the local lvmetad state must be updated.
*
* There are two cases where the global lock can be taken in shared mode,
* and then later converted to ex. pvchange and pvresize use process_each_pv
* which does lockd_gl("sh") to get the list of VGs. Later, in the "_single"
@ -1491,7 +1472,6 @@ int lockd_gl(struct cmd_context *cmd, const char *def_mode, uint32_t flags)
const char *mode = NULL;
const char *opts = NULL;
uint32_t lockd_flags;
int force_cache_update = 0;
int retries = 0;
int result;
@ -1536,7 +1516,6 @@ int lockd_gl(struct cmd_context *cmd, const char *def_mode, uint32_t flags)
/* We can continue reading if a shared lock fails. */
if (!strcmp(mode, "sh")) {
log_warn("Reading without shared global lock.");
force_cache_update = 1;
goto allow;
}
@ -1615,26 +1594,22 @@ int lockd_gl(struct cmd_context *cmd, const char *def_mode, uint32_t flags)
if (result == -ESTARTING) {
log_warn("Skipping global lock: lockspace is starting");
force_cache_update = 1;
goto allow;
}
if (result == -ELOCKIO || result == -EVGKILLED) {
log_warn("Skipping global lock: storage %s for sanlock leases",
result == -ELOCKIO ? "errors" : "failed");
force_cache_update = 1;
goto allow;
}
if ((lockd_flags & LD_RF_NO_GL_LS) && (lockd_flags & LD_RF_WARN_GL_REMOVED)) {
log_warn("Skipping global lock: VG with global lock was removed");
force_cache_update = 1;
goto allow;
}
if ((lockd_flags & LD_RF_NO_GL_LS) || (lockd_flags & LD_RF_NO_LOCKSPACES)) {
log_warn("Skipping global lock: lockspace not found or started");
force_cache_update = 1;
goto allow;
}
@ -1669,7 +1644,6 @@ int lockd_gl(struct cmd_context *cmd, const char *def_mode, uint32_t flags)
}
allow:
lvmetad_validate_global_cache(cmd, force_cache_update);
return 1;
}
@ -1688,9 +1662,7 @@ int lockd_gl(struct cmd_context *cmd, const char *def_mode, uint32_t flags)
* assessed in combination with vg->lock_type.
*
* The VG lock protects the VG metadata on disk from concurrent access
* among hosts. The VG lock also ensures that the local lvmetad cache
* contains the latest version of the VG metadata from disk. (Since
* another host may have changed the VG since it was last read.)
* among hosts.
*
* The VG lock must be acquired before the VG is read, i.e. before vg_read().
* The result from lockd_vg() is saved in the "lockd_state" variable, and
@ -1700,13 +1672,6 @@ int lockd_gl(struct cmd_context *cmd, const char *def_mode, uint32_t flags)
* looking at lockd_state. If vg_read() sees that the VG is a local VG,
* i.e. lock_type is not sanlock or dlm, then no lock is required, and it
* ignores lockd_state (which would indicate no lock was found.)
*
* When acquiring the VG lock, lvmlockd checks if the local cached copy
* of the VG metadata in lvmetad is up to date. If not, it invalidates
* the VG cached in lvmetad. This would happen if another host changed
* the VG since it was last read. When lvm commands read the VG from
* lvmetad, they will check if the metadata is invalid, and if so they
* will reread it from disk, and update the copy in lvmetad.
*/
int lockd_vg(struct cmd_context *cmd, const char *vg_name, const char *def_mode,
@ -1726,24 +1691,6 @@ int lockd_vg(struct cmd_context *cmd, const char *vg_name, const char *def_mode,
*/
*lockd_state = 0;
/*
* Use of lockd_vg_rescan.
*
* This is the VG equivalent of using lvmetad_validate_global_cache()
* for the global lock (after failing to acquire the global lock). If
* we fail to acquire the VG lock from lvmlockd, then the lvmlockd
* mechanism has been missed that would have updated the cached lvmetad
* copy of the VG. So, set lockd_vg_rescan to tell the VG reading code
* to treat the lvmetad copy as if the invalid flag had been returned.
* i.e. If a lockd VG is read without a lock, ignore the lvmetad copy
* and read it from disk since we don't know if the cache is stale.
*
* Because lvmlockd requests return an error for local VGs, this will
* be set for local VGs, but it ends up being ignored once the VG is
* read and found to be a local VG.
*/
cmd->lockd_vg_rescan = 0;
if (!is_real_vg(vg_name))
return 1;
@ -1812,7 +1759,6 @@ int lockd_vg(struct cmd_context *cmd, const char *vg_name, const char *def_mode,
*/
if (!_use_lvmlockd) {
*lockd_state |= LDST_FAIL_REQUEST;
cmd->lockd_vg_rescan = 1;
return 1;
}
@ -1829,7 +1775,6 @@ int lockd_vg(struct cmd_context *cmd, const char *vg_name, const char *def_mode,
* this error for local VGs, but we do care for lockd VGs.
*/
*lockd_state |= LDST_FAIL_REQUEST;
cmd->lockd_vg_rescan = 1;
return 1;
}
@ -1848,15 +1793,12 @@ int lockd_vg(struct cmd_context *cmd, const char *vg_name, const char *def_mode,
break;
case -ENOLS:
*lockd_state |= LDST_FAIL_NOLS;
cmd->lockd_vg_rescan = 1;
break;
case -ESTARTING:
*lockd_state |= LDST_FAIL_STARTING;
cmd->lockd_vg_rescan = 1;
break;
default:
*lockd_state |= LDST_FAIL_OTHER;
cmd->lockd_vg_rescan = 1;
}
/*

View File

@ -20,7 +20,6 @@
#include "lib/misc/lvm-string.h"
#include "lib/misc/lvm-file.h"
#include "lib/cache/lvmcache.h"
#include "lib/cache/lvmetad.h"
#include "lib/mm/memlock.h"
#include "lib/datastruct/str_list.h"
#include "lib/metadata/pv_alloc.h"
@ -542,11 +541,6 @@ int vg_remove_direct(struct volume_group *vg)
struct pv_list *pvl;
int ret = 1;
if (!lvmetad_vg_remove_pending(vg)) {
log_error("Failed to update lvmetad for pending remove.");
return 0;
}
if (!vg_remove_mdas(vg)) {
log_error("vg_remove_mdas %s failed", vg->name);
return 0;
@ -578,9 +572,6 @@ int vg_remove_direct(struct volume_group *vg)
}
}
if (!lvmetad_vg_remove_finish(vg))
stack;
lockd_vg_update(vg);
set_vg_notify(vg->cmd);
@ -2987,17 +2978,6 @@ int vg_write(struct volume_group *vg)
lockd_vg_update(vg);
/*
* This tells lvmetad the new seqno it should expect to receive
* the metadata for after the commit. The cached VG will be
* invalid in lvmetad until this command sends the new metadata
* after it's committed.
*/
if (!lvmetad_vg_update_pending(vg)) {
log_error("Failed to prepare new VG metadata in lvmetad cache.");
return 0;
}
return 1;
}
@ -3030,7 +3010,6 @@ static int _vg_commit_mdas(struct volume_group *vg)
/* Update cache first time we succeed */
if (!failed && !cache_updated) {
lvmcache_update_vg(vg, 0);
// lvmetad_vg_commit(vg);
cache_updated = 1;
}
}
@ -3070,14 +3049,6 @@ void vg_revert(struct volume_group *vg)
struct metadata_area *mda;
struct lv_list *lvl;
/*
* This will leave the cached copy in lvmetad INVALID (from
* lvmetad_vg_update_pending) and means the VG will be reread from disk
* to update the lvmetad copy, which is what we want to ensure that the
* cached copy is correct.
*/
vg->lvmetad_update_pending = 0;
dm_list_iterate_items(lvl, &vg->lvs) {
if (lvl->lv->new_lock_args) {
lockd_free_lv(vg->cmd, vg, lvl->lv->name, &lvl->lv->lvid.id[1], lvl->lv->lock_args);
@ -3646,7 +3617,6 @@ static struct volume_group *_vg_read(struct cmd_context *cmd,
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;
@ -3669,49 +3639,6 @@ static struct volume_group *_vg_read(struct cmd_context *cmd,
log_very_verbose("Reading VG %s %s", vgname ?: "<no name>", vgid ? uuid : "<no vgid>");
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, enable_repair);
if (reappeared && enable_repair)
*mdas_consistent = _repair_inconsistent_vg(correct_vg, lockd_state);
else
*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);
lvmetad_vg_clear_outdated_pvs(correct_vg);
}
}
if (correct_vg) {
if (update_old_pv_ext && !_vg_update_old_pv_ext_if_needed(correct_vg)) {
release_vg(correct_vg);
return_NULL;
}
if (strip_historical_lvs && !vg_strip_outdated_historical_lvs(correct_vg)) {
release_vg(correct_vg);
return_NULL;
}
/*
* When a command reads the vg from lvmetad, and then
* writes the vg, the write path does some disk reads
* of the devs.
* FIXME: when a command is going to write the vg,
* we should just read the vg from disk entirely
* and skip reading it from lvmetad.
*/
dm_list_iterate_items(pvl, &correct_vg->pvs)
label_scan_open(pvl->pv->dev);
}
return correct_vg;
}
/*
* Rescan the devices that are associated with this vg in lvmcache.
* This repeats what was done by the command's initial label scan,
@ -4489,7 +4416,6 @@ int get_vgnameids(struct cmd_context *cmd, struct dm_list *vgnameids,
const char *only_this_vgname, int include_internal)
{
struct vgnameid_list *vgnl;
struct format_type *fmt;
if (only_this_vgname) {
if (!(vgnl = dm_pool_alloc(cmd->mem, sizeof(*vgnl)))) {
@ -4503,32 +4429,7 @@ int get_vgnameids(struct cmd_context *cmd, struct dm_list *vgnameids,
return 1;
}
if (lvmetad_used()) {
/*
* This just gets the list of names/ids from lvmetad
* and does not populate lvmcache.
*/
lvmetad_get_vgnameids(cmd, vgnameids);
if (include_internal) {
dm_list_iterate_items(fmt, &cmd->formats) {
if (!(vgnl = dm_pool_alloc(cmd->mem, sizeof(*vgnl)))) {
log_error("vgnameid_list allocation failed.");
return 0;
}
vgnl->vg_name = dm_pool_strdup(cmd->mem, fmt->orphan_vg_name);
vgnl->vgid = NULL;
dm_list_add(vgnameids, &vgnl->list);
}
}
} else {
/*
* The non-lvmetad case. This function begins by calling
* lvmcache_label_scan() to populate lvmcache.
*/
lvmcache_get_vgnameids(cmd, include_internal, vgnameids);
}
lvmcache_get_vgnameids(cmd, include_internal, vgnameids);
return 1;
}
@ -4559,9 +4460,6 @@ int pv_write(struct cmd_context *cmd,
pv->status &= ~UNLABELLED_PV;
if (!lvmetad_pv_found(cmd, &pv->id, pv->dev, pv->fmt, pv->label_sector, NULL, NULL, NULL))
return_0;
return 1;
}

View File

@ -460,8 +460,6 @@ size_t export_vg_to_buffer(struct volume_group *vg, char **buf);
struct dm_config_tree *export_vg_to_config_tree(struct volume_group *vg);
struct volume_group *import_vg_from_config_tree(const struct dm_config_tree *cft,
struct format_instance *fid);
struct volume_group *import_vg_from_lvmetad_config_tree(const struct dm_config_tree *cft,
struct format_instance *fid);
/*
* Mirroring functions

View File

@ -20,7 +20,6 @@
#include "lib/commands/toolcontext.h"
#include "lib/cache/lvmcache.h"
#include "lib/format_text/archiver.h"
#include "lib/cache/lvmetad.h"
struct volume_group *alloc_vg(const char *pool_name, struct cmd_context *cmd,
const char *vg_name)
@ -56,7 +55,6 @@ struct volume_group *alloc_vg(const char *pool_name, struct cmd_context *cmd,
dm_list_init(&vg->pvs);
dm_list_init(&vg->pv_write_list);
dm_list_init(&vg->pvs_outdated);
dm_list_init(&vg->lvs);
dm_list_init(&vg->historical_lvs);
dm_list_init(&vg->tags);
@ -90,11 +88,6 @@ void release_vg(struct volume_group *vg)
if (!vg || (vg->fid && vg == vg->fid->fmt->orphan_vg))
return;
if (vg->saved_in_clvmd) {
log_debug("release_vg skip saved %s %p", vg->name, vg);
return;
}
release_vg(vg->vg_committed);
release_vg(vg->vg_precommitted);
_free_vg(vg);

View File

@ -42,8 +42,6 @@ struct volume_group {
struct lvmcache_vginfo *vginfo;
uint32_t seqno; /* Metadata sequence number */
unsigned skip_validate_lock_args : 1;
unsigned lvmetad_update_pending: 1;
unsigned saved_in_clvmd: 1;
/*
* The parsed committed (on-disk) copy of this VG; is NULL if this VG is committed
@ -84,24 +82,6 @@ struct volume_group {
struct dm_list pv_write_list; /* struct pv_list */
/*
* List of physical volumes that carry outdated metadata that belongs
* to this VG. Currently only populated when lvmetad is in use. The PVs
* on this list could still belong to the VG (but their MDA carries an
* out-of-date copy of the VG metadata) or they could no longer belong
* to the VG. With lvmetad, this list is populated with all PVs that
* have a VGID matching ours, but seqno that is smaller than the
* current seqno for the VG. The MDAs on still-in-VG PVs are updated as
* part of the normal vg_write/vg_commit process. The MDAs on PVs that
* no longer belong to the VG are wiped during vg_read.
*
* However, even though still-in-VG PVs *may* be on the list, this is
* not guaranteed. The in-lvmetad list is cleared whenever out-of-VG
* outdated PVs are wiped during vg_read.
*/
struct dm_list pvs_outdated;
/*
* logical volumes
* The following relationship should always hold:

View File

@ -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 $@ \

View File

@ -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,

View File

@ -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
---

View File

@ -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

View File

@ -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",

View File

@ -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;

View File

@ -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);

View File

@ -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);

View File

@ -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());
}
}
/*

View File

@ -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

View File

@ -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;
}

View File

@ -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;
}

View File

@ -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);

View File

@ -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.",

View File

@ -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

View File

@ -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;
}

View File

@ -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.");

View File

@ -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);
}

View File

@ -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);

View File

@ -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,

View File

@ -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;
}

View File

@ -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;

View File

@ -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);

View File

@ -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);

View File

@ -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\"",