master - cov: fix memleak for duplicate device
by Zdenek Kabelac
Gitweb: https://sourceware.org/git/?p=lvm2.git;a=commitdiff;h=44bf9c9a6af2d76d4de...
Commit: 44bf9c9a6af2d76d4de04b456362abd4ed454ff9
Parent: 82e6b820b84512ffb9f124c5d450c1036e7dd843
Author: Zdenek Kabelac <zkabelac(a)redhat.com>
AuthorDate: Thu Nov 14 17:08:20 2019 +0100
Committer: Zdenek Kabelac <zkabelac(a)redhat.com>
CommitterDate: Thu Nov 14 18:06:42 2019 +0100
cov: fix memleak for duplicate device
For dev_in_device_list() != 0 allocated 'devl' was
actually leaking - so instead allocate 'devl' only
when !dev_in_device_list() and indent code around.
---
lib/cache/lvmcache.c | 29 +++++++++++++++--------------
1 files changed, 15 insertions(+), 14 deletions(-)
diff --git a/lib/cache/lvmcache.c b/lib/cache/lvmcache.c
index 99818de..25d110d 100644
--- a/lib/cache/lvmcache.c
+++ b/lib/cache/lvmcache.c
@@ -1952,24 +1952,25 @@ struct lvmcache_info *lvmcache_add(struct labeller *labeller,
strncpy(dev->pvid, pvid_s, sizeof(dev->pvid));
- /*
- * Keep the existing PV/dev in lvmcache, and save the
- * new duplicate in the list of duplicates. After
- * scanning is complete, compare the duplicate devs
- * with those in lvmcache to check if one of the
- * duplicates is preferred and if so switch lvmcache to
- * use it.
- */
-
- if (!(devl = zalloc(sizeof(*devl))))
- return_NULL;
- devl->dev = dev;
-
/* shouldn't happen */
if (dev_in_device_list(dev, &_initial_duplicates))
log_debug_cache("Initial duplicate already in list %s", dev_name(dev));
- else
+ else {
+ /*
+ * Keep the existing PV/dev in lvmcache, and save the
+ * new duplicate in the list of duplicates. After
+ * scanning is complete, compare the duplicate devs
+ * with those in lvmcache to check if one of the
+ * duplicates is preferred and if so switch lvmcache to
+ * use it.
+ */
+
+ if (!(devl = zalloc(sizeof(*devl))))
+ return_NULL;
+ devl->dev = dev;
+
dm_list_add(&_initial_duplicates, &devl->list);
+ }
if (is_duplicate)
*is_duplicate = 1;
4 years, 5 months
master - cov: check for NULL
by Zdenek Kabelac
Gitweb: https://sourceware.org/git/?p=lvm2.git;a=commitdiff;h=82e6b820b84512ffb9f...
Commit: 82e6b820b84512ffb9f124c5d450c1036e7dd843
Parent: 43f149526d5074dbc6deeaca38e30d02611eadf8
Author: Zdenek Kabelac <zkabelac(a)redhat.com>
AuthorDate: Thu Nov 14 17:04:33 2019 +0100
Committer: Zdenek Kabelac <zkabelac(a)redhat.com>
CommitterDate: Thu Nov 14 18:06:42 2019 +0100
cov: check for NULL
Since we check for NULL pointers earlier we need
to be consistent across function - since the NULL
would applies across whole function.
When dropping 'mda' check - we are actually
already dereferencing it before - so it can't
be NULL at that places (and it's validated
before entering _read_mda_header_and_metadata).
---
lib/format_text/format-text.c | 2 +-
lib/format_text/text_label.c | 6 ++----
tools/pvscan.c | 2 +-
tools/toollib.c | 3 ++-
4 files changed, 6 insertions(+), 7 deletions(-)
diff --git a/lib/format_text/format-text.c b/lib/format_text/format-text.c
index 894a710..f3536e7 100644
--- a/lib/format_text/format-text.c
+++ b/lib/format_text/format-text.c
@@ -341,7 +341,7 @@ static struct raw_locn *_read_metadata_location_vg(struct device_area *dev_area,
* Don't try to check existing metadata
* if given vgname is an empty string.
*/
- if (!*vgname)
+ if (!vgname || !*vgname)
return rlocn;
/*
diff --git a/lib/format_text/text_label.c b/lib/format_text/text_label.c
index 246fb7b..cb60c15 100644
--- a/lib/format_text/text_label.c
+++ b/lib/format_text/text_label.c
@@ -332,14 +332,12 @@ static int _read_mda_header_and_metadata(const struct format_type *fmt,
log_warn("WARNING: bad metadata header on %s at %llu.",
dev_name(mdac->area.dev),
(unsigned long long)mdac->area.start);
- if (mda)
- mda->header_start = mdac->area.start;
+ mda->header_start = mdac->area.start;
*bad_fields |= BAD_MDA_HEADER;
return 0;
}
- if (mda)
- mda->header_start = mdah->start;
+ mda->header_start = mdah->start;
mda_set_ignored(mda, rlocn_is_ignored(mdah->raw_locns));
diff --git a/tools/pvscan.c b/tools/pvscan.c
index 96ef438..312a633 100644
--- a/tools/pvscan.c
+++ b/tools/pvscan.c
@@ -420,7 +420,7 @@ check_duplicate:
log_error("pvscan[%d] PV %s is duplicate for PVID %s on %d:%d and %d:%d.",
getpid(), dev_name(dev), dev->pvid, major, minor, file_major, file_minor);
- if (file_vgname[0] && strcmp(file_vgname, vgname))
+ if (file_vgname[0] && vgname && strcmp(file_vgname, vgname))
log_error("pvscan[%d] PV %s has unexpected VG %s vs %s.",
getpid(), dev_name(dev), vgname, file_vgname);
diff --git a/tools/toollib.c b/tools/toollib.c
index bb97e15..ee2419b 100644
--- a/tools/toollib.c
+++ b/tools/toollib.c
@@ -4284,7 +4284,8 @@ static int _process_pvs_in_vg(struct cmd_context *cmd,
/*
* When processing only specific PVs, we can quit once they've all been found.
*/
- if (!process_all_pvs && dm_list_empty(arg_tags) && dm_list_empty(arg_devices))
+ if (!process_all_pvs && dm_list_empty(arg_tags) &&
+ (!arg_devices || dm_list_empty(arg_devices)))
break;
log_set_report_object_name_and_id(NULL, NULL);
}
4 years, 5 months
master - devtype: simplify code
by Zdenek Kabelac
Gitweb: https://sourceware.org/git/?p=lvm2.git;a=commitdiff;h=43f149526d5074dbc6d...
Commit: 43f149526d5074dbc6deeaca38e30d02611eadf8
Parent: 33c8e4de33b2b2fced148e04f725af9d350a989a
Author: Zdenek Kabelac <zkabelac(a)redhat.com>
AuthorDate: Thu Nov 14 16:57:02 2019 +0100
Committer: Zdenek Kabelac <zkabelac(a)redhat.com>
CommitterDate: Thu Nov 14 18:06:14 2019 +0100
devtype: simplify code
Update code with simpler form and check for fclose().
---
lib/device/dev-type.c | 39 +++++++++++++--------------------------
1 files changed, 13 insertions(+), 26 deletions(-)
diff --git a/lib/device/dev-type.c b/lib/device/dev-type.c
index ebe0f99..fba4dc9 100644
--- a/lib/device/dev-type.c
+++ b/lib/device/dev-type.c
@@ -42,7 +42,6 @@ int dev_is_pmem(struct device *dev)
{
FILE *fp;
char path[PATH_MAX];
- char buffer[64];
int is_pmem = 0;
if (dm_snprintf(path, sizeof(path), "%sdev/block/%d:%d/queue/dax",
@@ -56,27 +55,16 @@ int dev_is_pmem(struct device *dev)
if (!(fp = fopen(path, "r")))
return 0;
- if (!fgets(buffer, sizeof(buffer), fp)) {
- log_warn("Failed to read %s.", path);
- if (fclose(fp))
- log_sys_debug("fclose", path);
- return 0;
- } else if (sscanf(buffer, "%d", &is_pmem) != 1) {
- log_warn("Failed to parse %s '%s'.", path, buffer);
- if (fclose(fp))
- log_sys_debug("fclose", path);
- return 0;
- }
+ if (fscanf(fp, "%d", &is_pmem) != 1)
+ log_warn("Failed to parse DAX %s.", path);
+
+ if (is_pmem)
+ log_debug("%s is pmem", dev_name(dev));
if (fclose(fp))
log_sys_debug("fclose", path);
- if (is_pmem) {
- log_debug("%s is pmem", dev_name(dev));
- return 1;
- }
-
- return 0;
+ return is_pmem ? 1 : 0;
}
int dev_is_lv(struct device *dev)
@@ -84,6 +72,7 @@ int dev_is_lv(struct device *dev)
FILE *fp;
char path[PATH_MAX];
char buffer[64];
+ int ret = 0;
if (dm_snprintf(path, sizeof(path), "%sdev/block/%d:%d/dm/uuid",
dm_sysfs_dir(),
@@ -96,17 +85,15 @@ int dev_is_lv(struct device *dev)
if (!(fp = fopen(path, "r")))
return 0;
- if (!fgets(buffer, sizeof(buffer), fp)) {
+ if (!fgets(buffer, sizeof(buffer), fp))
log_warn("Failed to read %s.", path);
- fclose(fp);
- return 0;
- }
+ else if (!strncmp(buffer, "LVM-", 4))
+ ret = 1;
- fclose(fp);
+ if (fclose(fp))
+ log_sys_debug("fclose", path);
- if (!strncmp(buffer, "LVM-", 4))
- return 1;
- return 0;
+ return ret;
}
struct dev_types *create_dev_types(const char *proc_dir,
4 years, 5 months
master - cov: fix memory leak
by Zdenek Kabelac
Gitweb: https://sourceware.org/git/?p=lvm2.git;a=commitdiff;h=33c8e4de33b2b2fced1...
Commit: 33c8e4de33b2b2fced148e04f725af9d350a989a
Parent: 13c254fc05386d05ab6bbda2806f9ca4d3358a0c
Author: Zdenek Kabelac <zkabelac(a)redhat.com>
AuthorDate: Thu Nov 14 16:23:38 2019 +0100
Committer: Zdenek Kabelac <zkabelac(a)redhat.com>
CommitterDate: Thu Nov 14 18:05:41 2019 +0100
cov: fix memory leak
Reapply 23cc7ddc50e2800a6dc248de897a4c88c1514160 to internal version
of libdm.
---
device_mapper/libdm-common.c | 4 +++-
1 files changed, 3 insertions(+), 1 deletions(-)
diff --git a/device_mapper/libdm-common.c b/device_mapper/libdm-common.c
index 1cb29f1..bc691d6 100644
--- a/device_mapper/libdm-common.c
+++ b/device_mapper/libdm-common.c
@@ -2012,7 +2012,8 @@ static int _sysfs_get_kernel_name(uint32_t major, uint32_t minor, char *buf, siz
log_sys_error("readlink", sysfs_path);
else {
log_sys_debug("readlink", sysfs_path);
- return _sysfs_find_kernel_name(major, minor, buf, buf_size);
+ r = _sysfs_find_kernel_name(major, minor, buf, buf_size);
+ goto out;
}
goto bad;
}
@@ -2033,6 +2034,7 @@ static int _sysfs_get_kernel_name(uint32_t major, uint32_t minor, char *buf, siz
strcpy(buf, name);
r = 1;
bad:
+out:
free(temp_buf);
free(sysfs_path);
4 years, 5 months
stable-2.02 - fix dev_unset_last_byte after write error
by David Teigland
Gitweb: https://sourceware.org/git/?p=lvm2.git;a=commitdiff;h=245d7fcd590583166f6...
Commit: 245d7fcd590583166f6cdd78a81bac903fea92eb
Parent: fa4ce13e3f4077105106ab6c3aa80eba1b7ba284
Author: Heming Zhao <heming.zhao(a)suse.com>
AuthorDate: Wed Nov 13 11:28:22 2019 -0600
Committer: David Teigland <teigland(a)redhat.com>
CommitterDate: Wed Nov 13 11:28:22 2019 -0600
fix dev_unset_last_byte after write error
ev_unset_last_byte() must be called while the fd is still valid.
After a write error, dev_unset_last_byte() must be called before
closing the dev and resetting the fd.
In the write error path, dev_unset_last_byte() was being called
after label_scan_invalidate() which meant that it would not unset
the last_byte values.
After a write error, dev_unset_last_byte() is now called in
dev_write_bytes() before label_scan_invalidate(), instead of by
the caller of dev_write_bytes().
In the common case of a successful write, the sequence is still:
dev_set_last_byte(); dev_write_bytes(); dev_unset_last_byte();
Signed-off-by: Zhao Heming <heming.zhao(a)suse.com>
---
lib/format_text/format-text.c | 3 ---
lib/label/label.c | 8 ++++----
lib/metadata/mirror.c | 1 -
3 files changed, 4 insertions(+), 8 deletions(-)
diff --git a/lib/format_text/format-text.c b/lib/format_text/format-text.c
index 6eea07f..026f93a 100644
--- a/lib/format_text/format-text.c
+++ b/lib/format_text/format-text.c
@@ -402,7 +402,6 @@ static int _raw_write_mda_header(const struct format_type *fmt,
dev_set_last_byte(dev, start_byte + MDA_HEADER_SIZE);
if (!dev_write_bytes(dev, start_byte, MDA_HEADER_SIZE, mdah)) {
- dev_unset_last_byte(dev);
log_error("Failed to write mda header to %s fd %d", dev_name(dev), dev->bcache_fd);
return 0;
}
@@ -691,7 +690,6 @@ static int _vg_write_raw(struct format_instance *fid, struct volume_group *vg,
(size_t) (mdac->rlocn.size - new_wrap),
fidtc->raw_metadata_buf)) {
log_error("Failed to write metadata to %s fd %d", dev_name(mdac->area.dev), mdac->area.dev->bcache_fd);
- dev_unset_last_byte(mdac->area.dev);
goto out;
}
@@ -705,7 +703,6 @@ static int _vg_write_raw(struct format_instance *fid, struct volume_group *vg,
(size_t) new_wrap,
fidtc->raw_metadata_buf + mdac->rlocn.size - new_wrap)) {
log_error("Failed to write metadata wrap to %s fd %d", dev_name(mdac->area.dev), mdac->area.dev->bcache_fd);
- dev_unset_last_byte(mdac->area.dev);
goto out;
}
}
diff --git a/lib/label/label.c b/lib/label/label.c
index e4a1068..ae5c142 100644
--- a/lib/label/label.c
+++ b/lib/label/label.c
@@ -216,7 +216,7 @@ int label_write(struct device *dev, struct label *label)
if (!dev_write_bytes(dev, offset, LABEL_SIZE, buf)) {
log_debug_devs("Failed to write label to %s", dev_name(dev));
- r = 0;
+ return 0;
}
dev_unset_last_byte(dev);
@@ -621,7 +621,6 @@ static int _scan_list(struct cmd_context *cmd, struct dev_filter *f,
int submit_count;
int scan_failed;
int is_lvm_device;
- int error;
int ret;
dm_list_init(&wait_devs);
@@ -668,12 +667,11 @@ static int _scan_list(struct cmd_context *cmd, struct dev_filter *f,
dm_list_iterate_items_safe(devl, devl2, &wait_devs) {
bb = NULL;
- error = 0;
scan_failed = 0;
is_lvm_device = 0;
if (!bcache_get(scan_bcache, devl->dev->bcache_fd, 0, 0, &bb)) {
- log_debug_devs("Scan failed to read %s error %d.", dev_name(devl->dev), error);
+ log_debug_devs("Scan failed to read %s.", dev_name(devl->dev));
scan_failed = 1;
scan_read_errors++;
scan_failed_count++;
@@ -1385,6 +1383,7 @@ bool dev_write_bytes(struct device *dev, uint64_t start, size_t len, void *data)
if (!bcache_write_bytes(scan_bcache, dev->bcache_fd, start, len, data)) {
log_error("Error writing device %s at %llu length %u.",
dev_name(dev), (unsigned long long)start, (uint32_t)len);
+ dev_unset_last_byte(dev);
label_scan_invalidate(dev);
return false;
}
@@ -1392,6 +1391,7 @@ bool dev_write_bytes(struct device *dev, uint64_t start, size_t len, void *data)
if (!bcache_flush(scan_bcache)) {
log_error("Error writing device %s at %llu length %u.",
dev_name(dev), (unsigned long long)start, (uint32_t)len);
+ dev_unset_last_byte(dev);
label_scan_invalidate(dev);
return false;
}
diff --git a/lib/metadata/mirror.c b/lib/metadata/mirror.c
index 4e88f25..068ebd2 100644
--- a/lib/metadata/mirror.c
+++ b/lib/metadata/mirror.c
@@ -305,7 +305,6 @@ static int _write_log_header(struct cmd_context *cmd, struct logical_volume *lv)
dev_set_last_byte(dev, sizeof(log_header));
if (!dev_write_bytes(dev, UINT64_C(0), sizeof(log_header), &log_header)) {
- dev_unset_last_byte(dev);
log_error("Failed to write log header to %s.", name);
return 0;
}
4 years, 5 months
master - fix dev_unset_last_byte after write error
by David Teigland
Gitweb: https://sourceware.org/git/?p=lvm2.git;a=commitdiff;h=13c254fc05386d05ab6...
Commit: 13c254fc05386d05ab6bbda2806f9ca4d3358a0c
Parent: 9cad26be321844868a904c7b07bebe37be4e0169
Author: Heming Zhao <heming.zhao(a)suse.com>
AuthorDate: Wed Nov 13 09:15:07 2019 -0600
Committer: David Teigland <teigland(a)redhat.com>
CommitterDate: Wed Nov 13 09:36:58 2019 -0600
fix dev_unset_last_byte after write error
dev_unset_last_byte() must be called while the fd is still valid.
After a write error, dev_unset_last_byte() must be called before
closing the dev and resetting the fd.
In the write error path, dev_unset_last_byte() was being called
after label_scan_invalidate() which meant that it would not unset
the last_byte values.
After a write error, dev_unset_last_byte() is now called in
dev_write_bytes() before label_scan_invalidate(), instead of by
the caller of dev_write_bytes().
In the common case of a successful write, the sequence is still:
dev_set_last_byte(); dev_write_bytes(); dev_unset_last_byte();
Signed-off-by: Zhao Heming <heming.zhao(a)suse.com>
---
lib/format_text/format-text.c | 3 ---
lib/label/label.c | 8 ++++----
lib/metadata/mirror.c | 1 -
3 files changed, 4 insertions(+), 8 deletions(-)
diff --git a/lib/format_text/format-text.c b/lib/format_text/format-text.c
index 6ec47bf..894a710 100644
--- a/lib/format_text/format-text.c
+++ b/lib/format_text/format-text.c
@@ -277,7 +277,6 @@ static int _raw_write_mda_header(const struct format_type *fmt,
dev_set_last_byte(dev, start_byte + MDA_HEADER_SIZE);
if (!dev_write_bytes(dev, start_byte, MDA_HEADER_SIZE, mdah)) {
- dev_unset_last_byte(dev);
log_error("Failed to write mda header to %s fd %d", dev_name(dev), dev->bcache_fd);
return 0;
}
@@ -989,7 +988,6 @@ static int _vg_write_raw(struct format_instance *fid, struct volume_group *vg,
if (!dev_write_bytes(mdac->area.dev, write1_start, (size_t)write1_size, write_buf)) {
log_error("Failed to write metadata to %s fd %d", devname, mdac->area.dev->bcache_fd);
- dev_unset_last_byte(mdac->area.dev);
goto out;
}
@@ -1002,7 +1000,6 @@ static int _vg_write_raw(struct format_instance *fid, struct volume_group *vg,
if (!dev_write_bytes(mdac->area.dev, write2_start, write2_size,
write_buf + new_size - new_wrap)) {
log_error("Failed to write metadata wrap to %s fd %d", devname, mdac->area.dev->bcache_fd);
- dev_unset_last_byte(mdac->area.dev);
goto out;
}
}
diff --git a/lib/label/label.c b/lib/label/label.c
index 7dcaf8a..05986cb 100644
--- a/lib/label/label.c
+++ b/lib/label/label.c
@@ -218,7 +218,7 @@ int label_write(struct device *dev, struct label *label)
if (!dev_write_bytes(dev, offset, LABEL_SIZE, buf)) {
log_debug_devs("Failed to write label to %s", dev_name(dev));
- r = 0;
+ return 0;
}
dev_unset_last_byte(dev);
@@ -655,7 +655,6 @@ static int _scan_list(struct cmd_context *cmd, struct dev_filter *f,
int submit_count;
int scan_failed;
int is_lvm_device;
- int error;
int ret;
dm_list_init(&wait_devs);
@@ -702,12 +701,11 @@ static int _scan_list(struct cmd_context *cmd, struct dev_filter *f,
dm_list_iterate_items_safe(devl, devl2, &wait_devs) {
bb = NULL;
- error = 0;
scan_failed = 0;
is_lvm_device = 0;
if (!bcache_get(scan_bcache, devl->dev->bcache_fd, 0, 0, &bb)) {
- log_debug_devs("Scan failed to read %s error %d.", dev_name(devl->dev), error);
+ log_debug_devs("Scan failed to read %s.", dev_name(devl->dev));
scan_failed = 1;
scan_read_errors++;
scan_failed_count++;
@@ -1451,6 +1449,7 @@ bool dev_write_bytes(struct device *dev, uint64_t start, size_t len, void *data)
if (!bcache_write_bytes(scan_bcache, dev->bcache_fd, start, len, data)) {
log_error("Error writing device %s at %llu length %u.",
dev_name(dev), (unsigned long long)start, (uint32_t)len);
+ dev_unset_last_byte(dev);
label_scan_invalidate(dev);
return false;
}
@@ -1458,6 +1457,7 @@ bool dev_write_bytes(struct device *dev, uint64_t start, size_t len, void *data)
if (!bcache_flush(scan_bcache)) {
log_error("Error writing device %s at %llu length %u.",
dev_name(dev), (unsigned long long)start, (uint32_t)len);
+ dev_unset_last_byte(dev);
label_scan_invalidate(dev);
return false;
}
diff --git a/lib/metadata/mirror.c b/lib/metadata/mirror.c
index 01f0246..d8803b3 100644
--- a/lib/metadata/mirror.c
+++ b/lib/metadata/mirror.c
@@ -266,7 +266,6 @@ static int _write_log_header(struct cmd_context *cmd, struct logical_volume *lv)
dev_set_last_byte(dev, sizeof(log_header));
if (!dev_write_bytes(dev, UINT64_C(0), sizeof(log_header), &log_header)) {
- dev_unset_last_byte(dev);
log_error("Failed to write log header to %s.", name);
return 0;
}
4 years, 5 months
master - WHATS_NEW: update
by Zdenek Kabelac
Gitweb: https://sourceware.org/git/?p=lvm2.git;a=commitdiff;h=9cad26be321844868a9...
Commit: 9cad26be321844868a904c7b07bebe37be4e0169
Parent: 38617213f080492e03f324a73cd8f912ae557349
Author: Zdenek Kabelac <zkabelac(a)redhat.com>
AuthorDate: Mon Nov 11 17:44:14 2019 +0100
Committer: Zdenek Kabelac <zkabelac(a)redhat.com>
CommitterDate: Mon Nov 11 22:44:25 2019 +0100
WHATS_NEW: update
---
WHATS_NEW | 1 +
1 files changed, 1 insertions(+), 0 deletions(-)
diff --git a/WHATS_NEW b/WHATS_NEW
index 816dd86..e5af036 100644
--- a/WHATS_NEW
+++ b/WHATS_NEW
@@ -1,5 +1,6 @@
Version 2.03.07 -
===================================
+ Fix resize of thin-pool with data and metadata of different segtype.
Improve mirror type leg splitting.
Fix activation order when removing merged snapshot.
Experimental VDO support for lvmdbusd.
4 years, 5 months
master - tests: add test of resize of different segtypes
by Zdenek Kabelac
Gitweb: https://sourceware.org/git/?p=lvm2.git;a=commitdiff;h=38617213f080492e03f...
Commit: 38617213f080492e03f324a73cd8f912ae557349
Parent: 08f36dd093c708f0d4a4edd1fd1d84e9a2316313
Author: Zdenek Kabelac <zkabelac(a)redhat.com>
AuthorDate: Mon Nov 11 17:43:24 2019 +0100
Committer: Zdenek Kabelac <zkabelac(a)redhat.com>
CommitterDate: Mon Nov 11 22:44:25 2019 +0100
tests: add test of resize of different segtypes
---
test/shell/lvextend-thin-raid.sh | 13 ++++++++++++-
1 files changed, 12 insertions(+), 1 deletions(-)
diff --git a/test/shell/lvextend-thin-raid.sh b/test/shell/lvextend-thin-raid.sh
index afbc630..a706887 100644
--- a/test/shell/lvextend-thin-raid.sh
+++ b/test/shell/lvextend-thin-raid.sh
@@ -20,7 +20,7 @@ export LVM_TEST_THIN_REPAIR_CMD=${LVM_TEST_THIN_REPAIR_CMD-/bin/false}
aux have_thin 1 0 0 || skip
aux have_raid 1 3 0 || skip
-aux prepare_vg 6
+aux prepare_vg 6 600
lvcreate --type raid1 -l2 --nosync -n pool $vg
lvconvert --yes --thinpool $vg/pool "$dev3"
@@ -49,4 +49,15 @@ lvextend --poolmetadatasize +1 --size +1 $vg/pool
check lv_field $vg/pool_tdata lv_size "7.50m" -a
check lv_field $vg/pool_tmeta lv_size "4.50m" -a
+lvremove -f $vg
+
+# check resize of pool and metadata being a different segtype
+# https://bugzilla.redhat.com/1722666
+lvcreate -L4 -n pool $vg
+lvcreate --type raid1 -m1 -L2 --nosync -n meta $vg
+lvconvert --yes --thinpool $vg/pool --poolmetadata $vg/meta
+# using big enough pool so resize of pool metadata is enforced
+# (and it's using a differnt segtype)
+lvextend -L3G $vg/pool
+
vgremove -ff $vg
4 years, 5 months
master - lvextend: fix resizing volumes of different segtype
by Zdenek Kabelac
Gitweb: https://sourceware.org/git/?p=lvm2.git;a=commitdiff;h=08f36dd093c708f0d4a...
Commit: 08f36dd093c708f0d4a4edd1fd1d84e9a2316313
Parent: 3b05fd4d072d94bfead8c2d188ecf704fe57e2a8
Author: Zdenek Kabelac <zkabelac(a)redhat.com>
AuthorDate: Mon Nov 11 17:36:58 2019 +0100
Committer: Zdenek Kabelac <zkabelac(a)redhat.com>
CommitterDate: Mon Nov 11 22:44:25 2019 +0100
lvextend: fix resizing volumes of different segtype
When resizing 2 volumes like thin-pool and it's metadata and they
would be of a different type - command would be actually expecting
both LVs being of a same segtype - and would throw an error in
case they are different.
This patch fixes is by setting a new segtype from last segment of
2nd. extented device.
Also it fixes the possible 'percentage' extension setup that
might have been used for 'primary' volume - while the 'secondary'
LV always goes with direct size - as we do not support 'percentage'
setup for them
This affects maily usage of thin-pool where the extension of
thin-pool data size may also lead to extension of metadata size.
---
lib/metadata/lv_manip.c | 2 ++
1 files changed, 2 insertions(+), 0 deletions(-)
diff --git a/lib/metadata/lv_manip.c b/lib/metadata/lv_manip.c
index ae103d3..b4daa56 100644
--- a/lib/metadata/lv_manip.c
+++ b/lib/metadata/lv_manip.c
@@ -5623,6 +5623,8 @@ static struct logical_volume *_lvresize_setup_aux(struct logical_volume *lv,
struct lv_segment *mseg = last_seg(lv);
lp->alloc = lv->alloc;
+ lp->percent = PERCENT_NONE;
+ lp->segtype = mseg->segtype;
lp->mirrors = seg_is_mirrored(mseg) ? lv_mirror_count(lv) : 0;
lp->resizefs = 0;
lp->stripes = lp->mirrors ? mseg->area_count / lp->mirrors : 0;
4 years, 5 months
master - tests: add extra settle
by Zdenek Kabelac
Gitweb: https://sourceware.org/git/?p=lvm2.git;a=commitdiff;h=3b05fd4d072d94bfead...
Commit: 3b05fd4d072d94bfead8c2d188ecf704fe57e2a8
Parent: ba313ac84a7bc27ce69d225dec1bfc80bcb20988
Author: Zdenek Kabelac <zkabelac(a)redhat.com>
AuthorDate: Fri Nov 8 15:09:17 2019 +0100
Committer: Zdenek Kabelac <zkabelac(a)redhat.com>
CommitterDate: Mon Nov 11 22:44:25 2019 +0100
tests: add extra settle
To avoid removing, while 'add' might not have been processed yet.
(when emulating reboot in pvmove-restart)
---
test/lib/aux.sh | 4 ++++
1 files changed, 4 insertions(+), 0 deletions(-)
diff --git a/test/lib/aux.sh b/test/lib/aux.sh
index 36e1c2b..6822d7e 100644
--- a/test/lib/aux.sh
+++ b/test/lib/aux.sh
@@ -1652,6 +1652,10 @@ wait_pvmove_lv_ready() {
retries=$((retries-1))
done
fi
+
+ # Adding settle here, to avoid remove, before processing of 'add' is finished
+ # (masking systemd-udevd issue)
+ udevadm settle --timeout=2 || true
}
# Holds device open with sleep which automatically expires after given timeout
4 years, 5 months