main - toollib: prioritize processing thin-pool first
by Zdenek Kabelac
Gitweb: https://sourceware.org/git/?p=lvm2.git;a=commitdiff;h=dac827470195f463935...
Commit: dac827470195f46393522b20ef5678136f72126b
Parent: 7a99dac9ad44f0097fb64c48f7fe14a10aea07b7
Author: Zdenek Kabelac <zkabelac(a)redhat.com>
AuthorDate: Wed Mar 10 22:02:38 2021 +0100
Committer: Zdenek Kabelac <zkabelac(a)redhat.com>
CommitterDate: Thu Mar 11 00:18:01 2021 +0100
toollib: prioritize processing thin-pool first
When generating list of processed LV, add thin-pool to the head of the
list, while other LVs are added on tail.
This makes it easier when removing many thin volumes, to recognize easily
when its thin-pool is also supposed to be removed.
---
tools/toollib.c | 6 +++++-
1 file changed, 5 insertions(+), 1 deletion(-)
diff --git a/tools/toollib.c b/tools/toollib.c
index 3c81de26b..de51632a6 100644
--- a/tools/toollib.c
+++ b/tools/toollib.c
@@ -3082,7 +3082,11 @@ int process_each_lv_in_vg(struct cmd_context *cmd, struct volume_group *vg,
goto out;
}
final_lvl->lv = lvl->lv;
- dm_list_add(&final_lvs, &final_lvl->list);
+ if (lv_is_thin_pool(lvl->lv)) {
+ /* Add to the front of the list */
+ dm_list_add_h(&final_lvs, &final_lvl->list);
+ } else
+ dm_list_add(&final_lvs, &final_lvl->list);
}
log_set_report_object_name_and_id(NULL, NULL);
3 years, 2 months
main - lvconvert: fix error path on writecache removal
by Zdenek Kabelac
Gitweb: https://sourceware.org/git/?p=lvm2.git;a=commitdiff;h=7a99dac9ad44f0097fb...
Commit: 7a99dac9ad44f0097fb64c48f7fe14a10aea07b7
Parent: 127c2fc6e287f0f7edb9c0a061aaaba31bf47e45
Author: Zdenek Kabelac <zkabelac(a)redhat.com>
AuthorDate: Wed Mar 10 14:07:40 2021 +0100
Committer: Zdenek Kabelac <zkabelac(a)redhat.com>
CommitterDate: Wed Mar 10 23:32:12 2021 +0100
lvconvert: fix error path on writecache removal
After setting ret=0 there was missing 'goto out_release'.
Simplify with setting ret to 0 at front and to 1
at succesful end.
---
tools/lvconvert.c | 9 ++-------
1 file changed, 2 insertions(+), 7 deletions(-)
diff --git a/tools/lvconvert.c b/tools/lvconvert.c
index 4e27008fa..4c159b01e 100644
--- a/tools/lvconvert.c
+++ b/tools/lvconvert.c
@@ -5751,7 +5751,7 @@ static int _lvconvert_detach_writecache_when_clean(struct cmd_context *cmd,
struct logical_volume *lv_fast;
uint32_t lockd_state, error_flags;
uint64_t dirty;
- int ret;
+ int ret = 0;
idl = dm_list_item(dm_list_first(&lr->poll_idls), struct convert_poll_id_list);
id = idl->id;
@@ -5780,13 +5780,11 @@ static int _lvconvert_detach_writecache_when_clean(struct cmd_context *cmd,
if (!vg) {
log_error("Detaching writecache interrupted - reading VG failed.");
- ret = 0;
goto out_lockd;
}
if (error_flags) {
log_error("Detaching writecache interrupted - reading VG error %x.", error_flags);
- ret = 0;
goto out_release;
}
@@ -5797,13 +5795,11 @@ static int _lvconvert_detach_writecache_when_clean(struct cmd_context *cmd,
if (!lv) {
log_error("Detaching writecache interrupted - LV not found.");
- ret = 0;
goto out_release;
}
if (!lv_is_active(lv)) {
log_error("Detaching writecache interrupted - LV not active.");
- ret = 0;
goto out_release;
}
@@ -5840,7 +5836,6 @@ static int _lvconvert_detach_writecache_when_clean(struct cmd_context *cmd,
if (!lv_detach_writecache_cachevol(lv, 1)) {
log_error("Detaching writecache cachevol failed.");
- ret = 0;
goto out_release;
}
@@ -5851,7 +5846,7 @@ static int _lvconvert_detach_writecache_when_clean(struct cmd_context *cmd,
if (lr->remove_cache) {
if (lvremove_single(cmd, lv_fast, NULL) != ECMD_PROCESSED) {
log_error("Removing the writecache cachevol failed.");
- ret = 0;
+ goto out_release;
}
}
3 years, 2 months
main - lv_check_not_in_use: correct check
by Zdenek Kabelac
Gitweb: https://sourceware.org/git/?p=lvm2.git;a=commitdiff;h=127c2fc6e287f0f7edb...
Commit: 127c2fc6e287f0f7edb9c0a061aaaba31bf47e45
Parent: d4293b579df61b5eb96dfcce5a7ec8f2116e9561
Author: Zdenek Kabelac <zkabelac(a)redhat.com>
AuthorDate: Wed Mar 10 14:05:03 2021 +0100
Committer: Zdenek Kabelac <zkabelac(a)redhat.com>
CommitterDate: Wed Mar 10 23:32:12 2021 +0100
lv_check_not_in_use: correct check
Since lv_info() may return 0 without setting info struct,
make the test correct and even more readable.
---
lib/activate/activate.c | 6 ++++--
1 file changed, 4 insertions(+), 2 deletions(-)
diff --git a/lib/activate/activate.c b/lib/activate/activate.c
index c450eab14..4452d4d40 100644
--- a/lib/activate/activate.c
+++ b/lib/activate/activate.c
@@ -834,8 +834,10 @@ int lv_check_not_in_use(const struct logical_volume *lv, int error_if_used)
struct lvinfo info;
unsigned int open_count_check_retries;
- if (!lv_info(lv->vg->cmd, lv, 0, &info, 1, 0) || !info.exists || !info.open_count)
- return !info.exists ? 2 : 1;
+ if (!lv_info(lv->vg->cmd, lv, 0, &info, 1, 0) || !info.exists)
+ return 2;
+ else if (!info.open_count)
+ return 1;
/* If sysfs is not used, use open_count information only. */
if (dm_sysfs_dir()) {
3 years, 2 months
main - tests: Skip test killing kernel
by Marian Csontos
Gitweb: https://sourceware.org/git/?p=lvm2.git;a=commitdiff;h=d4293b579df61b5eb96...
Commit: d4293b579df61b5eb96dfcce5a7ec8f2116e9561
Parent: 6097dfb9ad2faae1c28295b35e1fba82cb4b6f8b
Author: Marian Csontos <mcsontos(a)redhat.com>
AuthorDate: Wed Mar 10 15:50:35 2021 +0100
Committer: Marian Csontos <mcsontos(a)redhat.com>
CommitterDate: Wed Mar 10 16:31:04 2021 +0100
tests: Skip test killing kernel
Fix the pattern and for now skip all RHEL-8.4 kernels
Bug 1916891
---
test/shell/lvconvert-raid-reshape-stripes-load-reload.sh | 6 +++++-
1 file changed, 5 insertions(+), 1 deletion(-)
diff --git a/test/shell/lvconvert-raid-reshape-stripes-load-reload.sh b/test/shell/lvconvert-raid-reshape-stripes-load-reload.sh
index 6fe34250a..3023782dd 100644
--- a/test/shell/lvconvert-raid-reshape-stripes-load-reload.sh
+++ b/test/shell/lvconvert-raid-reshape-stripes-load-reload.sh
@@ -22,7 +22,11 @@ which mkfs.ext4 || skip
aux have_raid 1 13 2 || skip
case "$(uname -r)" in
- 5.[891]*|3.10.0-862*|4.18.0-283.el8) die "Cannot run this test on unfixed kernel." ;;
+ 5.[891]*|3.10.0-862*) die "Cannot run this test on unfixed kernel." ;;
+ 4.18.0-*.el8*)
+ REL="$(uname -r)"
+ REL="${REL#4.18.0-}"
+ [[ "${REL%%.*}" -lt 283 ]] || die "Cannot run this test on unfixed kernel." ;;
esac
mount_dir="mnt"
3 years, 2 months
main - cov: happier with defined extent_size
by Zdenek Kabelac
Gitweb: https://sourceware.org/git/?p=lvm2.git;a=commitdiff;h=6097dfb9ad2faae1c28...
Commit: 6097dfb9ad2faae1c28295b35e1fba82cb4b6f8b
Parent: 94712e3233ac7610ed74c3207c131ec7d9a843c1
Author: Zdenek Kabelac <zkabelac(a)redhat.com>
AuthorDate: Tue Mar 9 19:28:24 2021 +0100
Committer: Zdenek Kabelac <zkabelac(a)redhat.com>
CommitterDate: Wed Mar 10 01:35:02 2021 +0100
cov: happier with defined extent_size
Set extent_size with != 0 value so there is not division by 0
in any code path.
---
tools/toollib.c | 1 +
1 file changed, 1 insertion(+)
diff --git a/tools/toollib.c b/tools/toollib.c
index b9be54ebb..3c81de26b 100644
--- a/tools/toollib.c
+++ b/tools/toollib.c
@@ -4006,6 +4006,7 @@ static int _process_duplicate_pvs(struct cmd_context *cmd,
};
struct volume_group dummy_vg = {
+ .extent_size = 1,
.fid = &dummy_fid,
.name = "",
.system_id = (char *) "",
3 years, 2 months
main - cov: defined flv
by Zdenek Kabelac
Gitweb: https://sourceware.org/git/?p=lvm2.git;a=commitdiff;h=94712e3233ac7610ed7...
Commit: 94712e3233ac7610ed74c3207c131ec7d9a843c1
Parent: a66380ea3ebcdb21e5b63f5991810e421092b245
Author: Zdenek Kabelac <zkabelac(a)redhat.com>
AuthorDate: Tue Mar 9 16:42:38 2021 +0100
Committer: Zdenek Kabelac <zkabelac(a)redhat.com>
CommitterDate: Wed Mar 10 01:35:02 2021 +0100
cov: defined flv
---
lib/activate/activate.c | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/lib/activate/activate.c b/lib/activate/activate.c
index ddad7c3f7..c450eab14 100644
--- a/lib/activate/activate.c
+++ b/lib/activate/activate.c
@@ -2846,7 +2846,7 @@ static int _deactivate_sub_lv_cb(struct logical_volume *lv, void *data)
*/
int deactivate_lv_with_sub_lv(const struct logical_volume *lv)
{
- struct logical_volume *flv;
+ struct logical_volume *flv = NULL;
if (!deactivate_lv(lv->vg->cmd, lv)) {
log_error("Cannot deactivate logical volume %s.",
@@ -2856,7 +2856,7 @@ int deactivate_lv_with_sub_lv(const struct logical_volume *lv)
if (!for_each_sub_lv((struct logical_volume *)lv, _deactivate_sub_lv_cb, &flv)) {
log_error("Cannot deactivate subvolume %s of logical volume %s.",
- display_lvname(flv), display_lvname(lv));
+ (flv) ? display_lvname(flv) : "", display_lvname(lv));
return 0;
}
3 years, 2 months
main - cov: ensure settings is set
by Zdenek Kabelac
Gitweb: https://sourceware.org/git/?p=lvm2.git;a=commitdiff;h=a66380ea3ebcdb21e5b...
Commit: a66380ea3ebcdb21e5b63f5991810e421092b245
Parent: f7912635a0698b73120adf499f335145506a8b9e
Author: Zdenek Kabelac <zkabelac(a)redhat.com>
AuthorDate: Tue Mar 9 16:32:36 2021 +0100
Committer: Zdenek Kabelac <zkabelac(a)redhat.com>
CommitterDate: Wed Mar 10 01:35:02 2021 +0100
cov: ensure settings is set
---
lib/report/properties.c | 17 ++++++++++-------
lib/report/report.c | 9 +++++----
2 files changed, 15 insertions(+), 11 deletions(-)
diff --git a/lib/report/properties.c b/lib/report/properties.c
index 82a6a7856..f2174b83c 100644
--- a/lib/report/properties.c
+++ b/lib/report/properties.c
@@ -93,23 +93,26 @@ static uint32_t _raidmaxrecoveryrate(const struct logical_volume *lv)
static const char *_raidintegritymode(const struct logical_volume *lv)
{
- struct integrity_settings *settings;
+ struct integrity_settings *settings = NULL;
if (lv_raid_has_integrity((struct logical_volume *)lv))
lv_get_raid_integrity_settings((struct logical_volume *)lv, &settings);
else if (lv_is_integrity(lv))
settings = &first_seg(lv)->integrity_settings;
- if (settings->mode[0] == 'B')
- return "bitmap";
- if (settings->mode[0] == 'J')
- return "journal";
+ if (settings) {
+ switch (settings->mode[0]) {
+ case 'B': return "bitmap";
+ case 'J': return "journal";
+ }
+ }
+
return "unknown";
}
static uint32_t _raidintegrityblocksize(const struct logical_volume *lv)
{
- struct integrity_settings *settings;
+ struct integrity_settings *settings = NULL;
if (lv_raid_has_integrity((struct logical_volume *)lv))
lv_get_raid_integrity_settings((struct logical_volume *)lv, &settings);
@@ -118,7 +121,7 @@ static uint32_t _raidintegrityblocksize(const struct logical_volume *lv)
else
return 0;
- return settings->block_size;
+ return (settings) ? settings->block_size : 0;
}
static uint64_t _integritymismatches(const struct logical_volume *lv)
diff --git a/lib/report/report.c b/lib/report/report.c
index 80fae2147..2f5811a96 100644
--- a/lib/report/report.c
+++ b/lib/report/report.c
@@ -3278,7 +3278,7 @@ static int _raidintegritymode_disp(struct dm_report *rh __attribute__((unused)),
void *private __attribute__((unused)))
{
struct logical_volume *lv = (struct logical_volume *) data;
- struct integrity_settings *settings;
+ struct integrity_settings *settings = NULL;
const char *mode = NULL;
char *repstr;
@@ -3289,7 +3289,7 @@ static int _raidintegritymode_disp(struct dm_report *rh __attribute__((unused)),
else
goto out;
- if (settings->mode[0]) {
+ if (settings && settings->mode[0]) {
if (settings->mode[0] == 'B')
mode = "bitmap";
else if (settings->mode[0] == 'J')
@@ -3314,13 +3314,14 @@ static int _raidintegrityblocksize_disp(struct dm_report *rh __attribute__((unus
void *private __attribute__((unused)))
{
struct logical_volume *lv = (struct logical_volume *) data;
- struct integrity_settings *settings;
+ struct integrity_settings *settings = NULL;
if (lv_raid_has_integrity(lv))
lv_get_raid_integrity_settings(lv, &settings);
else if (lv_is_integrity(lv))
settings = &first_seg(lv)->integrity_settings;
- else
+
+ if (!settings)
return dm_report_field_int32(rh, field, &GET_TYPE_RESERVED_VALUE(num_undef_32));
return dm_report_field_uint32(rh, field, &settings->block_size);
3 years, 2 months
main - cov: ensure buffer is initialized
by Zdenek Kabelac
Gitweb: https://sourceware.org/git/?p=lvm2.git;a=commitdiff;h=f7912635a0698b73120...
Commit: f7912635a0698b73120adf499f335145506a8b9e
Parent: 8a0367524182f55e7e982f0b5700d90f2a9519e2
Author: Zdenek Kabelac <zkabelac(a)redhat.com>
AuthorDate: Tue Mar 9 16:12:38 2021 +0100
Committer: Zdenek Kabelac <zkabelac(a)redhat.com>
CommitterDate: Wed Mar 10 01:35:02 2021 +0100
cov: ensure buffer is initialized
---
lib/config/config.c | 2 ++
libdm/dm-tools/dmsetup.c | 1 +
2 files changed, 3 insertions(+)
diff --git a/lib/config/config.c b/lib/config/config.c
index 409555096..485063a3d 100644
--- a/lib/config/config.c
+++ b/lib/config/config.c
@@ -1141,6 +1141,8 @@ int config_def_check(struct cft_check_handle *handle)
* sections and settings with full path as a key.
* If section name is variable, use '#' as a substitute.
*/
+ *vp = 0;
+ *rp = 0;
if (!handle->cmd->cft_def_hash) {
if (!(handle->cmd->cft_def_hash = dm_hash_create(60))) {
log_error("Failed to create configuration definition hash.");
diff --git a/libdm/dm-tools/dmsetup.c b/libdm/dm-tools/dmsetup.c
index 46fa81069..a3d1248bc 100644
--- a/libdm/dm-tools/dmsetup.c
+++ b/libdm/dm-tools/dmsetup.c
@@ -5158,6 +5158,7 @@ static int _stats_group_segments(struct dm_stats *dms, uint64_t *region_ids,
return 0;
}
+ *regions = 0;
for (i = 0; i < count; i++) {
/*
* We don't expect large numbers of segments (compared to e.g.
3 years, 2 months
main - cov: variable initialization
by Zdenek Kabelac
Gitweb: https://sourceware.org/git/?p=lvm2.git;a=commitdiff;h=8a0367524182f55e7e9...
Commit: 8a0367524182f55e7e982f0b5700d90f2a9519e2
Parent: bee9b5c1d8d8f54c3ffe3c96abd2ce28cd2b5558
Author: Zdenek Kabelac <zkabelac(a)redhat.com>
AuthorDate: Tue Mar 9 16:05:46 2021 +0100
Committer: Zdenek Kabelac <zkabelac(a)redhat.com>
CommitterDate: Wed Mar 10 01:34:58 2021 +0100
cov: variable initialization
---
lib/device/device_id.c | 2 +-
lib/format_text/text_label.c | 2 +-
tools/pvscan.c | 2 +-
3 files changed, 3 insertions(+), 3 deletions(-)
diff --git a/lib/device/device_id.c b/lib/device/device_id.c
index 1c4ba78f6..2de8b0a14 100644
--- a/lib/device/device_id.c
+++ b/lib/device/device_id.c
@@ -761,7 +761,7 @@ out:
static void _device_ids_update_try(struct cmd_context *cmd)
{
- int held;
+ int held = 0;
/* Defer updates to non-pvscan-cache commands. */
if (cmd->pvscan_cache_single) {
diff --git a/lib/format_text/text_label.c b/lib/format_text/text_label.c
index 1674126c8..be5195039 100644
--- a/lib/format_text/text_label.c
+++ b/lib/format_text/text_label.c
@@ -379,7 +379,7 @@ static int _text_read(struct cmd_context *cmd, struct labeller *labeller, struct
struct label_header *lh = (struct label_header *) label_buf;
struct pv_header *pvhdr;
struct pv_header_extension *pvhdr_ext;
- struct metadata_area *mda;
+ struct metadata_area *mda = NULL;
struct metadata_area *mda1 = NULL;
struct metadata_area *mda2 = NULL;
struct disk_locn *dlocn_xl;
diff --git a/tools/pvscan.c b/tools/pvscan.c
index fdd8c482f..8bcfe311c 100644
--- a/tools/pvscan.c
+++ b/tools/pvscan.c
@@ -1088,7 +1088,7 @@ static int _get_args(struct cmd_context *cmd, int argc, char **argv,
struct arg_value_group_list *current_group;
struct pvscan_arg *arg;
const char *arg_name;
- int major, minor;
+ int major = -1, minor = -1;
/* Process position args, which can be /dev/name or major:minor */
3 years, 2 months
main - cov: mask uninitialized value
by Zdenek Kabelac
Gitweb: https://sourceware.org/git/?p=lvm2.git;a=commitdiff;h=bee9b5c1d8d8f54c3ff...
Commit: bee9b5c1d8d8f54c3ffe3c96abd2ce28cd2b5558
Parent: 74936f53f7123c092d2ba6b9b7883db47bf0c61c
Author: Zdenek Kabelac <zkabelac(a)redhat.com>
AuthorDate: Tue Mar 9 15:58:48 2021 +0100
Committer: Zdenek Kabelac <zkabelac(a)redhat.com>
CommitterDate: Wed Mar 10 01:34:27 2021 +0100
cov: mask uninitialized value
Coverity doesn't track ioctl() too well, so let's just make it quiet.
---
device_mapper/libdm-common.c | 2 +-
lib/device/dev-dasd.c | 2 +-
lib/device/dev-io.c | 2 +-
lib/device/dev-type.c | 2 +-
libdm/libdm-common.c | 2 +-
5 files changed, 5 insertions(+), 5 deletions(-)
diff --git a/device_mapper/libdm-common.c b/device_mapper/libdm-common.c
index a2304b603..c0dde2071 100644
--- a/device_mapper/libdm-common.c
+++ b/device_mapper/libdm-common.c
@@ -1224,7 +1224,7 @@ int get_dev_node_read_ahead(const char *dev_name, uint32_t major, uint32_t minor
int len;
int r = 1;
int fd;
- long read_ahead_long;
+ long read_ahead_long = 0;
/*
* If we know the device number, use sysfs if we can.
diff --git a/lib/device/dev-dasd.c b/lib/device/dev-dasd.c
index dc11030d7..0448e1f78 100644
--- a/lib/device/dev-dasd.c
+++ b/lib/device/dev-dasd.c
@@ -81,7 +81,7 @@ typedef struct dasd_information2_t {
int dasd_is_cdl_formatted(struct device *dev)
{
int ret = 0;
- dasd_information2_t dasd_info2;
+ dasd_information2_t dasd_info2 = { 0 };
if (!dev_open_readonly(dev))
return_0;
diff --git a/lib/device/dev-io.c b/lib/device/dev-io.c
index 9b007dcaa..17993d82c 100644
--- a/lib/device/dev-io.c
+++ b/lib/device/dev-io.c
@@ -124,7 +124,7 @@ static int _dev_get_size_dev(struct device *dev, uint64_t *size)
static int _dev_read_ahead_dev(struct device *dev, uint32_t *read_ahead)
{
- long read_ahead_long;
+ long read_ahead_long = 0;
if (dev->read_ahead != -1) {
*read_ahead = (uint32_t) dev->read_ahead;
diff --git a/lib/device/dev-type.c b/lib/device/dev-type.c
index 40c2a748e..7cbb7fbed 100644
--- a/lib/device/dev-type.c
+++ b/lib/device/dev-type.c
@@ -891,7 +891,7 @@ static int _wipe_signature(struct device *dev, const char *type, const char *nam
int (*signature_detection_fn)(struct device *dev, uint64_t *offset_found, int full))
{
int wipe;
- uint64_t offset_found;
+ uint64_t offset_found = 0;
wipe = signature_detection_fn(dev, &offset_found, 1);
if (wipe == -1) {
diff --git a/libdm/libdm-common.c b/libdm/libdm-common.c
index f2ea64905..1f3fe1642 100644
--- a/libdm/libdm-common.c
+++ b/libdm/libdm-common.c
@@ -1222,7 +1222,7 @@ int get_dev_node_read_ahead(const char *dev_name, uint32_t major, uint32_t minor
int len;
int r = 1;
int fd;
- long read_ahead_long;
+ long read_ahead_long = 0;
/*
* If we know the device number, use sysfs if we can.
3 years, 2 months