7f9b3f4598
- backport patches for lvm2 to avoid software abnormal work (bsc#1158861) + bug-1158861_01-config-remove-filter-typo.patch + bug-1158861_02-config-Fix-default-option-which-makes-no-sense.patch + bug-1158861_03-vgchange-don-t-fail-monitor-command-if-vg-is-exporte.patch + bug-1158861_04-fix-duplicate-pv-size-check.patch + bug-1158861_05-hints-fix-copy-of-filter.patch + bug-1158861_06-fix-segfault-for-invalid-characters-in-vg-name.patch + bug-1158861_07-vgck-let-updatemetadata-repair-mismatched-metadata.patch + bug-1158861_08-hints-fix-mem-leaking-buffers.patch + bug-1158861_09-pvcreate-pvremove-fix-reacquiring-global-lock-after.patch - add necessary patches for passing lvm2 testsuite (bsc#1158628) + bug-1158628_01-tests-replaces-grep-q-usage.patch + bug-1158628_02-tests-fix-ra-checking.patch + bug-1158628_03-tests-simplify-some-var-settings.patch + bug-1158628-04-pvmove-correcting-read_ahead-setting.patch + bug-1158628_05-activation-add-synchronization-point.patch + bug-1158628_06-pvmove-add-missing-synchronization.patch + bug-1158628_07-activation-extend-handling-of-pending_delete.patch + bug-1158628_08-lv_manip-add-synchronizations.patch + bug-1158628_09-lvconvert-improve-validation-thin-and-cache-pool-con.patch + bug-1158628_10-thin-activate-layer-pool-aas-read-only-LV.patch + bug-1158628_11-tests-mdadm-stop-in-test-cleanup.patch + bug-1158628_12-test-increase-size-of-raid10-LV-allowing-tests-to-su.patch + bug-1158628_13-lvconvert-fix-return-value-when-zeroing-fails.patch + bug-1158628_14-tests-add-extra-settle.patch + bug-1158628_15-test-Fix-handling-leftovers-from-previous-tests.patch OBS-URL: https://build.opensuse.org/request/show/755483 OBS-URL: https://build.opensuse.org/package/show/Base:System/lvm2?expand=0&rev=260
158 lines
4.5 KiB
Diff
158 lines
4.5 KiB
Diff
From 12707adac8ba9e3a58175616bcd59b0e229a6705 Mon Sep 17 00:00:00 2001
|
|
From: David Teigland <teigland@redhat.com>
|
|
Date: Wed, 28 Aug 2019 12:33:04 -0500
|
|
Subject: [PATCH] hints: fix copy of filter
|
|
|
|
Only the first entry of the filter array was being
|
|
included in the copy of the filter, rather than the
|
|
entire thing. The result is that hints would not be
|
|
refreshed if the filter was changed but the first
|
|
entry was unchanged.
|
|
---
|
|
lib/label/hints.c | 79 ++++++++++++++++++++++++++++++++++++++++-------
|
|
1 file changed, 68 insertions(+), 11 deletions(-)
|
|
|
|
diff --git a/lib/label/hints.c b/lib/label/hints.c
|
|
index 6de54bc60b..580304dee0 100644
|
|
--- a/lib/label/hints.c
|
|
+++ b/lib/label/hints.c
|
|
@@ -579,6 +579,52 @@ static void _apply_hints(struct cmd_context *cmd, struct dm_list *hints,
|
|
}
|
|
}
|
|
|
|
+static void _filter_to_str(struct cmd_context *cmd, int filter_cfg, char **strp)
|
|
+{
|
|
+ const struct dm_config_node *cn;
|
|
+ const struct dm_config_value *cv;
|
|
+ char *str;
|
|
+ int pos = 0;
|
|
+ int len = 0;
|
|
+ int ret;
|
|
+
|
|
+ *strp = NULL;
|
|
+
|
|
+ if (!(cn = find_config_tree_array(cmd, filter_cfg, NULL))) {
|
|
+ /* shouldn't happen because default is a|*| */
|
|
+ return;
|
|
+ }
|
|
+
|
|
+ for (cv = cn->v; cv; cv = cv->next) {
|
|
+ if (cv->type != DM_CFG_STRING)
|
|
+ continue;
|
|
+
|
|
+ len += (strlen(cv->v.str) + 1);
|
|
+ }
|
|
+ len++;
|
|
+
|
|
+ if (len == 1) {
|
|
+ /* shouldn't happen because default is a|*| */
|
|
+ return;
|
|
+ }
|
|
+
|
|
+ str = malloc(len);
|
|
+ memset(str, 0, len);
|
|
+
|
|
+ for (cv = cn->v; cv; cv = cv->next) {
|
|
+ if (cv->type != DM_CFG_STRING)
|
|
+ continue;
|
|
+
|
|
+ ret = snprintf(str + pos, len - pos, "%s", cv->v.str);
|
|
+
|
|
+ if (ret >= len - pos)
|
|
+ break;
|
|
+ pos += ret;
|
|
+ }
|
|
+
|
|
+ *strp = str;
|
|
+}
|
|
+
|
|
/*
|
|
* Return 1 and needs_refresh 0: the hints can be used
|
|
* Return 1 and needs_refresh 1: the hints can't be used and should be updated
|
|
@@ -590,12 +636,11 @@ static int _read_hint_file(struct cmd_context *cmd, struct dm_list *hints, int *
|
|
{
|
|
char devpath[PATH_MAX];
|
|
FILE *fp;
|
|
- const struct dm_config_node *cn;
|
|
struct dev_iter *iter;
|
|
struct hint *hint;
|
|
struct device *dev;
|
|
char *split[HINT_LINE_WORDS];
|
|
- char *name, *pvid, *devn, *vgname, *p;
|
|
+ char *name, *pvid, *devn, *vgname, *p, *filter_str = NULL;
|
|
uint32_t read_hash = 0;
|
|
uint32_t calc_hash = INITIAL_CRC;
|
|
uint32_t read_count = 0;
|
|
@@ -655,23 +700,31 @@ static int _read_hint_file(struct cmd_context *cmd, struct dm_list *hints, int *
|
|
|
|
keylen = strlen("global_filter:");
|
|
if (!strncmp(_hint_line, "global_filter:", keylen)) {
|
|
- cn = find_config_tree_array(cmd, devices_global_filter_CFG, NULL);
|
|
- if (strcmp(cn->v->v.str, _hint_line + keylen)) {
|
|
+ _filter_to_str(cmd, devices_global_filter_CFG, &filter_str);
|
|
+ if (!filter_str || strcmp(filter_str, _hint_line + keylen)) {
|
|
log_debug("ignore hints with different global_filter");
|
|
+ if (filter_str)
|
|
+ free(filter_str);
|
|
*needs_refresh = 1;
|
|
break;
|
|
}
|
|
+ if (filter_str)
|
|
+ free(filter_str);
|
|
continue;
|
|
}
|
|
|
|
keylen = strlen("filter:");
|
|
if (!strncmp(_hint_line, "filter:", keylen)) {
|
|
- cn = find_config_tree_array(cmd, devices_filter_CFG, NULL);
|
|
- if (strcmp(cn->v->v.str, _hint_line + keylen)) {
|
|
+ _filter_to_str(cmd, devices_filter_CFG, &filter_str);
|
|
+ if (!filter_str || strcmp(filter_str, _hint_line + keylen)) {
|
|
log_debug("ignore hints with different filter");
|
|
+ if (filter_str)
|
|
+ free(filter_str);
|
|
*needs_refresh = 1;
|
|
break;
|
|
}
|
|
+ if (filter_str)
|
|
+ free(filter_str);
|
|
continue;
|
|
}
|
|
|
|
@@ -800,11 +853,11 @@ int write_hint_file(struct cmd_context *cmd, int newhints)
|
|
{
|
|
char devpath[PATH_MAX];
|
|
FILE *fp;
|
|
- const struct dm_config_node *cn;
|
|
struct lvmcache_info *info;
|
|
struct dev_iter *iter;
|
|
struct device *dev;
|
|
const char *vgname;
|
|
+ char *filter_str = NULL;
|
|
uint32_t hash = INITIAL_CRC;
|
|
uint32_t count = 0;
|
|
time_t t;
|
|
@@ -855,11 +908,15 @@ int write_hint_file(struct cmd_context *cmd, int newhints)
|
|
fprintf(fp, "# Created by %s pid %d %s", cmd->name, getpid(), ctime(&t));
|
|
fprintf(fp, "hints_version: %d.%d\n", HINTS_VERSION_MAJOR, HINTS_VERSION_MINOR);
|
|
|
|
- cn = find_config_tree_array(cmd, devices_global_filter_CFG, NULL);
|
|
- fprintf(fp, "global_filter:%s\n", cn->v->v.str);
|
|
+ _filter_to_str(cmd, devices_global_filter_CFG, &filter_str);
|
|
+ fprintf(fp, "global_filter:%s\n", filter_str ?: "-");
|
|
+ if (filter_str)
|
|
+ free(filter_str);
|
|
|
|
- cn = find_config_tree_array(cmd, devices_filter_CFG, NULL);
|
|
- fprintf(fp, "filter:%s\n", cn->v->v.str);
|
|
+ _filter_to_str(cmd, devices_filter_CFG, &filter_str);
|
|
+ fprintf(fp, "filter:%s\n", filter_str ?: "-");
|
|
+ if (filter_str)
|
|
+ free(filter_str);
|
|
|
|
fprintf(fp, "scan_lvs:%d\n", cmd->scan_lvs);
|
|
|
|
--
|
|
2.24.0
|
|
|