Version 2.02.105 -
=====================================
+ Do not connect to lvmetad on vg/lvchange --sysinit -aay and socket absent.
Use lv_check_not_in_use() when testing device in use before merging.
Move test for target present from init_snapshot_merge() to lvconvert.
Check for failure of lvmcache_add_mda() when writing pv.
#include "daemon-client.h"
+#define LVMETAD_SOCKET DEFAULT_RUN_DIR "/lvmetad.socket"
+
struct volume_group;
/* Different types of replies we may get from lvmetad. */
{
daemon_info lvmetad_info = {
.path = "lvmetad",
- .socket = socket ?: DEFAULT_RUN_DIR "/lvmetad.socket",
+ .socket = socket ?: LVMETAD_SOCKET,
.protocol = "lvmetad",
.protocol_version = 1,
.autostart = 0
#include <math.h> /* fabs() */
#include <float.h> /* DBL_EPSILON */
+#define LVMETAD_SOCKET DEFAULT_RUN_DIR "/lvmetad.socket"
+
typedef struct {
log_state *log; /* convenience */
const char *log_config;
if (!s.socket_path) {
_socket_override = 0;
- s.socket_path = DEFAULT_RUN_DIR "/lvmetad.socket";
+ s.socket_path = LVMETAD_SOCKET;
}
ls.log_config = "";
strerror(_lvmetad.error));
}
+int lvmetad_used(void)
+{
+ return _lvmetad_use;
+}
+
+int lvmetad_socket_present(void)
+{
+ const char *socket = _lvmetad_socket ?: LVMETAD_SOCKET;
+ int r;
+
+ if ((r = access(socket, F_OK)) && errno != ENOENT)
+ log_sys_error("lvmetad_socket_present", "");
+
+ return !r;
+}
+
int lvmetad_active(void)
{
if (!_lvmetad_use)
*/
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.
+ */
+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).
# define lvmetad_disconnect() do { } while (0)
# define lvmetad_set_active(a) do { } while (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)
return EINVALID_CMD_LINE;
}
- if (arg_count(cmd, sysinit_ARG) && lvmetad_active() &&
+ /*
+ * 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_count(cmd, sysinit_ARG) && lvmetad_used() &&
arg_uint_value(cmd, activate_ARG, 0) == CHANGE_AAY) {
- log_warn("lvmetad is active while using --sysinit -a ay, "
- "skipping manual activation");
- return ECMD_PROCESSED;
+ 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(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");
+ return ECMD_PROCESSED;
+ }
}
return process_each_lv(cmd, argc, argv,
return EINVALID_CMD_LINE;
}
- if (arg_count(cmd, sysinit_ARG) && lvmetad_active() &&
+ /*
+ * 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_count(cmd, sysinit_ARG) && lvmetad_used() &&
arg_uint_value(cmd, activate_ARG, 0) == CHANGE_AAY) {
- log_warn("lvmetad is active while using --sysinit -a ay, "
- "skipping manual activation");
- return ECMD_PROCESSED;
+ 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(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");
+ return ECMD_PROCESSED;
+ }
}
if (arg_count(cmd, clustered_ARG) && !argc && !arg_count(cmd, yes_ARG) &&