Gitweb: http://git.fedorahosted.org/git/?p=lvm2.git;a=commitdiff;h=b21a8412c482ae73…
Commit: b21a8412c482ae735d0d044d355e1541ccba6edf
Parent: 00b36ef06acb15c82d7c9b37872753f02c638316
Author: Peter Rajnoha <prajnoha(a)redhat.com>
AuthorDate: Wed Dec 10 13:43:54 2014 +0100
Committer: Peter Rajnoha <prajnoha(a)redhat.com>
CommitterDate: Wed Dec 10 14:00:56 2014 +0100
vgimportclone: also notify lvmetad about changes if it's used
All the LVM commands are run in mode without lvmetad use (since lvmetad
can't handle duplicates). When we're finished with vgimportclone, we
need to notify lvmetad about changes.
Before this patch (/dev/sda and /dev/sdb contains a copy VG called "vg"):
$ vgimportclone --basevgname vg_snap /dev/sdb
WARNING: lvmetad is running but disabled. Restart lvmetad before enabling it!
WARNING: lvmetad is running but disabled. Restart lvmetad before enabling it!
WARNING: lvmetad is running but disabled. Restart lvmetad before enabling it!
WARNING: Activation disabled. No device-mapper interaction will be attempted.
WARNING: lvmetad is running but disabled. Restart lvmetad before enabling it!
Physical volume "/tmp/snap.zcJ8LCmj/vgimport0" changed 1 physical volume changed / 0 physical volumes not changed
WARNING: lvmetad is running but disabled. Restart lvmetad before enabling it!
WARNING: lvmetad is running but disabled. Restart lvmetad before enabling it!
WARNING: Activation disabled. No device-mapper interaction will be attempted.
WARNING: lvmetad is running but disabled. Restart lvmetad before enabling it!
Volume group "vg" successfully changed
WARNING: lvmetad is running but disabled. Restart lvmetad before enabling it!
WARNING: lvmetad is running but disabled. Restart lvmetad before enabling it!
Volume group "vg" successfully renamed to "vg_snap"
Reading all physical volumes. This may take a while...
Found volume group "vg" using metadata type lvm2
Found volume group "fedora" using metadata type lvm2
$ vgs
VG #PV #LV #SN Attr VSize VFree
fedora 1 2 0 wz--n- 9.50g 0
vg 1 1 0 wz--n- 124.00m 120.00m
(...lvmetad doesn't see the new "vg_snap"!)
With this patch applied:
$ vgimportclone --basevgname vg_snap /dev/sdb
...
WARNING: lvmetad is running but disabled. Restart lvmetad before enabling it!
Volume group "vg" successfully renamed to "vg_snap"
Notifying lvmetad about changes since it was disabled temporarily.
Reading all physical volumes. This may take a while...
Found volume group "vg_snap" using metadata type lvm2
Found volume group "fedora" using metadata type lvm2
Found volume group "vg" using metadata type lvm2
$ vgs
VG #PV #LV #SN Attr VSize VFree
fedora 1 2 0 wz--n- 9.50g 0
vg 1 1 0 wz--n- 124.00m 120.00m
vg_snap 1 1 0 wz--n- 124.00m 120.00m
The "restart lvmetad before enabling it" message is a bit misleading
here - we should probably suppress this one, but we can't suppress
warning messages selectively at the moment and we don't want to lose
other warning/error messages printed...
---
WHATS_NEW | 1 +
scripts/vgimportclone.sh | 9 +++++++++
2 files changed, 10 insertions(+), 0 deletions(-)
diff --git a/WHATS_NEW b/WHATS_NEW
index 72d3b6a..5e1b143 100644
--- a/WHATS_NEW
+++ b/WHATS_NEW
@@ -1,5 +1,6 @@
Version 2.02.115 -
=====================================
+ Fix vgimportclone to notify lvmetad about changes done if lvmetad is used.
Fix vgimportclone to properly override config if it is missing in lvm.conf.
Fix automatic use of configure --enable-udev-systemd-background-jobs.
Correctly rename active split LV with -splitmirrors for raid1.
diff --git a/scripts/vgimportclone.sh b/scripts/vgimportclone.sh
index bfff131..719cd8d 100755
--- a/scripts/vgimportclone.sh
+++ b/scripts/vgimportclone.sh
@@ -363,6 +363,15 @@ fi
### the device nodes we need are straight
if [ ${CHANGES_MADE} -eq 1 ]
then
+ # get global/use_lvmetad config and if set also notify lvmetad about changes
+ # since we were running LVM commands above with use_lvmetad=0
+ eval $(${LVM} dumpconfig ${LVM_OPTS} global/use_lvmetad)
+ if [ "$use_lvmetad" = "1" ]
+ then
+ echo "Notifying lvmetad about changes since it was disabled temporarily."
+ LVM_OPTS="${LVM_OPTS} --cache"
+ fi
+
"$LVM" vgscan ${LVM_OPTS} --mknodes
fi
Gitweb: http://git.fedorahosted.org/git/?p=lvm2.git;a=commitdiff;h=f94f8463b0d3ddda…
Commit: f94f8463b0d3dddaa0e429123aba673d106f783e
Parent: 4c62215bd178c17d0776448bdc99740180c85402
Author: Peter Rajnoha <prajnoha(a)redhat.com>
AuthorDate: Tue Dec 9 10:36:27 2014 +0100
Committer: Peter Rajnoha <prajnoha(a)redhat.com>
CommitterDate: Tue Dec 9 10:41:55 2014 +0100
libdm: report: fix incorrect memory use while using --select with --unbuffered for reporting
Under certain circumstances, the selection code can segfault:
$ vgs --select 'pv_name=~/dev/sda' --unbuffered vg0
VG #PV #LV #SN Attr VSize VFree
vg0 6 3 0 wz--n- 744.00m 588.00m
Segmentation fault (core dumped)
The problem here is the use of --ubuffered together with regex used in
selection criteria. If the report output is not buffered, each row is
discarded as soon as it is reported. The bug is in the use of report
handle's memory - in the example above, what happens is:
1) report handle is initialized together with its memory pool
2) selection tree is initialized from selection criteria string
(using the report handle's memory pool!)
2a) this also means the regex is initialized from report handle's mem pool
3) the object (row) is reported
3a) any memory needed for output is intialized out of report handle's mem pool
3b) selection criteria matching is executed - if the regex is checked the
very first time (for the very first row reported), some more memory
allocation happens as regex allocates internal structures "on-demand",
it's allocating from report handle's mem pool (see also step 2a)
4) the report output is executed
5) the object (row) is discarded, meaning discarding all the mem pool
memory used since step 3.
Now, with step 5) we have discarded the regex internal structures from step 3b.
When we execute reporting for another object (row), we're using the same
selection criteria (step 3b), but tihs is second time we're using the regex
and as such, it's already initialized completely. But the regex is missing the
internal structures now as they got discarded in step 5) from previous
object (row) reporting (because we're using "unbuffered" reporting).
To resolve this issue and to prevent any similar future issues where each
object/row memory is discarded after output (the unbuffered reporting) while
selection tree is global for all the object/rows, use separate memory pool
for report's selection.
This patch replaces "struct selection_node *selection_root" in struct
dm_report with new struct selection which contains both "selection_root"
and "mem" for separate mem pool used for selection.
We can change struct dm_report this way as it is not exposed via libdevmapper.
(This patch will have even more meaning for upcoming patches where selection
is used even for non-reporting commands where "internal" reporting and
selection criteria matching happens and where the internal reporting is
not buffered.)
---
WHATS_NEW | 1 +
libdm/libdm-report.c | 49 ++++++++++++++++++++++++++++++++-----------------
2 files changed, 33 insertions(+), 17 deletions(-)
diff --git a/WHATS_NEW b/WHATS_NEW
index 9201f36..ff06b7b 100644
--- a/WHATS_NEW
+++ b/WHATS_NEW
@@ -1,5 +1,6 @@
Version 2.02.115 -
=====================================
+ Fix segfault while using --select with regex and --unbuffered for reporting.
Fix automatic use of configure --enable-udev-systemd-background-jobs.
Correctly rename active split LV with -splitmirrors for raid1.
Add report/compact_output to lvm.conf to enable/disable compact report output.
diff --git a/libdm/libdm-report.c b/libdm/libdm-report.c
index 6d36c1e..e3c3d2f 100644
--- a/libdm/libdm-report.c
+++ b/libdm/libdm-report.c
@@ -26,6 +26,11 @@
#define RH_HEADINGS_PRINTED 0x00000200
#define RH_ALREADY_REPORTED 0x00000400
+struct selection {
+ struct dm_pool *mem;
+ struct selection_node *selection_root;
+};
+
struct dm_report {
struct dm_pool *mem;
@@ -52,7 +57,9 @@ struct dm_report {
/* To store caller private data */
void *private;
- struct selection_node *selection_root;
+ /* Selection handle */
+ struct selection *selection;
+
/* Null-terminated array of reserved values */
const struct dm_report_reserved_value *reserved_values;
};
@@ -1193,6 +1200,8 @@ struct dm_report *dm_report_init(uint32_t *report_types,
void dm_report_free(struct dm_report *rh)
{
+ if (rh->selection)
+ dm_pool_destroy(rh->selection->mem);
dm_pool_destroy(rh->mem);
dm_free(rh);
}
@@ -1560,10 +1569,10 @@ static int _check_selection(struct dm_report *rh, struct selection_node *sn,
static int _check_report_selection(struct dm_report *rh, struct dm_list *fields)
{
- if (!rh->selection_root)
+ if (!rh->selection)
return 1;
- return _check_selection(rh, rh->selection_root, fields);
+ return _check_selection(rh, rh->selection->selection_root, fields);
}
int dm_report_object(struct dm_report *rh, void *object)
@@ -2410,7 +2419,7 @@ static struct field_selection *_create_field_selection(struct dm_report *rh,
}
/* set up selection */
- if (!(fs = dm_pool_zalloc(rh->mem, sizeof(struct field_selection)))) {
+ if (!(fs = dm_pool_zalloc(rh->selection->mem, sizeof(struct field_selection)))) {
log_error("dm_report: struct field_selection "
"allocation failed for selection field %s", field_id);
return NULL;
@@ -2429,7 +2438,7 @@ static struct field_selection *_create_field_selection(struct dm_report *rh,
memcpy(s, v, len);
s[len] = '\0';
- fs->v.r = dm_regex_create(rh->mem, (const char **) &s, 1);
+ fs->v.r = dm_regex_create(rh->selection->mem, (const char **) &s, 1);
dm_free(s);
if (!fs->v.r) {
log_error("dm_report: failed to create regex "
@@ -2438,7 +2447,7 @@ static struct field_selection *_create_field_selection(struct dm_report *rh,
}
} else {
/* STRING, NUMBER, SIZE or STRING_LIST */
- if (!(s = dm_pool_alloc(rh->mem, len + 1))) {
+ if (!(s = dm_pool_alloc(rh->selection->mem, len + 1))) {
log_error("dm_report: dm_pool_alloc failed to store "
"value for selection field %s", field_id);
goto error;
@@ -2450,7 +2459,7 @@ static struct field_selection *_create_field_selection(struct dm_report *rh,
case DM_REPORT_FIELD_TYPE_STRING:
if (reserved) {
fs->v.s = (const char *) _get_reserved_value(reserved);
- dm_pool_free(rh->mem, s);
+ dm_pool_free(rh->selection->mem, s);
} else {
fs->v.s = s;
if (_check_value_is_reserved(rh, DM_REPORT_FIELD_TYPE_STRING, fs->v.s)) {
@@ -2473,7 +2482,7 @@ static struct field_selection *_create_field_selection(struct dm_report *rh,
goto error;
}
}
- dm_pool_free(rh->mem, s);
+ dm_pool_free(rh->selection->mem, s);
break;
case DM_REPORT_FIELD_TYPE_SIZE:
if (reserved)
@@ -2492,7 +2501,7 @@ static struct field_selection *_create_field_selection(struct dm_report *rh,
goto error;
}
}
- dm_pool_free(rh->mem, s);
+ dm_pool_free(rh->selection->mem, s);
break;
case DM_REPORT_FIELD_TYPE_PERCENT:
if (reserved)
@@ -2528,7 +2537,7 @@ static struct field_selection *_create_field_selection(struct dm_report *rh,
return fs;
error:
- dm_pool_free(rh->mem, fs);
+ dm_pool_free(rh->selection->mem, fs);
return NULL;
}
@@ -2730,7 +2739,7 @@ static struct selection_node *_parse_selection(struct dm_report *rh,
custom = NULL;
if (!(last = _tok_value(rh, ft, field_num, implicit,
last, &vs, &ve, &flags,
- &reserved, rh->mem, custom)))
+ &reserved, rh->selection->mem, custom)))
goto_bad;
}
@@ -2741,7 +2750,7 @@ static struct selection_node *_parse_selection(struct dm_report *rh,
return_NULL;
/* create selection node */
- if (!(sn = _alloc_selection_node(rh->mem, SEL_ITEM)))
+ if (!(sn = _alloc_selection_node(rh->selection->mem, SEL_ITEM)))
return_NULL;
/* add selection to selection node */
@@ -2828,7 +2837,7 @@ static struct selection_node *_parse_and_ex(struct dm_report *rh,
}
if (!and_sn) {
- if (!(and_sn = _alloc_selection_node(rh->mem, SEL_AND)))
+ if (!(and_sn = _alloc_selection_node(rh->selection->mem, SEL_AND)))
goto error;
}
dm_list_add(&and_sn->selection.set, &n->list);
@@ -2860,7 +2869,7 @@ static struct selection_node *_parse_or_ex(struct dm_report *rh,
}
if (!or_sn) {
- if (!(or_sn = _alloc_selection_node(rh->mem, SEL_OR)))
+ if (!(or_sn = _alloc_selection_node(rh->selection->mem, SEL_OR)))
goto error;
}
dm_list_add(&or_sn->selection.set, &n->list);
@@ -2893,7 +2902,7 @@ struct dm_report *dm_report_init_with_selection(uint32_t *report_types,
return NULL;
if (!selection || !selection[0]) {
- rh->selection_root = NULL;
+ rh->selection = NULL;
return rh;
}
@@ -2914,7 +2923,13 @@ struct dm_report *dm_report_init_with_selection(uint32_t *report_types,
return rh;
}
- if (!(root = _alloc_selection_node(rh->mem, SEL_OR)))
+ if (!(rh->selection = dm_pool_zalloc(rh->mem, sizeof(struct selection))) ||
+ !(rh->selection->mem = dm_pool_create("report selection", 10 * 1024))) {
+ log_error("Failed to allocate report selection structure.");
+ goto bad;
+ }
+
+ if (!(root = _alloc_selection_node(rh->selection->mem, SEL_OR)))
goto_bad;
if (!_parse_or_ex(rh, selection, &fin, root))
@@ -2930,7 +2945,7 @@ struct dm_report *dm_report_init_with_selection(uint32_t *report_types,
_dm_report_init_update_types(rh, report_types);
- rh->selection_root = root;
+ rh->selection->selection_root = root;
return rh;
bad:
dm_report_free(rh);
Gitweb: http://git.fedorahosted.org/git/?p=lvm2.git;a=commitdiff;h=4c62215bd178c17d…
Commit: 4c62215bd178c17d0776448bdc99740180c85402
Parent: 42d71b9af393bdbf0e9409eea176b2801a07ea25
Author: Peter Rajnoha <prajnoha(a)redhat.com>
AuthorDate: Mon Dec 8 10:51:33 2014 +0100
Committer: Peter Rajnoha <prajnoha(a)redhat.com>
CommitterDate: Mon Dec 8 10:52:47 2014 +0100
configure: fix automatic use of configure --enable-udev-systemd-background-jobs
Fix incorrect test in configure which sets --enable-udev-systemd-background-jobs
automatically if proper systemd version is available.
The UDEV_SYSTEMD_BACKGROUND_JOBS variable was not properly set to "yes" in
case systemd is available and we had "maybe" for this variable before.
---
WHATS_NEW | 1 +
configure | 2 +-
configure.in | 2 +-
3 files changed, 3 insertions(+), 2 deletions(-)
diff --git a/WHATS_NEW b/WHATS_NEW
index 213cc31..9201f36 100644
--- a/WHATS_NEW
+++ b/WHATS_NEW
@@ -1,5 +1,6 @@
Version 2.02.115 -
=====================================
+ Fix automatic use of configure --enable-udev-systemd-background-jobs.
Correctly rename active split LV with -splitmirrors for raid1.
Add report/compact_output to lvm.conf to enable/disable compact report output.
Still restrict mirror region size to power of 2 when VG extent size is not.
diff --git a/configure b/configure
index df902c3..9d1d32f 100755
--- a/configure
+++ b/configure
@@ -10694,7 +10694,7 @@ else
SYSTEMD_LIBS=$pkg_cv_SYSTEMD_LIBS
{ $as_echo "$as_me:${as_lineno-$LINENO}: result: yes" >&5
$as_echo "yes" >&6; }
- test "UDEV_SYSTEMD_BACKGROUND_JOBS" = maybe && UDEV_SYSTEMD_BACKGROUND_JOBS=yes
+ test "$UDEV_SYSTEMD_BACKGROUND_JOBS" = maybe && UDEV_SYSTEMD_BACKGROUND_JOBS=yes
fi
fi
diff --git a/configure.in b/configure.in
index 5b22b93..107bb29 100644
--- a/configure.in
+++ b/configure.in
@@ -1104,7 +1104,7 @@ AC_MSG_RESULT($UDEV_SYSTEMD_BACKGROUND_JOBS)
if test "$UDEV_SYSTEMD_BACKGROUND_JOBS" != no; then
pkg_config_init
PKG_CHECK_MODULES(SYSTEMD, systemd >= 205,
- [test "UDEV_SYSTEMD_BACKGROUND_JOBS" = maybe && UDEV_SYSTEMD_BACKGROUND_JOBS=yes],
+ [test "$UDEV_SYSTEMD_BACKGROUND_JOBS" = maybe && UDEV_SYSTEMD_BACKGROUND_JOBS=yes],
[if test "$UDEV_SYSTEMD_BACKGROUND_JOBS" = maybe; then
UDEV_SYSTEMD_BACKGROUND_JOBS=no
else
Gitweb: http://git.fedorahosted.org/git/?p=lvm2.git;a=commitdiff;h=42d71b9af393bdbf…
Commit: 42d71b9af393bdbf0e9409eea176b2801a07ea25
Parent: f867dc6b294c434e69499e38e66a67812361d8c9
Author: Peter Rajnoha <prajnoha(a)redhat.com>
AuthorDate: Fri Dec 5 15:10:50 2014 +0100
Committer: Peter Rajnoha <prajnoha(a)redhat.com>
CommitterDate: Fri Dec 5 15:10:50 2014 +0100
libdm: report: return immediately from dm_report_compact_fields without error if there are no rows
Let's make dm_report_compact_fields consistent with dm_report_output fn
which also returns with success immediately if there are no rows.
---
libdm/libdm-report.c | 7 ++++---
1 files changed, 4 insertions(+), 3 deletions(-)
diff --git a/libdm/libdm-report.c b/libdm/libdm-report.c
index f81d964..6d36c1e 100644
--- a/libdm/libdm-report.c
+++ b/libdm/libdm-report.c
@@ -1696,11 +1696,12 @@ int dm_report_compact_fields(struct dm_report *rh)
struct field_properties *fp;
struct row *row;
- if (!(rh->flags & DM_REPORT_OUTPUT_BUFFERED))
+ if (!(rh->flags & DM_REPORT_OUTPUT_BUFFERED) ||
+ dm_list_empty(&rh->rows))
return 1;
- if (!rh || dm_list_empty(&rh->rows)) {
- log_error("dm_report_enable_compact_output: no report fields to compact");
+ if (!rh) {
+ log_error("dm_report_enable_compact_output: dm report handler is NULL.");
return 0;
}