main - udev: don't reset SYSTEMD_READY in udev for PVs on MD and loop
by Peter Rajnoha
Gitweb: https://sourceware.org/git/?p=lvm2.git;a=commitdiff;h=e7c8a825061d57efaff...
Commit: e7c8a825061d57efaffad80667873fa8d68d31ab
Parent: 94eda42e7ad7c2dbd7fedfdfbf38032857318fec
Author: Peter Rajnoha <prajnoha(a)redhat.com>
AuthorDate: Wed Feb 1 14:33:25 2023 +0100
Committer: Peter Rajnoha <prajnoha(a)redhat.com>
CommitterDate: Wed Feb 1 14:46:52 2023 +0100
udev: don't reset SYSTEMD_READY in udev for PVs on MD and loop
Since 67722b312390cdab29c076c912e14bd739c5c0f6, we have a new mechanism
to run the autoactivation from udev. With this change, we also replaced
the way the LVM autoactivation service is instantiatiated - instead of
setting the SYSTEM_WANTS udev variable (which systemd read and then
instantiated the service), we're now directly instantiating the
transient 'lvm-activate-<vgname>' service by calling systemd-run.
As such, we don't need to bother with setting the SYSTEMD_READY variable
for foreign devices anymore (in this case, MD and loop devices on top of
which there's a PV).
Before, we set the SYSTEMD_READY variable to make sure that the SYSTEMD_WANTS
is applied correctly - the service instantiation was edge-triggered by
flipping the SYSTEMD_READY from 0 to 1 and at the same time having the
SYSTEMD_WANTS variable set to the service name to instantiate. We're
using systemd-run now so this condition does not apply anymore.
Also, it was not completely correct to set SYSTEMD_READY for foreign
devices because there might be cases where this could cause issues,
see also https://github.com/lvmteam/lvm2/issues/94.
---
WHATS_NEW | 1 +
udev/69-dm-lvm.rules.in | 4 ----
2 files changed, 1 insertion(+), 4 deletions(-)
diff --git a/WHATS_NEW b/WHATS_NEW
index 7dbb669a1..1a0812df8 100644
--- a/WHATS_NEW
+++ b/WHATS_NEW
@@ -1,5 +1,6 @@
version 2.03.19 -
====================================
+ Do not reset SYSTEMD_READY variable in udev for PVs on MD and loop devices.
Ensure udev is processing origin LV before its thick snapshots LVs.
Fix and improve runtime memory size detection for VDO volumes.
diff --git a/udev/69-dm-lvm.rules.in b/udev/69-dm-lvm.rules.in
index 14e7dd26d..3cda30023 100644
--- a/udev/69-dm-lvm.rules.in
+++ b/udev/69-dm-lvm.rules.in
@@ -38,7 +38,6 @@ IMPORT{db}="LVM_MD_PV_ACTIVATED"
ACTION=="add", ENV{LVM_MD_PV_ACTIVATED}=="1", GOTO="lvm_scan"
ACTION=="change", ENV{LVM_MD_PV_ACTIVATED}!="1", TEST=="md/array_state", ENV{LVM_MD_PV_ACTIVATED}="1", GOTO="lvm_scan"
ACTION=="add", KERNEL=="md[0-9]*p[0-9]*", GOTO="lvm_scan"
-ENV{LVM_MD_PV_ACTIVATED}!="1", ENV{SYSTEMD_READY}="0"
GOTO="lvm_end"
# Loop device:
@@ -46,7 +45,6 @@ LABEL="next"
KERNEL!="loop[0-9]*", GOTO="next"
ACTION=="add", ENV{LVM_LOOP_PV_ACTIVATED}=="1", GOTO="lvm_scan"
ACTION=="change", ENV{LVM_LOOP_PV_ACTIVATED}!="1", TEST=="loop/backing_file", ENV{LVM_LOOP_PV_ACTIVATED}="1", GOTO="lvm_scan"
-ENV{LVM_LOOP_PV_ACTIVATED}!="1", ENV{SYSTEMD_READY}="0"
GOTO="lvm_end"
LABEL="next"
@@ -54,8 +52,6 @@ ACTION!="add", GOTO="lvm_end"
LABEL="lvm_scan"
-ENV{SYSTEMD_READY}="1"
-
# pvscan will check if this device completes a VG,
# i.e. all PVs in the VG are now present with the
# arrival of this PV. If so, it prints to stdout:
3 months, 4 weeks
main - lv/vgchange: when refreshing whole vg skip snapshot
by Zdenek Kabelac
Gitweb: https://sourceware.org/git/?p=lvm2.git;a=commitdiff;h=94eda42e7ad7c2dbd7f...
Commit: 94eda42e7ad7c2dbd7fedfdfbf38032857318fec
Parent: 0ec087e8b82848891512f100ff594add8f47cfb2
Author: Zdenek Kabelac <zkabelac(a)redhat.com>
AuthorDate: Tue Jan 31 22:48:43 2023 +0100
Committer: Zdenek Kabelac <zkabelac(a)redhat.com>
CommitterDate: Wed Feb 1 11:48:53 2023 +0100
lv/vgchange: when refreshing whole vg skip snapshot
When refreshing all LVs in a VG, skip processing of thick snapshots,
since they will be refreshed through its origin LV.
Should reduce some unnecessary ioctl().
---
tools/toollib.c | 8 ++++++--
1 file changed, 6 insertions(+), 2 deletions(-)
diff --git a/tools/toollib.c b/tools/toollib.c
index d52c9e342..194088ea6 100644
--- a/tools/toollib.c
+++ b/tools/toollib.c
@@ -883,7 +883,9 @@ int vg_refresh_visible(struct cmd_context *cmd, struct volume_group *vg)
break;
}
- if (lv_is_visible(lvl->lv) && !lv_refresh(cmd, lvl->lv)) {
+ if (lv_is_visible(lvl->lv) &&
+ !(lv_is_cow(lvl->lv) && !lv_is_virtual_origin(origin_from_cow(lvl->lv))) &&
+ !lv_refresh(cmd, lvl->lv)) {
r = 0;
stack;
}
@@ -3292,7 +3294,9 @@ int process_each_lv_in_vg(struct cmd_context *cmd, struct volume_group *vg,
/* Skip availability change for non-virt snaps when processing all LVs */
/* FIXME: pass process_all to process_single_lv() */
- if (process_all && arg_is_set(cmd, activate_ARG) &&
+ if (process_all &&
+ (arg_is_set(cmd, activate_ARG) ||
+ arg_is_set(cmd, refresh_ARG)) &&
lv_is_cow(lvl->lv) && !lv_is_virtual_origin(origin_from_cow(lvl->lv)))
continue;
3 months, 4 weeks
main - debug: compatibility with x32 ABI
by Zdenek Kabelac
Gitweb: https://sourceware.org/git/?p=lvm2.git;a=commitdiff;h=0ec087e8b8284889151...
Commit: 0ec087e8b82848891512f100ff594add8f47cfb2
Parent: c8a5948a71b041ae2cce03e1b3a9843f0fab023f
Author: Zdenek Kabelac <zkabelac(a)redhat.com>
AuthorDate: Wed Jan 18 14:27:56 2023 +0100
Committer: Zdenek Kabelac <zkabelac(a)redhat.com>
CommitterDate: Wed Feb 1 11:47:47 2023 +0100
debug: compatibility with x32 ABI
Keep the conversion 64bit as on x32 arch time_t is 64bit value
and we may loose precision (y2038).
TODO: like use universal string for time printing as in log/log.c
_set_time_prefix()
---
daemons/dmeventd/libdevmapper-event.c | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/daemons/dmeventd/libdevmapper-event.c b/daemons/dmeventd/libdevmapper-event.c
index c6532b9a5..b5ae37fbc 100644
--- a/daemons/dmeventd/libdevmapper-event.c
+++ b/daemons/dmeventd/libdevmapper-event.c
@@ -928,8 +928,8 @@ void dm_event_log(const char *subsys, int level, const char *file,
start = now;
now -= start;
if (_debug_level)
- fprintf(stream, "[%2ld:%02ld] %8x:%-6s%s",
- (long)now / 60, (long)now % 60,
+ fprintf(stream, "[%2lld:%02lld] %8x:%-6s%s",
+ (long long)now / 60, (long long)now % 60,
// TODO: Maybe use shorter ID
// ((int)(pthread_self()) >> 6) & 0xffff,
(int)pthread_self(), subsys,
3 months, 4 weeks
main - device_mapper: reactivate siblings for snapshot
by Zdenek Kabelac
Gitweb: https://sourceware.org/git/?p=lvm2.git;a=commitdiff;h=c8a5948a71b041ae2cc...
Commit: c8a5948a71b041ae2cce03e1b3a9843f0fab023f
Parent: 85aa236946d3c290c7fab2c6229684ed268b1670
Author: Zdenek Kabelac <zkabelac(a)redhat.com>
AuthorDate: Mon Jan 30 14:32:44 2023 +0100
Committer: Zdenek Kabelac <zkabelac(a)redhat.com>
CommitterDate: Wed Feb 1 11:47:47 2023 +0100
device_mapper: reactivate siblings for snapshot
When activating origin and its thick snapshots, ensure the
origin's LV udev processing is finished first and after this
reactivate its snapshot so the udev can scan them afterwards.
This should fix the problems for users using UUID of such device
in their fstab and occasionaly mounted snapshot instead of origin LV.
---
WHATS_NEW | 1 +
device_mapper/libdm-deptree.c | 89 +++++++++++++++++++++++++++++++++++++++++++
2 files changed, 90 insertions(+)
diff --git a/WHATS_NEW b/WHATS_NEW
index 191338868..7dbb669a1 100644
--- a/WHATS_NEW
+++ b/WHATS_NEW
@@ -1,5 +1,6 @@
version 2.03.19 -
====================================
+ Ensure udev is processing origin LV before its thick snapshots LVs.
Fix and improve runtime memory size detection for VDO volumes.
version 2.03.18 - 22nd december 2022
diff --git a/device_mapper/libdm-deptree.c b/device_mapper/libdm-deptree.c
index 6a7fd08ee..ebf1d0257 100644
--- a/device_mapper/libdm-deptree.c
+++ b/device_mapper/libdm-deptree.c
@@ -294,6 +294,10 @@ struct load_properties {
unsigned send_messages;
/* Skip suspending node's children, used when sending messages to thin-pool */
int skip_suspend;
+
+ /* Suspend and Resume siblings after node activation with udev flags*/
+ unsigned reactivate_siblings;
+ uint16_t reactivate_udev_flags;
};
/* Two of these used to join two nodes with uses and used_by. */
@@ -2030,6 +2034,68 @@ static int _rename_conflict_exists(struct dm_tree_node *parent,
return 0;
}
+/*
+ * Reactivation of sibling nodes
+ *
+ * Function is used when activating origin and its thick snapshots
+ * to ensure udev is processing first the origin LV and all the
+ * snapshot LVs are processed afterwards.
+ */
+static int _reactivate_siblings(struct dm_tree_node *dnode,
+ const char *uuid_prefix,
+ size_t uuid_prefix_len)
+{
+ struct dm_tree_node *child;
+ const char *uuid;
+ void *handle = NULL;
+ int r = 1;
+
+ /* Wait for udev before reactivating siblings */
+ if (!dm_udev_wait(dm_tree_get_cookie(dnode)))
+ stack;
+
+ dm_tree_set_cookie(dnode, 0);
+
+ while ((child = dm_tree_next_child(&handle, dnode, 0))) {
+ if (child->props.reactivate_siblings) {
+ /* Skip 'leading' device in this group, marked with flag */
+ child->props.reactivate_siblings = 0;
+ continue;
+ }
+
+ if (!(uuid = dm_tree_node_get_uuid(child))) {
+ stack;
+ continue;
+ }
+
+ if (!_uuid_prefix_matches(uuid, uuid_prefix, uuid_prefix_len))
+ continue;
+
+ if (!_suspend_node(child->name, child->info.major, child->info.minor,
+ child->dtree->skip_lockfs,
+ child->dtree->no_flush, &child->info)) {
+ log_error("Unable to suspend %s (" FMTu32
+ ":" FMTu32 ")", child->name,
+ child->info.major, child->info.minor);
+ r = 0;
+ continue;
+ }
+ if (!_resume_node(child->name, child->info.major, child->info.minor,
+ child->props.read_ahead, child->props.read_ahead_flags,
+ &child->info, &child->dtree->cookie,
+ child->props.reactivate_udev_flags, // use these flags
+ child->info.suspended)) {
+ log_error("Failed to suspend %s (" FMTu32
+ ":" FMTu32 ")", child->name,
+ child->info.major, child->info.minor);
+ r = 0;
+ continue;
+ }
+ }
+
+ return r;
+}
+
int dm_tree_activate_children(struct dm_tree_node *dnode,
const char *uuid_prefix,
size_t uuid_prefix_len)
@@ -2122,6 +2188,11 @@ int dm_tree_activate_children(struct dm_tree_node *dnode,
if (r && (child->props.send_messages > 1) &&
!(r = _node_send_messages(child, uuid_prefix, uuid_prefix_len, 1)))
stack;
+
+ /* Reactivate only for fresh activated origin */
+ if (r && child->props.reactivate_siblings &&
+ (!(r = _reactivate_siblings(dnode, uuid_prefix, uuid_prefix_len))))
+ stack;
}
if (awaiting_peer_rename)
priority--; /* redo priority level */
@@ -3455,6 +3526,10 @@ int dm_tree_node_add_snapshot_origin_target(struct dm_tree_node *dnode,
/* Resume snapshot origins after new snapshots */
dnode->activation_priority = 1;
+ if (!dnode->info.exists)
+ /* Reactivate siblings for this origin after being resumed */
+ dnode->props.reactivate_siblings = 1;
+
/*
* Don't resume the origin immediately in case it is a non-trivial
* target that must not be active more than once concurrently!
@@ -3517,6 +3592,20 @@ static int _add_snapshot_target(struct dm_tree_node *node,
/* Resume merging snapshot after snapshot-merge */
seg->merge->activation_priority = 2;
}
+ } else if (!origin_node->info.exists) {
+ /* Keep original udev_flags for reactivation. */
+ node->props.reactivate_udev_flags = node->udev_flags;
+
+ /* Reactivation is needed if the origin's -real device is not in DM table.
+ * For this case after the resume of its origin LV we resume its snapshots
+ * with updated udev_flags to completely avoid udev scanning for the first resume.
+ * Reactivation then resumes snapshots with original udev_flags.
+ */
+ node->udev_flags |= DM_SUBSYSTEM_UDEV_FLAG0 |
+ DM_UDEV_DISABLE_DISK_RULES_FLAG |
+ DM_UDEV_DISABLE_OTHER_RULES_FLAG;
+ log_debug_activation("Using udev_flags 0x%x for activation of %s.",
+ node->udev_flags, node->name);
}
return 1;
3 months, 4 weeks
main - device_mapper: reduce unnecessary looping passed
by Zdenek Kabelac
Gitweb: https://sourceware.org/git/?p=lvm2.git;a=commitdiff;h=85aa236946d3c290c7f...
Commit: 85aa236946d3c290c7fab2c6229684ed268b1670
Parent: f89c369a0119a701a5a550694258a145202ab4a2
Author: Zdenek Kabelac <zkabelac(a)redhat.com>
AuthorDate: Mon Jan 30 14:31:04 2023 +0100
Committer: Zdenek Kabelac <zkabelac(a)redhat.com>
CommitterDate: Wed Feb 1 11:47:47 2023 +0100
device_mapper: reduce unnecessary looping passed
While looping through the list of nodes, check if there is higher
priority present and another iteration is still needed.
---
device_mapper/libdm-deptree.c | 12 +++++++++---
1 file changed, 9 insertions(+), 3 deletions(-)
diff --git a/device_mapper/libdm-deptree.c b/device_mapper/libdm-deptree.c
index c6cc8de56..6a7fd08ee 100644
--- a/device_mapper/libdm-deptree.c
+++ b/device_mapper/libdm-deptree.c
@@ -2040,7 +2040,7 @@ int dm_tree_activate_children(struct dm_tree_node *dnode,
struct dm_tree_node *child = dnode;
const char *name;
const char *uuid;
- int priority;
+ int priority, next_priority;
/* Activate children first */
while ((child = dm_tree_next_child(&handle, dnode, 0))) {
@@ -2058,12 +2058,16 @@ int dm_tree_activate_children(struct dm_tree_node *dnode,
}
handle = NULL;
-
for (priority = 0; priority < 3; priority++) {
awaiting_peer_rename = 0;
+ next_priority = 0;
while ((child = dm_tree_next_child(&handle, dnode, 0))) {
- if (priority != child->activation_priority)
+ if (priority != child->activation_priority) {
+ if ((next_priority < child->activation_priority) &&
+ (child->activation_priority > priority))
+ next_priority = child->activation_priority;
continue;
+ }
if (!(uuid = dm_tree_node_get_uuid(child))) {
stack;
@@ -2121,6 +2125,8 @@ int dm_tree_activate_children(struct dm_tree_node *dnode,
}
if (awaiting_peer_rename)
priority--; /* redo priority level */
+ else if (!next_priority)
+ break; /* no more work, higher priority was not found in the chain */
}
return r;
3 months, 4 weeks
main - archive: update message
by Zdenek Kabelac
Gitweb: https://sourceware.org/git/?p=lvm2.git;a=commitdiff;h=f89c369a0119a701a5a...
Commit: f89c369a0119a701a5a550694258a145202ab4a2
Parent: 6d14144d311fb347e4225ad6a48d4900b39445c4
Author: Zdenek Kabelac <zkabelac(a)redhat.com>
AuthorDate: Tue Jan 17 23:58:41 2023 +0100
Committer: Zdenek Kabelac <zkabelac(a)redhat.com>
CommitterDate: Wed Feb 1 11:47:30 2023 +0100
archive: update message
Better suggesting message as suggested by RHBZ 2123151.
---
lib/format_text/archive.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/lib/format_text/archive.c b/lib/format_text/archive.c
index 2e8792a93..5acf0c04a 100644
--- a/lib/format_text/archive.c
+++ b/lib/format_text/archive.c
@@ -219,7 +219,7 @@ static void _remove_expired(const char *dir, const char *vgname,
sum /= 1024 * 1024;
if (sum > 128 || archives_size > 8192)
- log_print_unless_silent("Consider pruning %s VG archive with more then %u MiB in %u files (check archiving is needed in lvm.conf).",
+ log_print_unless_silent("Consider pruning %s VG archive with more then %u MiB in %u files (see archiving settings in lvm.conf).",
vgname, (unsigned)sum, archives_size);
}
3 months, 4 weeks