master - cleanup: readable test to check for 32bit overflow
by Zdenek Kabelac
Gitweb: http://git.fedorahosted.org/git/?p=lvm2.git;a=commitdiff;h=9bb210192dd5b6...
Commit: 9bb210192dd5b60582633079d4769a582ac11074
Parent: 3972bd98fbec1c2ab9453a33790636a632e7be65
Author: Zdenek Kabelac <zkabelac(a)redhat.com>
AuthorDate: Thu Jan 19 22:28:06 2012 +0100
Committer: Zdenek Kabelac <zkabelac(a)redhat.com>
CommitterDate: Sun Oct 14 23:19:27 2012 +0200
cleanup: readable test to check for 32bit overflow
also swap return value 0 - fail, 1 - success.
---
tools/toollib.c | 11 ++++++-----
1 files changed, 6 insertions(+), 5 deletions(-)
diff --git a/tools/toollib.c b/tools/toollib.c
index 1916bfd..3fe1c14 100644
--- a/tools/toollib.c
+++ b/tools/toollib.c
@@ -994,10 +994,11 @@ static int xstrtouint32(const char *s, char **p, int base, uint32_t *result)
errno = 0;
ul = strtoul(s, p, base);
- if (errno || *p == s || (uint32_t) ul != ul)
- return -1;
+ if (errno || *p == s || ul > UINT32_MAX)
+ return 0;
*result = ul;
- return 0;
+
+ return 1;
}
static int _parse_pes(struct dm_pool *mem, char *c, struct dm_list *pe_ranges,
@@ -1029,7 +1030,7 @@ static int _parse_pes(struct dm_pool *mem, char *c, struct dm_list *pe_ranges,
/* Start extent given? */
if (isdigit(*c)) {
- if (xstrtouint32(c, &endptr, 10, &start))
+ if (!xstrtouint32(c, &endptr, 10, &start))
goto error;
c = endptr;
/* Just one number given? */
@@ -1040,7 +1041,7 @@ static int _parse_pes(struct dm_pool *mem, char *c, struct dm_list *pe_ranges,
if (*c == '-') {
c++;
if (isdigit(*c)) {
- if (xstrtouint32(c, &endptr, 10, &end))
+ if (!xstrtouint32(c, &endptr, 10, &end))
goto error;
c = endptr;
}
11 years, 5 months
master - thin: add support to unmount volumes
by Zdenek Kabelac
Gitweb: http://git.fedorahosted.org/git/?p=lvm2.git;a=commitdiff;h=3972bd98fbec1c...
Commit: 3972bd98fbec1c2ab9453a33790636a632e7be65
Parent: c6f2821b9fb74bec2de29a878e71fc64a70d11bb
Author: Zdenek Kabelac <zkabelac(a)redhat.com>
AuthorDate: Thu Mar 22 18:29:38 2012 +0100
Committer: Zdenek Kabelac <zkabelac(a)redhat.com>
CommitterDate: Sun Oct 14 23:19:20 2012 +0200
thin: add support to unmount volumes
Reset counter after thin pool resize failure.
If the pool goes above threshold, support unmounting
of all thin volumes if the lvextend fails to avoid
overfilling of the pool.
---
WHATS_NEW_DM | 1 +
daemons/dmeventd/plugins/thin/dmeventd_thin.c | 299 +++++++++++++++++++------
test/shell/thin-autoumount-dmeventd.sh | 70 ++++++
3 files changed, 301 insertions(+), 69 deletions(-)
diff --git a/WHATS_NEW_DM b/WHATS_NEW_DM
index 22d4b01..342605f 100644
--- a/WHATS_NEW_DM
+++ b/WHATS_NEW_DM
@@ -1,5 +1,6 @@
Version 1.02.77 -
=================================
+ Support unmount of thin volumes from pool above thin pool threshold.
Update man page to reflect that dm UUIDs are being mangled as well.
Apply 'dmsetup mangle' for dm UUIDs besides dm names.
Add 'mangled_uuid' and 'unmangled_uuid' fields to dmsetup info -c -o.
diff --git a/daemons/dmeventd/plugins/thin/dmeventd_thin.c b/daemons/dmeventd/plugins/thin/dmeventd_thin.c
index 5a408a8..a1af4c0 100644
--- a/daemons/dmeventd/plugins/thin/dmeventd_thin.c
+++ b/daemons/dmeventd/plugins/thin/dmeventd_thin.c
@@ -1,5 +1,5 @@
/*
- * Copyright (C) 2011 Red Hat, Inc. All rights reserved.
+ * Copyright (C) 2011-2012 Red Hat, Inc. All rights reserved.
*
* This file is part of LVM2.
*
@@ -43,6 +43,152 @@ struct dso_state {
char cmd_str[1024];
};
+
+/* TODO - move this mountinfo code into library to be reusable */
+#ifdef linux
+# include "kdev_t.h"
+#else
+# define MAJOR(x) major((x))
+# define MINOR(x) minor((x))
+# define MKDEV(x,y) makedev((x),(y))
+#endif
+
+/* Macros to make string defines */
+#define TO_STRING_EXP(A) #A
+#define TO_STRING(A) TO_STRING_EXP(A)
+
+static int _is_octal(int a)
+{
+ return (((a) & ~7) == '0');
+}
+
+/* Convert mangled mountinfo into normal ASCII string */
+static void _unmangle_mountinfo_string(const char *src, char *buf)
+{
+ if (!src)
+ return;
+
+ while (*src) {
+ if ((*src == '\\') &&
+ _is_octal(src[1]) && _is_octal(src[2]) && _is_octal(src[3])) {
+ *buf++ = 64 * (src[1] & 7) + 8 * (src[2] & 7) + (src[3] & 7);
+ src += 4;
+ } else
+ *buf++ = *src++;
+ }
+ *buf = '\0';
+}
+
+/* Parse one line of mountinfo */
+static int _parse_mountinfo_line(const char *line, unsigned *maj, unsigned *min, char *buf)
+{
+ char root[PATH_MAX + 1];
+ char target[PATH_MAX + 1];
+
+ /* TODO: maybe detect availability of %ms glib support ? */
+ if (sscanf(line, "%*u %*u %u:%u %" TO_STRING(PATH_MAX)
+ "s %" TO_STRING(PATH_MAX) "s",
+ maj, min, root, target) < 4)
+ return 0;
+
+ _unmangle_mountinfo_string(target, buf);
+
+#if THIN_DEBUG
+ syslog(LOG_DEBUG, "Mounted %u:%u %s", *maj, *min, buf);
+#endif
+
+ return 1;
+}
+
+/* Get dependencies for device, and try to find matching device */
+static int _has_deps(const char *name, int tp_major, int tp_minor, int *dev_minor)
+{
+ struct dm_task *dmt;
+ const struct dm_deps *deps;
+ struct dm_info info;
+ int major, minor;
+ int r = 0;
+
+ if (!(dmt = dm_task_create(DM_DEVICE_DEPS)))
+ return 0;
+
+ if (!dm_task_set_name(dmt, name))
+ goto out;
+
+ if (!dm_task_no_open_count(dmt))
+ goto out;
+
+ if (!dm_task_run(dmt))
+ goto out;
+
+ if (!dm_task_get_info(dmt, &info))
+ goto out;
+
+ if (!(deps = dm_task_get_deps(dmt)))
+ goto out;
+
+ if (!info.exists || deps->count != 1)
+ goto out;
+
+ major = (int) MAJOR(deps->device[0]);
+ minor = (int) MINOR(deps->device[0]);
+ if ((major != tp_major) || (minor != tp_minor))
+ goto out;
+
+ *dev_minor = info.minor;
+
+#if THIN_DEBUG
+ {
+ char dev_name[PATH_MAX];
+ if (dm_device_get_name(major, minor, 0, dev_name, sizeof(dev_name)))
+ syslog(LOG_DEBUG, "Found %s (%u:%u) depends on %s",
+ name, major, *dev_minor, dev_name);
+ }
+#endif
+ r = 1;
+out:
+ dm_task_destroy(dmt);
+
+ return r;
+}
+
+/* Get all active devices */
+static int _find_all_devs(dm_bitset_t bs, int tp_major, int tp_minor)
+{
+ struct dm_task *dmt;
+ struct dm_names *names;
+ unsigned next = 0;
+ int minor, r = 1;
+
+ if (!(dmt = dm_task_create(DM_DEVICE_LIST)))
+ return 0;
+
+ if (!dm_task_run(dmt)) {
+ r = 0;
+ goto out;
+ }
+
+ if (!(names = dm_task_get_names(dmt))) {
+ r = 0;
+ goto out;
+ }
+
+ if (!names->dev)
+ goto out;
+
+ do {
+ names = (struct dm_names *)((char *) names + next);
+ if (_has_deps(names->name, tp_major, tp_minor, &minor))
+ dm_bit_set(bs, minor);
+ next = names->next;
+ } while (next);
+
+out:
+ dm_task_destroy(dmt);
+
+ return r;
+}
+
static int _extend(struct dso_state *state)
{
#if THIN_DEBUG
@@ -51,87 +197,104 @@ static int _extend(struct dso_state *state)
return (dmeventd_lvm2_run(state->cmd_str) == ECMD_PROCESSED);
}
-#if 0
static int _run(const char *cmd, ...)
{
- va_list ap;
- int argc = 1; /* for argv[0], i.e. cmd */
- int i = 0;
- const char **argv;
- pid_t pid = fork();
- int status;
-
- if (pid == 0) { /* child */
- va_start(ap, cmd);
- while (va_arg(ap, const char *))
- ++argc;
- va_end(ap);
-
- /* + 1 for the terminating NULL */
- argv = alloca(sizeof(const char *) * (argc + 1));
-
- argv[0] = cmd;
+ va_list ap;
+ int argc = 1; /* for argv[0], i.e. cmd */
+ int i = 0;
+ const char **argv;
+ pid_t pid = fork();
+ int status;
+
+ if (pid == 0) { /* child */
+ va_start(ap, cmd);
+ while (va_arg(ap, const char *))
+ ++argc;
+ va_end(ap);
+
+ /* + 1 for the terminating NULL */
+ argv = alloca(sizeof(const char *) * (argc + 1));
+
+ argv[0] = cmd;
va_start(ap, cmd);
- while ((argv[++i] = va_arg(ap, const char *)));
- va_end(ap);
+ while ((argv[++i] = va_arg(ap, const char *)));
+ va_end(ap);
- execvp(cmd, (char **)argv);
- syslog(LOG_ERR, "Failed to execute %s: %s.\n", cmd, strerror(errno));
- exit(127);
- }
+ execvp(cmd, (char **)argv);
+ syslog(LOG_ERR, "Failed to execute %s: %s.\n", cmd, strerror(errno));
+ exit(127);
+ }
- if (pid > 0) { /* parent */
- if (waitpid(pid, &status, 0) != pid)
- return 0; /* waitpid failed */
- if (!WIFEXITED(status) || WEXITSTATUS(status))
- return 0; /* the child failed */
- }
+ if (pid > 0) { /* parent */
+ if (waitpid(pid, &status, 0) != pid)
+ return 0; /* waitpid failed */
+ if (!WIFEXITED(status) || WEXITSTATUS(status))
+ return 0; /* the child failed */
+ }
- if (pid < 0)
- return 0; /* fork failed */
+ if (pid < 0)
+ return 0; /* fork failed */
- return 1; /* all good */
+ return 1; /* all good */
}
-/* FIXME: all thin pool users needs to be here */
-static void _umount(const char *device, int major, int minor)
+/*
+ * Find all thin pool users and try to umount them.
+ * TODO: work with read-only thin pool support
+ */
+static void _umount(struct dm_task *dmt, const char *device)
{
- FILE *mounts;
+ static const char mountinfo[] = "/proc/self/mountinfo";
+ static const size_t MINORS = 4096;
+ FILE *minfo;
char buffer[4096];
- char *words[3];
- struct stat st;
+ char target[PATH_MAX];
+ struct dm_info info;
+ unsigned maj, min;
+ dm_bitset_t minors; /* Bitset for active thin pool minors */
- if (!(mounts = fopen("/proc/mounts", "r"))) {
- syslog(LOG_ERR, "Could not read /proc/mounts. Not umounting %s.\n", device);
+ if (!dm_task_get_info(dmt, &info))
return;
+
+ dmeventd_lvm2_unlock();
+
+ if (!(minors = dm_bitset_create(NULL, MINORS))) {
+ syslog(LOG_ERR, "Failed to allocate bitset. Not unmounting %s.\n", device);
+ goto out;
}
- while (!feof(mounts)) {
- /* read a line of /proc/mounts */
- if (!fgets(buffer, sizeof(buffer), mounts))
- break; /* eof, likely */
+ if (!(minfo = fopen(mountinfo, "r"))) {
+ syslog(LOG_ERR, "Could not read %s. Not umounting %s.\n", mountinfo, device);
+ goto out;
+ }
- /* words[0] is the mount point and words[1] is the device path */
- dm_split_words(buffer, 3, 0, words);
+ if (!_find_all_devs(minors, info.major, info.minor)) {
+ syslog(LOG_ERR, "Failed to detect mounted volumes for %s.\n", device);
+ goto out;
+ }
- /* find the major/minor of the device */
- if (stat(words[0], &st))
- continue; /* can't stat, skip this one */
+ while (!feof(minfo)) {
+ /* read mountinfo line */
+ if (!fgets(buffer, sizeof(buffer), minfo))
+ break; /* eof, likely */
- if (S_ISBLK(st.st_mode) &&
- (int) major(st.st_rdev) == major &&
- (int) minor(st.st_rdev) == minor) {
- syslog(LOG_ERR, "Unmounting invalid thin %s from %s.\n", device, words[1]);
- if (!_run(UMOUNT_COMMAND, "-fl", words[1], NULL))
+ if (_parse_mountinfo_line(buffer, &maj, &min, target) &&
+ (maj == info.major) && dm_bit(minors, min)) {
+ syslog(LOG_INFO, "Unmounting thin volume %s from %s.\n",
+ device, target);
+ if (!_run(UMOUNT_COMMAND, "-fl", target, NULL))
syslog(LOG_ERR, "Failed to umount thin %s from %s: %s.\n",
- device, words[1], strerror(errno));
+ device, target, strerror(errno));
}
}
- if (fclose(mounts))
- syslog(LOG_ERR, "Failed to close /proc/mounts.\n");
+ if (fclose(minfo))
+ syslog(LOG_ERR, "Failed to close %s\n", mountinfo);
+
+ dm_bitset_destroy(minors);
+out:
+ dmeventd_lvm2_lock();
}
-#endif
void process_event(struct dm_task *dmt,
enum dm_event_mask event __attribute__((unused)),
@@ -162,14 +325,7 @@ void process_event(struct dm_task *dmt,
if (!dm_get_status_thin_pool(state->mem, params, &tps)) {
syslog(LOG_ERR, "Failed to parse status.\n");
-#if 0
- /* FIXME hmm what we should do? */
- struct dm_info info;
- if (dm_task_get_info(dmt, &info)) {
- dmeventd_lvm2_unlock();
- _umount(device, info.major, info.minor);
- } /* else; too bad, but this is best-effort thing... */
-#endif
+ _umount(dmt, device);
goto out;
}
@@ -204,9 +360,11 @@ void process_event(struct dm_task *dmt,
syslog(LOG_WARNING, "Thin metadata %s is now %i%% full.\n",
device, percent);
/* Try to extend the metadata, in accord with user-set policies */
- if (!_extend(state))
+ if (!_extend(state)) {
syslog(LOG_ERR, "Failed to extend thin metadata %s.\n",
device);
+ _umount(dmt, device);
+ }
/* FIXME: hmm READ-ONLY switch should happen in error path */
}
@@ -221,8 +379,11 @@ void process_event(struct dm_task *dmt,
if (percent >= WARNING_THRESH) /* Print a warning to syslog. */
syslog(LOG_WARNING, "Thin %s is now %i%% full.\n", device, percent);
/* Try to extend the thin data, in accord with user-set policies */
- if (!_extend(state))
+ if (!_extend(state)) {
syslog(LOG_ERR, "Failed to extend thin %s.\n", device);
+ state->data_percent_check = 0;
+ _umount(dmt, device);
+ }
/* FIXME: hmm READ-ONLY switch should happen in error path */
}
out:
diff --git a/test/shell/thin-autoumount-dmeventd.sh b/test/shell/thin-autoumount-dmeventd.sh
new file mode 100644
index 0000000..bbffe8a
--- /dev/null
+++ b/test/shell/thin-autoumount-dmeventd.sh
@@ -0,0 +1,70 @@
+#!/bin/bash
+# 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
+
+# no automatic extensions, just umount
+
+is_dir_mounted_()
+{
+ cat /proc/mounts | sed 's:\\040: :g' | grep "$1"
+}
+
+. lib/test
+
+#
+# Main
+#
+which mkfs.ext2 || skip
+
+aux have_thin 1 0 0 || skip
+
+aux prepare_dmeventd
+
+aux lvmconf "activation/thin_pool_autoextend_percent = 0" \
+ "activation/thin_pool_autoextend_threshold = 70"
+
+aux prepare_vg 2
+
+mntdir="${PREFIX}mnt with space"
+mntusedir="${PREFIX}mntuse"
+
+lvcreate -L8M -V8M -n $lv1 -T $vg/pool
+lvcreate -V8M -n $lv2 -T $vg/pool
+
+mkfs.ext2 "$DM_DEV_DIR/$vg/$lv1"
+mkfs.ext2 "$DM_DEV_DIR/$vg/$lv2"
+
+lvchange --monitor y $vg/pool
+
+mkdir "$mntdir" "$mntusedir"
+mount "$DM_DEV_DIR/mapper/$vg-$lv1" "$mntdir"
+mount "$DM_DEV_DIR/mapper/$vg-$lv2" "$mntusedir"
+
+is_dir_mounted_ "$mntdir"
+
+# fill above 70%
+dd if=/dev/zero of="$mntdir/file$$" bs=1M count=6
+touch "$mntusedir/file$$"
+tail -f "$mntusedir/file$$" &
+PID_TAIL=$!
+sync
+lvs -a $vg
+sleep 12 # dmeventd only checks every 10 seconds :(
+
+lvs -a $vg
+# both dirs should be unmounted
+not is_dir_mounted "$mntdir"
+not is_dir_mounted "$mntusedir"
+
+# running tail keeps the block device still in use
+kill $PID_TAIL
+lvs -a $vg
+
+vgremove -f $vg
11 years, 5 months
master - test: speedup a bit
by Zdenek Kabelac
Gitweb: http://git.fedorahosted.org/git/?p=lvm2.git;a=commitdiff;h=c6f2821b9fb74b...
Commit: c6f2821b9fb74bec2de29a878e71fc64a70d11bb
Parent: 16060b101bdb541376fdfd7c0e6cac8cf73c0271
Author: Zdenek Kabelac <zkabelac(a)redhat.com>
AuthorDate: Sun Oct 14 19:45:59 2012 +0200
Committer: Zdenek Kabelac <zkabelac(a)redhat.com>
CommitterDate: Sun Oct 14 23:17:33 2012 +0200
test: speedup a bit
Do not wait full 10s if the invalid snapshot is already dropped.
---
test/shell/snapshot-autoumount-dmeventd.sh | 11 +++++++----
1 files changed, 7 insertions(+), 4 deletions(-)
diff --git a/test/shell/snapshot-autoumount-dmeventd.sh b/test/shell/snapshot-autoumount-dmeventd.sh
index dbb90df..3b4b711 100644
--- a/test/shell/snapshot-autoumount-dmeventd.sh
+++ b/test/shell/snapshot-autoumount-dmeventd.sh
@@ -1,5 +1,5 @@
#!/bin/bash
-# Copyright (C) 2010 Red Hat, Inc. All rights reserved.
+# Copyright (C) 2010-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
@@ -32,10 +32,13 @@ mkdir "$mntdir"
mount "$DM_DEV_DIR/mapper/$vg-snap" "$mntdir"
mount
cat /proc/mounts | grep "$mntdir"
-
-dd if=/dev/zero of="$mntdir/file$1" bs=1M count=17
+dd if=/dev/zero of="$mntdir/file$1" bs=1M count=16
sync
-sleep 10 # dmeventd only checks every 10 seconds :(
+#dmeventd only checks every 10 seconds :(
+for i in {1..10}; do
+ cat /proc/mounts | grep "$mntdir" || break
+ sleep 1
+done
cat /proc/mounts | not grep "$mntdir"
11 years, 5 months
master - thin: lvextend will fail is autoextend is 0%
by Zdenek Kabelac
Gitweb: http://git.fedorahosted.org/git/?p=lvm2.git;a=commitdiff;h=16060b101bdb54...
Commit: 16060b101bdb541376fdfd7c0e6cac8cf73c0271
Parent: a6f53b5c0d2a23f73af7d4a2778dfc0da4da0944
Author: Zdenek Kabelac <zkabelac(a)redhat.com>
AuthorDate: Sun Oct 14 19:43:25 2012 +0200
Committer: Zdenek Kabelac <zkabelac(a)redhat.com>
CommitterDate: Sun Oct 14 23:17:30 2012 +0200
thin: lvextend will fail is autoextend is 0%
Since extending by 0% will not increase the size of pool,
return failure.
---
WHATS_NEW | 1 +
tools/lvresize.c | 2 ++
2 files changed, 3 insertions(+), 0 deletions(-)
diff --git a/WHATS_NEW b/WHATS_NEW
index a170bfe..d60cad5 100644
--- a/WHATS_NEW
+++ b/WHATS_NEW
@@ -1,5 +1,6 @@
Version 2.02.98 -
=================================
+ Using autoextend percent 0 for thin pool fails 'lvextend --use-policies'.
Introduce blkdeactivate script.
Implement devices/global_filter (affects lvmetad).
Make vgscan --cache an alias to pvscan --cache.
diff --git a/tools/lvresize.c b/tools/lvresize.c
index 18e5917..4c9580d 100644
--- a/tools/lvresize.c
+++ b/tools/lvresize.c
@@ -293,6 +293,8 @@ static int _adjust_policy_params(struct cmd_context *cmd,
policy_amount =
find_config_tree_int(cmd, "activation/thin_pool_autoextend_percent",
DEFAULT_THIN_POOL_AUTOEXTEND_PERCENT);
+ if (!policy_amount && policy_threshold < PERCENT_100)
+ return 0;
} else {
policy_threshold =
find_config_tree_int(cmd, "activation/snapshot_autoextend_threshold",
11 years, 5 months
master - test: coverage
by Zdenek Kabelac
Gitweb: http://git.fedorahosted.org/git/?p=lvm2.git;a=commitdiff;h=a6f53b5c0d2a23...
Commit: a6f53b5c0d2a23f73af7d4a2778dfc0da4da0944
Parent: 920352da70245f9b385aa0465f9ee88091676371
Author: Zdenek Kabelac <zkabelac(a)redhat.com>
AuthorDate: Sat Oct 13 21:57:33 2012 +0200
Committer: Zdenek Kabelac <zkabelac(a)redhat.com>
CommitterDate: Sun Oct 14 23:14:48 2012 +0200
test: coverage
Improve a bit code coverage.
Use lvm shell to reduce a bit CPU time.
---
test/shell/covercmd.sh | 20 ++++++++++++++------
test/shell/lvcreate-thin.sh | 1 +
2 files changed, 15 insertions(+), 6 deletions(-)
diff --git a/test/shell/covercmd.sh b/test/shell/covercmd.sh
index 3fa9ea5..0514468 100644
--- a/test/shell/covercmd.sh
+++ b/test/shell/covercmd.sh
@@ -28,15 +28,23 @@ vgcreate -c n $vg $(cat DEVICES)
lvcreate -l 5 -i5 -I256 -n $lv $vg
# test *scan and *display tools
+cat <<EOF | lvm
pvscan
vgscan
lvscan
lvmdiskscan
-vgdisplay --units k
-lvdisplay --units g
+vgdisplay --units k $vg
+lvdisplay --units g $vg
+pvdisplay -c "$dev1"
+pvdisplay -s "$dev1"
+vgdisplay -c $vg
+vgdisplay -s $vg
+lvdisplay -c $vg
+EOF
+
for i in h b s k m g t p e H B S K M G T P E; do
- pvdisplay --units $i "$dev1"
-done
+ echo pvdisplay --units $i "$dev1"
+done | lvm
# test vgexport vgimport tools
vgchange -an $vg
@@ -53,8 +61,8 @@ done
for i in pr "p rw" an ay "-monitor y" "-monitor n" \
-resync -refresh "-addtag MYTAG" "-deltag MYETAG"; do
- lvchange -$i $vg/$lv
-done
+ echo lvchange -$i $vg/$lv
+done | lvm
pvck "$dev1"
vgck $vg
diff --git a/test/shell/lvcreate-thin.sh b/test/shell/lvcreate-thin.sh
index 8ac5468..e651a81 100644
--- a/test/shell/lvcreate-thin.sh
+++ b/test/shell/lvcreate-thin.sh
@@ -162,6 +162,7 @@ check vg_field $vg lv_count 6
lvremove -ff $vg
check vg_field $vg lv_count 0
+lvdisplay $vg
# Fail cases
# Too small pool size (1 extent 64KB) for given chunk size
11 years, 5 months
master - lvmetad: fix leak of append on error path
by Zdenek Kabelac
Gitweb: http://git.fedorahosted.org/git/?p=lvm2.git;a=commitdiff;h=920352da70245f...
Commit: 920352da70245f9b385aa0465f9ee88091676371
Parent: 6595cae6e9b65658430714b9731b604c036d0816
Author: Zdenek Kabelac <zkabelac(a)redhat.com>
AuthorDate: Sat Oct 13 21:04:01 2012 +0200
Committer: Zdenek Kabelac <zkabelac(a)redhat.com>
CommitterDate: Sun Oct 14 23:14:48 2012 +0200
lvmetad: fix leak of append on error path
---
libdaemon/client/config-util.c | 2 +-
1 files changed, 1 insertions(+), 1 deletions(-)
diff --git a/libdaemon/client/config-util.c b/libdaemon/client/config-util.c
index 1f4b55b..1c83134 100644
--- a/libdaemon/client/config-util.c
+++ b/libdaemon/client/config-util.c
@@ -55,7 +55,7 @@ int buffer_append_vf(struct buffer *buf, va_list ap)
if (!append ||
!buffer_append(buf, append))
- return 0;
+ goto fail;
dm_free(append);
}
11 years, 5 months
master - cleanup: resolve dereferencing type-punned pointer
by Zdenek Kabelac
Gitweb: http://git.fedorahosted.org/git/?p=lvm2.git;a=commitdiff;h=6595cae6e9b656...
Commit: 6595cae6e9b65658430714b9731b604c036d0816
Parent: 4379365cae3a1efa8299e0d6cf248520a136c798
Author: Zdenek Kabelac <zkabelac(a)redhat.com>
AuthorDate: Sat Oct 13 20:51:07 2012 +0200
Committer: Zdenek Kabelac <zkabelac(a)redhat.com>
CommitterDate: Sun Oct 14 23:14:00 2012 +0200
cleanup: resolve dereferencing type-punned pointer
fix gcc warning:
dereferencing type-punned pointer will break strict-aliasing rules
Replace call by value and pass just const pointer to pvid.
---
lib/cache/lvmetad.c | 8 ++++----
lib/cache/lvmetad.h | 2 +-
lib/metadata/metadata.c | 2 +-
3 files changed, 6 insertions(+), 6 deletions(-)
diff --git a/lib/cache/lvmetad.c b/lib/cache/lvmetad.c
index 1a52787..a3b45d5 100644
--- a/lib/cache/lvmetad.c
+++ b/lib/cache/lvmetad.c
@@ -444,7 +444,7 @@ int lvmetad_vg_update(struct volume_group *vg)
dm_list_iterate_items(pvl, &vg->pvs) {
/* NB. the PV fmt pointer is sometimes wrong during vgconvert */
- if (pvl->pv->dev && !lvmetad_pv_found(pvl->pv->id, pvl->pv->dev,
+ if (pvl->pv->dev && !lvmetad_pv_found(&pvl->pv->id, pvl->pv->dev,
vg->fid ? vg->fid->fmt : pvl->pv->fmt,
pvl->pv->label_sector, NULL, NULL))
return 0;
@@ -657,7 +657,7 @@ static int _extract_mdas(struct lvmcache_info *info, struct dm_config_tree *cft,
return 1;
}
-int lvmetad_pv_found(struct id pvid, struct device *device, const struct format_type *fmt,
+int lvmetad_pv_found(const struct id *pvid, struct device *device, const struct format_type *fmt,
uint64_t label_sector, struct volume_group *vg, activation_handler handler)
{
char uuid[64];
@@ -670,7 +670,7 @@ int lvmetad_pv_found(struct id pvid, struct device *device, const struct format_
if (!lvmetad_active() || test_mode())
return 1;
- if (!id_write_format(&pvid, uuid, sizeof(uuid)))
+ if (!id_write_format(pvid, uuid, sizeof(uuid)))
return_0;
pvmeta = dm_config_create();
@@ -848,7 +848,7 @@ int lvmetad_pvscan_single(struct cmd_context *cmd, struct device *dev,
* *exact* image of the system, the lvmetad instance that went out of
* sync needs to be killed.
*/
- if (!lvmetad_pv_found(*(struct id *)dev->pvid, dev, lvmcache_fmt(info),
+ if (!lvmetad_pv_found((const struct id *) &dev->pvid, dev, lvmcache_fmt(info),
label->sector, baton.vg, handler)) {
release_vg(baton.vg);
goto_bad;
diff --git a/lib/cache/lvmetad.h b/lib/cache/lvmetad.h
index 724922d..5f0f552 100644
--- a/lib/cache/lvmetad.h
+++ b/lib/cache/lvmetad.h
@@ -93,7 +93,7 @@ int lvmetad_vg_remove(struct volume_group *vg);
* number on the cached and on the discovered PV match but the metadata content
* does not.
*/
-int lvmetad_pv_found(struct id pvid, struct device *device,
+int lvmetad_pv_found(const struct id *pvid, struct device *device,
const struct format_type *fmt, uint64_t label_sector,
struct volume_group *vg, activation_handler handler);
diff --git a/lib/metadata/metadata.c b/lib/metadata/metadata.c
index 5a633b6..c210a63 100644
--- a/lib/metadata/metadata.c
+++ b/lib/metadata/metadata.c
@@ -3807,7 +3807,7 @@ int pv_write(struct cmd_context *cmd __attribute__((unused)),
if (!pv->fmt->ops->pv_write(pv->fmt, pv))
return_0;
- if (!lvmetad_pv_found(pv->id, pv->dev, pv->fmt, pv->label_sector,
+ if (!lvmetad_pv_found(&pv->id, pv->dev, pv->fmt, pv->label_sector,
NULL, NULL))
return_0;
11 years, 5 months
master - lvmetad: fix memory leaks in error paths
by Zdenek Kabelac
Gitweb: http://git.fedorahosted.org/git/?p=lvm2.git;a=commitdiff;h=4379365cae3a1e...
Commit: 4379365cae3a1efa8299e0d6cf248520a136c798
Parent: 5df6ec24bffc2df7028639f06b580eda46d894df
Author: Zdenek Kabelac <zkabelac(a)redhat.com>
AuthorDate: Sat Oct 13 19:19:50 2012 +0200
Committer: Zdenek Kabelac <zkabelac(a)redhat.com>
CommitterDate: Sat Oct 13 19:19:50 2012 +0200
lvmetad: fix memory leaks in error paths
Destroy interator in error path.
Releasy any possible allocated buffer from buffer_append_f
and buffer_append_vf in error path.
---
lib/cache/lvmetad.c | 1 +
libdaemon/client/daemon-client.c | 7 ++++---
2 files changed, 5 insertions(+), 3 deletions(-)
diff --git a/lib/cache/lvmetad.c b/lib/cache/lvmetad.c
index 81b6f04..1a52787 100644
--- a/lib/cache/lvmetad.c
+++ b/lib/cache/lvmetad.c
@@ -880,6 +880,7 @@ int lvmetad_pvscan_all_devs(struct cmd_context *cmd, activation_handler handler)
future_token = _lvmetad_token;
_lvmetad_token = (char *) "update in progress";
if (!_token_update()) {
+ dev_iter_destroy(iter);
_lvmetad_token = future_token;
return 0;
}
diff --git a/libdaemon/client/daemon-client.c b/libdaemon/client/daemon-client.c
index c4422d6..a010cc0 100644
--- a/libdaemon/client/daemon-client.c
+++ b/libdaemon/client/daemon-client.c
@@ -108,10 +108,11 @@ daemon_reply daemon_send_simple_v(daemon_handle h, const char *id, va_list ap)
daemon_request rq = { .cft = NULL };
daemon_reply repl;
- if (!buffer_append_f(&rq.buffer, "request = %s", id, NULL))
- return err;
- if (!buffer_append_vf(&rq.buffer, ap))
+ if (!buffer_append_f(&rq.buffer, "request = %s", id, NULL) ||
+ !buffer_append_vf(&rq.buffer, ap)) {
+ buffer_destroy(&rq.buffer);
return err;
+ }
repl = daemon_send(h, rq);
buffer_destroy(&rq.buffer);
11 years, 5 months
master - cleanup: used old C standard
by Zdenek Kabelac
Gitweb: http://git.fedorahosted.org/git/?p=lvm2.git;a=commitdiff;h=5df6ec24bffc2d...
Commit: 5df6ec24bffc2df7028639f06b580eda46d894df
Parent: 9effc6ab316db0f3f7122019ccdc546972ea1e94
Author: Zdenek Kabelac <zkabelac(a)redhat.com>
AuthorDate: Sat Oct 13 19:18:33 2012 +0200
Committer: Zdenek Kabelac <zkabelac(a)redhat.com>
CommitterDate: Sat Oct 13 19:18:33 2012 +0200
cleanup: used old C standard
---
lib/cache/lvmetad.c | 2 +-
1 files changed, 1 insertions(+), 1 deletions(-)
diff --git a/lib/cache/lvmetad.c b/lib/cache/lvmetad.c
index 64820d8..81b6f04 100644
--- a/lib/cache/lvmetad.c
+++ b/lib/cache/lvmetad.c
@@ -52,7 +52,7 @@ void lvmetad_init(struct cmd_context *cmd)
}
}
-void lvmetad_warning()
+void lvmetad_warning(void)
{
if (_lvmetad_use && (_lvmetad.socket_fd < 0 || _lvmetad.error))
log_warn("WARNING: Failed to connect to lvmetad: %s. Falling back to internal scanning.",
11 years, 5 months
master - cleanup: drop unused assignment
by Zdenek Kabelac
Gitweb: http://git.fedorahosted.org/git/?p=lvm2.git;a=commitdiff;h=9effc6ab316db0...
Commit: 9effc6ab316db0f3f7122019ccdc546972ea1e94
Parent: 88c547d1ca83426f4de5371baac885f5500b5487
Author: Zdenek Kabelac <zkabelac(a)redhat.com>
AuthorDate: Sat Oct 13 19:17:10 2012 +0200
Committer: Zdenek Kabelac <zkabelac(a)redhat.com>
CommitterDate: Sat Oct 13 19:17:10 2012 +0200
cleanup: drop unused assignment
Since 'n' is later reassigned and unused between, drop it's first
assign.
---
daemons/lvmetad/lvmetad-core.c | 2 +-
1 files changed, 1 insertions(+), 1 deletions(-)
diff --git a/daemons/lvmetad/lvmetad-core.c b/daemons/lvmetad/lvmetad-core.c
index 9a5c8b9..1992467 100644
--- a/daemons/lvmetad/lvmetad-core.c
+++ b/daemons/lvmetad/lvmetad-core.c
@@ -1113,7 +1113,7 @@ static int init(daemon_state *s)
static int fini(daemon_state *s)
{
lvmetad_state *ls = s->private;
- struct dm_hash_node *n = dm_hash_get_first(ls->vgid_to_metadata);
+ struct dm_hash_node *n;
DEBUG(s, "fini");
11 years, 5 months