!51 lvm2: fix three issues in one pr
Merge pull request !51 from liuzhiqiang/master
This commit is contained in:
commit
7d58c6a587
@ -0,0 +1,31 @@
|
|||||||
|
From cec542e471201e5cd82667a3ec39dc75441d65eb Mon Sep 17 00:00:00 2001
|
||||||
|
From: Zhiqiang Liu <liuzhiqiang26@huawei.com>
|
||||||
|
Date: Sun, 30 Jan 2022 11:14:01 +0800
|
||||||
|
Subject: [PATCH] 13-dm-disk.rules: check DM_NAME before create symlink
|
||||||
|
|
||||||
|
It is necessary to determin whether DM_NAME is NULL before
|
||||||
|
generating the symlink, otherwise the symlink systemd cannot
|
||||||
|
be deleted automatically, and there will be left.
|
||||||
|
|
||||||
|
Signed-off-by: wuguagnhao <wuguanghao3@huawei.com>
|
||||||
|
Signed-off-by: Zhiqiang Liu <liuzhiqiang26@huawei.com>
|
||||||
|
---
|
||||||
|
udev/13-dm-disk.rules.in | 2 +-
|
||||||
|
1 file changed, 1 insertion(+), 1 deletion(-)
|
||||||
|
|
||||||
|
diff --git a/udev/13-dm-disk.rules.in b/udev/13-dm-disk.rules.in
|
||||||
|
index 5355810..fcb2f37 100644
|
||||||
|
--- a/udev/13-dm-disk.rules.in
|
||||||
|
+++ b/udev/13-dm-disk.rules.in
|
||||||
|
@@ -14,7 +14,7 @@ ACTION!="add|change", GOTO="dm_end"
|
||||||
|
ENV{DM_UDEV_RULES_VSN}!="?*", GOTO="dm_end"
|
||||||
|
ENV{DM_UDEV_DISABLE_DISK_RULES_FLAG}=="1", GOTO="dm_end"
|
||||||
|
|
||||||
|
-SYMLINK+="disk/by-id/dm-name-$env{DM_NAME}"
|
||||||
|
+ENV{DM_NAME}=="?*", SYMLINK+="disk/by-id/dm-name-$env{DM_NAME}"
|
||||||
|
ENV{DM_UUID}=="?*", SYMLINK+="disk/by-id/dm-uuid-$env{DM_UUID}"
|
||||||
|
|
||||||
|
ENV{DM_SUSPENDED}=="1", GOTO="dm_end"
|
||||||
|
--
|
||||||
|
1.8.3.1
|
||||||
|
|
||||||
@ -0,0 +1,36 @@
|
|||||||
|
From 472dd53a091e0e4b0d2db8fcd10da3f408873633 Mon Sep 17 00:00:00 2001
|
||||||
|
From: Zhiqiang Liu <liuzhiqiang26@huawei.com>
|
||||||
|
Date: Sun, 30 Jan 2022 11:37:51 +0800
|
||||||
|
Subject: [PATCH] dev_name() determine whether the dev->aliases linked list is
|
||||||
|
empty before obtaining the dev name
|
||||||
|
|
||||||
|
If dev->aliases linked list is empty, then directly obtain the str
|
||||||
|
address of dm_str_list saved in dev_aliases.n, an unknown address
|
||||||
|
will be returned, which may cause segfault.
|
||||||
|
|
||||||
|
So we need to judge whether the dev->aliases linked list is empty before
|
||||||
|
getting it to avoid returning unknown address.
|
||||||
|
|
||||||
|
Signed-off-by: Zhiqiang Liu <liuzhiqiang26@huawei.com>
|
||||||
|
---
|
||||||
|
lib/device/dev-cache.c | 4 ++--
|
||||||
|
1 file changed, 2 insertions(+), 2 deletions(-)
|
||||||
|
|
||||||
|
diff --git a/lib/device/dev-cache.c b/lib/device/dev-cache.c
|
||||||
|
index 33b75a9..1263820 100644
|
||||||
|
--- a/lib/device/dev-cache.c
|
||||||
|
+++ b/lib/device/dev-cache.c
|
||||||
|
@@ -1703,8 +1703,8 @@ int dev_fd(struct device *dev)
|
||||||
|
|
||||||
|
const char *dev_name(const struct device *dev)
|
||||||
|
{
|
||||||
|
- return (dev && dev->aliases.n) ? dm_list_item(dev->aliases.n, struct dm_str_list)->str :
|
||||||
|
- unknown_device_name();
|
||||||
|
+ return (dev && dev->aliases.n && !dm_list_empty(&dev->aliases)) ?\
|
||||||
|
+ dm_list_item(dev->aliases.n, struct dm_str_list)->str : unknown_device_name();
|
||||||
|
}
|
||||||
|
|
||||||
|
bool dev_cache_has_md_with_end_superblock(struct dev_types *dt)
|
||||||
|
--
|
||||||
|
1.8.3.1
|
||||||
|
|
||||||
97
0014-lvm-code-reduce-cyclomatic-complexity.patch
Normal file
97
0014-lvm-code-reduce-cyclomatic-complexity.patch
Normal file
@ -0,0 +1,97 @@
|
|||||||
|
From f2fe10e3918bcab97a5948c3d88ca91a35b0ede2 Mon Sep 17 00:00:00 2001
|
||||||
|
From: lixiaokeng <lixiaokeng@huawei.com>
|
||||||
|
Date: Wed, 1 Jul 2020 11:07:06 +0000
|
||||||
|
Subject: [PATCH] lvm: code reduce cyclomatic complexity
|
||||||
|
|
||||||
|
enhance code and reduce cyclomatic complexity
|
||||||
|
|
||||||
|
Fix issue: https://gitee.com/src-openeuler/lvm2/issues/I4RZQQ
|
||||||
|
|
||||||
|
Signed-off-by:lixiaokeng <lixiaokeng@huawei.com>
|
||||||
|
Signed-off-by: Zhiqiang Liu <liuzhiqiang26@huawei.com>
|
||||||
|
---
|
||||||
|
lib/device/dev-cache.c | 41 +++++++++++++++++++++++------------------
|
||||||
|
1 file changed, 23 insertions(+), 18 deletions(-)
|
||||||
|
|
||||||
|
diff --git a/lib/device/dev-cache.c b/lib/device/dev-cache.c
|
||||||
|
index 94e39fa..868a218 100644
|
||||||
|
--- a/lib/device/dev-cache.c
|
||||||
|
+++ b/lib/device/dev-cache.c
|
||||||
|
@@ -1059,6 +1059,19 @@ static int _device_in_udev_db(const dev_t d)
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
+bool time_out(long* time_use, struct timeval start)
|
||||||
|
+{
|
||||||
|
+ struct timeval end;
|
||||||
|
+
|
||||||
|
+ if (!gettimeofday(&end, NULL)) {
|
||||||
|
+ *time_use = (end.tv_sec - start.tv_sec) * 1000000 + (end.tv_usec - start.tv_usec);
|
||||||
|
+ if (*time_use > udev_getdev_timemax) {
|
||||||
|
+ return true;
|
||||||
|
+ }
|
||||||
|
+ }
|
||||||
|
+ return false;
|
||||||
|
+}
|
||||||
|
+
|
||||||
|
static int _insert_udev_dir(struct udev *udev, const char *dir)
|
||||||
|
{
|
||||||
|
struct udev_enumerate *udev_enum = NULL;
|
||||||
|
@@ -1067,16 +1080,13 @@ static int _insert_udev_dir(struct udev *udev, const char *dir)
|
||||||
|
struct udev_device *device;
|
||||||
|
int r = 1;
|
||||||
|
int ret = -1;
|
||||||
|
- struct timeval start, end;
|
||||||
|
+ struct timeval start;
|
||||||
|
long time_use = 0;
|
||||||
|
|
||||||
|
ret = gettimeofday(&start,NULL);
|
||||||
|
udev_enum = udev_enumerate_new(udev);
|
||||||
|
- if (!ret && !gettimeofday(&end,NULL)) {
|
||||||
|
- time_use = (end.tv_sec - start.tv_sec) * 1000000 + (end.tv_usec - start.tv_usec);
|
||||||
|
- if (time_use > udev_getdev_timemax) {
|
||||||
|
- log_print_unless_silent("Call udev_enumerate_new use %ld usec", time_use);
|
||||||
|
- }
|
||||||
|
+ if (!ret && time_out(&time_use, start)) {
|
||||||
|
+ log_print_unless_silent("Call udev_enumerate_new use %ld usec", time_use);
|
||||||
|
}
|
||||||
|
if (!udev_enum) {
|
||||||
|
log_error("Failed to udev_enumerate_new.");
|
||||||
|
@@ -1110,14 +1120,12 @@ static int _insert_udev_dir(struct udev *udev, const char *dir)
|
||||||
|
entry_name);
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
+
|
||||||
|
ret = gettimeofday(&start,NULL);
|
||||||
|
node_name = udev_device_get_devnode(device);
|
||||||
|
- if (!ret && !gettimeofday(&end,NULL)) {
|
||||||
|
- time_use = (end.tv_sec - start.tv_sec) * 1000000 + (end.tv_usec - start.tv_usec);
|
||||||
|
- if (time_use > udev_getdev_timemax) {
|
||||||
|
- log_print_unless_silent("Call udev_device_get_devnode use %ld usec, device:%s",
|
||||||
|
- time_use, entry_name);
|
||||||
|
- }
|
||||||
|
+ if (!ret && time_out(&time_use, start)) {
|
||||||
|
+ log_print_unless_silent("Call udev_device_get_devnode use %ld usec, device:%s",
|
||||||
|
+ time_use, entry_name);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!node_name)
|
||||||
|
@@ -1128,12 +1136,9 @@ static int _insert_udev_dir(struct udev *udev, const char *dir)
|
||||||
|
|
||||||
|
ret = gettimeofday(&start,NULL);
|
||||||
|
first_entry = udev_device_get_devlinks_list_entry(device);
|
||||||
|
- if (!ret && !gettimeofday(&end,NULL)) {
|
||||||
|
- time_use = (end.tv_sec - start.tv_sec) * 1000000 + (end.tv_usec - start.tv_usec);
|
||||||
|
- if (time_use > udev_getdev_timemax) {
|
||||||
|
- log_print_unless_silent("Call udev_device_get_devlinks_list_entry use %ld usec, dev:%s",
|
||||||
|
- time_use, entry_name);
|
||||||
|
- }
|
||||||
|
+ if (!ret && time_out(&time_use, start)) {
|
||||||
|
+ log_print_unless_silent("Call udev_device_get_devlinks_list_entry use %ld usec, dev:%s",
|
||||||
|
+ time_use, entry_name);
|
||||||
|
}
|
||||||
|
udev_list_entry_foreach(symlink_entry, first_entry) {
|
||||||
|
if (!(symlink_name = udev_list_entry_get_name(symlink_entry)))
|
||||||
|
--
|
||||||
|
1.8.3.1
|
||||||
|
|
||||||
15
lvm2.spec
15
lvm2.spec
@ -43,7 +43,7 @@
|
|||||||
|
|
||||||
Name: lvm2
|
Name: lvm2
|
||||||
Version: 2.03.14
|
Version: 2.03.14
|
||||||
Release: 1
|
Release: 4
|
||||||
Epoch: 8
|
Epoch: 8
|
||||||
Summary: Tools for logical volume management
|
Summary: Tools for logical volume management
|
||||||
License: GPLv2+ and LGPLv2.1 and BSD
|
License: GPLv2+ and LGPLv2.1 and BSD
|
||||||
@ -60,6 +60,9 @@ Patch8: 0008-enhancement-add-dfx-log.patch
|
|||||||
Patch9: 0009-enhancement-syslog-more-when-use-libdevmapper-so.patch
|
Patch9: 0009-enhancement-syslog-more-when-use-libdevmapper-so.patch
|
||||||
Patch10: 0010-enhancement-log-it-when-disk-slow.patch
|
Patch10: 0010-enhancement-log-it-when-disk-slow.patch
|
||||||
Patch11: 0011-bugfix-lvm2-fix-the-reuse-of-va_list.patch
|
Patch11: 0011-bugfix-lvm2-fix-the-reuse-of-va_list.patch
|
||||||
|
Patch12: 0012-13-dm-disk.rules-check-DM_NAME-before-create-symlink.patch
|
||||||
|
Patch13: 0013-dev_name-determine-whether-the-dev-aliases-linked-li.patch
|
||||||
|
Patch14: 0014-lvm-code-reduce-cyclomatic-complexity.patch
|
||||||
|
|
||||||
BuildRequires: gcc
|
BuildRequires: gcc
|
||||||
BuildRequires: gcc-c++
|
BuildRequires: gcc-c++
|
||||||
@ -486,6 +489,16 @@ fi
|
|||||||
|
|
||||||
|
|
||||||
%changelog
|
%changelog
|
||||||
|
* Sun Jan 30 2022 Zhiqiang Liu <liuzhiqiang26@huawei.com> - 8.2.03.14-4
|
||||||
|
- lvm: code reduce cyclomatic complexity
|
||||||
|
|
||||||
|
* Sun Jan 30 2022 Zhiqiang Liu <liuzhiqiang26@huawei.com> - 8.2.03.14-3
|
||||||
|
- dev_name() determine whether the dev->aliases linked list is
|
||||||
|
empty before obtaining the dev name
|
||||||
|
|
||||||
|
* Sun Jan 30 2022 Zhiqiang Liu <liuzhiqiang26@huawei.com> - 8.2.03.14-2
|
||||||
|
- check DM_NAME before creating symlink in 13-dm-disk.rules
|
||||||
|
|
||||||
* Mon Nov 22 2021 wuguanghao<wuguanghao3@huawei.com> - 8:2.03.14-1
|
* Mon Nov 22 2021 wuguanghao<wuguanghao3@huawei.com> - 8:2.03.14-1
|
||||||
- upgrade to 2.03.14
|
- upgrade to 2.03.14
|
||||||
|
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user