mirror of
git://sourceware.org/git/lvm2.git
synced 2024-12-21 13:34:40 +03:00
scripts: activation generator: do not use --sysinit if lvmpolld used
If lvmetad is not used, we generate lvm2-activation{-early,-net}.service systemd services to activate any VGs found on the system. So far we used --sysinit during this activation as polling was still forked off of the lvm activation command. This has changed with lvmpolld - we have proper lvmpolld systemd service now (activated via its socket unit). As such, we don't need to use --sysinit anymore during activation in systemd environment as polling was the only barrier to remove the need for --sysinit.
This commit is contained in:
parent
6d998aa13d
commit
ba68aed836
@ -1,5 +1,6 @@
|
|||||||
Version 2.02.121 -
|
Version 2.02.121 -
|
||||||
================================
|
================================
|
||||||
|
Do not use --sysinit in lvm2-activation{-early,-net}.service if lvmpolld used.
|
||||||
Do not fail polling when poll LV not found (already finished or removed).
|
Do not fail polling when poll LV not found (already finished or removed).
|
||||||
Replace poll_get_copy_vg/lv fns with vg_read() and find_lv() in polldaemon.
|
Replace poll_get_copy_vg/lv fns with vg_read() and find_lv() in polldaemon.
|
||||||
Close all device fds only in before sleep call in polldaemon.
|
Close all device fds only in before sleep call in polldaemon.
|
||||||
|
@ -26,6 +26,7 @@
|
|||||||
|
|
||||||
#define KMSG_DEV_PATH "/dev/kmsg"
|
#define KMSG_DEV_PATH "/dev/kmsg"
|
||||||
#define LVM_CONF_USE_LVMETAD "global/use_lvmetad"
|
#define LVM_CONF_USE_LVMETAD "global/use_lvmetad"
|
||||||
|
#define LVM_CONF_USE_LVMPOLLD "global/use_lvmpolld"
|
||||||
|
|
||||||
#define UNIT_TARGET_LOCAL_FS "local-fs.target"
|
#define UNIT_TARGET_LOCAL_FS "local-fs.target"
|
||||||
#define UNIT_TARGET_REMOTE_FS "remote-fs.target"
|
#define UNIT_TARGET_REMOTE_FS "remote-fs.target"
|
||||||
@ -66,19 +67,18 @@ static void kmsg(int log_level, const char *format, ...)
|
|||||||
(void) write(kmsg_fd, message, n + 4);
|
(void) write(kmsg_fd, message, n + 4);
|
||||||
}
|
}
|
||||||
|
|
||||||
static int lvm_uses_lvmetad(void)
|
static void lvm_get_use_lvmetad_and_lvmpolld(int *use_lvmetad, int *use_lvmpolld)
|
||||||
{
|
{
|
||||||
lvm_t lvm;
|
lvm_t lvm;
|
||||||
int r;
|
|
||||||
|
|
||||||
|
*use_lvmetad = *use_lvmpolld = 0;
|
||||||
if (!(lvm = lvm_init(NULL))) {
|
if (!(lvm = lvm_init(NULL))) {
|
||||||
kmsg(LOG_ERR, "LVM: Failed to initialize library context for activation generator.\n");
|
kmsg(LOG_ERR, "LVM: Failed to initialize library context for activation generator.\n");
|
||||||
return 0;
|
return;
|
||||||
}
|
}
|
||||||
r = lvm_config_find_bool(lvm, LVM_CONF_USE_LVMETAD, 0);
|
*use_lvmetad = lvm_config_find_bool(lvm, LVM_CONF_USE_LVMETAD, 0);
|
||||||
|
*use_lvmpolld = lvm_config_find_bool(lvm, LVM_CONF_USE_LVMPOLLD, 0);
|
||||||
lvm_quit(lvm);
|
lvm_quit(lvm);
|
||||||
|
|
||||||
return r;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static int register_unit_with_target(const char *dir, const char *unit, const char *target)
|
static int register_unit_with_target(const char *dir, const char *unit, const char *target)
|
||||||
@ -107,7 +107,7 @@ out:
|
|||||||
return r;
|
return r;
|
||||||
}
|
}
|
||||||
|
|
||||||
static int generate_unit(const char *dir, int unit)
|
static int generate_unit(const char *dir, int unit, int sysinit_needed)
|
||||||
{
|
{
|
||||||
FILE *f;
|
FILE *f;
|
||||||
const char *unit_name = unit_names[unit];
|
const char *unit_name = unit_names[unit];
|
||||||
@ -150,8 +150,10 @@ static int generate_unit(const char *dir, int unit)
|
|||||||
"[Service]\n", f);
|
"[Service]\n", f);
|
||||||
}
|
}
|
||||||
|
|
||||||
fputs("ExecStart=" LVM_PATH " vgchange -aay --sysinit --ignoreskippedcluster\n"
|
fputs("ExecStart=" LVM_PATH " vgchange -aay --ignoreskippedcluster", f);
|
||||||
"Type=oneshot\n", f);
|
if (sysinit_needed)
|
||||||
|
fputs (" --sysinit", f);
|
||||||
|
fputs("\nType=oneshot\n", f);
|
||||||
|
|
||||||
if (fclose(f) < 0) {
|
if (fclose(f) < 0) {
|
||||||
kmsg(LOG_ERR, "LVM: Failed to write unit file %s: %m.\n", unit_name);
|
kmsg(LOG_ERR, "LVM: Failed to write unit file %s: %m.\n", unit_name);
|
||||||
@ -168,6 +170,7 @@ static int generate_unit(const char *dir, int unit)
|
|||||||
|
|
||||||
int main(int argc, char *argv[])
|
int main(int argc, char *argv[])
|
||||||
{
|
{
|
||||||
|
int use_lvmetad, use_lvmpolld, sysinit_needed;
|
||||||
const char *dir;
|
const char *dir;
|
||||||
int r = EXIT_SUCCESS;
|
int r = EXIT_SUCCESS;
|
||||||
mode_t old_mask;
|
mode_t old_mask;
|
||||||
@ -180,16 +183,20 @@ int main(int argc, char *argv[])
|
|||||||
}
|
}
|
||||||
|
|
||||||
/* If lvmetad used, rely on autoactivation instead of direct activation. */
|
/* If lvmetad used, rely on autoactivation instead of direct activation. */
|
||||||
if (lvm_uses_lvmetad())
|
lvm_get_use_lvmetad_and_lvmpolld(&use_lvmetad, &use_lvmpolld);
|
||||||
|
if (use_lvmetad)
|
||||||
goto out;
|
goto out;
|
||||||
|
|
||||||
dir = argv[1];
|
dir = argv[1];
|
||||||
|
|
||||||
/* mark lvm2-activation.*.service as world-accessible */
|
/* mark lvm2-activation.*.service as world-accessible */
|
||||||
old_mask = umask(0022);
|
old_mask = umask(0022);
|
||||||
if (!generate_unit(dir, UNIT_EARLY) ||
|
|
||||||
!generate_unit(dir, UNIT_MAIN) ||
|
sysinit_needed = !use_lvmpolld;
|
||||||
!generate_unit(dir, UNIT_NET))
|
|
||||||
|
if (!generate_unit(dir, UNIT_EARLY, sysinit_needed) ||
|
||||||
|
!generate_unit(dir, UNIT_MAIN, sysinit_needed) ||
|
||||||
|
!generate_unit(dir, UNIT_NET, sysinit_needed))
|
||||||
r = EXIT_FAILURE;
|
r = EXIT_FAILURE;
|
||||||
umask(old_mask);
|
umask(old_mask);
|
||||||
out:
|
out:
|
||||||
|
Loading…
Reference in New Issue
Block a user