master - TEST: Support testing new RAID features in RHEL6 kernels
by Jonathan Brassow
Gitweb: http://git.fedorahosted.org/git/?p=lvm2.git;a=commitdiff;h=081308af30b32b...
Commit: 081308af30b32b86b690c727125f0615e5a7a7fb
Parent: 3fdb45d0402ac9b404f4277d7954043ea257f019
Author: Jonathan Brassow <jbrassow(a)redhat.com>
AuthorDate: Mon Jul 22 08:50:27 2013 -0500
Committer: Jonathan Brassow <jbrassow(a)redhat.com>
CommitterDate: Mon Jul 22 08:50:27 2013 -0500
TEST: Support testing new RAID features in RHEL6 kernels
We check the version number of dm-raid before testing certain
features to make sure they are present. However, this has
become somewhat complicated by the fact that the version #'s
in the upstream kernel and the REHL6 kernel have been diverging.
This has been a necessity because the upstream kernel has
undergone ABI changes that have necessitated a bump in the
'Y' component of the version #, while the RHEL6 kernel has not.
Thus, we need to know that the ABI has not changed but the
features have been added. So, the current version #'ing stands
as follows:
RHEL6 Upstream Comment
======|==========|========
** Same until version 1.3.1 **
------|----------|--------
N/A | 1.4.0 | Non-functional change.
| | Removes arg from mapping function.
------|----------|--------
1.3.2 | 1.4.1 | RAID10 fix redundancy validation checks.
------|----------|--------
1.3.5 | 1.4.2 | Add RAID10 "far" and "offset" algorithm support.
| | Note this feature came later in RHEL6 as part of
| | a separate update/feature.
------|----------|--------
1.3.3 | 1.5.0 | Add message interface to allow manipulation of
| | the sync_action.
| | New status (STATUSTYPE_INFO) fields: sync_action
| | and mismatch_cnt.
------|----------|--------
1.3.4 | 1.5.1 | Add ability to restore transiently failed devices
| | on resume.
------|----------|--------
1.3.5 | 1.5.2 | 'mismatch_cnt' is zero unless [last_]sync_action
| | is "check".
------|----------|--------
To simplify, writemostly/writebehind, scrubbing, and transient device
failure restoration are all tested based on the same version
requirements: (1.3.5 < V < 1.4.0) || (V > 1.5.2). Since kernel
support for writemostly/writebehind has been around for some time,
this could mean a reduction in the scope of kernels tested for this
feature. I don't view this as much of a problem, since support for
this feature was only recently added to LVM. Thus, the user would
have to be using a very recent LVM version with an older kernel.
---
test/shell/lvchange-raid.sh | 55 +++++++++++++-----------------------------
1 files changed, 17 insertions(+), 38 deletions(-)
diff --git a/test/shell/lvchange-raid.sh b/test/shell/lvchange-raid.sh
index 1e20934..2e62312 100644
--- a/test/shell/lvchange-raid.sh
+++ b/test/shell/lvchange-raid.sh
@@ -11,8 +11,15 @@
. lib/test
-# dm-raid v1.4.1+ contains RAID10 support
-aux target_at_least dm-raid 1 4 1 || skip
+# Writemostly has been in every version since the begining
+# Device refresh in 1.5.1 upstream and 1.3.4 < x < 1.4.0 in RHEL6
+# Sync action in 1.5.0 upstream and 1.3.3 < x < 1.4.0 in RHEL6
+# Proper mismatch count 1.5.2 upstream,1.3.5 < x < 1.4.0 in RHEL6
+#
+# We will simplify and simple test for 1.5.2 and 1.3.5 < x < 1.4.0
+aux target_at_least dm-raid 1 3 5 &&
+ ! aux target_at_least dm-raid 1 4 0 ||
+ aux target_at_least dm-raid 1 5 2 || skip
aux prepare_vg 6
@@ -140,24 +147,6 @@ run_syncaction_check() {
seek=$(($seek + $size)) # Jump halfway through the RAID image
- # Check all is normal
- if ! aux target_at_least dm-raid 1 5 2; then
- # As of version 1.5.2, the mismatch_cnt is non-zero only
- # after a 'check' sync action has been performed and only
- # if discrepancies have been found.
- #
- # Previous to this version, mismatch_cnt was basically
- # undefined unless it was queried after a 'check' was
- # performed. This meant that unless a 'check' was done,
- # the 'm' character in the 'lvs' output could show up
- # randomly.
-
- # Run "check" should turn up clean
- lvchange --syncaction check $1/$2
- aux wait_for_sync $1 $2
- sync
- fi
-
lvs --noheadings -o lv_attr $1/$2 | grep '.*-.$'
[ `lvs --noheadings -o raid_mismatch_count $1/$2` == 0 ]
@@ -228,32 +217,22 @@ run_refresh_check() {
# run_checks <VG> <LV> [snapshot_dev]
run_checks() {
# Without snapshots
- if aux target_at_least dm-raid 1 1 0; then
- run_writemostly_check $1 $2
- fi
+ run_writemostly_check $1 $2
- if aux target_at_least dm-raid 1 5 0; then
- run_syncaction_check $1 $2
- fi
+ run_syncaction_check $1 $2
- if aux target_at_least dm-raid 1 5 1; then
- run_refresh_check $1 $2
- fi
+ run_refresh_check $1 $2
# With snapshots
if [ ! -z $3 ]; then
lvcreate -s $1/$2 -l 4 -n snap $3
- if aux target_at_least dm-raid 1 1 0; then
- run_writemostly_check $1 $2
- fi
- if aux target_at_least dm-raid 1 5 0; then
- run_syncaction_check $1 $2
- fi
+ run_writemostly_check $1 $2
+
+ run_syncaction_check $1 $2
+
+ run_refresh_check $1 $2
- if aux target_at_least dm-raid 1 5 1; then
- run_refresh_check $1 $2
- fi
lvremove -ff $1/snap
fi
}
9 years, 8 months
master - pvscan: Respect lvmetad (global) filter in --cache w/ a device.
by Petr Rockai
Gitweb: http://git.fedorahosted.org/git/?p=lvm2.git;a=commitdiff;h=3fdb45d0402ac9...
Commit: 3fdb45d0402ac9b404f4277d7954043ea257f019
Parent: ea333a894e93f665a515986fdebf2a6c9e10d42a
Author: Petr Rockai <prockai(a)redhat.com>
AuthorDate: Mon Jul 22 15:03:56 2013 +0200
Committer: Petr Rockai <prockai(a)redhat.com>
CommitterDate: Mon Jul 22 15:05:39 2013 +0200
pvscan: Respect lvmetad (global) filter in --cache w/ a device.
---
test/shell/lvmetad-pvscan-filter.sh | 29 +++++++++++++++++++++++++++++
tools/pvscan.c | 5 ++---
2 files changed, 31 insertions(+), 3 deletions(-)
diff --git a/test/shell/lvmetad-pvscan-filter.sh b/test/shell/lvmetad-pvscan-filter.sh
new file mode 100644
index 0000000..5dd66c4
--- /dev/null
+++ b/test/shell/lvmetad-pvscan-filter.sh
@@ -0,0 +1,29 @@
+#!/bin/sh
+# Copyright (C) 2012 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., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+
+. lib/test
+
+test -e LOCAL_LVMETAD || skip
+
+aux prepare_pvs 2
+
+maj=$(($(stat --printf=0x%t "$dev2")))
+min=$(($(stat --printf=0x%T "$dev2")))
+
+aux hide_dev $dev2
+not pvscan --cache $dev2 2>&1 | grep "not found"
+# pvscan with --major/--minor does not fail (for udev's sake?)
+pvscan --cache --major $maj --minor $min 2>&1 | grep "not found"
+aux unhide_dev $dev2
+
+pvscan --cache $dev2 2>&1 | not grep "not found"
+pvscan --cache --major $maj --minor $min 2>&1 | not grep "not found"
+pvs | grep $dev2
diff --git a/tools/pvscan.c b/tools/pvscan.c
index 63dc524..96bbf6b 100644
--- a/tools/pvscan.c
+++ b/tools/pvscan.c
@@ -187,7 +187,7 @@ static int _pvscan_lvmetad(struct cmd_context *cmd, int argc, char **argv)
/* Process any command line PVs first. */
while (argc--) {
pv_name = *argv++;
- dev = dev_cache_get(pv_name, NULL);
+ dev = dev_cache_get(pv_name, cmd->lvmetad_filter);
if (!dev) {
log_error("Physical Volume %s not found.", pv_name);
ret = ECMD_FAILED;
@@ -218,10 +218,9 @@ static int _pvscan_lvmetad(struct cmd_context *cmd, int argc, char **argv)
devno = MKDEV((dev_t)major, minor);
- if (!(dev = dev_cache_get_by_devt(devno, NULL))) {
+ if (!(dev = dev_cache_get_by_devt(devno, cmd->lvmetad_filter))) {
if (!dm_asprintf(&buf, "%" PRIi32 ":%" PRIi32, major, minor))
stack;
- /* FIXME Filters? */
if (!lvmetad_pv_gone(devno, buf ? : "", handler)) {
ret = ECMD_FAILED;
if (buf)
9 years, 8 months
master - systemd: lvm2-activation-generator: use LOG_DEBUG/ERR severity for kmsg
by Peter Rajnoha
Gitweb: http://git.fedorahosted.org/git/?p=lvm2.git;a=commitdiff;h=ea333a894e93f6...
Commit: ea333a894e93f665a515986fdebf2a6c9e10d42a
Parent: f1d5f6ae81f4723e6aeb2f04bd68cba59cd65403
Author: Peter Rajnoha <prajnoha(a)redhat.com>
AuthorDate: Mon Jul 22 14:04:12 2013 +0200
Committer: Peter Rajnoha <prajnoha(a)redhat.com>
CommitterDate: Mon Jul 22 14:04:12 2013 +0200
systemd: lvm2-activation-generator: use LOG_DEBUG/ERR severity for kmsg
---
WHATS_NEW | 1 +
.../lvm2_activation_generator_systemd_red_hat.c | 35 +++++++++++--------
2 files changed, 21 insertions(+), 15 deletions(-)
diff --git a/WHATS_NEW b/WHATS_NEW
index 1cce9c9..15419bb 100644
--- a/WHATS_NEW
+++ b/WHATS_NEW
@@ -1,5 +1,6 @@
Version 2.02.99 -
===================================
+ Use LOG_DEBUG/ERR msg severity instead default for lvm2-activation-generator.
Support ARG_GROUPABLE with merge_synonym (for --raidwritemostly).
Fix segfault when reporting raid_syncaction for older kernels.
Add LV reporting fields raid_mismatch_count, raid_sync_action, raid_write_behind.
diff --git a/scripts/lvm2_activation_generator_systemd_red_hat.c b/scripts/lvm2_activation_generator_systemd_red_hat.c
index 5514522..d257479 100644
--- a/scripts/lvm2_activation_generator_systemd_red_hat.c
+++ b/scripts/lvm2_activation_generator_systemd_red_hat.c
@@ -16,6 +16,7 @@
#include <unistd.h>
#include <errno.h>
#include <stdarg.h>
+#include <syslog.h>
#include <sys/types.h>
#include <sys/stat.h>
#include <fcntl.h>
@@ -31,7 +32,7 @@
static char unit_path[PATH_MAX];
static char target_path[PATH_MAX];
-static char message[PATH_MAX];
+static char message[PATH_MAX + 3]; /* +3 for '<n>' where n is the log level */
static int kmsg_fd = -1;
enum {
@@ -46,20 +47,23 @@ static const char *unit_names[] = {
[UNIT_NET] = "lvm2-activation-net.service"
};
-__attribute__ ((format(printf, 1, 2)))
-static void kmsg(const char *format, ...)
+__attribute__ ((format(printf, 2, 3)))
+static void kmsg(int log_level, const char *format, ...)
{
va_list ap;
int n;
+ snprintf(message, 4, "<%d>", log_level);
+
va_start(ap, format);
- n = vsnprintf(message, sizeof(message), format, ap);
+ n = vsnprintf(message + 3, PATH_MAX, format, ap);
va_end(ap);
- if (kmsg_fd < 0 || (n < 0 || ((unsigned) n + 1 > sizeof(message))))
+ if (kmsg_fd < 0 || (n < 0 || ((unsigned) n + 1 > PATH_MAX)))
return;
- (void) write(kmsg_fd, message, n + 1);
+ /* The n+4: +3 for "<n>" prefix and +1 for '\0' suffix */
+ (void) write(kmsg_fd, message, n + 4);
}
static int lvm_uses_lvmetad(void)
@@ -68,7 +72,7 @@ static int lvm_uses_lvmetad(void)
int r;
if (!(lvm = lvm_init(NULL))) {
- kmsg("LVM: Failed to initialize library context for activation generator.\n");
+ kmsg(LOG_ERR, "LVM: Failed to initialize library context for activation generator.\n");
return 0;
}
r = lvm_config_find_bool(lvm, LVM_CONF_USE_LVMETAD, 0);
@@ -86,7 +90,7 @@ static int register_unit_with_target(const char *dir, const char *unit, const ch
}
(void) dm_prepare_selinux_context(target_path, S_IFDIR);
if (mkdir(target_path, 0755) < 0 && errno != EEXIST) {
- kmsg("LVM: Failed to create target directory %s: %m.\n", target_path);
+ kmsg(LOG_ERR, "LVM: Failed to create target directory %s: %m.\n", target_path);
r = 0; goto out;
}
@@ -95,7 +99,7 @@ static int register_unit_with_target(const char *dir, const char *unit, const ch
}
(void) dm_prepare_selinux_context(target_path, S_IFLNK);
if (symlink(unit_path, target_path) < 0) {
- kmsg("LVM: Failed to create symlink for unit %s: %m.\n", unit);
+ kmsg(LOG_ERR, "LVM: Failed to create symlink for unit %s: %m.\n", unit);
r = 0;
}
out:
@@ -113,7 +117,7 @@ static int generate_unit(const char *dir, int unit)
return 0;
if (!(f = fopen(unit_path, "wxe"))) {
- kmsg("LVM: Failed to create unit file %s: %m.\n", unit_name);
+ kmsg(LOG_ERR, "LVM: Failed to create unit file %s: %m.\n", unit_name);
return 0;
}
@@ -148,12 +152,12 @@ static int generate_unit(const char *dir, int unit)
"Type=oneshot\n", f);
if (fclose(f) < 0) {
- kmsg("LVM: Failed to write unit file %s: %m.\n", unit_name);
+ kmsg(LOG_ERR, "LVM: Failed to write unit file %s: %m.\n", unit_name);
return 0;
}
if (!register_unit_with_target(dir, unit_name, target_name)) {
- kmsg("LVM: Failed to register unit %s with target %s.\n", unit_name, target_name);
+ kmsg(LOG_ERR, "LVM: Failed to register unit %s with target %s.\n", unit_name, target_name);
return 0;
}
@@ -168,13 +172,13 @@ int main(int argc, char *argv[])
kmsg_fd = open(KMSG_DEV_PATH, O_WRONLY|O_NOCTTY);
if (argc > 1 && argc != 4) {
- kmsg("LVM: Activation generator takes three or no arguments.\n");
+ kmsg(LOG_ERR, "LVM: Activation generator takes three or no arguments.\n");
r = EXIT_FAILURE; goto out;
}
/* If lvmetad used, rely on autoactivation instead of direct activation. */
if (lvm_uses_lvmetad()) {
- kmsg("LVM: Logical Volume autoactivation enabled.\n");
+ kmsg(LOG_DEBUG, "LVM: Logical Volume autoactivation enabled.\n");
goto out;
}
@@ -185,7 +189,8 @@ int main(int argc, char *argv[])
!generate_unit(dir, UNIT_NET))
r = EXIT_FAILURE;
out:
- kmsg("LVM: Activation generator %s.\n", r ? "failed" : "successfully completed");
+ kmsg(r ? LOG_ERR : LOG_DEBUG, "LVM: Activation generator %s.\n",
+ r ? "failed" : "successfully completed");
if (kmsg_fd != -1)
(void) close(kmsg_fd);
return r;
9 years, 8 months
master - lvconvert: drop limit on thin pool conversion
by Zdenek Kabelac
Gitweb: http://git.fedorahosted.org/git/?p=lvm2.git;a=commitdiff;h=f1d5f6ae81f472...
Commit: f1d5f6ae81f4723e6aeb2f04bd68cba59cd65403
Parent: 03efb7c2e121d68ba39691b796dae8c9606108d4
Author: Zdenek Kabelac <zkabelac(a)redhat.com>
AuthorDate: Sun Jun 16 21:05:00 2013 +0200
Committer: Zdenek Kabelac <zkabelac(a)redhat.com>
CommitterDate: Mon Jul 22 12:41:22 2013 +0200
lvconvert: drop limit on thin pool conversion
---
tools/lvconvert.c | 7 -------
1 files changed, 0 insertions(+), 7 deletions(-)
diff --git a/tools/lvconvert.c b/tools/lvconvert.c
index 97ef7e4..ce28947 100644
--- a/tools/lvconvert.c
+++ b/tools/lvconvert.c
@@ -1541,13 +1541,6 @@ static int _lvconvert_mirrors(struct cmd_context *cmd,
return 0;
}
- /* TODO: decide what should be done here */
- if (lv_is_thin_type(lv)) {
- log_error("Converting segment type for %s/%s to mirror is not yet supported.",
- lv->vg->name, lv->name);
- return 0;
- }
-
/* Adjust mimage and/or log count */
if (!_lvconvert_mirrors_parse_params(cmd, lv, lp,
&old_mimage_count, &old_log_count,
9 years, 8 months
master - python: make install to prefix dir
by Zdenek Kabelac
Gitweb: http://git.fedorahosted.org/git/?p=lvm2.git;a=commitdiff;h=03efb7c2e121d6...
Commit: 03efb7c2e121d68ba39691b796dae8c9606108d4
Parent: c394c2a624b24193ca769bff956ca2bd8d1e5c1b
Author: Zdenek Kabelac <zkabelac(a)redhat.com>
AuthorDate: Fri Jul 19 20:48:41 2013 +0200
Committer: Zdenek Kabelac <zkabelac(a)redhat.com>
CommitterDate: Mon Jul 22 12:41:22 2013 +0200
python: make install to prefix dir
Respect $prefix and avoid install to live system.
---
python/Makefile.in | 4 ++--
1 files changed, 2 insertions(+), 2 deletions(-)
diff --git a/python/Makefile.in b/python/Makefile.in
index 1fead22..9f9046b 100644
--- a/python/Makefile.in
+++ b/python/Makefile.in
@@ -1,5 +1,5 @@
#
-# Copyright (C) 2011-2012 Red Hat, Inc.
+# Copyright (C) 2011-2013 Red Hat, Inc.
#
# This file is part of LVM2.
#
@@ -27,7 +27,7 @@ liblvm_python.c:
include $(top_builddir)/make.tmpl
install_python_bindings: python_bindings
- $(PYTHON) setup.py install --skip-build --root $(rootdir)
+ $(PYTHON) setup.py install --skip-build --root $(DESTDIR)$(prefix)
install_lvm2: install_python_bindings
9 years, 8 months
master - dumpconfig: check conf tree was created
by Zdenek Kabelac
Gitweb: http://git.fedorahosted.org/git/?p=lvm2.git;a=commitdiff;h=c394c2a624b241...
Commit: c394c2a624b24193ca769bff956ca2bd8d1e5c1b
Parent: baada4316dd2fcf0383ed7bcfa539c0429e17131
Author: Zdenek Kabelac <zkabelac(a)redhat.com>
AuthorDate: Fri Jul 19 17:32:08 2013 +0200
Committer: Zdenek Kabelac <zkabelac(a)redhat.com>
CommitterDate: Mon Jul 22 12:41:21 2013 +0200
dumpconfig: check conf tree was created
Missing error path.
---
tools/dumpconfig.c | 7 +++++--
1 files changed, 5 insertions(+), 2 deletions(-)
diff --git a/tools/dumpconfig.c b/tools/dumpconfig.c
index da216f5..0887297 100644
--- a/tools/dumpconfig.c
+++ b/tools/dumpconfig.c
@@ -196,8 +196,11 @@ int dumpconfig(struct cmd_context *cmd, int argc, char **argv)
if (cft_check_handle)
tree_spec.check_status = cft_check_handle->status;
- if (tree_spec.type != CFG_DEF_TREE_CURRENT)
- cft = config_def_create_tree(&tree_spec);
+ if ((tree_spec.type != CFG_DEF_TREE_CURRENT) &&
+ !(cft = config_def_create_tree(&tree_spec))) {
+ r = ECMD_FAILED;
+ goto_out;
+ }
if (!config_write(cft, arg_count(cmd, withcomments_ARG),
arg_count(cmd, withversions_ARG),
9 years, 8 months
master - liblvm: check lvmetad cache return values
by Zdenek Kabelac
Gitweb: http://git.fedorahosted.org/git/?p=lvm2.git;a=commitdiff;h=baada4316dd2fc...
Commit: baada4316dd2fcf0383ed7bcfa539c0429e17131
Parent: dedec81d7b939650f390c0be5a23632b39d83012
Author: Zdenek Kabelac <zkabelac(a)redhat.com>
AuthorDate: Fri Jul 19 17:31:13 2013 +0200
Committer: Zdenek Kabelac <zkabelac(a)redhat.com>
CommitterDate: Mon Jul 22 12:41:21 2013 +0200
liblvm: check lvmetad cache return values
Missing error path.
---
liblvm/lvm_vg.c | 8 ++++++--
1 files changed, 6 insertions(+), 2 deletions(-)
diff --git a/liblvm/lvm_vg.c b/liblvm/lvm_vg.c
index c128ba7..3f4968e 100644
--- a/liblvm/lvm_vg.c
+++ b/liblvm/lvm_vg.c
@@ -362,13 +362,17 @@ int lvm_vg_set_property(const vg_t vg, const char *name,
struct dm_list *lvm_list_vg_names(lvm_t libh)
{
- lvmetad_vg_list_to_lvmcache((struct cmd_context *)libh);
+ if (!lvmetad_vg_list_to_lvmcache((struct cmd_context *)libh))
+ return NULL;
+
return get_vgnames((struct cmd_context *)libh, 0);
}
struct dm_list *lvm_list_vg_uuids(lvm_t libh)
{
- lvmetad_vg_list_to_lvmcache((struct cmd_context *)libh);
+ if (!lvmetad_vg_list_to_lvmcache((struct cmd_context *)libh))
+ return NULL;
+
return get_vgids((struct cmd_context *)libh, 0);
}
9 years, 8 months
master - cleanup: do not return stack content
by Zdenek Kabelac
Gitweb: http://git.fedorahosted.org/git/?p=lvm2.git;a=commitdiff;h=dedec81d7b9396...
Commit: dedec81d7b939650f390c0be5a23632b39d83012
Parent: aed4e9c703a81aec0a56dc7134ff336683ab5c1a
Author: Zdenek Kabelac <zkabelac(a)redhat.com>
AuthorDate: Fri Jul 19 17:29:37 2013 +0200
Committer: Zdenek Kabelac <zkabelac(a)redhat.com>
CommitterDate: Mon Jul 22 12:41:21 2013 +0200
cleanup: do not return stack content
Return initialized struct in error path.
---
liblvm/lvm_lv.c | 7 ++++---
1 files changed, 4 insertions(+), 3 deletions(-)
diff --git a/liblvm/lvm_lv.c b/liblvm/lvm_lv.c
index f416195..7fc2392 100644
--- a/liblvm/lvm_lv.c
+++ b/liblvm/lvm_lv.c
@@ -593,15 +593,16 @@ struct lvm_property_value lvm_lv_params_get_property(
const lv_create_params_t params,
const char *name)
{
- struct lvm_property_value rc;
-
- rc.is_valid = 0;
+ struct lvm_property_value rc = {
+ .is_valid = 0
+ };
if (params && params->magic == LV_CREATE_PARAMS_MAGIC) {
rc = get_property(NULL, NULL, NULL, NULL, NULL, ¶ms->lvp, name);
} else {
log_error("Invalid lv_create_params parameter");
}
+
return rc;
}
9 years, 8 months
master - coverity: pointer validation
by Zdenek Kabelac
Gitweb: http://git.fedorahosted.org/git/?p=lvm2.git;a=commitdiff;h=aed4e9c703a81a...
Commit: aed4e9c703a81aec0a56dc7134ff336683ab5c1a
Parent: 90bdbcc2017cf9bc868aaa95616fcdb3de19b96f
Author: Zdenek Kabelac <zkabelac(a)redhat.com>
AuthorDate: Fri Jul 19 17:28:43 2013 +0200
Committer: Zdenek Kabelac <zkabelac(a)redhat.com>
CommitterDate: Mon Jul 22 12:41:21 2013 +0200
coverity: pointer validation
Check for metadata_lv and make sure we have got proper thin pool segment.
Check we are working with merging snapshot when adding merging target.
---
lib/activate/dev_manager.c | 7 ++++++-
lib/thin/thin.c | 5 +++++
2 files changed, 11 insertions(+), 1 deletions(-)
diff --git a/lib/activate/dev_manager.c b/lib/activate/dev_manager.c
index 50e52d1..6a68653 100644
--- a/lib/activate/dev_manager.c
+++ b/lib/activate/dev_manager.c
@@ -1998,7 +1998,12 @@ static int _add_snapshot_merge_target_to_dtree(struct dev_manager *dm,
struct logical_volume *lv)
{
const char *origin_dlid, *cow_dlid, *merge_dlid;
- struct lv_segment *merging_snap_seg = find_merging_snapshot(lv);
+ struct lv_segment *merging_snap_seg;
+
+ if (!(merging_snap_seg = find_merging_snapshot(lv))) {
+ log_error(INTERNAL_ERROR "LV %s is not merging snapshot.", lv->name);
+ return 0;
+ }
if (!(origin_dlid = build_dm_uuid(dm->mem, lv->lvid.s, "real")))
return_0;
diff --git a/lib/thin/thin.c b/lib/thin/thin.c
index 520a3d2..bdb9c88 100644
--- a/lib/thin/thin.c
+++ b/lib/thin/thin.c
@@ -245,6 +245,11 @@ static int _thin_pool_add_target_line(struct dev_manager *dm,
if (!_thin_target_present(cmd, seg, &attr))
return_0;
+ if (!seg->metadata_lv) {
+ log_error(INTERNAL_ERROR "Thin pool is missing metadata device.");
+ return 0;
+ }
+
if (!(attr & THIN_FEATURE_BLOCK_SIZE) &&
(seg->chunk_size & (seg->chunk_size - 1))) {
log_error("Thin pool target does not support %uKiB chunk size "
9 years, 8 months
master - liblvm: check extents_from_size
by Zdenek Kabelac
Gitweb: http://git.fedorahosted.org/git/?p=lvm2.git;a=commitdiff;h=90bdbcc2017cf9...
Commit: 90bdbcc2017cf9bc868aaa95616fcdb3de19b96f
Parent: d4ad728610db1751af1eab2c8c7d6130a3742394
Author: Zdenek Kabelac <zkabelac(a)redhat.com>
AuthorDate: Fri Jul 19 15:35:04 2013 +0200
Committer: Zdenek Kabelac <zkabelac(a)redhat.com>
CommitterDate: Mon Jul 22 12:41:21 2013 +0200
liblvm: check extents_from_size
Since the function may fail, check for error.
(in release fix)
---
liblvm/lvm_lv.c | 34 ++++++++++++++++++++++------------
1 files changed, 22 insertions(+), 12 deletions(-)
diff --git a/liblvm/lvm_lv.c b/liblvm/lvm_lv.c
index 27a0f07..f416195 100644
--- a/liblvm/lvm_lv.c
+++ b/liblvm/lvm_lv.c
@@ -368,7 +368,7 @@ lv_t lvm_lv_snapshot(const lv_t lv, const char *snap_name,
}
/* Set defaults for thin pool specific LV parameters */
-static void _lv_set_pool_params(struct lvcreate_params *lp,
+static int _lv_set_pool_params(struct lvcreate_params *lp,
vg_t vg, const char *pool,
uint64_t extents, uint64_t meta_size)
{
@@ -396,9 +396,12 @@ static void _lv_set_pool_params(struct lvcreate_params *lp,
lp->poolmetadatasize +=
vg->extent_size - lp->poolmetadatasize % vg->extent_size;
- lp->poolmetadataextents =
- extents_from_size(vg->cmd, lp->poolmetadatasize / SECTOR_SIZE,
- vg->extent_size);
+ if (!(lp->poolmetadataextents =
+ extents_from_size(vg->cmd, lp->poolmetadatasize / SECTOR_SIZE,
+ vg->extent_size)))
+ return_0;
+
+ return 1;
}
lv_create_params_t lvm_lv_params_create_thin_pool(vg_t vg,
@@ -453,7 +456,8 @@ lv_create_params_t lvm_lv_params_create_thin_pool(vg_t vg,
return NULL;
}
- _lv_set_pool_params(&lvcp->lvp, vg, pool_name, extents, meta_size);
+ if (!_lv_set_pool_params(&lvcp->lvp, vg, pool_name, extents, meta_size))
+ return_NULL;
lvcp->magic = LV_CREATE_PARAMS_MAGIC;
}
@@ -461,7 +465,7 @@ lv_create_params_t lvm_lv_params_create_thin_pool(vg_t vg,
}
/* Set defaults for thin LV specific parameters */
-static void _lv_set_thin_params(struct lvcreate_params *lp,
+static int _lv_set_thin_params(struct lvcreate_params *lp,
vg_t vg, const char *pool,
const char *lvname,
uint64_t extents)
@@ -473,15 +477,18 @@ static void _lv_set_thin_params(struct lvcreate_params *lp,
lp->segtype = get_segtype_from_string(vg->cmd, "thin");
lp->voriginsize = extents * vg->extent_size;
- lp->voriginextents = extents_from_size(vg->cmd, lp->voriginsize,
- vg->extent_size);
+ if (!(lp->voriginextents = extents_from_size(vg->cmd, lp->voriginsize,
+ vg->extent_size)))
+ return_0;
lp->stripes = 1;
+
+ return 1;
}
lv_create_params_t lvm_lv_params_create_snapshot(const lv_t lv,
- const char *snap_name,
- uint64_t max_snap_size)
+ const char *snap_name,
+ uint64_t max_snap_size)
{
uint64_t size = 0;
uint64_t extents = 0;
@@ -501,7 +508,8 @@ lv_create_params_t lvm_lv_params_create_snapshot(const lv_t lv,
if (max_snap_size) {
size = max_snap_size >> SECTOR_SHIFT;
- extents = extents_from_size(lv->vg->cmd, size, lv->vg->extent_size);
+ if (!(extents = extents_from_size(lv->vg->cmd, size, lv->vg->extent_size)))
+ return_NULL;
}
if (!size && !lv_is_thin_volume(lv) ) {
@@ -572,7 +580,9 @@ lv_create_params_t lvm_lv_params_create_thin(const vg_t vg, const char *pool_nam
lvcp = dm_pool_zalloc(vg->vgmem, sizeof (struct lvm_lv_create_params));
if (lvcp) {
lvcp->vg = vg;
- _lv_set_thin_params(&lvcp->lvp, vg, pool_name, lvname, extents);
+ if (!_lv_set_thin_params(&lvcp->lvp, vg, pool_name, lvname, extents))
+ return_NULL;
+
lvcp->magic = LV_CREATE_PARAMS_MAGIC;
}
9 years, 8 months