master - cache: disallow to combine format 2 with mq
by Zdenek Kabelac
Gitweb: https://sourceware.org/git/?p=lvm2.git;a=commitdiff;h=8d7ece126b96337326d...
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) {
6 years, 1 month
master - tests: use 4k extents
by Zdenek Kabelac
Gitweb: https://sourceware.org/git/?p=lvm2.git;a=commitdiff;h=08487a30983bfa4b3c0...
Commit: 08487a30983bfa4b3c0a7bcd9060657b6c1803ae
Parent: e5b40e0488ae85e4adf8736e06a973666ea9280c
Author: Zdenek Kabelac <zkabelac(a)redhat.com>
AuthorDate: Sun Mar 18 00:30:43 2018 +0100
Committer: Zdenek Kabelac <zkabelac(a)redhat.com>
CommitterDate: Sun Mar 18 00:30:43 2018 +0100
tests: use 4k extents
Use 4K chunks since some older kernels are not capable
to create striped volumes with smaller size.
TODO: lvm2 should detect this ahead and avoid kernel
reporting "Invalid chunk".
---
test/shell/lvconvert-snapshot.sh | 8 +++++++-
1 files changed, 7 insertions(+), 1 deletions(-)
diff --git a/test/shell/lvconvert-snapshot.sh b/test/shell/lvconvert-snapshot.sh
index ecf6b3c..f18115d 100644
--- a/test/shell/lvconvert-snapshot.sh
+++ b/test/shell/lvconvert-snapshot.sh
@@ -30,7 +30,6 @@ lvcreate -L1 -s -n $lv3 $vg/$lv2
lvcreate -l1 -n $lv4 $vg
lvcreate -L1 -n $lv5 $vg
lvcreate -L1 -n $lv6 $vg
-lvcreate -L1 -i2 -n $lv7 $vg
not lvconvert -s $vg/$lv1 $vg/not_exist
@@ -61,6 +60,13 @@ grep "smaller" err
lvconvert --yes -s $vg/$lv2 $vg/$lv5
lvconvert --yes --type snapshot $vg/$lv2 $vg/$lv6
+vgremove -f $vg
+
+# FIXME: older stripe target can't handle 1K chunks
+vgcreate -s 4k "$vg" "${DEVICES[@]}"
+lvcreate -aey -L1 -n $lv2 $vg
+lvcreate -L1 -i2 -n $lv7 $vg
+
# Striped LV is also supported
lvconvert --yes --snapshot $vg/$lv2 $vg/$lv7
6 years, 1 month
master - tests: check activation of cache without cache_check
by Zdenek Kabelac
Gitweb: https://sourceware.org/git/?p=lvm2.git;a=commitdiff;h=e5b40e0488ae85e4adf...
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
6 years, 1 month
master - tests: test striped COW LV
by Zdenek Kabelac
Gitweb: https://sourceware.org/git/?p=lvm2.git;a=commitdiff;h=9e7b00a3b9cecd43c7a...
Commit: 9e7b00a3b9cecd43c7a339ee4ae5fb174179d3dd
Parent: c82ab92d04acec41f9a3550e2ee7970d3937566e
Author: Zdenek Kabelac <zkabelac(a)redhat.com>
AuthorDate: Sat Mar 17 14:26:15 2018 +0100
Committer: Zdenek Kabelac <zkabelac(a)redhat.com>
CommitterDate: Sat Mar 17 23:33:58 2018 +0100
tests: test striped COW LV
---
test/shell/lvconvert-snapshot.sh | 6 +++++-
1 files changed, 5 insertions(+), 1 deletions(-)
diff --git a/test/shell/lvconvert-snapshot.sh b/test/shell/lvconvert-snapshot.sh
index f751c30..ecf6b3c 100644
--- a/test/shell/lvconvert-snapshot.sh
+++ b/test/shell/lvconvert-snapshot.sh
@@ -17,7 +17,7 @@ SKIP_WITH_LVMPOLLD=1
. lib/inittest
-aux prepare_pvs 1
+aux prepare_pvs 2
get_devs
vgcreate -s 1k "$vg" "${DEVICES[@]}"
@@ -30,6 +30,7 @@ lvcreate -L1 -s -n $lv3 $vg/$lv2
lvcreate -l1 -n $lv4 $vg
lvcreate -L1 -n $lv5 $vg
lvcreate -L1 -n $lv6 $vg
+lvcreate -L1 -i2 -n $lv7 $vg
not lvconvert -s $vg/$lv1 $vg/not_exist
@@ -60,4 +61,7 @@ grep "smaller" err
lvconvert --yes -s $vg/$lv2 $vg/$lv5
lvconvert --yes --type snapshot $vg/$lv2 $vg/$lv6
+# Striped LV is also supported
+lvconvert --yes --snapshot $vg/$lv2 $vg/$lv7
+
vgremove -f $vg
6 years, 1 month
master - cleanup: use zalloc
by Zdenek Kabelac
Gitweb: https://sourceware.org/git/?p=lvm2.git;a=commitdiff;h=c82ab92d04acec41f9a...
Commit: c82ab92d04acec41f9a3550e2ee7970d3937566e
Parent: 5c40e81a7e6a42e40a49c89758f8e9fd269de8d7
Author: Zdenek Kabelac <zkabelac(a)redhat.com>
AuthorDate: Sat Mar 17 14:14:25 2018 +0100
Committer: Zdenek Kabelac <zkabelac(a)redhat.com>
CommitterDate: Sat Mar 17 23:33:58 2018 +0100
cleanup: use zalloc
Replace malloc() + memset() with zalloc().
---
daemons/lvmetad/lvmetad-core.c | 4 +---
libdm/datastruct/hash.c | 8 +++-----
libdm/ioctl/libdm-iface.c | 4 +---
3 files changed, 5 insertions(+), 11 deletions(-)
diff --git a/daemons/lvmetad/lvmetad-core.c b/daemons/lvmetad/lvmetad-core.c
index 66a6b82..f4f5f42 100644
--- a/daemons/lvmetad/lvmetad-core.c
+++ b/daemons/lvmetad/lvmetad-core.c
@@ -2528,10 +2528,8 @@ inval:
info = dm_hash_lookup(s->vgid_to_info, uuid);
if (!info) {
- info = malloc(sizeof(struct vg_info));
- if (!info)
+ if (!(info = dm_zalloc(sizeof(struct vg_info))))
goto bad;
- memset(info, 0, sizeof(struct vg_info));
if (!dm_hash_insert(s->vgid_to_info, uuid, (void*)info))
goto bad;
}
diff --git a/libdm/datastruct/hash.c b/libdm/datastruct/hash.c
index 6df3efe..fb153ce 100644
--- a/libdm/datastruct/hash.c
+++ b/libdm/datastruct/hash.c
@@ -102,11 +102,9 @@ struct dm_hash_table *dm_hash_create(unsigned size_hint)
hc->num_slots = new_size;
len = sizeof(*(hc->slots)) * new_size;
- if (!(hc->slots = dm_malloc(len))) {
- stack;
- goto bad;
- }
- memset(hc->slots, 0, len);
+ if (!(hc->slots = dm_zalloc(len)))
+ goto_bad;
+
return hc;
bad:
diff --git a/libdm/ioctl/libdm-iface.c b/libdm/ioctl/libdm-iface.c
index 8bee24b..3965be6 100644
--- a/libdm/ioctl/libdm-iface.c
+++ b/libdm/ioctl/libdm-iface.c
@@ -1156,11 +1156,9 @@ static struct dm_ioctl *_flatten(struct dm_task *dmt, unsigned repeat_count)
while (repeat_count--)
len *= 2;
- if (!(dmi = dm_malloc(len)))
+ if (!(dmi = dm_zalloc(len)))
return NULL;
- memset(dmi, 0, len);
-
version = &_cmd_data_v4[dmt->type].version;
dmi->version[0] = (*version)[0];
6 years, 1 month
master - cleanup: use direct initializer
by Zdenek Kabelac
Gitweb: https://sourceware.org/git/?p=lvm2.git;a=commitdiff;h=5c40e81a7e6a42e40a4...
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) {
6 years, 1 month
master - coverity: drop unused local static var
by Zdenek Kabelac
Gitweb: https://sourceware.org/git/?p=lvm2.git;a=commitdiff;h=f4383a70ba0538f2906...
Commit: f4383a70ba0538f290657adfa20fe00967553195
Parent: aa75e181bec4e61ac08a5f1029e966d0593c5d45
Author: Zdenek Kabelac <zkabelac(a)redhat.com>
AuthorDate: Sat Mar 17 14:00:44 2018 +0100
Committer: Zdenek Kabelac <zkabelac(a)redhat.com>
CommitterDate: Sat Mar 17 23:33:58 2018 +0100
coverity: drop unused local static var
---
lib/locking/lvmlockd.c | 4 ----
1 files changed, 0 insertions(+), 4 deletions(-)
diff --git a/lib/locking/lvmlockd.c b/lib/locking/lvmlockd.c
index a4684b4..0521ede 100644
--- a/lib/locking/lvmlockd.c
+++ b/lib/locking/lvmlockd.c
@@ -20,7 +20,6 @@
static daemon_handle _lvmlockd;
static const char *_lvmlockd_socket = NULL;
-static struct cmd_context *_lvmlockd_cmd = NULL;
static int _use_lvmlockd = 0; /* is 1 if command is configured to use lvmlockd */
static int _lvmlockd_connected = 0; /* is 1 if command is connected to lvmlockd */
static int _lvmlockd_init_failed = 0; /* used to suppress further warnings */
@@ -69,8 +68,6 @@ void lvmlockd_init(struct cmd_context *cmd)
} else {
_lvmlockd_init_failed = 0;
}
-
- _lvmlockd_cmd = cmd;
}
void lvmlockd_connect(void)
@@ -103,7 +100,6 @@ void lvmlockd_disconnect(void)
if (_lvmlockd_connected)
daemon_close(_lvmlockd);
_lvmlockd_connected = 0;
- _lvmlockd_cmd = NULL;
}
/* Translate the result strings from lvmlockd to bit flags. */
6 years, 1 month
master - coverity: drop unneeded header files
by Zdenek Kabelac
Gitweb: https://sourceware.org/git/?p=lvm2.git;a=commitdiff;h=aa75e181bec4e61ac08...
Commit: aa75e181bec4e61ac08a5f1029e966d0593c5d45
Parent: b4c69320fcccaf5257039c3489d5227e82183f8a
Author: Zdenek Kabelac <zkabelac(a)redhat.com>
AuthorDate: Sat Mar 17 14:00:21 2018 +0100
Committer: Zdenek Kabelac <zkabelac(a)redhat.com>
CommitterDate: Sat Mar 17 23:33:58 2018 +0100
coverity: drop unneeded header files
---
lib/locking/file_locking.c | 1 -
lib/misc/lvm-globals.c | 1 -
2 files changed, 0 insertions(+), 2 deletions(-)
diff --git a/lib/locking/file_locking.c b/lib/locking/file_locking.c
index 517a64f..8dbc54e 100644
--- a/lib/locking/file_locking.c
+++ b/lib/locking/file_locking.c
@@ -21,7 +21,6 @@
#include "defaults.h"
#include "lvm-string.h"
#include "lvm-flock.h"
-#include "lvmcache.h"
#include <limits.h>
#include <unistd.h>
diff --git a/lib/misc/lvm-globals.c b/lib/misc/lvm-globals.c
index be33091..0575d21 100644
--- a/lib/misc/lvm-globals.c
+++ b/lib/misc/lvm-globals.c
@@ -15,7 +15,6 @@
#include "lib.h"
#include "device.h"
-#include "memlock.h"
#include "lvm-string.h"
#include "defaults.h"
#include "metadata-exported.h"
6 years, 1 month
master - coverity: move declaration out of the loop
by Zdenek Kabelac
Gitweb: https://sourceware.org/git/?p=lvm2.git;a=commitdiff;h=b4c69320fcccaf52570...
Commit: b4c69320fcccaf5257039c3489d5227e82183f8a
Parent: f2d0eefa770468e8cdd126ce09a251bdf804884e
Author: Zdenek Kabelac <zkabelac(a)redhat.com>
AuthorDate: Sat Mar 17 13:57:40 2018 +0100
Committer: Zdenek Kabelac <zkabelac(a)redhat.com>
CommitterDate: Sat Mar 17 23:33:58 2018 +0100
coverity: move declaration out of the loop
Move declaration of count counter outside the while loop.
---
daemons/cmirrord/cluster.c | 3 +--
1 files changed, 1 insertions(+), 2 deletions(-)
diff --git a/daemons/cmirrord/cluster.c b/daemons/cmirrord/cluster.c
index 94be563..5b8b68d 100644
--- a/daemons/cmirrord/cluster.c
+++ b/daemons/cmirrord/cluster.c
@@ -166,6 +166,7 @@ int cluster_send(struct clog_request *rq)
{
int r;
int found = 0;
+ int count = 0;
struct iovec iov;
struct clog_cpg *entry;
@@ -203,8 +204,6 @@ int cluster_send(struct clog_request *rq)
#if CMIRROR_HAS_CHECKPOINT
do {
- int count = 0;
-
r = cpg_mcast_joined(entry->handle, CPG_TYPE_AGREED, &iov, 1);
if (r != SA_AIS_ERR_TRY_AGAIN)
break;
6 years, 1 month
master - coverity: make use of defined variable
by Zdenek Kabelac
Gitweb: https://sourceware.org/git/?p=lvm2.git;a=commitdiff;h=f2d0eefa770468e8cdd...
Commit: f2d0eefa770468e8cdd126ce09a251bdf804884e
Parent: 26c58027fb9df068c927abe61336ff6364fe3d0e
Author: Zdenek Kabelac <zkabelac(a)redhat.com>
AuthorDate: Sat Mar 17 13:56:44 2018 +0100
Committer: Zdenek Kabelac <zkabelac(a)redhat.com>
CommitterDate: Sat Mar 17 23:33:58 2018 +0100
coverity: make use of defined variable
Since we declare 'r', let's use the value for something.
---
lib/device/dev-io.c | 8 ++------
1 files changed, 2 insertions(+), 6 deletions(-)
diff --git a/lib/device/dev-io.c b/lib/device/dev-io.c
index cb3a234..1d16a66 100644
--- a/lib/device/dev-io.c
+++ b/lib/device/dev-io.c
@@ -649,14 +649,10 @@ static int _aligned_io(struct device_area *where, char *write_buffer,
/* ... then we write */
devbuf->write = 1;
if (!(r = _io(devbuf, 0)))
- goto_bad;
-
- _release_devbuf(devbuf);
- return 1;
-
+ stack;
bad:
_release_devbuf(devbuf);
- return 0;
+ return r;
}
static int _dev_get_size_file(struct device *dev, uint64_t *size)
6 years, 1 month