master - configure: respect --disable-lvmetad/lvmpolld
by Zdenek Kabelac
Gitweb: http://git.fedorahosted.org/git/?p=lvm2.git;a=commitdiff;h=57f468a53ed8ec...
Commit: 57f468a53ed8ec425d1087ce06c90862caa19ff1
Parent: 600d7ca15f410c8abf41cee0195bc575148253b4
Author: Zdenek Kabelac <zkabelac(a)redhat.com>
AuthorDate: Thu Apr 21 00:31:15 2016 +0200
Committer: Zdenek Kabelac <zkabelac(a)redhat.com>
CommitterDate: Thu Apr 21 00:34:01 2016 +0200
configure: respect --disable-lvmetad/lvmpolld
When user requested on cmdline disabling of lvmetad/lvmpoll,
respect it and when lvmlockd requires these daemon,
Error configure with clear message about misconfiguration.
---
configure | 28 ++++++++++++++++------------
configure.in | 20 ++++++++++----------
2 files changed, 26 insertions(+), 22 deletions(-)
diff --git a/configure b/configure
index c2de9a8..83d5964 100755
--- a/configure
+++ b/configure
@@ -3168,8 +3168,8 @@ case "$host_os" in
LDDEPS="$LDDEPS .export.sym"
LIB_SUFFIX=so
DEVMAPPER=yes
- LVMETAD=no
- LVMPOLLD=no
+ BUILD_LVMETAD=no
+ BUILD_LVMPOLLD=no
LOCKDSANLOCK=no
LOCKDDLM=no
ODIRECT=yes
@@ -11486,10 +11486,9 @@ if test "${enable_lvmetad+set}" = set; then :
enableval=$enable_lvmetad; LVMETAD=$enableval
fi
-{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $LVMETAD" >&5
-$as_echo "$LVMETAD" >&6; }
-
-BUILD_LVMETAD=$LVMETAD
+test -n "$LVMETAD" && BUILD_LVMETAD=$LVMETAD
+{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $BUILD_LVMETAD" >&5
+$as_echo "$BUILD_LVMETAD" >&6; }
################################################################################
{ $as_echo "$as_me:${as_lineno-$LINENO}: checking whether to build lvmpolld" >&5
@@ -11499,10 +11498,9 @@ if test "${enable_lvmpolld+set}" = set; then :
enableval=$enable_lvmpolld; LVMPOLLD=$enableval
fi
-{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $LVMPOLLD" >&5
-$as_echo "$LVMPOLLD" >&6; }
-
-BUILD_LVMPOLLD=$LVMPOLLD
+test -n "$LVMPOLLD" && BUILD_LVMPOLLD=$LVMPOLLD
+{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $BUILD_LVMPOLLD" >&5
+$as_echo "$BUILD_LVMPOLLD" >&6; }
################################################################################
BUILD_LVMLOCKD=no
@@ -11695,11 +11693,17 @@ $as_echo_n "checking whether to build lvmlockd... " >&6; }
$as_echo "$BUILD_LVMLOCKD" >&6; }
if test "$BUILD_LVMLOCKD" = yes; then
- if test -n "$BUILD_LVMPOLLD"; then :
+ if test "$LVMPOLLD" = no; then :
+ as_fn_error $? "cannot build lvmlockd with --disable-lvmpolld." "$LINENO" 5
+fi
+ if test "$LVMETAD" = no; then :
+ as_fn_error $? "cannot build lvmlockd with --disable-lvmetad." "$LINENO" 5
+fi
+ if test "$BUILD_LVMPOLLD" = no; then :
BUILD_LVMPOLLD=yes; { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: Enabling lvmpolld - required by lvmlockd." >&5
$as_echo "$as_me: WARNING: Enabling lvmpolld - required by lvmlockd." >&2;}
fi
- if test -n "$BUILD_LVMETAD"; then :
+ if test "$BUILD_LVMETAD" = no; then :
BUILD_LVMETAD=yes; { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: Enabling lvmetad - required by lvmlockd." >&5
$as_echo "$as_me: WARNING: Enabling lvmetad - required by lvmlockd." >&2;}
fi
diff --git a/configure.in b/configure.in
index 4161df7..b87f8ff 100644
--- a/configure.in
+++ b/configure.in
@@ -37,8 +37,8 @@ case "$host_os" in
LDDEPS="$LDDEPS .export.sym"
LIB_SUFFIX=so
DEVMAPPER=yes
- LVMETAD=no
- LVMPOLLD=no
+ BUILD_LVMETAD=no
+ BUILD_LVMPOLLD=no
LOCKDSANLOCK=no
LOCKDDLM=no
ODIRECT=yes
@@ -1129,9 +1129,8 @@ AC_ARG_ENABLE(lvmetad,
AC_HELP_STRING([--enable-lvmetad],
[enable the LVM Metadata Daemon]),
LVMETAD=$enableval)
-AC_MSG_RESULT($LVMETAD)
-
-BUILD_LVMETAD=$LVMETAD
+test -n "$LVMETAD" && BUILD_LVMETAD=$LVMETAD
+AC_MSG_RESULT($BUILD_LVMETAD)
################################################################################
dnl -- Build lvmpolld
@@ -1140,9 +1139,8 @@ AC_ARG_ENABLE(lvmpolld,
AC_HELP_STRING([--enable-lvmpolld],
[enable the LVM Polling Daemon]),
LVMPOLLD=$enableval)
-AC_MSG_RESULT($LVMPOLLD)
-
-BUILD_LVMPOLLD=$LVMPOLLD
+test -n "$LVMPOLLD" && BUILD_LVMPOLLD=$LVMPOLLD
+AC_MSG_RESULT($BUILD_LVMPOLLD)
################################################################################
BUILD_LVMLOCKD=no
@@ -1188,8 +1186,10 @@ AC_MSG_CHECKING(whether to build lvmlockd)
AC_MSG_RESULT($BUILD_LVMLOCKD)
if test "$BUILD_LVMLOCKD" = yes; then
- AS_IF([test -n "$BUILD_LVMPOLLD"], [BUILD_LVMPOLLD=yes; AC_MSG_WARN([Enabling lvmpolld - required by lvmlockd.])])
- AS_IF([test -n "$BUILD_LVMETAD"], [BUILD_LVMETAD=yes; AC_MSG_WARN([Enabling lvmetad - required by lvmlockd.])])
+ 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],
6 years, 11 months
master - configure: detect for /var/lock dir
by Zdenek Kabelac
Gitweb: http://git.fedorahosted.org/git/?p=lvm2.git;a=commitdiff;h=600d7ca15f410c...
Commit: 600d7ca15f410c8abf41cee0195bc575148253b4
Parent: 5c104c5de9b019f5cf9b93ff2ee5468e1f0641d1
Author: Zdenek Kabelac <zkabelac(a)redhat.com>
AuthorDate: Wed Apr 20 23:15:00 2016 +0200
Committer: Zdenek Kabelac <zkabelac(a)redhat.com>
CommitterDate: Wed Apr 20 23:32:51 2016 +0200
configure: detect for /var/lock dir
Detecs systems with /run/lock dir and use such path directly instead
of /var/lock.
---
WHATS_NEW | 1 +
configure | 9 +++++++--
configure.in | 8 ++++++--
3 files changed, 14 insertions(+), 4 deletions(-)
diff --git a/WHATS_NEW b/WHATS_NEW
index 4a435bb..10f688d 100644
--- a/WHATS_NEW
+++ b/WHATS_NEW
@@ -1,5 +1,6 @@
Version 2.02.151 -
=================================
+ Autodetect and use /run/lock dir when available instead of /var/lock.
lvchange --refresh for merging thin origin will retry to deactivate snapshot.
Recognize in-progress snapshot merge for thin volumes from dm table.
Avoid deciding to initiate a pending snapshot merge during resume.
diff --git a/configure b/configure
index eb55243..c2de9a8 100755
--- a/configure
+++ b/configure
@@ -1820,7 +1820,7 @@ Optional Packages:
--with-default-cache-subdir=SUBDIR
default metadata cache subdir [cache]
--with-default-locking-dir=DIR
- default locking directory [/var/lock/lvm]
+ default locking directory [autodetect_lock_dir/lvm]
--with-default-data-alignment=NUM
set the default data alignment in MiB [1]
--with-interface=IFACE choose kernel interface (ioctl) [ioctl]
@@ -15113,7 +15113,12 @@ _ACEOF
if test "${with_default_locking_dir+set}" = set; then :
withval=$with_default_locking_dir; DEFAULT_LOCK_DIR=$withval
else
- DEFAULT_LOCK_DIR="/var/lock/lvm"
+ { $as_echo "$as_me:${as_lineno-$LINENO}: checking for default lock directory" >&5
+$as_echo_n "checking for default lock directory... " >&6; }
+ DEFAULT_LOCK_DIR="$RUN_DIR/lock/lvm"
+ test -d "$RUN_DIR/lock" || DEFAULT_LOCK_DIR="/var/lock/lvm"
+ { $as_echo "$as_me:${as_lineno-$LINENO}: result: $DEFAULT_LOCK_DIR" >&5
+$as_echo "$DEFAULT_LOCK_DIR" >&6; }
fi
diff --git a/configure.in b/configure.in
index 33cd0fe..4161df7 100644
--- a/configure.in
+++ b/configure.in
@@ -1933,8 +1933,12 @@ AC_DEFINE_UNQUOTED(DEFAULT_CACHE_SUBDIR, ["$DEFAULT_CACHE_SUBDIR"],
AC_ARG_WITH(default-locking-dir,
AC_HELP_STRING([--with-default-locking-dir=DIR],
- [default locking directory [/var/lock/lvm]]),
- DEFAULT_LOCK_DIR=$withval, DEFAULT_LOCK_DIR="/var/lock/lvm")
+ [default locking directory [autodetect_lock_dir/lvm]]),
+ DEFAULT_LOCK_DIR=$withval,
+ [AC_MSG_CHECKING(for default lock directory)
+ DEFAULT_LOCK_DIR="$RUN_DIR/lock/lvm"
+ test -d "$RUN_DIR/lock" || DEFAULT_LOCK_DIR="/var/lock/lvm"
+ AC_MSG_RESULT($DEFAULT_LOCK_DIR)])
AC_DEFINE_UNQUOTED(DEFAULT_LOCK_DIR, ["$DEFAULT_LOCK_DIR"],
[Name of default locking directory.])
6 years, 11 months
master - lvmetad: connect from forked polling process
by David Teigland
Gitweb: http://git.fedorahosted.org/git/?p=lvm2.git;a=commitdiff;h=5c104c5de9b019...
Commit: 5c104c5de9b019f5cf9b93ff2ee5468e1f0641d1
Parent: 955326067348d29aa7b42159f43b119ce7d8c491
Author: David Teigland <teigland(a)redhat.com>
AuthorDate: Tue Apr 19 17:07:22 2016 -0500
Committer: David Teigland <teigland(a)redhat.com>
CommitterDate: Wed Apr 20 09:04:39 2016 -0500
lvmetad: connect from forked polling process
With commit 5e9e43074a6c, lvmetad connections are
now made explicitly, so a new connection must be
created from a child created for polling.
---
tools/polldaemon.c | 5 +++++
1 files changed, 5 insertions(+), 0 deletions(-)
diff --git a/tools/polldaemon.c b/tools/polldaemon.c
index 71d6b3e..c2211d7 100644
--- a/tools/polldaemon.c
+++ b/tools/polldaemon.c
@@ -596,6 +596,11 @@ 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) {
+ if (!lvmetad_connect(cmd))
+ log_warn("WARNING: lvm polling process %d cannot connect to lvmetad.", getpid());
+ }
}
/*
6 years, 11 months
master - test: lvmetad-override
by David Teigland
Gitweb: http://git.fedorahosted.org/git/?p=lvm2.git;a=commitdiff;h=955326067348d2...
Commit: 955326067348d29aa7b42159f43b119ce7d8c491
Parent: 5e9e43074a6c5e251ee44768421879b03ad2e530
Author: David Teigland <teigland(a)redhat.com>
AuthorDate: Tue Apr 19 14:26:05 2016 -0500
Committer: David Teigland <teigland(a)redhat.com>
CommitterDate: Tue Apr 19 14:26:05 2016 -0500
test: lvmetad-override
Fix test case where a warning appears when it's not expected.
---
test/shell/lvmetad-override.sh | 4 +++-
1 files changed, 3 insertions(+), 1 deletions(-)
diff --git a/test/shell/lvmetad-override.sh b/test/shell/lvmetad-override.sh
index cd005fc..e22f7ba 100644
--- a/test/shell/lvmetad-override.sh
+++ b/test/shell/lvmetad-override.sh
@@ -35,7 +35,9 @@ lvchange -an $vg1
check inactive $vg1 $lv1
lvchange -ay --config global/use_lvmetad=0 $vg1 2>&1 | tee out
-not grep "WARNING: Failed to connect" out
+# FIXME: this warning appears when the command tries to connect to
+# lvmetad during refresh at the end after the --config is cleared.
+should not grep "WARNING: Failed to connect" out
check active $vg1 $lv1
lvchange -an $vg1
check inactive $vg1 $lv1
6 years, 11 months
master - lvmetad: rework command connection setup and checking
by David Teigland
Gitweb: http://git.fedorahosted.org/git/?p=lvm2.git;a=commitdiff;h=5e9e43074a6c5e...
Commit: 5e9e43074a6c5e251ee44768421879b03ad2e530
Parent: 593900b795e194608e9e2088aa8f75f4f42484c1
Author: David Teigland <teigland(a)redhat.com>
AuthorDate: Wed Apr 13 17:00:01 2016 -0500
Committer: David Teigland <teigland(a)redhat.com>
CommitterDate: Tue Apr 19 14:00:02 2016 -0500
lvmetad: rework command connection setup and checking
The lvmetad connection is created within the
init_connections() path during command startup,
rather than via the old lvmetad_active() check.
The old lvmetad_active() checks are replaced
with lvmetad_used() which is a simple check that
tests if the command is using/connected to lvmetad.
The old lvmetad_set_active(cmd, 0) calls, which
stopped the command from using lvmetad (to revert to
disk scanning), are replaced with lvmetad_make_unused(cmd).
---
lib/cache/lvmcache.c | 14 ++--
lib/cache/lvmetad.c | 122 ++++++++++++++++++-----------------------
lib/cache/lvmetad.h | 53 ++++-------------
lib/commands/toolcontext.c | 46 +++++++++++++--
lib/format_text/archiver.c | 2 +-
lib/format_text/format-text.c | 2 +-
lib/format_text/import_vsn1.c | 6 +-
lib/metadata/metadata.c | 6 +-
tools/lvchange.c | 23 +------
tools/lvmcmdline.c | 14 ++---
tools/lvscan.c | 4 +-
tools/pvdisplay.c | 2 +-
tools/pvscan.c | 4 +-
tools/reporter.c | 2 +-
tools/vgchange.c | 21 +------
tools/vgck.c | 2 +-
tools/vgimport.c | 4 +-
tools/vgscan.c | 4 +-
18 files changed, 144 insertions(+), 187 deletions(-)
diff --git a/lib/cache/lvmcache.c b/lib/cache/lvmcache.c
index 3432ef6..e2c86c4 100644
--- a/lib/cache/lvmcache.c
+++ b/lib/cache/lvmcache.c
@@ -164,7 +164,7 @@ void lvmcache_set_preferred_duplicates(const char *vgid)
void lvmcache_seed_infos_from_lvmetad(struct cmd_context *cmd)
{
- if (!lvmetad_active() || _has_scanned)
+ if (!lvmetad_used() || _has_scanned)
return;
if (!lvmetad_pv_list_to_lvmcache(cmd)) {
@@ -542,7 +542,7 @@ const struct format_type *lvmcache_fmt_from_vgname(struct cmd_context *cmd,
char vgid_found[ID_LEN + 1] __attribute__((aligned(8)));
if (!(vginfo = lvmcache_vginfo_from_vgname(vgname, vgid))) {
- if (!lvmetad_active())
+ if (!lvmetad_used())
return NULL; /* too bad */
/* If we don't have the info but we have lvmetad, we can ask
* there before failing. */
@@ -784,7 +784,7 @@ int lvmcache_label_scan(struct cmd_context *cmd)
int r = 0;
- if (lvmetad_active())
+ if (lvmetad_used())
return 1;
/* Avoid recursion when a PVID can't be found! */
@@ -862,7 +862,7 @@ struct volume_group *lvmcache_get_vg(struct cmd_context *cmd, const char *vgname
* using the classic scanning mechanics, and read from disk or from
* lvmcache.
*/
- if (lvmetad_active() && !precommitted) {
+ if (lvmetad_used() && !precommitted) {
/* Still serve the locally cached VG if available */
if (vgid && (vginfo = lvmcache_vginfo_from_vgid(vgid)) &&
vginfo->vgmetadata && (vg = vginfo->cached_vg))
@@ -1082,7 +1082,7 @@ static struct device *_device_from_pvid(const struct id *pvid,
struct label *label;
if ((info = lvmcache_info_from_pvid((const char *) pvid, 0))) {
- if (lvmetad_active()) {
+ if (lvmetad_used()) {
if (info->label && label_sector)
*label_sector = info->label->sector;
return info->dev;
@@ -2397,7 +2397,7 @@ int lvmcache_is_orphan(struct lvmcache_info *info) {
int lvmcache_vgid_is_cached(const char *vgid) {
struct lvmcache_vginfo *vginfo;
- if (lvmetad_active())
+ if (lvmetad_used())
return 1;
vginfo = lvmcache_vginfo_from_vgid(vgid);
@@ -2497,7 +2497,7 @@ int lvmcache_vg_is_foreign(struct cmd_context *cmd, const char *vgname, const ch
struct lvmcache_vginfo *vginfo;
int ret = 0;
- if (lvmetad_active())
+ if (lvmetad_used())
return lvmetad_vg_is_foreign(cmd, vgname, vgid);
if ((vginfo = lvmcache_vginfo_from_vgid(vgid)))
diff --git a/lib/cache/lvmetad.c b/lib/cache/lvmetad.c
index 858be4d..bbf3550 100644
--- a/lib/cache/lvmetad.c
+++ b/lib/cache/lvmetad.c
@@ -120,50 +120,36 @@ void lvmetad_disconnect(void)
daemon_close(_lvmetad);
_lvmetad_connected = 0;
+ _lvmetad_use = 0;
+ _lvmetad_cmd = NULL;
}
-void lvmetad_init(struct cmd_context *cmd)
+int lvmetad_connect(struct cmd_context *cmd)
{
- if (!_lvmetad_use && !access(getenv("LVM_LVMETAD_PIDFILE") ? : LVMETAD_PIDFILE, F_OK))
- log_warn("WARNING: lvmetad is running but disabled."
- " Restart lvmetad before enabling it!");
-
- if (_lvmetad_connected)
- log_debug(INTERNAL_ERROR "Refreshing lvmetad global handle while connection with the daemon is active");
-
- _lvmetad_cmd = cmd;
-}
-
-static void _lvmetad_connect(void)
-{
- if (!_lvmetad_use || !_lvmetad_socket || _lvmetad_connected)
- return;
+ if (access(getenv("LVM_LVMETAD_PIDFILE") ? : LVMETAD_PIDFILE, F_OK)) {
+ log_debug_lvmetad("Failed to connect to lvmetad: not running.");
+ _lvmetad_connected = 0;
+ _lvmetad_use = 0;
+ _lvmetad_cmd = NULL;
+ return 0;
+ }
_lvmetad = lvmetad_open(_lvmetad_socket);
+
if (_lvmetad.socket_fd >= 0 && !_lvmetad.error) {
log_debug_lvmetad("Successfully connected to lvmetad on fd %d.",
_lvmetad.socket_fd);
_lvmetad_connected = 1;
- }
-
- if (!_lvmetad_connected)
+ _lvmetad_use = 1;
+ _lvmetad_cmd = cmd;
+ return 1;
+ } else {
+ log_debug_lvmetad("Failed to connect to lvmetad: %s", strerror(_lvmetad.error));
+ _lvmetad_connected = 0;
_lvmetad_use = 0;
-}
-
-void lvmetad_connect_or_warn(void)
-{
- if (!_lvmetad_use)
- return;
-
- if (!_lvmetad_connected && !_lvmetad.error) {
- _lvmetad_connect();
-
- if ((_lvmetad.socket_fd < 0 || _lvmetad.error))
- log_warn("WARNING: Failed to connect to lvmetad. Falling back to internal scanning.");
+ _lvmetad_cmd = NULL;
+ return 0;
}
-
- if (!_lvmetad_connected)
- _lvmetad_use = 0;
}
int lvmetad_used(void)
@@ -171,6 +157,14 @@ int lvmetad_used(void)
return _lvmetad_use;
}
+void lvmetad_make_unused(struct cmd_context *cmd)
+{
+ lvmetad_disconnect();
+
+ if (cmd && !refresh_filters(cmd))
+ stack;
+}
+
int lvmetad_socket_present(void)
{
const char *socket = _lvmetad_socket ?: LVMETAD_SOCKET;
@@ -182,22 +176,9 @@ int lvmetad_socket_present(void)
return !r;
}
-int lvmetad_active(void)
-{
- lvmetad_connect_or_warn();
-
- return _lvmetad_connected;
-}
-
-void lvmetad_set_active(struct cmd_context *cmd, int active)
+void lvmetad_set_socket(const char *sock)
{
- _lvmetad_use = active;
-
- if (!active && lvmetad_active())
- lvmetad_disconnect();
-
- if (cmd && !refresh_filters(cmd))
- stack;
+ _lvmetad_socket = sock;
}
/*
@@ -224,11 +205,6 @@ void lvmetad_release_token(void)
_lvmetad_token = NULL;
}
-void lvmetad_set_socket(const char *sock)
-{
- _lvmetad_socket = sock;
-}
-
/*
* Check if lvmetad's token matches our token. The token is a hash of the
* global filter used to populate lvmetad. The lvmetad token was set by the
@@ -351,7 +327,7 @@ out:
fail:
daemon_reply_destroy(reply);
/* The command will not use lvmetad and will revert to scanning. */
- lvmetad_set_active(cmd, 0);
+ lvmetad_make_unused(cmd);
return 0;
}
@@ -428,6 +404,11 @@ static daemon_reply _lvmetad_send(struct cmd_context *cmd, const char *id, ...)
unsigned int wait_sec = 0;
uint64_t now = 0, wait_start = 0;
+ if (!_lvmetad_connected || !_lvmetad_use) {
+ reply.error = ECONNRESET;
+ return reply;
+ }
+
if (cmd)
wait_sec = (unsigned int)find_config_tree_int(cmd, global_lvmetad_update_wait_time_CFG, NULL);
retry:
@@ -448,6 +429,9 @@ retry:
daemon_request_destroy(req);
+ if (reply.error == ECONNRESET)
+ log_warn("WARNING: lvmetad connection failed, cannot reconnect.");
+
if (reply.error)
goto out;
@@ -846,7 +830,7 @@ struct volume_group *lvmetad_vg_lookup(struct cmd_context *cmd, const char *vgna
struct pv_list *pvl;
int rescan = 0;
- if (!lvmetad_active())
+ if (!lvmetad_used())
return NULL;
if (vgid) {
@@ -1026,7 +1010,7 @@ int lvmetad_vg_update(struct volume_group *vg)
if (!vg)
return 0;
- if (!lvmetad_active() || test_mode())
+ if (!lvmetad_used() || test_mode())
return 1; /* fake it */
if (!vg->cft_precommitted) {
@@ -1080,7 +1064,7 @@ int lvmetad_vg_remove(struct volume_group *vg)
daemon_reply reply;
int result;
- if (!lvmetad_active() || test_mode())
+ if (!lvmetad_used() || test_mode())
return 1; /* just fake it */
if (!id_write_format(&vg->id, uuid, sizeof(uuid)))
@@ -1102,7 +1086,7 @@ int lvmetad_pv_lookup(struct cmd_context *cmd, struct id pvid, int *found)
int result = 0;
struct dm_config_node *cn;
- if (!lvmetad_active())
+ if (!lvmetad_used())
return_0;
if (!id_write_format(&pvid, uuid, sizeof(uuid)))
@@ -1136,7 +1120,7 @@ int lvmetad_pv_lookup_by_dev(struct cmd_context *cmd, struct device *dev, int *f
daemon_reply reply;
struct dm_config_node *cn;
- if (!lvmetad_active())
+ if (!lvmetad_used())
return_0;
log_debug_lvmetad("Asking lvmetad for PV on %s", dev_name(dev));
@@ -1165,7 +1149,7 @@ int lvmetad_pv_list_to_lvmcache(struct cmd_context *cmd)
daemon_reply reply;
struct dm_config_node *cn;
- if (!lvmetad_active())
+ if (!lvmetad_used())
return 1;
log_debug_lvmetad("Asking lvmetad for complete list of known PVs");
@@ -1243,7 +1227,7 @@ int lvmetad_vg_list_to_lvmcache(struct cmd_context *cmd)
daemon_reply reply;
struct dm_config_node *cn;
- if (!lvmetad_active())
+ if (!lvmetad_used())
return 1;
log_debug_lvmetad("Asking lvmetad for complete list of known VGs");
@@ -1362,7 +1346,7 @@ int lvmetad_pv_found(const struct id *pvid, struct device *dev, const struct for
int64_t changed;
int result;
- if (!lvmetad_active() || test_mode())
+ if (!lvmetad_used() || test_mode())
return 1;
if (!id_write_format(pvid, uuid, sizeof(uuid)))
@@ -1502,7 +1486,7 @@ int lvmetad_pv_gone(dev_t devno, const char *pv_name, activation_handler handler
int result;
int found;
- if (!lvmetad_active() || test_mode())
+ if (!lvmetad_used() || test_mode())
return 1;
/*
@@ -1692,7 +1676,7 @@ int lvmetad_pvscan_single(struct cmd_context *cmd, struct device *dev,
struct format_instance_ctx fic = { .type = 0 };
struct metadata_area *mda;
- if (!lvmetad_active()) {
+ if (!lvmetad_used()) {
log_error("Cannot proceed since lvmetad is not active.");
return 0;
}
@@ -1805,7 +1789,7 @@ static int _lvmetad_pvscan_all_devs(struct cmd_context *cmd, activation_handler
int replaced_update = 0;
int retries = 0;
- if (!lvmetad_active()) {
+ if (!lvmetad_used()) {
log_error("Cannot proceed since lvmetad is not active.");
return 0;
}
@@ -1952,7 +1936,7 @@ static int _lvmetad_get_pv_cache_list(struct cmd_context *cmd, struct dm_list *p
const char *pvid_txt;
const char *vgid;
- if (!lvmetad_active())
+ if (!lvmetad_used())
return 1;
log_debug_lvmetad("Asking lvmetad for complete list of known PVs");
@@ -2146,7 +2130,7 @@ void lvmetad_validate_global_cache(struct cmd_context *cmd, int force)
return;
}
- if (!lvmetad_active())
+ if (!lvmetad_used())
return;
log_debug_lvmetad("Validating global lvmetad cache");
@@ -2195,13 +2179,13 @@ void lvmetad_validate_global_cache(struct cmd_context *cmd, int force)
*/
if (!lvmetad_pvscan_all_devs(cmd, NULL, 1)) {
log_warn("WARNING: Not using lvmetad because cache update failed.");
- lvmetad_set_active(cmd, 0);
+ lvmetad_make_unused(cmd);
return;
}
if (lvmetad_is_disabled(cmd, &reason)) {
log_warn("WARNING: Not using lvmetad because %s.", reason);
- lvmetad_set_active(cmd, 0);
+ lvmetad_make_unused(cmd);
return;
}
diff --git a/lib/cache/lvmetad.h b/lib/cache/lvmetad.h
index 9ae3f26..82371d9 100644
--- a/lib/cache/lvmetad.h
+++ b/lib/cache/lvmetad.h
@@ -28,15 +28,18 @@ typedef int (*activation_handler) (struct cmd_context *cmd,
enum activation_change activate);
#ifdef LVMETAD_SUPPORT
-/*
- * Sets up a global handle for our process.
- */
-void lvmetad_init(struct cmd_context *);
/*
- * Override the use of lvmetad for retrieving scan results and metadata.
+ * 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)
*/
-void lvmetad_set_active(struct cmd_context *, int);
+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.
@@ -44,40 +47,12 @@ void lvmetad_set_active(struct cmd_context *, int);
void lvmetad_set_socket(const char *);
/*
- * Check whether lvmetad is used.
- */
-int lvmetad_used(void);
-
-/*
* Check if lvmetad socket is present (either the one set by lvmetad_set_socket
- * or the default one if not set). For example, this may be used before calling
- * lvmetad_active() check that does connect to the socket - this would produce
- * various connection errors if the socket is not present.
+ * or the default one if not set).
*/
int lvmetad_socket_present(void);
/*
- * Check whether lvmetad is active (where active means both that it is running
- * and that we have a working connection with it). It opens new connection
- * with lvmetad in the process when lvmetad is supposed to be used and the
- * connection is not open yet.
- */
-int lvmetad_active(void);
-
-/*
- * Connect to lvmetad unless the connection is already open or lvmetad is
- * not configured to be used. If we fail to connect, print a warning.
- */
-void lvmetad_connect_or_warn(void);
-
-/*
- * Drop connection to lvmetad. A subsequent lvmetad_connect_or_warn or
- * lvmetad_active will re-establish the connection (possibly at a
- * different socket path).
- */
-void lvmetad_disconnect(void);
-
-/*
* Set the "lvmetad validity token" (currently only consists of the lvmetad
* filter. See lvm.conf.
*/
@@ -178,14 +153,12 @@ void lvmetad_clear_disabled(struct cmd_context *cmd);
# else /* LVMETAD_SUPPORT */
-# define lvmetad_init(cmd) do { } while (0)
# define lvmetad_disconnect() do { } while (0)
-# define lvmetad_set_active(cmd, a) do { } while (0)
+# define lvmetad_connect(cmd) do { } while (0)
+# define lvmetad_make_unused() do { } while (0)
+# define lvmetad_used() (0)
# define lvmetad_set_socket(a) do { } while (0)
-# define lvmetad_used() (0)
# define lvmetad_socket_present() (0)
-# define lvmetad_active() (0)
-# define lvmetad_connect_or_warn() do { } while (0)
# define lvmetad_set_token(a) do { } while (0)
# define lvmetad_release_token() do { } while (0)
# define lvmetad_vg_update(vg) (1)
diff --git a/lib/commands/toolcontext.c b/lib/commands/toolcontext.c
index 08e857c..1f8ac4c 100644
--- a/lib/commands/toolcontext.c
+++ b/lib/commands/toolcontext.c
@@ -1673,6 +1673,26 @@ static int _reopen_stream(FILE *stream, int fd, const char *mode, const char *na
return 1;
}
+/*
+ * 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;
@@ -1695,13 +1715,27 @@ static int _init_lvmetad(struct cmd_context *cmd)
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: configuration setting use_lvmetad overridden to 0 due to locking_type 3. "
- "Clustered environment not supported by lvmetad yet.");
- lvmetad_set_active(NULL, 0);
- } else
- lvmetad_set_active(NULL, 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_socket_present())
+ log_warn("WARNING: Not using lvmetad because config setting use_lvmetad=0.");
+ 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;
+ }
- lvmetad_init(cmd);
return 1;
}
diff --git a/lib/format_text/archiver.c b/lib/format_text/archiver.c
index b92f4a5..8220c38 100644
--- a/lib/format_text/archiver.c
+++ b/lib/format_text/archiver.c
@@ -502,7 +502,7 @@ int backup_restore_vg(struct cmd_context *cmd, struct volume_group *vg,
if (!vg_write(vg))
return_0;
- if (drop_lvmetad && lvmetad_active()) {
+ if (drop_lvmetad && lvmetad_used()) {
struct volume_group *vg_lvmetad = lvmetad_vg_lookup(cmd, vg->name, NULL);
if (vg_lvmetad) {
/* FIXME Cope with failure to update lvmetad */
diff --git a/lib/format_text/format-text.c b/lib/format_text/format-text.c
index bd20670..43ebd27 100644
--- a/lib/format_text/format-text.c
+++ b/lib/format_text/format-text.c
@@ -1525,7 +1525,7 @@ static int _text_pv_read(const struct format_type *fmt, const char *pv_name,
if (!(dev = dev_cache_get(pv_name, fmt->cmd->filter)))
return_0;
- if (lvmetad_active()) {
+ if (lvmetad_used()) {
info = lvmcache_info_from_pvid(dev->pvid, 0);
if (!info && !lvmetad_pv_lookup_by_dev(fmt->cmd, dev, NULL))
return 0;
diff --git a/lib/format_text/import_vsn1.c b/lib/format_text/import_vsn1.c
index 22f519e..f9a1040 100644
--- a/lib/format_text/import_vsn1.c
+++ b/lib/format_text/import_vsn1.c
@@ -63,7 +63,7 @@ static int _vsn1_check_version(const struct dm_config_tree *cft)
const struct dm_config_value *cv;
// TODO if this is pvscan --cache, we want this check back.
- if (lvmetad_active())
+ if (lvmetad_used())
return 1;
/*
@@ -241,8 +241,8 @@ static int _read_pv(struct format_instance *fid,
return 0;
}
- /* TODO is the !lvmetad_active() too coarse here? */
- if (!pv->dev && !lvmetad_active())
+ /* TODO is the !lvmetad_used() too coarse here? */
+ if (!pv->dev && !lvmetad_used())
pv->status |= MISSING_PV;
if ((pv->status & MISSING_PV) && pv->dev && pv_mda_used_count(pv) == 0) {
diff --git a/lib/metadata/metadata.c b/lib/metadata/metadata.c
index 782235e..e9f5fa5 100644
--- a/lib/metadata/metadata.c
+++ b/lib/metadata/metadata.c
@@ -4122,7 +4122,7 @@ static struct volume_group *_vg_read(struct cmd_context *cmd,
return _vg_read_orphans(cmd, warn_flags, vgname, consistent);
}
- if (lvmetad_active() && !use_precommitted) {
+ if (lvmetad_used() && !use_precommitted) {
if ((correct_vg = lvmcache_get_vg(cmd, vgname, vgid, precommitted))) {
dm_list_iterate_items(pvl, &correct_vg->pvs)
if (pvl->pv->dev)
@@ -4949,7 +4949,7 @@ static struct physical_volume *_pv_read(struct cmd_context *cmd,
if (!(dev = dev_cache_get(pv_name, cmd->filter)))
return_NULL;
- if (lvmetad_active()) {
+ if (lvmetad_used()) {
info = lvmcache_info_from_pvid(dev->pvid, 0);
if (!info) {
if (!lvmetad_pv_lookup_by_dev(cmd, dev, &found))
@@ -5044,7 +5044,7 @@ int get_vgnameids(struct cmd_context *cmd, struct dm_list *vgnameids,
return 1;
}
- if (lvmetad_active()) {
+ if (lvmetad_used()) {
/*
* This just gets the list of names/ids from lvmetad
* and does not populate lvmcache.
diff --git a/tools/lvchange.c b/tools/lvchange.c
index 316a786..3a050e9 100644
--- a/tools/lvchange.c
+++ b/tools/lvchange.c
@@ -1258,25 +1258,10 @@ int lvchange(struct cmd_context *cmd, int argc, char **argv)
* 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_count(cmd, sysinit_ARG) && lvmetad_used() &&
- arg_uint_value(cmd, activate_ARG, 0) == CHANGE_AAY) {
- if (!lvmetad_socket_present()) {
- /*
- * If lvmetad socket is not present yet,
- * the service is just not started. It'll
- * be started a bit later so we need to do
- * the activation without lvmetad which means
- * direct activation instead of autoactivation.
- */
- log_warn("lvmetad is not active yet, using direct activation during sysinit");
- lvmetad_set_active(cmd, 0);
- } else if (lvmetad_active()) {
- /*
- * If lvmetad is active already, we want
- * to make use of the autoactivation.
- */
- log_warn("lvmetad is active, skipping direct activation during sysinit");
+ */
+ if (arg_count(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;
}
}
diff --git a/tools/lvmcmdline.c b/tools/lvmcmdline.c
index dd89a7b..e6c82cf 100644
--- a/tools/lvmcmdline.c
+++ b/tools/lvmcmdline.c
@@ -1112,9 +1112,6 @@ static int _get_settings(struct cmd_context *cmd)
*/
cmd->vg_read_print_access_error = 1;
- if (!arg_count(cmd, sysinit_ARG))
- lvmetad_connect_or_warn();
-
if (arg_count(cmd, nosuffix_ARG))
cmd->current_settings.suffix = 0;
@@ -1474,8 +1471,7 @@ static int _cmd_no_meta_proc(struct cmd_context *cmd)
int lvm_run_command(struct cmd_context *cmd, int argc, char **argv)
{
- struct dm_config_tree *config_string_cft;
- struct dm_config_tree *config_profile_command_cft, *config_profile_metadata_cft;
+ 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;
@@ -1606,7 +1602,7 @@ int lvm_run_command(struct cmd_context *cmd, int argc, char **argv)
log_warn("WARNING: Disabling lvmetad cache which does not support obsolete metadata.");
lvmetad_set_disabled(cmd, "LVM1");
log_warn("WARNING: Not using lvmetad because lvm1 format is used.");
- lvmetad_set_active(cmd, 0);
+ lvmetad_make_unused(cmd);
}
if (cmd->metadata_read_only &&
@@ -1633,7 +1629,7 @@ int lvm_run_command(struct cmd_context *cmd, int argc, char **argv)
}
if (lvmetad_used()) {
- lvmetad_set_active(cmd, 0);
+ lvmetad_make_unused(cmd);
log_verbose("Not using lvmetad because read-only is set.");
}
} else if (arg_count(cmd, nolocking_ARG))
@@ -1674,13 +1670,13 @@ int lvm_run_command(struct cmd_context *cmd, int argc, char **argv)
if (cmd->include_foreign_vgs || !lvmetad_token_matches(cmd)) {
if (lvmetad_used() && !lvmetad_pvscan_all_devs(cmd, NULL, cmd->include_foreign_vgs ? 1 : 0)) {
log_warn("WARNING: Not using lvmetad because cache update failed.");
- lvmetad_set_active(cmd, 0);
+ lvmetad_make_unused(cmd);
}
}
if (lvmetad_used() && lvmetad_is_disabled(cmd, &reason)) {
log_warn("WARNING: Not using lvmetad because %s.", reason);
- lvmetad_set_active(cmd, 0);
+ lvmetad_make_unused(cmd);
}
}
diff --git a/tools/lvscan.c b/tools/lvscan.c
index 4f13587..4ae3ce6 100644
--- a/tools/lvscan.c
+++ b/tools/lvscan.c
@@ -105,12 +105,12 @@ int lvscan(struct cmd_context *cmd, int argc, char **argv)
if (lvmetad_used() && (!lvmetad_token_matches(cmd) || lvmetad_is_disabled(cmd, &reason))) {
if (lvmetad_used() && !lvmetad_pvscan_all_devs(cmd, NULL, 0)) {
log_warn("WARNING: Not using lvmetad because cache update failed.");
- lvmetad_set_active(cmd, 0);
+ lvmetad_make_unused(cmd);
}
if (lvmetad_used() && lvmetad_is_disabled(cmd, &reason)) {
log_warn("WARNING: Not using lvmetad because %s.", reason);
- lvmetad_set_active(cmd, 0);
+ lvmetad_make_unused(cmd);
}
/*
diff --git a/tools/pvdisplay.c b/tools/pvdisplay.c
index 4d8275c..46439c8 100644
--- a/tools/pvdisplay.c
+++ b/tools/pvdisplay.c
@@ -99,7 +99,7 @@ int pvdisplay(struct cmd_context *cmd, int argc, char **argv)
* we lock VG_GLOBAL to enable use of metadata cache.
* This can pause alongide pvscan or vgscan process for a while.
*/
- if (!lvmetad_active()) {
+ if (!lvmetad_used()) {
lock_global = 1;
if (!lock_vol(cmd, VG_GLOBAL, LCK_VG_READ, NULL)) {
log_error("Unable to obtain global lock.");
diff --git a/tools/pvscan.c b/tools/pvscan.c
index 44e7737..425383a 100644
--- a/tools/pvscan.c
+++ b/tools/pvscan.c
@@ -465,12 +465,12 @@ int pvscan(struct cmd_context *cmd, int argc, char **argv)
if (lvmetad_used() && (!lvmetad_token_matches(cmd) || lvmetad_is_disabled(cmd, &reason))) {
if (lvmetad_used() && !lvmetad_pvscan_all_devs(cmd, NULL, 0)) {
log_warn("WARNING: Not using lvmetad because cache update failed.");
- lvmetad_set_active(cmd, 0);
+ lvmetad_make_unused(cmd);
}
if (lvmetad_used() && lvmetad_is_disabled(cmd, &reason)) {
log_warn("WARNING: Not using lvmetad because %s.", reason);
- lvmetad_set_active(cmd, 0);
+ lvmetad_make_unused(cmd);
}
}
diff --git a/tools/reporter.c b/tools/reporter.c
index ab11be2..fb09263 100644
--- a/tools/reporter.c
+++ b/tools/reporter.c
@@ -897,7 +897,7 @@ static int _report(struct cmd_context *cmd, int argc, char **argv,
* This can pause alongide pvscan or vgscan process for a while.
*/
if (args_are_pvs && (report_type == PVS || report_type == PVSEGS) &&
- !lvmetad_active()) {
+ !lvmetad_used()) {
lock_global = 1;
if (!lock_vol(cmd, VG_GLOBAL, LCK_VG_READ, NULL)) {
log_error("Unable to obtain global lock.");
diff --git a/tools/vgchange.c b/tools/vgchange.c
index 83f75fa..372f881 100644
--- a/tools/vgchange.c
+++ b/tools/vgchange.c
@@ -1184,24 +1184,9 @@ int vgchange(struct cmd_context *cmd, int argc, char **argv)
* not neet to be running at this moment yet - it could be
* just too early during system initialization time.
*/
- if (arg_count(cmd, sysinit_ARG) && lvmetad_used() &&
- arg_uint_value(cmd, activate_ARG, 0) == CHANGE_AAY) {
- if (!lvmetad_socket_present()) {
- /*
- * If lvmetad socket is not present yet,
- * the service is just not started. It'll
- * be started a bit later so we need to do
- * the activation without lvmetad which means
- * direct activation instead of autoactivation.
- */
- log_warn("lvmetad is not active yet, using direct activation during sysinit");
- lvmetad_set_active(cmd, 0);
- } else if (lvmetad_active()) {
- /*
- * If lvmetad is active already, we want
- * to make use of the autoactivation.
- */
- log_warn("lvmetad is active, skipping direct activation during sysinit");
+ if (arg_count(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;
}
}
diff --git a/tools/vgck.c b/tools/vgck.c
index fc2f886..15f7bc3 100644
--- a/tools/vgck.c
+++ b/tools/vgck.c
@@ -37,7 +37,7 @@ static int vgck_single(struct cmd_context *cmd __attribute__((unused)),
int vgck(struct cmd_context *cmd, int argc, char **argv)
{
- lvmetad_set_active(cmd, 0);
+ lvmetad_make_unused(cmd);
return process_each_vg(cmd, argc, argv, NULL, 0, NULL,
&vgck_single);
}
diff --git a/tools/vgimport.c b/tools/vgimport.c
index f5980a1..5bcf7e0 100644
--- a/tools/vgimport.c
+++ b/tools/vgimport.c
@@ -98,12 +98,12 @@ int vgimport(struct cmd_context *cmd, int argc, char **argv)
if (lvmetad_used()) {
if (!lvmetad_pvscan_all_devs(cmd, NULL, 1)) {
log_warn("WARNING: Not using lvmetad because cache update failed.");
- lvmetad_set_active(cmd, 0);
+ lvmetad_make_unused(cmd);
}
if (lvmetad_used() && lvmetad_is_disabled(cmd, &reason)) {
log_warn("WARNING: Not using lvmetad because %s.", reason);
- lvmetad_set_active(cmd, 0);
+ lvmetad_make_unused(cmd);
}
}
diff --git a/tools/vgscan.c b/tools/vgscan.c
index 78048c0..59a0f6a 100644
--- a/tools/vgscan.c
+++ b/tools/vgscan.c
@@ -103,12 +103,12 @@ int vgscan(struct cmd_context *cmd, int argc, char **argv)
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, NULL, arg_is_set(cmd, cache_long_ARG))) {
log_warn("WARNING: Not using lvmetad because cache update failed.");
- lvmetad_set_active(cmd, 0);
+ lvmetad_make_unused(cmd);
}
if (lvmetad_used() && lvmetad_is_disabled(cmd, &reason)) {
log_warn("WARNING: Not using lvmetad because %s.", reason);
- lvmetad_set_active(cmd, 0);
+ lvmetad_make_unused(cmd);
}
}
6 years, 11 months
master - lvmetad: use defines for disabled reason strings
by David Teigland
Gitweb: http://git.fedorahosted.org/git/?p=lvm2.git;a=commitdiff;h=593900b795e194...
Commit: 593900b795e194608e9e2088aa8f75f4f42484c1
Parent: fa904a844f7129c39e15ce5e3dc310854646fb87
Author: David Teigland <teigland(a)redhat.com>
AuthorDate: Tue Apr 19 10:51:11 2016 -0500
Committer: David Teigland <teigland(a)redhat.com>
CommitterDate: Tue Apr 19 11:45:24 2016 -0500
lvmetad: use defines for disabled reason strings
---
daemons/lvmetad/lvmetactl.c | 2 +-
daemons/lvmetad/lvmetad-client.h | 4 ++++
daemons/lvmetad/lvmetad-core.c | 13 +++++++------
lib/cache/lvmetad.c | 10 +++++-----
4 files changed, 17 insertions(+), 12 deletions(-)
diff --git a/daemons/lvmetad/lvmetactl.c b/daemons/lvmetad/lvmetactl.c
index 90db173..30ca1d6 100644
--- a/daemons/lvmetad/lvmetactl.c
+++ b/daemons/lvmetad/lvmetactl.c
@@ -98,7 +98,7 @@ int main(int argc, char **argv)
reply = daemon_send_simple(h, "set_global_info",
"global_disable = " FMTd64, (int64_t) val,
- "disable_reason = %s", "DIRECT",
+ "disable_reason = %s", LVMETAD_DISABLE_REASON_DIRECT,
"token = %s", "skip",
NULL);
print_reply(reply);
diff --git a/daemons/lvmetad/lvmetad-client.h b/daemons/lvmetad/lvmetad-client.h
index 012f3a8..dce8a7e 100644
--- a/daemons/lvmetad/lvmetad-client.h
+++ b/daemons/lvmetad/lvmetad-client.h
@@ -19,6 +19,10 @@
#define LVMETAD_SOCKET DEFAULT_RUN_DIR "/lvmetad.socket"
+#define LVMETAD_DISABLE_REASON_DIRECT "DIRECT"
+#define LVMETAD_DISABLE_REASON_LVM1 "LVM1"
+#define LVMETAD_DISABLE_REASON_DUPLICATES "DUPLICATES"
+
struct volume_group;
/* Different types of replies we may get from lvmetad. */
diff --git a/daemons/lvmetad/lvmetad-core.c b/daemons/lvmetad/lvmetad-core.c
index 1c2ac81..45641a6 100644
--- a/daemons/lvmetad/lvmetad-core.c
+++ b/daemons/lvmetad/lvmetad-core.c
@@ -22,6 +22,7 @@
#include "daemon-server.h"
#include "daemon-log.h"
#include "lvm-version.h"
+#include "lvmetad-client.h"
#include <assert.h>
#include <errno.h>
@@ -2626,11 +2627,11 @@ static response set_global_info(lvmetad_state *s, request r)
uint32_t reason_flags = 0;
if ((reason = daemon_request_str(r, "disable_reason", NULL))) {
- if (strstr(reason, "DIRECT"))
+ if (strstr(reason, LVMETAD_DISABLE_REASON_DIRECT))
reason_flags |= GLFL_DISABLE_REASON_DIRECT;
- if (strstr(reason, "LVM1"))
+ if (strstr(reason, LVMETAD_DISABLE_REASON_LVM1))
reason_flags |= GLFL_DISABLE_REASON_LVM1;
- if (strstr(reason, "DUPLICATES"))
+ if (strstr(reason, LVMETAD_DISABLE_REASON_DUPLICATES))
reason_flags |= GLFL_DISABLE_REASON_DUPLICATES;
}
@@ -2686,9 +2687,9 @@ static response get_global_info(lvmetad_state *s, request r)
if (s->flags & GLFL_DISABLE) {
snprintf(reason, REASON_BUF_SIZE - 1, "%s%s%s",
- (s->flags & GLFL_DISABLE_REASON_DIRECT) ? "DIRECT," : "",
- (s->flags & GLFL_DISABLE_REASON_LVM1) ? "LVM1," : "",
- (s->flags & GLFL_DISABLE_REASON_DUPLICATES) ? "DUPLICATES," : "");
+ (s->flags & GLFL_DISABLE_REASON_DIRECT) ? LVMETAD_DISABLE_REASON_DIRECT "," : "",
+ (s->flags & GLFL_DISABLE_REASON_LVM1) ? LVMETAD_DISABLE_REASON_LVM1 "," : "",
+ (s->flags & GLFL_DISABLE_REASON_DUPLICATES) ? LVMETAD_DISABLE_REASON_DUPLICATES "," : "");
}
if (!reason[0])
diff --git a/lib/cache/lvmetad.c b/lib/cache/lvmetad.c
index bcf6f93..858be4d 100644
--- a/lib/cache/lvmetad.c
+++ b/lib/cache/lvmetad.c
@@ -1598,7 +1598,7 @@ static struct volume_group *lvmetad_pvscan_vg(struct cmd_context *cmd, struct vo
baton.fid->fmt->name, dev_name(pvl->pv->dev));
lvmcache_fmt(info)->ops->destroy_instance(baton.fid);
log_warn("WARNING: Disabling lvmetad cache which does not support obsolete metadata.");
- lvmetad_set_disabled(cmd, "LVM1");
+ lvmetad_set_disabled(cmd, LVMETAD_DISABLE_REASON_LVM1);
_found_lvm1_metadata = 1;
return NULL;
}
@@ -1722,7 +1722,7 @@ int lvmetad_pvscan_single(struct cmd_context *cmd, struct device *dev,
lvmcache_fmt(info)->ops->destroy_instance(baton.fid);
log_warn("WARNING: Disabling lvmetad cache which does not support obsolete metadata.");
- lvmetad_set_disabled(cmd, "LVM1");
+ lvmetad_set_disabled(cmd, LVMETAD_DISABLE_REASON_LVM1);
_found_lvm1_metadata = 1;
if (ignore_obsolete)
@@ -2352,13 +2352,13 @@ int lvmetad_is_disabled(struct cmd_context *cmd, const char **reason)
if (!reply_reason) {
*reason = "<not set>";
- } else if (strstr(reply_reason, "DIRECT")) {
+ } else if (strstr(reply_reason, LVMETAD_DISABLE_REASON_DIRECT)) {
*reason = "the disable flag was set directly";
- } else if (strstr(reply_reason, "LVM1")) {
+ } else if (strstr(reply_reason, LVMETAD_DISABLE_REASON_LVM1)) {
*reason = "LVM1 metadata was found";
- } else if (strstr(reply_reason, "DUPLICATES")) {
+ } else if (strstr(reply_reason, LVMETAD_DISABLE_REASON_DUPLICATES)) {
*reason = "duplicate PVs were found";
} else {
6 years, 11 months
master - test: lvmetad-warning
by David Teigland
Gitweb: http://git.fedorahosted.org/git/?p=lvm2.git;a=commitdiff;h=fa904a844f7129...
Commit: fa904a844f7129c39e15ce5e3dc310854646fb87
Parent: 6b1c0a4190082728de1be2f2d19c1ef46c7f2d5c
Author: David Teigland <teigland(a)redhat.com>
AuthorDate: Mon Apr 18 16:49:22 2016 -0500
Committer: David Teigland <teigland(a)redhat.com>
CommitterDate: Tue Apr 19 11:45:24 2016 -0500
test: lvmetad-warning
The test was a weak attempt at verifying the special
combination of lvchange/vgchange -aay --sysinit, but
was only looking for lvmetad connection warnings.
Update the warning checks, and check the LV activation
state directly which is the main point.
Rename the test to reflect its purpose of checking
the -aay --sysinit combination.
---
test/shell/lvmetad-sysinit.sh | 91 +++++++++++++++++++++++++++++++++++++++++
test/shell/lvmetad-warning.sh | 36 ----------------
2 files changed, 91 insertions(+), 36 deletions(-)
diff --git a/test/shell/lvmetad-sysinit.sh b/test/shell/lvmetad-sysinit.sh
new file mode 100644
index 0000000..442f728
--- /dev/null
+++ b/test/shell/lvmetad-sysinit.sh
@@ -0,0 +1,91 @@
+#!/bin/sh
+# Copyright (C) 2012 Red Hat, Inc. All rights reserved.
+#
+# 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
+
+SKIP_WITH_LVMLOCKD=1
+SKIP_WITHOUT_LVMETAD=1
+SKIP_WITH_LVMPOLLD=1
+
+. lib/inittest
+
+aux prepare_pvs 2
+
+#
+# lvchange/vgchange -aay --sysinit should not activate LVs
+# if lvmetad is configured and running.
+#
+
+vgcreate $vg1 "$dev1" "$dev2"
+lvcreate -an -l1 --zero n -n $lv1 $vg1
+
+#
+# lvmetad is configured and running
+#
+
+lvchange -ay $vg1 2>&1 | tee out
+not grep "WARNING: Failed to connect" out
+not grep "WARNING: lvmetad is active, skipping direct activation during sysinit" out
+check active $vg1 $lv1
+lvchange -an $vg1
+check inactive $vg1 $lv1
+
+lvchange -aay --sysinit $vg1 2>&1 | tee out
+not grep "WARNING: Failed to connect" out
+grep "WARNING: lvmetad is active, skipping direct activation during sysinit" out
+check inactive $vg1 $lv1
+
+lvchange -ay --sysinit $vg1 2>&1 | tee out
+not grep "WARNING: Failed to connect" out
+not grep "WARNING: lvmetad is active, skipping direct activation during sysinit" out
+check active $vg1 $lv1
+lvchange -an $vg1
+check inactive $vg1 $lv1
+
+#
+# lvmetad is configured and not running
+#
+
+kill $(< LOCAL_LVMETAD)
+
+lvchange -ay $vg1 2>&1 | tee out
+grep "WARNING: Failed to connect" out
+not grep "WARNING: lvmetad is active, skipping direct activation during sysinit" out
+check active $vg1 $lv1
+lvchange -an $vg1
+check inactive $vg1 $lv1
+
+lvchange -aay --sysinit $vg1 2>&1 | tee out
+grep "WARNING: Failed to connect" out
+not grep "WARNING: lvmetad is active, skipping direct activation during sysinit" out
+check active $vg1 $lv1
+lvchange -an $vg1
+check inactive $vg1 $lv1
+
+#
+# lvmetad is not configured and not running
+#
+
+aux lvmconf 'global/use_lvmetad = 0'
+
+lvchange -ay $vg1 2>&1 | tee out
+not grep "WARNING: Failed to connect" out
+not grep "WARNING: lvmetad is active, skipping direct activation during sysinit" out
+check active $vg1 $lv1
+lvchange -an $vg1
+check inactive $vg1 $lv1
+
+lvchange -aay $vg1 --sysinit 2>&1 | tee out
+not grep "WARNING: Failed to connect"
+not grep "WARNING: lvmetad is active, skipping direct activation during sysinit" out
+check active $vg1 $lv1
+lvchange -an $vg1
+check inactive $vg1 $lv1
+
+vgremove -ff $vg1
diff --git a/test/shell/lvmetad-warning.sh b/test/shell/lvmetad-warning.sh
deleted file mode 100644
index e631f9c..0000000
--- a/test/shell/lvmetad-warning.sh
+++ /dev/null
@@ -1,36 +0,0 @@
-#!/bin/sh
-# Copyright (C) 2012 Red Hat, Inc. All rights reserved.
-#
-# 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
-
-SKIP_WITH_LVMLOCKD=1
-SKIP_WITHOUT_LVMETAD=1
-SKIP_WITH_LVMPOLLD=1
-
-. lib/inittest
-
-aux prepare_pvs 2
-
-vgcreate $vg1 "$dev1" "$dev2"
-lvchange -ay $vg1 2>&1 | not grep "Failed to connect"
-
-kill $(< LOCAL_LVMETAD)
-lvchange -ay $vg1 2>&1 | grep "Failed to connect"
-lvchange -aay $vg1 --sysinit 2>&1 | tee sysinit.txt
-not grep "Failed to connect" sysinit.txt
-
-aux lvmconf 'global/use_lvmetad = 0'
-lvchange -ay $vg1 2>&1 | not grep "Failed to connect"
-lvchange -ay $vg1 --sysinit 2>&1 | not grep "Failed to connect"
-
-aux prepare_lvmetad
-lvchange -ay $vg1 2>&1 | not grep "Failed to connect"
-lvchange -ay $vg1 --sysinit 2>&1 | not grep "Failed to connect"
-
-vgremove -ff $vg1
6 years, 11 months
master - test: lvmetad-override
by David Teigland
Gitweb: http://git.fedorahosted.org/git/?p=lvm2.git;a=commitdiff;h=6b1c0a41900827...
Commit: 6b1c0a4190082728de1be2f2d19c1ef46c7f2d5c
Parent: c5cd5b4b696ae85727be8df1fa5b335134531cd6
Author: David Teigland <teigland(a)redhat.com>
AuthorDate: Mon Apr 18 15:19:45 2016 -0500
Committer: David Teigland <teigland(a)redhat.com>
CommitterDate: Tue Apr 19 11:45:24 2016 -0500
test: lvmetad-override
---
test/shell/lvmetad-override.sh | 32 +++++++++++++++++++++++++++-----
1 files changed, 27 insertions(+), 5 deletions(-)
diff --git a/test/shell/lvmetad-override.sh b/test/shell/lvmetad-override.sh
index 0e56904..cd005fc 100644
--- a/test/shell/lvmetad-override.sh
+++ b/test/shell/lvmetad-override.sh
@@ -18,12 +18,34 @@ SKIP_WITH_LVMPOLLD=1
aux prepare_pvs 2
vgcreate $vg1 "$dev1" "$dev2"
-lvchange -ay $vg1 2>&1 | not grep "Failed to connect"
+lvcreate -an -l1 --zero n -n $lv1 $vg1
+
+lvchange -ay $vg1 2>&1 | tee out
+not grep "WARNING: Failed to connect" out
+check active $vg1 $lv1
+lvchange -an $vg1
+check inactive $vg1 $lv1
+
kill $(< LOCAL_LVMETAD)
-lvchange -ay $vg1 2>&1 | grep "Failed to connect"
-lvchange -aay $vg1 --sysinit 2>&1 | not grep "Failed to connect"
-lvchange -ay $vg1 --config 'global { use_lvmetad = 0 }' 2>&1 | not grep "Failed to connect"
+
+lvchange -ay $vg1 2>&1 | tee out
+grep "WARNING: Failed to connect" out
+check active $vg1 $lv1
+lvchange -an $vg1
+check inactive $vg1 $lv1
+
+lvchange -ay --config global/use_lvmetad=0 $vg1 2>&1 | tee out
+not grep "WARNING: Failed to connect" out
+check active $vg1 $lv1
+lvchange -an $vg1
+check inactive $vg1 $lv1
+
aux lvmconf "global/use_lvmetad = 0"
-lvchange -ay $vg1 --config 'global { use_lvmetad = 1 }' 2>&1 | grep "Failed to connect"
+
+lvchange -ay --config global/use_lvmetad=1 $vg1 2>&1 | tee out
+grep "WARNING: Failed to connect" out
+check active $vg1 $lv1
+lvchange -an $vg1
+check inactive $vg1 $lv1
vgremove -ff $vg1
6 years, 11 months
master - test: lvmetad-no-cluster
by David Teigland
Gitweb: http://git.fedorahosted.org/git/?p=lvm2.git;a=commitdiff;h=c5cd5b4b696ae8...
Commit: c5cd5b4b696ae85727be8df1fa5b335134531cd6
Parent: a5722ed7e7b382f3bbb87c5e88c4a78e9ec4cf90
Author: David Teigland <teigland(a)redhat.com>
AuthorDate: Mon Apr 18 13:39:03 2016 -0500
Committer: David Teigland <teigland(a)redhat.com>
CommitterDate: Tue Apr 19 11:45:24 2016 -0500
test: lvmetad-no-cluster
Update warning message check
---
test/shell/lvmetad-no-cluster.sh | 5 ++---
1 files changed, 2 insertions(+), 3 deletions(-)
diff --git a/test/shell/lvmetad-no-cluster.sh b/test/shell/lvmetad-no-cluster.sh
index 7ac448f..d894114 100644
--- a/test/shell/lvmetad-no-cluster.sh
+++ b/test/shell/lvmetad-no-cluster.sh
@@ -17,8 +17,7 @@ SKIP_WITH_LVMPOLLD=1
aux prepare_vg 2
aux prepare_lvmetad
-vgs -vv 2> errs
-cat errs
-grep 'use_lvmetad' errs
+vgs 2>&1 | tee out
+grep "WARNING: Not using lvmetad because locking_type is 3" out
vgremove -ff $vg
6 years, 11 months
master - test: update lvmetad-disabled
by David Teigland
Gitweb: http://git.fedorahosted.org/git/?p=lvm2.git;a=commitdiff;h=a5722ed7e7b382...
Commit: a5722ed7e7b382f3bbb87c5e88c4a78e9ec4cf90
Parent: c9cf85f606d14bcffdbdfaf19e0fa3a8e8b2a5d3
Author: David Teigland <teigland(a)redhat.com>
AuthorDate: Mon Apr 18 13:07:11 2016 -0500
Committer: David Teigland <teigland(a)redhat.com>
CommitterDate: Tue Apr 19 11:45:24 2016 -0500
test: update lvmetad-disabled
Update the check about lvmetad running but not used.
Also add tests related to the new lvmetad disabled state.
lvm1 metadata is used here to test the disabled state
because lvm1 metadata is the first condition using the
disabled state.
---
test/shell/lvmetad-disabled.sh | 66 +++++++++++++++++++++++++++++++++++++---
1 files changed, 61 insertions(+), 5 deletions(-)
diff --git a/test/shell/lvmetad-disabled.sh b/test/shell/lvmetad-disabled.sh
index 60cd2ff..e905ba7 100644
--- a/test/shell/lvmetad-disabled.sh
+++ b/test/shell/lvmetad-disabled.sh
@@ -15,18 +15,74 @@ SKIP_WITH_LVMPOLLD=1
. lib/inittest
+aux prepare_devs 2
+
kill $(< LOCAL_LVMETAD)
while test -e "$TESTDIR/lvmetad.socket"; do echo -n .; sleep .1; done # wait for the socket close
test ! -e "$LVM_LVMETAD_PIDFILE"
+aux lvmconf "global/use_lvmetad = 0"
+
+pvcreate --metadatatype 1 "$dev1"
+pvcreate "$dev2"
+vgcreate -M1 $vg1 "$dev1"
+vgcreate $vg2 "$dev2"
+
+pvs 2>&1 | tee out
+grep "$dev1" out
+grep "$dev2" out
+
+vgs 2>&1 | tee out
+grep $vg1 out
+grep $vg2 out
+
+aux lvmconf "global/use_lvmetad = 1"
lvmetad
while ! test -e "$TESTDIR/lvmetad.socket"; do echo -n .; sleep .1; done # wait for the socket
test -e "$LVM_LVMETAD_PIDFILE"
cp "$LVM_LVMETAD_PIDFILE" LOCAL_LVMETAD
-pvs 2>&1 | not grep "lvmetad is running"
-aux lvmconf "global/use_lvmetad = 0"
-pvs 2>&1 | grep "lvmetad is running"
+not pvscan --cache 2>&1 | tee out
+grep "WARNING: Disabling lvmetad cache" out
+
+pvs 2>&1 | tee out
+grep "$dev1" out
+grep "$dev2" out
+grep "WARNING: Not using lvmetad" out
+
+vgs 2>&1 | tee out
+grep $vg1 out
+grep $vg2 out
+grep "WARNING: Not using lvmetad" out
+
+vgremove $vg1 2>&1 | tee out
+grep "WARNING: Not using lvmetad" out
+
+pvremove "$dev1" 2>&1 | tee out
+grep "WARNING: Not using lvmetad" out
+
+pvscan --cache 2>&1 | tee out
+not grep "WARNING: Disabling lvmetad cache" out
+
+pvs 2>&1 | tee out
+not grep "$dev1" out
+grep "$dev2" out
+not grep "WARNING: Not using lvmetad" out
+
+vgs 2>&1 | tee out
+not grep $vg1 out
+grep $vg2 out
+not grep "WARNING: Not using lvmetad" out
+
+pvs --config 'global/use_lvmetad=0' 2>&1 | tee out
+not grep "$dev1" out
+grep "$dev2" out
+grep "WARNING: Not using lvmetad" out
+grep "use_lvmetad=0" out
+
+vgs --config 'global/use_lvmetad=0' 2>&1 | tee out
+not grep $vg1 out
+grep $vg2 out
+grep "WARNING: Not using lvmetad" out
+grep "use_lvmetad=0" out
-kill $(< "$LVM_LVMETAD_PIDFILE")
-not ls "$LVM_LVMETAD_PIDFILE"
6 years, 11 months