Gitweb: https://sourceware.org/git/?p=lvm2.git;a=commitdiff;h=8d7ece126b96337326d02…
Commit: 8d7ece126b96337326d026ab4edebe2db4333459
Parent: 08487a30983bfa4b3c0a7bcd9060657b6c1803ae
Author: Zdenek Kabelac <zkabelac(a)redhat.com>
AuthorDate: Mon Mar 19 10:23:48 2018 +0100
Committer: Zdenek Kabelac <zkabelac(a)redhat.com>
CommitterDate: Mon Mar 19 12:02:08 2018 +0100
cache: disallow to combine format 2 with mq
Only policy 'smq' is meant to be used with format version 2.
Code used to let pass 'mq' policy also with format 2. But 'mq'
is obsoloted wth smq and kernel currently matches it. But this
is incompatible with older original mq logic - so disallow creation
of this rather useless combination.
---
WHATS_NEW | 1 +
lib/metadata/cache_manip.c | 18 +++++++++++++++---
2 files changed, 16 insertions(+), 3 deletions(-)
diff --git a/WHATS_NEW b/WHATS_NEW
index 995b389..3750341 100644
--- a/WHATS_NEW
+++ b/WHATS_NEW
@@ -1,5 +1,6 @@
Version 2.02.178 -
=====================================
+ Disallow usage of cache format 2 with mq cache policy.
Again accept striped LV as COW LV with lvconvert -s (2.02.169).
Fix raid target version testing for supported features.
Allow activation of pools when thin/cache_check tool is missing.
diff --git a/lib/metadata/cache_manip.c b/lib/metadata/cache_manip.c
index 5167760..2a54682 100644
--- a/lib/metadata/cache_manip.c
+++ b/lib/metadata/cache_manip.c
@@ -841,6 +841,18 @@ int cache_set_metadata_format(struct lv_segment *seg, cache_metadata_format_t fo
return 0;
}
+ /*
+ * If policy is unselected, but format 2 is selected, policy smq is enforced.
+ * ATM no other then smq policy is allowed to select format 2.
+ */
+ if (!seg->policy_name) {
+ if (format == CACHE_METADATA_FORMAT_2)
+ seg->policy_name = "smq";
+ } else if (strcmp(seg->policy_name, "smq")) {
+ seg->cache_metadata_format = CACHE_METADATA_FORMAT_1;
+ return 1;
+ }
+
/* Check if we need to search for configured cache metadata format */
if (format == CACHE_METADATA_FORMAT_UNSELECTED) {
if (seg->cache_metadata_format != CACHE_METADATA_FORMAT_UNSELECTED)
@@ -894,15 +906,15 @@ int cache_set_params(struct lv_segment *seg,
struct lv_segment *pool_seg;
struct cmd_context *cmd = seg->lv->vg->cmd;
- if (!cache_set_metadata_format(seg, format))
- return_0;
-
if (!cache_set_cache_mode(seg, mode))
return_0;
if (!cache_set_policy(seg, policy_name, policy_settings))
return_0;
+ if (!cache_set_metadata_format(seg, format))
+ return_0;
+
pool_seg = seg_is_cache(seg) ? first_seg(seg->pool_lv) : seg;
if (chunk_size) {
Gitweb: https://sourceware.org/git/?p=lvm2.git;a=commitdiff;h=e5b40e0488ae85e4adf87…
Commit: e5b40e0488ae85e4adf8736e06a973666ea9280c
Parent: 9e7b00a3b9cecd43c7a339ee4ae5fb174179d3dd
Author: Zdenek Kabelac <zkabelac(a)redhat.com>
AuthorDate: Sat Mar 17 23:26:48 2018 +0100
Committer: Zdenek Kabelac <zkabelac(a)redhat.com>
CommitterDate: Sat Mar 17 23:33:58 2018 +0100
tests: check activation of cache without cache_check
---
test/shell/lvcreate-cache-no-tools.sh | 81 +++++++++++++++++++++++++++++++++
1 files changed, 81 insertions(+), 0 deletions(-)
diff --git a/test/shell/lvcreate-cache-no-tools.sh b/test/shell/lvcreate-cache-no-tools.sh
new file mode 100644
index 0000000..72359e5
--- /dev/null
+++ b/test/shell/lvcreate-cache-no-tools.sh
@@ -0,0 +1,81 @@
+#!/usr/bin/env bash
+
+# Copyright (C) 2018 Red Hat, Inc. All rights reserved.
+#
+# This copyrighted material is made available to anyone wishing to use,
+# modify, copy, or redistribute it subject to the terms and conditions
+# of the GNU General Public License v.2.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program; if not, write to the Free Software Foundation,
+# Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
+
+# Exercise creation of cache without cache_check
+
+SKIP_WITH_LVMLOCKD=1
+SKIP_WITH_LVMPOLLD=1
+
+. lib/inittest
+
+aux have_cache 1 3 0 || skip
+
+# FIXME: parallel cache metadata allocator is crashing when used value 8000!
+aux prepare_vg 5 80000
+
+aux lvmconf 'global/cache_disabled_features = [ "policy_smq" ]' \
+ 'global/cache_check_executable = "./fake-tool.sh"'
+
+rm -f fake-tool.sh
+
+lvcreate -l1 -n $lv1 $vg
+lvcreate -H -l2 $vg/$lv1
+
+lvchange -an $vg |& tee out
+grep "Check is skipped" out
+
+lvchange -ay $vg
+grep "Check is skipped" out
+
+# prepare fake version of cache_check tool that reports old version
+cat <<- EOF >fake-tool.sh
+#!/bin/sh
+echo "0.1.0"
+exit 1
+EOF
+chmod +x fake-tool.sh
+
+lvchange -an $vg |& tee out
+grep "upgrade" out
+
+lvchange -ay $vg
+grep "upgrade" out
+
+# prepare fake version of cache_check tool that reports garbage
+cat <<- EOF >fake-tool.sh
+#!/bin/sh
+echo "garbage"
+exit 1
+EOF
+chmod +x fake-tool.sh
+
+lvchange -an $vg |& tee out
+grep "parse" out
+
+lvchange -ay $vg
+grep "parse" out
+
+# prepare fake version of cache_check tool with high version
+cat <<- EOF >fake-tool.sh
+#!/bin/sh
+echo "9.0.0"
+exit 1
+EOF
+chmod +x fake-tool.sh
+
+# Integrity check fails, but deactivation is OK
+lvchange -an $vg |& tee out
+grep "failed" out
+# Activation must fail
+fail lvchange -ay $vg
+
+vgremove -ff $vg
Gitweb: https://sourceware.org/git/?p=lvm2.git;a=commitdiff;h=5c40e81a7e6a42e40a49c…
Commit: 5c40e81a7e6a42e40a49c89758f8e9fd269de8d7
Parent: f4383a70ba0538f290657adfa20fe00967553195
Author: Zdenek Kabelac <zkabelac(a)redhat.com>
AuthorDate: Sat Mar 17 14:13:30 2018 +0100
Committer: Zdenek Kabelac <zkabelac(a)redhat.com>
CommitterDate: Sat Mar 17 23:33:58 2018 +0100
cleanup: use direct initializer
---
daemons/lvmetad/lvmetad-core.c | 7 ++-----
1 files changed, 2 insertions(+), 5 deletions(-)
diff --git a/daemons/lvmetad/lvmetad-core.c b/daemons/lvmetad/lvmetad-core.c
index eeb3f20..66a6b82 100644
--- a/daemons/lvmetad/lvmetad-core.c
+++ b/daemons/lvmetad/lvmetad-core.c
@@ -2421,14 +2421,11 @@ static response set_global_info(lvmetad_state *s, request r)
static response get_global_info(lvmetad_state *s, request r)
{
- char reason[REASON_BUF_SIZE];
+ /* This buffer should be large enough to hold all the possible reasons. */
+ char reason[REASON_BUF_SIZE] = { 0 };
char flag_str[64];
int pid;
- /* This buffer should be large enough to hold all the possible reasons. */
-
- memset(reason, 0, sizeof(reason));
-
pid = (int)daemon_request_int(r, "pid", 0);
if (s->flags & GLFL_DISABLE) {