main - cov: simplier code
by Zdenek Kabelac
Gitweb: https://sourceware.org/git/?p=lvm2.git;a=commitdiff;h=662020c221fdb3e23c6...
Commit: 662020c221fdb3e23c66947f6c81f99a0950744a
Parent: d7e922480e04ecfb7c4d8b2d42533699ddef5c34
Author: Zdenek Kabelac <zkabelac(a)redhat.com>
AuthorDate: Wed Apr 26 13:20:56 2023 +0200
Committer: Zdenek Kabelac <zkabelac(a)redhat.com>
CommitterDate: Sat May 6 19:22:05 2023 +0200
cov: simplier code
Avoid coverity to contruct some abstract scenarions of 'cft'
modification and simplify the code at the same time.
---
lib/config/config.c | 35 +++++++++++++++++++++--------------
1 file changed, 21 insertions(+), 14 deletions(-)
diff --git a/lib/config/config.c b/lib/config/config.c
index 5986e64b1..5531e431d 100644
--- a/lib/config/config.c
+++ b/lib/config/config.c
@@ -1300,8 +1300,9 @@ const char *find_config_tree_str(struct cmd_context *cmd, int id, struct profile
if (item->type != CFG_TYPE_STRING)
log_error(INTERNAL_ERROR "%s cfg tree element not declared as string.", path);
- str = _config_disabled(cmd, item, path) ? cfg_def_get_default_value(cmd, item, CFG_TYPE_STRING, profile)
- : dm_config_tree_find_str(cmd->cft, path, cfg_def_get_default_value(cmd, item, CFG_TYPE_STRING, profile));
+ str = cfg_def_get_default_value(cmd, item, CFG_TYPE_STRING, profile);
+ if (!_config_disabled(cmd, item, path))
+ str = dm_config_tree_find_str(cmd->cft, path, str);
if (profile_applied && profile)
remove_config_tree_by_source(cmd, profile->source);
@@ -1324,8 +1325,9 @@ const char *find_config_tree_str_allow_empty(struct cmd_context *cmd, int id, st
if (!(item->flags & CFG_ALLOW_EMPTY))
log_error(INTERNAL_ERROR "%s cfg tree element not declared to allow empty values.", path);
- str = _config_disabled(cmd, item, path) ? cfg_def_get_default_value(cmd, item, CFG_TYPE_STRING, profile)
- : dm_config_tree_find_str_allow_empty(cmd->cft, path, cfg_def_get_default_value(cmd, item, CFG_TYPE_STRING, profile));
+ str = cfg_def_get_default_value(cmd, item, CFG_TYPE_STRING, profile);
+ if (!_config_disabled(cmd, item, path))
+ str = dm_config_tree_find_str_allow_empty(cmd->cft, path, str);
if (profile_applied && profile)
remove_config_tree_by_source(cmd, profile->source);
@@ -1346,8 +1348,9 @@ int find_config_tree_int(struct cmd_context *cmd, int id, struct profile *profil
if (item->type != CFG_TYPE_INT)
log_error(INTERNAL_ERROR "%s cfg tree element not declared as integer.", path);
- i = _config_disabled(cmd, item, path) ? cfg_def_get_default_value(cmd, item, CFG_TYPE_INT, profile)
- : dm_config_tree_find_int(cmd->cft, path, cfg_def_get_default_value(cmd, item, CFG_TYPE_INT, profile));
+ i = cfg_def_get_default_value(cmd, item, CFG_TYPE_INT, profile);
+ if (!_config_disabled(cmd, item, path))
+ i = dm_config_tree_find_int(cmd->cft, path, i);
if (profile_applied && profile)
remove_config_tree_by_source(cmd, profile->source);
@@ -1368,8 +1371,9 @@ int64_t find_config_tree_int64(struct cmd_context *cmd, int id, struct profile *
if (item->type != CFG_TYPE_INT)
log_error(INTERNAL_ERROR "%s cfg tree element not declared as integer.", path);
- i64 = _config_disabled(cmd, item, path) ? cfg_def_get_default_value(cmd, item, CFG_TYPE_INT, profile)
- : dm_config_tree_find_int64(cmd->cft, path, cfg_def_get_default_value(cmd, item, CFG_TYPE_INT, profile));
+ i64 = cfg_def_get_default_value(cmd, item, CFG_TYPE_INT, profile);
+ if (!_config_disabled(cmd, item, path))
+ i64 = dm_config_tree_find_int64(cmd->cft, path, i64);
if (profile_applied && profile)
remove_config_tree_by_source(cmd, profile->source);
@@ -1390,8 +1394,9 @@ float find_config_tree_float(struct cmd_context *cmd, int id, struct profile *pr
if (item->type != CFG_TYPE_FLOAT)
log_error(INTERNAL_ERROR "%s cfg tree element not declared as float.", path);
- f = _config_disabled(cmd, item, path) ? cfg_def_get_default_value(cmd, item, CFG_TYPE_FLOAT, profile)
- : dm_config_tree_find_float(cmd->cft, path, cfg_def_get_default_value(cmd, item, CFG_TYPE_FLOAT, profile));
+ f = cfg_def_get_default_value(cmd, item, CFG_TYPE_FLOAT, profile);
+ if (!_config_disabled(cmd, item, path))
+ f = dm_config_tree_find_float(cmd->cft, path, f);
if (profile_applied && profile)
remove_config_tree_by_source(cmd, profile->source);
@@ -1410,8 +1415,9 @@ int find_config_bool(struct cmd_context *cmd, struct dm_config_tree *cft, int id
if (item->type != CFG_TYPE_BOOL)
log_error(INTERNAL_ERROR "%s cfg tree element not declared as boolean.", path);
- b = _config_disabled(cmd, item, path) ? cfg_def_get_default_value(cmd, item, CFG_TYPE_BOOL, NULL)
- : dm_config_tree_find_bool(cft, path, cfg_def_get_default_value(cmd, item, CFG_TYPE_BOOL, NULL));
+ b = cfg_def_get_default_value(cmd, item, CFG_TYPE_BOOL, NULL);
+ if (!_config_disabled(cmd, item, path))
+ b = dm_config_tree_find_bool(cft, path, b);
return b;
}
@@ -1429,8 +1435,9 @@ int find_config_tree_bool(struct cmd_context *cmd, int id, struct profile *profi
if (item->type != CFG_TYPE_BOOL)
log_error(INTERNAL_ERROR "%s cfg tree element not declared as boolean.", path);
- b = _config_disabled(cmd, item, path) ? cfg_def_get_default_value(cmd, item, CFG_TYPE_BOOL, profile)
- : dm_config_tree_find_bool(cmd->cft, path, cfg_def_get_default_value(cmd, item, CFG_TYPE_BOOL, profile));
+ b = cfg_def_get_default_value(cmd, item, CFG_TYPE_BOOL, profile);
+ if (!_config_disabled(cmd, item, path))
+ b = dm_config_tree_find_bool(cmd->cft, path, b);
if (profile_applied && profile)
remove_config_tree_by_source(cmd, profile->source);
6 months, 4 weeks
main - Fix "lvconvert -m 0 will always take rimage_0 even if it is out-of-sync"
by Heinz Mauelshagen
Gitweb: https://sourceware.org/git/?p=lvm2.git;a=commitdiff;h=d7e922480e04ecfb7c4...
Commit: d7e922480e04ecfb7c4d8b2d42533699ddef5c34
Parent: 368381fd4022dc99ffe551b30ed75c3ddbc5c5c8
Author: heinzm <heinzm(a)redhat.com>
AuthorDate: Fri May 5 15:00:49 2023 +0200
Committer: heinzm <heinzm(a)redhat.com>
CommitterDate: Fri May 5 20:51:58 2023 +0200
Fix "lvconvert -m 0 will always take rimage_0 even if it is out-of-sync"
Bail out in case first rimage is out-of-sync.
Refresh first, i.e. "lvchange --resync $RaidLV",
then retry downgrade to linear after resynchronization.
---
lib/metadata/raid_manip.c | 13 +++++++++++--
1 file changed, 11 insertions(+), 2 deletions(-)
diff --git a/lib/metadata/raid_manip.c b/lib/metadata/raid_manip.c
index 0e6a77bac..5112989ab 100644
--- a/lib/metadata/raid_manip.c
+++ b/lib/metadata/raid_manip.c
@@ -3112,14 +3112,23 @@ static int _raid_remove_images(struct logical_volume *lv, int yes,
{
struct dm_list removed_lvs;
- if (!archive(lv->vg))
- return_0;
+ if (new_count == 1) {
+ struct lv_segment *seg = first_seg(lv);
+
+ if (seg_is_raid1(seg) && !lv_raid_image_in_sync(seg_lv(seg, 0))) {
+ log_error("%s is out-of-sync! Please try refreshing first.", display_lvname(lv));
+ return 0;
+ }
+ }
if (!removal_lvs) {
dm_list_init(&removed_lvs);
removal_lvs = &removed_lvs;
}
+ if (!archive(lv->vg))
+ return_0;
+
if (!_raid_extract_images(lv, 0, new_count, allocate_pvs, 1,
removal_lvs, removal_lvs)) {
log_error("Failed to extract images from %s.",
6 months, 4 weeks
main - lvreduce: make _lvseg_get_stripes handle integrity layer
by David Teigland
Gitweb: https://sourceware.org/git/?p=lvm2.git;a=commitdiff;h=368381fd4022dc99ffe...
Commit: 368381fd4022dc99ffe551b30ed75c3ddbc5c5c8
Parent: c4440b5b495a2d11ff541dd7e7791e2a83c83609
Author: David Teigland <teigland(a)redhat.com>
AuthorDate: Tue May 2 16:12:23 2023 -0500
Committer: David Teigland <teigland(a)redhat.com>
CommitterDate: Wed May 3 11:34:59 2023 -0500
lvreduce: make _lvseg_get_stripes handle integrity layer
lvreduce uses _lvseg_get_stripes() which was unable to get raid stripe
info with an integrity layer present. This caused lvreduce on a
raid+integrity LV to fail prematurely when checking stripe parameters.
An unhelpful error message about stripe size would be printed.
---
lib/metadata/lv_manip.c | 35 ++++++++++++++++++++++++++---------
1 file changed, 26 insertions(+), 9 deletions(-)
diff --git a/lib/metadata/lv_manip.c b/lib/metadata/lv_manip.c
index 762a65785..2dfa3c77b 100644
--- a/lib/metadata/lv_manip.c
+++ b/lib/metadata/lv_manip.c
@@ -5144,22 +5144,39 @@ int lv_extend_policy_calculate_percent(struct logical_volume *lv,
static uint32_t _lvseg_get_stripes(struct lv_segment *seg, uint32_t *stripesize)
{
- uint32_t s;
- struct lv_segment *seg_mirr;
+ uint32_t s, a;
+ struct lv_segment *seg_get, *seg_image, *seg_iorig;
+ struct logical_volume *lv_image, *lv_iorig;
/* If segment mirrored, check if images are striped */
- if (seg_is_mirrored(seg))
+ if (seg_is_mirrored(seg)) {
for (s = 0; s < seg->area_count; s++) {
if (seg_type(seg, s) != AREA_LV)
continue;
- seg_mirr = first_seg(seg_lv(seg, s));
- if (seg_is_striped(seg_mirr)) {
- seg = seg_mirr;
+ lv_image = seg_lv(seg, s);
+ seg_image = first_seg(lv_image);
+ seg_get = NULL;
+
+ if (seg_is_integrity(seg_image)) {
+ /* Get stripe values from the iorig layer. */
+ for (a = 0; a < seg_image->area_count; a++) {
+ lv_iorig = seg_lv(seg_image, a);
+ seg_iorig = first_seg(lv_iorig);
+ seg_get = seg_iorig;
+ break;
+ }
+ } else {
+ /* Get stripe values from the image layer. */
+ seg_get = seg_image;
+ }
+
+ if (seg_get && seg_is_striped(seg_get)) {
+ seg = seg_get;
break;
}
}
-
+ }
if (seg_is_striped(seg)) {
*stripesize = seg->stripe_size;
@@ -5168,7 +5185,7 @@ static uint32_t _lvseg_get_stripes(struct lv_segment *seg, uint32_t *stripesize)
if (seg_is_raid(seg)) {
*stripesize = seg->stripe_size;
- return _raid_stripes_count(seg);
+ return _raid_stripes_count(seg);
}
*stripesize = 0;
@@ -5593,7 +5610,7 @@ static int _lvresize_adjust_extents(struct logical_volume *lv,
seg_size /= seg_mirrors;
lp->extents = logical_extents_used + seg_size;
break;
- }
+ }
} else if (new_extents <= logical_extents_used + seg_logical_extents) {
seg_size = new_extents - logical_extents_used;
lp->extents = new_extents;
7 months