mirror of
git://sourceware.org/git/lvm2.git
synced 2025-03-11 20:58:50 +03:00
pvscan systemd service for event based activation
The pvscan systemd service for autoactivation was mistakenly dropped along with the lvmetad related services. The activation generator program now looks at the new lvm.conf setting "event_activation" (default 1) to switch between event activation and direct activation. Previously, the old use_lvmetad setting was used to switch between event and direct activation.
This commit is contained in:
parent
229e63b638
commit
4b5d6de86b
@ -1828,6 +1828,7 @@ libdm/dm-tools/Makefile
|
|||||||
libdm/libdevmapper.pc
|
libdm/libdevmapper.pc
|
||||||
man/Makefile
|
man/Makefile
|
||||||
po/Makefile
|
po/Makefile
|
||||||
|
scripts/lvm2-pvscan.service
|
||||||
scripts/blkdeactivate.sh
|
scripts/blkdeactivate.sh
|
||||||
scripts/blk_availability_init_red_hat
|
scripts/blk_availability_init_red_hat
|
||||||
scripts/blk_availability_systemd_red_hat.service
|
scripts/blk_availability_systemd_red_hat.service
|
||||||
|
@ -997,6 +997,15 @@ 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"
|
"Previously this was always shown as /dev/vgname/lvname even when that\n"
|
||||||
"was never a valid path in the /dev filesystem.\n")
|
"was never a valid path in the /dev filesystem.\n")
|
||||||
|
|
||||||
|
cfg(global_event_activation_CFG, "event_activation", global_CFG_SECTION, 0, CFG_TYPE_BOOL, 1, vsn(2, 3, 1), 0, 0, NULL,
|
||||||
|
"Activate LVs based on system-generated device events.\n"
|
||||||
|
"When a device appears on the system, a system-generated event runs\n"
|
||||||
|
"the pvscan command to activate LVs if the new PV completes the VG.\n"
|
||||||
|
"Use auto_activation_volume_list to select which LVs should be\n"
|
||||||
|
"activated from these events (the default is all.)\n"
|
||||||
|
"When event_activation is disabled, the system will generally run\n"
|
||||||
|
"a direct activation command to activate LVs in complete VGs.\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,
|
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")
|
"This setting is no longer used.\n")
|
||||||
|
|
||||||
|
@ -8,10 +8,10 @@ lvm2-activation-generator - generator for systemd units to activate LVM volumes
|
|||||||
|
|
||||||
The lvm2-activation-generator is called by \fBsystemd\fP(1) on boot to
|
The lvm2-activation-generator is called by \fBsystemd\fP(1) on boot to
|
||||||
generate systemd units at runtime to activate LVM Logical Volumes (LVs)
|
generate systemd units at runtime to activate LVM Logical Volumes (LVs)
|
||||||
when global/use_lvmetad=0 is set in \fBlvm.conf\fP(5). These units use
|
when global/event_activation=0 is set in \fBlvm.conf\fP(5). These units use
|
||||||
\fBvgchange -ay\fP to activate LVs.
|
\fBvgchange -ay\fP to activate LVs.
|
||||||
|
|
||||||
If use_lvmetad=1, the lvm2-activation-generator exits immediately without
|
If event_activation=1, the lvm2-activation-generator exits immediately without
|
||||||
generating any systemd units, and LVM fully relies on event-based
|
generating any systemd units, and LVM fully relies on event-based
|
||||||
activation to activate LVs. In this case, event-generated \fBpvscan
|
activation to activate LVs. In this case, event-generated \fBpvscan
|
||||||
--cache -aay\fP commands activate LVs.
|
--cache -aay\fP commands activate LVs.
|
||||||
|
@ -84,6 +84,7 @@ install_systemd_generators:
|
|||||||
|
|
||||||
install_systemd_units: install_dbus_service
|
install_systemd_units: install_dbus_service
|
||||||
$(INSTALL_DIR) $(systemd_unit_dir)
|
$(INSTALL_DIR) $(systemd_unit_dir)
|
||||||
|
$(INSTALL_DATA) lvm2-pvscan.service $(systemd_unit_dir)/lvm2-pvscan@.service
|
||||||
ifeq ("@BUILD_DMEVENTD@", "yes")
|
ifeq ("@BUILD_DMEVENTD@", "yes")
|
||||||
$(INSTALL_DATA) dm_event_systemd_red_hat.socket $(systemd_unit_dir)/dm-event.socket
|
$(INSTALL_DATA) dm_event_systemd_red_hat.socket $(systemd_unit_dir)/dm-event.socket
|
||||||
$(INSTALL_DATA) dm_event_systemd_red_hat.service $(systemd_unit_dir)/dm-event.service
|
$(INSTALL_DATA) dm_event_systemd_red_hat.service $(systemd_unit_dir)/dm-event.service
|
||||||
|
@ -93,11 +93,11 @@ static bool _close_child(struct child_process *child)
|
|||||||
//----------------------------------------------------------------
|
//----------------------------------------------------------------
|
||||||
// Aquiring config from the lvmconfig process
|
// Aquiring config from the lvmconfig process
|
||||||
|
|
||||||
#define LVM_CONF_USE_LVMETAD "global/use_lvmetad"
|
#define LVM_CONF_EVENT_ACTIVATION "global/event_activation"
|
||||||
#define LVM_CONF_USE_LVMPOLLD "global/use_lvmpolld"
|
#define LVM_CONF_USE_LVMPOLLD "global/use_lvmpolld"
|
||||||
|
|
||||||
struct config {
|
struct config {
|
||||||
bool use_lvmetad;
|
bool event_activation;
|
||||||
bool sysinit_needed;
|
bool sysinit_needed;
|
||||||
};
|
};
|
||||||
|
|
||||||
@ -153,8 +153,8 @@ static bool _parse_line(const char *line, struct config *cfg)
|
|||||||
{
|
{
|
||||||
const char *val;
|
const char *val;
|
||||||
|
|
||||||
if (_begins_with(line, "use_lvmetad=", &val)) {
|
if (_begins_with(line, "event_activation=", &val)) {
|
||||||
return _parse_bool(val, &cfg->use_lvmetad);
|
return _parse_bool(val, &cfg->event_activation);
|
||||||
|
|
||||||
} else if (_begins_with(line, "use_lvmpolld=", &val)) {
|
} else if (_begins_with(line, "use_lvmpolld=", &val)) {
|
||||||
bool r;
|
bool r;
|
||||||
@ -170,14 +170,14 @@ static bool _parse_line(const char *line, struct config *cfg)
|
|||||||
static bool _get_config(struct config *cfg, const char *lvmconfig_path)
|
static bool _get_config(struct config *cfg, const char *lvmconfig_path)
|
||||||
{
|
{
|
||||||
static const char *_argv[] = {
|
static const char *_argv[] = {
|
||||||
"lvmconfig", LVM_CONF_USE_LVMETAD, LVM_CONF_USE_LVMPOLLD, NULL
|
"lvmconfig", LVM_CONF_EVENT_ACTIVATION, LVM_CONF_USE_LVMPOLLD, NULL
|
||||||
};
|
};
|
||||||
|
|
||||||
bool r = true;
|
bool r = true;
|
||||||
char buffer[256];
|
char buffer[256];
|
||||||
struct child_process child;
|
struct child_process child;
|
||||||
|
|
||||||
cfg->use_lvmetad = false;
|
cfg->event_activation = false;
|
||||||
cfg->sysinit_needed = true;
|
cfg->sysinit_needed = true;
|
||||||
|
|
||||||
if (!_open_child(&child, lvmconfig_path, _argv)) {
|
if (!_open_child(&child, lvmconfig_path, _argv)) {
|
||||||
|
14
scripts/lvm2-pvscan.service.in
Normal file
14
scripts/lvm2-pvscan.service.in
Normal file
@ -0,0 +1,14 @@
|
|||||||
|
[Unit]
|
||||||
|
Description=LVM event activation on device %i
|
||||||
|
Documentation=man:pvscan(8)
|
||||||
|
DefaultDependencies=no
|
||||||
|
StartLimitInterval=0
|
||||||
|
BindsTo=dev-block-%i.device
|
||||||
|
Before=shutdown.target
|
||||||
|
Conflicts=shutdown.target
|
||||||
|
|
||||||
|
[Service]
|
||||||
|
Type=oneshot
|
||||||
|
RemainAfterExit=yes
|
||||||
|
ExecStart=@SBINDIR@/lvm pvscan --cache --activate ay %i
|
||||||
|
ExecStop=@SBINDIR@/lvm pvscan --cache %i
|
@ -150,12 +150,11 @@ static int generate_unit(struct generator *gen, int unit)
|
|||||||
|
|
||||||
fputs("# Automatically generated by lvm2-activation-generator.\n"
|
fputs("# Automatically generated by lvm2-activation-generator.\n"
|
||||||
"#\n"
|
"#\n"
|
||||||
"# This unit is responsible for direct activation of LVM2 logical volumes\n"
|
"# This unit is responsible for direct activation of LVM logical volumes\n"
|
||||||
"# if lvmetad daemon is not used (global/use_lvmetad=0 lvm.conf setting),\n"
|
"# if event-based activation not used (global/event_activation=0 in\n"
|
||||||
"# hence volume autoactivation is not applicable.\n"
|
"# lvm.conf). Direct LVM activation requires udev to be settled!\n\n"
|
||||||
"# Direct LVM2 activation requires udev to be settled!\n\n"
|
|
||||||
"[Unit]\n"
|
"[Unit]\n"
|
||||||
"Description=Activation of LVM2 logical volumes\n"
|
"Description=LVM direct activation of logical volumes\n"
|
||||||
"Documentation=man:lvm2-activation-generator(8)\n"
|
"Documentation=man:lvm2-activation-generator(8)\n"
|
||||||
"SourcePath=/etc/lvm/lvm.conf\n" "DefaultDependencies=no\n", f);
|
"SourcePath=/etc/lvm/lvm.conf\n" "DefaultDependencies=no\n", f);
|
||||||
|
|
||||||
@ -217,8 +216,8 @@ static bool _run(int argc, const char **argv)
|
|||||||
if (!_get_config(&gen.cfg, LVMCONFIG_PATH))
|
if (!_get_config(&gen.cfg, LVMCONFIG_PATH))
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
if (gen.cfg.use_lvmetad)
|
if (gen.cfg.event_activation)
|
||||||
// If lvmetad used, rely on autoactivation instead of direct activation.
|
// If event_activation=1, pvscan --cache -aay does activation.
|
||||||
return true;
|
return true;
|
||||||
|
|
||||||
/* mark lvm2-activation.*.service as world-accessible */
|
/* mark lvm2-activation.*.service as world-accessible */
|
||||||
|
Loading…
x
Reference in New Issue
Block a user