From 5ffb684419d3eab538f0e358717cf78557b63c3e Mon Sep 17 00:00:00 2001 From: yanshuai01 Date: Mon, 22 Apr 2024 17:06:51 +0800 Subject: [PATCH] reduce unnecessary looping passed --- 0034-reduce-unnecessary-looping-passed.patch | 53 ++++++++++++++++++++ lvm2.spec | 6 ++- 2 files changed, 58 insertions(+), 1 deletion(-) create mode 100644 0034-reduce-unnecessary-looping-passed.patch diff --git a/0034-reduce-unnecessary-looping-passed.patch b/0034-reduce-unnecessary-looping-passed.patch new file mode 100644 index 0000000..43c1e97 --- /dev/null +++ b/0034-reduce-unnecessary-looping-passed.patch @@ -0,0 +1,53 @@ +From 85aa236946d3c290c7fab2c6229684ed268b1670 Mon Sep 17 00:00:00 2001 +From: Zdenek Kabelac +Date: Mon, 30 Jan 2023 14:31:04 +0100 +Subject: [PATCH] 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 | 10 +++++++++- + 1 file changed, 9 insertions(+), 1 deletion(-) + +diff --git a/device_mapper/libdm-deptree.c b/device_mapper/libdm-deptree.c +index e4bf4c8..cd36404 100644 +--- a/device_mapper/libdm-deptree.c ++++ b/device_mapper/libdm-deptree.c +@@ -2039,7 +2039,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))) { +@@ -2060,9 +2060,15 @@ int dm_tree_activate_children(struct dm_tree_node *dnode, + + 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; +@@ -2120,6 +2126,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; +-- +2.27.0 + diff --git a/lvm2.spec b/lvm2.spec index 1bb995c..0c81218 100644 --- a/lvm2.spec +++ b/lvm2.spec @@ -43,7 +43,7 @@ Name: lvm2 Version: 2.03.14 -Release: 14 +Release: 15 Epoch: 8 Summary: Tools for logical volume management License: GPLv2+ and LGPLv2.1 and BSD @@ -82,6 +82,7 @@ Patch30: 0030-udev-create-symlinks-and-watch-even-in-suspended-sta.patch Patch31: 0031-udev-import-previous-results-of-blkid-when-in-suspen.patch Patch32: 0032-clean-up-group-struct-in-_stats_create_group-error-path.patch Patch33: 0033-dm-event-release-buffer-on-dm_event_get_version.patch +Patch34: 0034-reduce-unnecessary-looping-passed.patch BuildRequires: gcc BuildRequires: gcc-c++ @@ -508,6 +509,9 @@ fi %changelog +* Mon Apr 22 2024 yanshuai - 8:2.03.14-15 +- device_mapper: reduce unnecessary looping passed + * Fri Feb 2 2024 peng.zou - 8:2.03.14-14 - lvm2-lockd: add suport for ppc64le -- Gitee