master - tests: restore usage of reading kmsg
by Zdenek Kabelac
Gitweb: http://git.fedorahosted.org/git/?p=lvm2.git;a=commitdiff;h=6c377f5b3c36cc...
Commit: 6c377f5b3c36cc0514210821b3d0b72c10d2a819
Parent: 33d69162e4b45e7926d4c0e4a425fedb4246088e
Author: Zdenek Kabelac <zkabelac(a)redhat.com>
AuthorDate: Sun Mar 2 21:30:26 2014 +0100
Committer: Zdenek Kabelac <zkabelac(a)redhat.com>
CommitterDate: Sun Mar 2 21:30:26 2014 +0100
tests: restore usage of reading kmsg
Basically reverts commit af8580d756d3d4ed56a00d377fd6bfb18d5bed41.
"test: Use klogctl in the harness instead of reading /var/log/messages."
Problem is - this interface clears dmesg buffer
(just like call of dmesg -c)
Thus after running lvm2 test suitedmesg is empty - while all the
messages are usually logged in the journal/message, it's still not nice to
clear dmesg buffer.
It's not a pure revert, but switch to use /proc/kmsg directly instead of
reading /var/log/messages.
---
test/lib/harness.c | 45 +++++++++++++++++++++------------------------
1 files changed, 21 insertions(+), 24 deletions(-)
diff --git a/test/lib/harness.c b/test/lib/harness.c
index ded86f0..5258c04 100644
--- a/test/lib/harness.c
+++ b/test/lib/harness.c
@@ -25,7 +25,6 @@
#include <sys/time.h>
#include <sys/types.h>
#include <sys/wait.h>
-#include <sys/klog.h>
#include <time.h>
#include <unistd.h>
#include <stdint.h>
@@ -263,23 +262,6 @@ static void drain(int fd, size_t size_limit)
}
}
-#define SYSLOG_ACTION_READ_CLEAR 4
-#define SYSLOG_ACTION_CLEAR 5
-
-static void clear_dmesg(void)
-{
- klogctl(SYSLOG_ACTION_CLEAR, 0, 0);
-}
-
-static void drain_dmesg(void)
-{
- char buf[16392 + 1];
- size_t sz = klogctl(SYSLOG_ACTION_READ_CLEAR, buf, sizeof(buf) - 1);
- buf[sz] = 0;
- _append_buf(buf, sz);
-}
-
-
static const char *duration(time_t start, const struct rusage *usage)
{
static char buf[100];
@@ -365,7 +347,6 @@ static void run(int i, char *f) {
struct rusage usage;
char flavour[512], script[512];
- clear_dmesg();
pid = fork();
if (pid < 0) {
perror("Fork failed.");
@@ -404,11 +385,13 @@ static void run(int i, char *f) {
int no_write = 0;
int collect_debug = 0;
int fd_debuglog = -1;
+ int fd_kmsg = -1;
+ FILE *kmsg;
//close(fds[1]);
testdirdebug[0] = '\0'; /* Capture RUNTESTDIR */
snprintf(buf, sizeof(buf), "%s ...", f);
- printf("Running %-60s ", buf);
+ printf("Running %-60s%c", buf, verbose ? '\n' : ' ');
fflush(stdout);
snprintf(outpath, sizeof(outpath), "%s/%s.txt", results, f);
while ((c = strchr(c, '/')))
@@ -416,6 +399,18 @@ static void run(int i, char *f) {
if (!(outfile = fopen(outpath, "w")))
perror("fopen");
+ /* Mix-in kernel log message */
+ if (!(kmsg = fopen("/proc/kmsg", "r")))
+ perror("fopen kmsg");
+ else if ((fd_kmsg = fileno(kmsg)) >= 0) {
+ if ((fcntl(fd_kmsg, F_SETFL, O_NONBLOCK ) == -1)) {
+ perror("fcntl kmsg");
+ fclose(kmsg);
+ kmsg = NULL;
+ } else if (fseek(kmsg, 0L, SEEK_END))
+ perror("fseek kmsg");
+ }
+
while ((w = wait4(pid, &st, WNOHANG, &usage)) == 0) {
if ((fullbuffer && fullbuffer++ == 8000) ||
(no_write > 180 * 2)) /* a 3 minute timeout */
@@ -459,14 +454,16 @@ static void run(int i, char *f) {
}
drain(fds[0], INT32_MAX);
no_write = 0;
- drain_dmesg();
+ if (fd_kmsg >= 0)
+ drain(fd_kmsg, INT32_MAX);
}
if (w != pid) {
perror("waitpid");
exit(206);
}
drain(fds[0], INT32_MAX);
- drain_dmesg();
+ if (fd_kmsg >= 0)
+ drain(fd_kmsg, INT32_MAX);
if (die == 2)
interrupted(i, f);
else if (runaway) {
@@ -487,8 +484,8 @@ static void run(int i, char *f) {
} else
failed(i, f, st);
- if (fd_debuglog >= 0)
- close(fd_debuglog);
+ if (kmsg)
+ fclose(kmsg);
if (outfile)
fclose(outfile);
if (fullbuffer)
10 years, 1 month
master - tests: split raid test
by Zdenek Kabelac
Gitweb: http://git.fedorahosted.org/git/?p=lvm2.git;a=commitdiff;h=33d69162e4b45e...
Commit: 33d69162e4b45e7926d4c0e4a425fedb4246088e
Parent: 3ff10f5e61df721ea06dc23575932df2d0215c50
Author: Zdenek Kabelac <zkabelac(a)redhat.com>
AuthorDate: Sun Mar 2 19:46:17 2014 +0100
Committer: Zdenek Kabelac <zkabelac(a)redhat.com>
CommitterDate: Sun Mar 2 21:27:26 2014 +0100
tests: split raid test
Use separate test file for raid456
Change test for broken kernel which has broken raid456 support.
---
test/lib/aux.sh | 7 ++--
test/shell/lvconvert-raid.sh | 40 +-----------------------
test/shell/lvconvert-raid456.sh | 66 +++++++++++++++++++++++++++++++++++++++
3 files changed, 71 insertions(+), 42 deletions(-)
diff --git a/test/lib/aux.sh b/test/lib/aux.sh
index eae01ee..67e046d 100644
--- a/test/lib/aux.sh
+++ b/test/lib/aux.sh
@@ -637,7 +637,7 @@ skip_if_mirror_recovery_broken() {
if test `uname -r` = 3.3.4-5.fc17.x86_64; then skip; fi
}
-skip_if_raid456_replace_broken() {
+raid456_replace_works() {
# The way kmem_cache aliasing is done in the kernel is broken.
# It causes RAID 4/5/6 tests to fail.
#
@@ -666,8 +666,9 @@ skip_if_raid456_replace_broken() {
# old instance to be preserved and causes a colision (and thus failure) in
# kmem_cache_create(). I see this regularly in testing the following
# kernels:
- if test `uname -r` = 3.10.11-200.fc19.i686; then skip; fi
- if test `uname -r` = 3.10.11-200.fc19.x86_64; then skip; fi
+ case $(uname -r) in
+ 3.10.11-200.fc19.i686|3.10.11-200.fc19.x86_64) return 1 ;;
+ esac
}
udev_wait() {
diff --git a/test/shell/lvconvert-raid.sh b/test/shell/lvconvert-raid.sh
index a2a7792..2c6a41a 100644
--- a/test/shell/lvconvert-raid.sh
+++ b/test/shell/lvconvert-raid.sh
@@ -24,8 +24,7 @@ get_image_pvs() {
########################################################
aux target_at_least dm-raid 1 2 0 || skip
-# 9 PVs needed for RAID10 testing (3-stripes/2-mirror - replacing 3 devs)
-aux prepare_pvs 9 80
+aux prepare_pvs 5
vgcreate -s 256k $vg $(cat DEVICES)
###########################################
@@ -203,41 +202,4 @@ for i in {1..3}; do
lvremove -ff $vg
done
-aux skip_if_raid456_replace_broken
-
-# RAID 4/5/6 (can replace up to 'parity' devices)
-for i in 4 5 6; do
- lvcreate --type raid$i -i 3 -l 3 -n $lv1 $vg
-
- if [ $i -eq 6 ]; then
- dev_cnt=5
- limit=2
- else
- dev_cnt=4
- limit=1
- fi
-
- for j in {1..3}; do
- for o in $(seq 0 $i); do
- replace=""
-
- devices=( $(get_image_pvs $vg $lv1) )
-
- for k in $(seq $j); do
- index=$((($k + $o) % $dev_cnt))
- replace="$replace --replace ${devices[$index]}"
- done
- aux wait_for_sync $vg $lv1
-
- if [ $j -gt $limit ]; then
- not lvconvert $replace $vg/$lv1
- else
- lvconvert $replace $vg/$lv1
- fi
- done
- done
-
- lvremove -ff $vg
-done
-
vgremove -ff $vg
diff --git a/test/shell/lvconvert-raid456.sh b/test/shell/lvconvert-raid456.sh
new file mode 100644
index 0000000..bf9a823
--- /dev/null
+++ b/test/shell/lvconvert-raid456.sh
@@ -0,0 +1,66 @@
+#!/bin/sh
+# Copyright (C) 2013-2014 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
+
+get_image_pvs() {
+ local d
+ local images
+
+ images=`dmsetup ls | grep ${1}-${2}_.image_.* | cut -f1 | sed -e s:-:/:`
+ lvs --noheadings -a -o devices $images | sed s/\(.\)//
+}
+
+########################################################
+# MAIN
+########################################################
+aux raid456_replace_works || skip
+aux target_at_least dm-raid 1 2 0 || skip
+
+aux prepare_pvs 6
+vgcreate -s 256k $vg $(cat DEVICES)
+
+# RAID 4/5/6 (can replace up to 'parity' devices)
+for i in 4 5 6; do
+ lvcreate --type raid$i -i 3 -l 3 -n $lv1 $vg
+
+ if [ $i -eq 6 ]; then
+ dev_cnt=5
+ limit=2
+ else
+ dev_cnt=4
+ limit=1
+ fi
+
+ for j in {1..3}; do
+ for o in $(seq 0 $i); do
+ replace=""
+
+ devices=( $(get_image_pvs $vg $lv1) )
+
+ for k in $(seq $j); do
+ index=$((($k + $o) % $dev_cnt))
+ replace="$replace --replace ${devices[$index]}"
+ done
+ aux wait_for_sync $vg $lv1
+
+ if [ $j -gt $limit ]; then
+ not lvconvert $replace $vg/$lv1
+ else
+ lvconvert $replace $vg/$lv1
+ fi
+ done
+ done
+
+ lvremove -ff $vg
+done
+
+vgremove -ff $vg
10 years, 1 month
master - tests: disable test which leaks node
by Zdenek Kabelac
Gitweb: http://git.fedorahosted.org/git/?p=lvm2.git;a=commitdiff;h=3ff10f5e61df72...
Commit: 3ff10f5e61df721ea06dc23575932df2d0215c50
Parent: 75b5855ca1b4d524cb30a4373d1d2fe81d7b21f2
Author: Zdenek Kabelac <zkabelac(a)redhat.com>
AuthorDate: Sun Mar 2 19:16:48 2014 +0100
Committer: Zdenek Kabelac <zkabelac(a)redhat.com>
CommitterDate: Sun Mar 2 21:27:26 2014 +0100
tests: disable test which leaks node
This test is not detected as fault but leak device node
on a real /dev.
Added FIXME.
---
test/shell/name-mangling.sh | 16 ++++++++++------
1 files changed, 10 insertions(+), 6 deletions(-)
diff --git a/test/shell/name-mangling.sh b/test/shell/name-mangling.sh
index 4522a55..b5906c1 100644
--- a/test/shell/name-mangling.sh
+++ b/test/shell/name-mangling.sh
@@ -83,9 +83,9 @@ function check_create_and_remove()
function check_dm_field()
{
local mode=$1
- local dm_name="$2"
+ local dm_name=$2
local field=$3
- local expected="$4"
+ local expected=$4
value=$(dmsetup info --rows --noheadings --manglename $mode -c -o $field "${DM_DEV_DIR}/mapper/${PREFIX}$dm_name" 2> err || true)
@@ -103,7 +103,7 @@ function check_dm_field()
function check_expected_names()
{
local mode=$1
- local dm_name="$2"
+ local dm_name=$2
local r=0
create_dm_dev none "$dm_name"
@@ -122,8 +122,8 @@ function check_expected_names()
function check_mangle_cmd()
{
local mode=$1
- local dm_name="$2"
- local expected="$3"
+ local dm_name=$2
+ local expected=$3
local rename_expected=0
local r=0
@@ -191,7 +191,11 @@ check_expected_names none 'a\x5cx20b' 'a\x5cx20b' 'a\x5cx20b' 'a\x20b'
check_mangle_cmd none 'a b' 'OK'
check_mangle_cmd none 'a\x20b' 'a b'
-check_mangle_cmd none 'a b\x20c' 'a b c'
+#
+# FIXME: this test leave entry in /dev/mapper dir
+# and is not detected nor cleaned
+#
+#check_mangle_cmd none 'a b\x20c' 'a b c'
check_mangle_cmd none 'a\x5cx20b' 'a\x20b'
10 years, 1 month
master - tests: report selinux mode
by Zdenek Kabelac
Gitweb: http://git.fedorahosted.org/git/?p=lvm2.git;a=commitdiff;h=75b5855ca1b4d5...
Commit: 75b5855ca1b4d524cb30a4373d1d2fe81d7b21f2
Parent: a2af5855c5b7e6360d246b802dadafbe79a6d5e4
Author: Zdenek Kabelac <zkabelac(a)redhat.com>
AuthorDate: Sun Mar 2 19:15:52 2014 +0100
Committer: Zdenek Kabelac <zkabelac(a)redhat.com>
CommitterDate: Sun Mar 2 21:27:26 2014 +0100
tests: report selinux mode
---
test/lib/test.sh | 9 +++++++++
1 files changed, 9 insertions(+), 0 deletions(-)
diff --git a/test/lib/test.sh b/test/lib/test.sh
index 71ad55d..3dc0dfb 100644
--- a/test/lib/test.sh
+++ b/test/lib/test.sh
@@ -67,6 +67,13 @@ export DM_DEV_DIR LVM_SYSTEM_DIR DM_ABORT_ON_INTERNAL_ERRORS
echo "$TESTNAME" >TESTNAME
+# Report SELinux mode
+if which getenforce &>/dev/null ; then
+ echo "Selinux mode is \"$(getenforce 2>/dev/null)\"."
+else
+ echo "Selinux mode is not installed."
+fi
+
# Setting up symlink from $i to $TESTDIR/lib
find "$abs_top_builddir/daemons/dmeventd/plugins/" -name '*.so' \
-exec ln -s -t lib "{}" +
@@ -85,6 +92,8 @@ test -n "$LVM_TEST_LVMETAD" && {
export LVM_LVMETAD_PIDFILE="$TESTDIR/lvmetad.pid"
aux prepare_lvmetad
}
+
+# Vars for harness
echo "@TESTDIR=$TESTDIR"
echo "@PREFIX=$PREFIX"
10 years, 1 month
master - tests: use longer sleep
by Zdenek Kabelac
Gitweb: http://git.fedorahosted.org/git/?p=lvm2.git;a=commitdiff;h=a2af5855c5b7e6...
Commit: a2af5855c5b7e6360d246b802dadafbe79a6d5e4
Parent: fade191aed03a9ec5027e9a61d8f39439bc01239
Author: Zdenek Kabelac <zkabelac(a)redhat.com>
AuthorDate: Sun Mar 2 19:08:02 2014 +0100
Committer: Zdenek Kabelac <zkabelac(a)redhat.com>
CommitterDate: Sun Mar 2 21:27:25 2014 +0100
tests: use longer sleep
Eplore why 30sec is not enough for hydra and try higher value.
---
test/shell/snapshot-usage.sh | 2 +-
1 files changed, 1 insertions(+), 1 deletions(-)
diff --git a/test/shell/snapshot-usage.sh b/test/shell/snapshot-usage.sh
index bd0723d..991c18a 100644
--- a/test/shell/snapshot-usage.sh
+++ b/test/shell/snapshot-usage.sh
@@ -74,7 +74,7 @@ lvs -a -o+lv_active $vg1
trap 'cleanup_tail' EXIT
# Keep device busy (but not mounted) for a while
-sleep 30 < "$DM_DEV_DIR/$vg1/$lv1" &
+sleep 120 < "$DM_DEV_DIR/$vg1/$lv1" &
SLEEP_PID=$!
# give some short time to lock file above
10 years, 1 month
master - test: Test that we cope with stray device nodes.
by Petr Rockai
Gitweb: http://git.fedorahosted.org/git/?p=lvm2.git;a=commitdiff;h=fade191aed03a9...
Commit: fade191aed03a9ec5027e9a61d8f39439bc01239
Parent: 3b958984f185fdbc220085b9faef04d11ae6ecf4
Author: Petr Rockai <me(a)mornfall.net>
AuthorDate: Sun Mar 2 20:45:37 2014 +0100
Committer: Petr Rockai <me(a)mornfall.net>
CommitterDate: Sun Mar 2 20:53:43 2014 +0100
test: Test that we cope with stray device nodes.
---
test/shell/stray-device-node.sh | 21 +++++++++++++++++++++
1 files changed, 21 insertions(+), 0 deletions(-)
diff --git a/test/shell/stray-device-node.sh b/test/shell/stray-device-node.sh
new file mode 100644
index 0000000..70677a7
--- /dev/null
+++ b/test/shell/stray-device-node.sh
@@ -0,0 +1,21 @@
+#!/bin/sh
+# Copyright (C) 2014 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
+
+aux prepare_devs 3
+cp -r $dev1 $DM_DEV_DIR/stray
+
+vgcreate $vg $dev1 $dev2 $dev3
+lvcreate -an -Zn --type mirror -m 1 -l 1 -n mirror $vg
+aux disable_dev "$dev1"
+vgreduce --removemissing --force $vg
+aux enable_dev "$dev1"
10 years, 1 month
master - test: Properly synchronize direct dmsetup calls.
by Petr Rockai
Gitweb: http://git.fedorahosted.org/git/?p=lvm2.git;a=commitdiff;h=3b958984f185fd...
Commit: 3b958984f185fdbc220085b9faef04d11ae6ecf4
Parent: 72ecf8e591d1ee6b863d814114a7a8045598efc0
Author: Petr Rockai <me(a)mornfall.net>
AuthorDate: Sun Mar 2 20:11:44 2014 +0100
Committer: Petr Rockai <me(a)mornfall.net>
CommitterDate: Sun Mar 2 20:53:43 2014 +0100
test: Properly synchronize direct dmsetup calls.
---
test/lib/aux.sh | 16 ++++++++++++++--
test/shell/lvconvert-repair-thin.sh | 4 ++--
test/shell/name-mangling.sh | 28 +++++++++++++---------------
3 files changed, 29 insertions(+), 19 deletions(-)
diff --git a/test/lib/aux.sh b/test/lib/aux.sh
index 5ae40e8..eae01ee 100644
--- a/test/lib/aux.sh
+++ b/test/lib/aux.sh
@@ -754,7 +754,19 @@ have_readline()
echo version | lvm &>/dev/null
}
+dmsetup_wrapped()
+{
+ udev_wait
+ init_udev_transaction
+ dmsetup "$@"
+ finish_udev_transaction
+}
+
test -f DEVICES && devs=$(cat DEVICES)
-#unset LVM_VALGRIND
-"$@"
+if test "$1" = dmsetup; then
+ shift
+ dmsetup_wrapped "$@"
+else
+ "$@"
+fi
diff --git a/test/shell/lvconvert-repair-thin.sh b/test/shell/lvconvert-repair-thin.sh
index b80b855..30cd76d 100644
--- a/test/shell/lvconvert-repair-thin.sh
+++ b/test/shell/lvconvert-repair-thin.sh
@@ -94,8 +94,8 @@ lvchange -an $vg
should lvremove -ff $vg
# let's not block PVs with openned _tdata/_tmeta devices
-dmsetup remove $vg-pool_tdata || true
-dmsetup remove $vg-pool_tmeta || true
+aux dmsetup remove $vg-pool_tdata || true
+aux dmsetup remove $vg-pool_tmeta || true
dmsetup table
diff --git a/test/shell/name-mangling.sh b/test/shell/name-mangling.sh
index 76d90fa..4522a55 100644
--- a/test/shell/name-mangling.sh
+++ b/test/shell/name-mangling.sh
@@ -11,8 +11,6 @@
. lib/test
-name_prefix=$RANDOM
-
CHARACTER_WHITELIST="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789#+-.:=@_"
FAIL_MIXED_STR="contains mixed mangled and unmangled characters"
FAIL_MULTI_STR="seems to be mangled more than once"
@@ -34,7 +32,7 @@ function create_dm_dev()
verify_udev=""
fi
- dmsetup create "${name_prefix}$name" $verify_udev --manglename $mode --table "0 1 zero"
+ aux dmsetup create "${PREFIX}$name" $verify_udev --manglename $mode --table "0 1 zero"
}
function remove_dm_dev()
@@ -48,7 +46,7 @@ function remove_dm_dev()
verify_udev=""
fi
- dmsetup remove $verify_udev --manglename $mode "${name_prefix}$name"
+ aux dmsetup remove $verify_udev --manglename $mode "${PREFIX}$name"
}
function check_create_and_remove()
@@ -64,9 +62,9 @@ function check_create_and_remove()
verify_udev=""
fi
- dmsetup create "${name_prefix}$input_name" $verify_udev --manglename $mode --table "0 1 zero" 2>err && \
- test -b "$DM_DEV_DIR/mapper/${name_prefix}$dm_name" && \
- dmsetup remove "${name_prefix}$input_name" $verify_udev --manglename $mode || r=1
+ aux dmsetup create "${PREFIX}$input_name" $verify_udev --manglename $mode --table "0 1 zero" 2>err && \
+ test -b "$DM_DEV_DIR/mapper/${PREFIX}$dm_name" && \
+ aux dmsetup remove "${PREFIX}$input_name" $verify_udev --manglename $mode || r=1
if [ $dm_name = "FAIL_MIXED" ]; then
r=0
@@ -89,7 +87,7 @@ function check_dm_field()
local field=$3
local expected="$4"
- value=$(dmsetup info --rows --noheadings --manglename $mode -c -o $field "${DM_DEV_DIR}/mapper/${name_prefix}$dm_name" 2> err || true)
+ value=$(dmsetup info --rows --noheadings --manglename $mode -c -o $field "${DM_DEV_DIR}/mapper/${PREFIX}$dm_name" 2> err || true)
if [ "$expected" = "FAIL_MIXED" ]; then
grep "$FAIL_MIXED_STR" err
@@ -98,7 +96,7 @@ function check_dm_field()
elif [ "$expected" = "FAIL_BLACK" ]; then
grep "$FAIL_BLACK_STR" err
else
- test "$value" = "${name_prefix}$expected"
+ test "$value" = "${PREFIX}$expected"
fi
}
@@ -110,7 +108,7 @@ function check_expected_names()
create_dm_dev none "$dm_name"
- test -b "$DM_DEV_DIR/mapper/${name_prefix}$dm_name" && \
+ test -b "$DM_DEV_DIR/mapper/${PREFIX}$dm_name" && \
check_dm_field none "$dm_name" name "$dm_name" && \
check_dm_field $mode "$dm_name" name "$3" && \
check_dm_field $mode "$dm_name" mangled_name "$4" && \
@@ -131,7 +129,7 @@ function check_mangle_cmd()
create_dm_dev none "$dm_name"
- dmsetup mangle --manglename $mode "${name_prefix}$dm_name" 1>out 2>err || true;
+ dmsetup mangle --manglename $mode "${PREFIX}$dm_name" 1>out 2>err || true;
if [ "$expected" = "OK" ]; then
grep "$CORRECT_FORM_STR" out || r=1
@@ -141,7 +139,7 @@ function check_mangle_cmd()
grep "$FAIL_MULTI_STR" err || r=1
else
rename_expected=1
- grep -F "$RENAMING_STR ${name_prefix}$expected" out || r=1
+ grep -F "$RENAMING_STR ${PREFIX}$expected" out || r=1
fi
if [ $r = 0 -a $rename_expected = 1 ]; then
@@ -151,7 +149,7 @@ function check_mangle_cmd()
# failed to rename to expected or renamed when it should not - find the new name
new_name=$(sed -e "s/.*: $RENAMING_STR //g" out)
# try to remove any of the form - falling back to less probable error scenario
- dmsetup remove --verifyudev --manglename none "$new_name" || \
+ aux dmsetup remove --verifyudev --manglename none "$new_name" || \
remove_dm_dev none "$dm_name" || remove_dm_dev none "$expected"
else
# successfuly done nothing
@@ -164,8 +162,8 @@ function check_mangle_cmd()
# check dmsetup can process path where the last component is not equal dm name (rhbz #797322)
r=0
create_dm_dev auto "abc"
-ln -s "$DM_DEV_DIR/mapper/${name_prefix}abc" "$DM_DEV_DIR/${name_prefix}xyz"
-dmsetup status "$DM_DEV_DIR/${name_prefix}xyz" || r=1
+ln -s "$DM_DEV_DIR/mapper/${PREFIX}abc" "$DM_DEV_DIR/${PREFIX}xyz"
+aux dmsetup status "$DM_DEV_DIR/${PREFIX}xyz" || r=1
remove_dm_dev auto "abc"
if [ r = 1 ]; then
exit 1
10 years, 1 month
master - tests: detect reiserfs support
by Zdenek Kabelac
Gitweb: http://git.fedorahosted.org/git/?p=lvm2.git;a=commitdiff;h=72ecf8e591d1ee...
Commit: 72ecf8e591d1ee6b863d814114a7a8045598efc0
Parent: 090e81281fbf88bf27ee6930dfaf03cd48aade88
Author: Zdenek Kabelac <zkabelac(a)redhat.com>
AuthorDate: Fri Feb 28 23:05:58 2014 +0100
Committer: Zdenek Kabelac <zkabelac(a)redhat.com>
CommitterDate: Sat Mar 1 14:08:59 2014 +0100
tests: detect reiserfs support
Since reiserfs is not commonly available detect its presence in kernel.
Stop reporting skipped test as WARNING.
---
test/shell/fsadm.sh | 7 +++++--
1 files changed, 5 insertions(+), 2 deletions(-)
diff --git a/test/shell/fsadm.sh b/test/shell/fsadm.sh
index 13e5304..04b659f 100644
--- a/test/shell/fsadm.sh
+++ b/test/shell/fsadm.sh
@@ -29,8 +29,11 @@ which mkfs.xfs || check_xfs=${check_xfs:-mkfs.xfs}
which xfs_check || {
which xfs_repair || check_xfs=${check_xfs:-xfs_repair}
}
+grep xfs /proc/filesystems || check_xfs=${check_xfs:-no_xfs}
+
which mkfs.reiserfs || check_reiserfs=${check_reiserfs:-mkfs.reiserfs}
which reiserfsck || check_reiserfs=${check_reiserfs:-reiserfsck}
+grep reiserfs /proc/filesystems || check_reiserfs=${check_reiserfs:-no_reiserfs}
vg_lv=$vg/$lv1
vg_lv2=$vg/${lv1}bar
@@ -75,9 +78,9 @@ check_missing()
eval local t=$\check_$1
test -z "$t" && return 0
test "$t" = skip && return 1
- # trick to get test listed with warning
echo "WARNING: fsadm test skipped $1 tests, $t tool is missing."
- should false;
+ # trick to get test listed with warning
+ # should false;
return 1
}
10 years, 1 month
master - lvmetad: more reuse precommit buffer
by Zdenek Kabelac
Gitweb: http://git.fedorahosted.org/git/?p=lvm2.git;a=commitdiff;h=090e81281fbf88...
Commit: 090e81281fbf88bf27ee6930dfaf03cd48aade88
Parent: bda98c4b8dcd17d27c582fe6e2bc2d3c2742d4d7
Author: Zdenek Kabelac <zkabelac(a)redhat.com>
AuthorDate: Fri Feb 28 22:40:00 2014 +0100
Committer: Zdenek Kabelac <zkabelac(a)redhat.com>
CommitterDate: Sat Mar 1 14:08:58 2014 +0100
lvmetad: more reuse precommit buffer
This patch moves more allocation to vg_write
(as started in 8c878438f5a75310d09a1ee035d9caf8e2b9e50b)
TODO: relocate also communication.
(in-release update)
---
lib/cache/lvmetad.c | 10 +++++-----
lib/metadata/metadata.c | 38 +++++++++++++++++++++++++++-----------
lib/metadata/vg.c | 2 ++
lib/metadata/vg.h | 3 ++-
4 files changed, 36 insertions(+), 17 deletions(-)
diff --git a/lib/cache/lvmetad.c b/lib/cache/lvmetad.c
index c994874..600fc19 100644
--- a/lib/cache/lvmetad.c
+++ b/lib/cache/lvmetad.c
@@ -468,7 +468,6 @@ int lvmetad_vg_update(struct volume_group *vg)
struct pv_list *pvl;
struct lvmcache_info *info;
struct _fixup_baton baton;
- struct dm_config_tree *vgmeta;
if (!vg)
return 0;
@@ -476,13 +475,14 @@ int lvmetad_vg_update(struct volume_group *vg)
if (!lvmetad_active() || test_mode())
return 1; /* fake it */
- if (!(vgmeta = export_vg_to_config_tree(vg)))
- return_0;
+ if (!vg->cft_precommitted) {
+ log_error(INTERNAL_ERROR "VG update without precommited");
+ return 0;
+ }
log_debug_lvmetad("Sending lvmetad updated metadata for VG %s (seqno %" PRIu32 ")", vg->name, vg->seqno);
reply = _lvmetad_send("vg_update", "vgname = %s", vg->name,
- "metadata = %t", vgmeta, NULL);
- dm_config_destroy(vgmeta);
+ "metadata = %t", vg->cft_precommitted, NULL);
if (!_lvmetad_handle_reply(reply, "update VG", vg->name, NULL)) {
daemon_reply_destroy(reply);
diff --git a/lib/metadata/metadata.c b/lib/metadata/metadata.c
index 8643b75..278b519 100644
--- a/lib/metadata/metadata.c
+++ b/lib/metadata/metadata.c
@@ -864,20 +864,24 @@ int vgcreate_params_validate(struct cmd_context *cmd,
*/
static int _vg_update_vg_precommitted(struct volume_group *vg)
{
- struct dm_config_tree *cft;
-
release_vg(vg->vg_precommitted);
vg->vg_precommitted = NULL;
- if (!(cft = export_vg_to_config_tree(vg)))
- return_0;
+ if (vg->cft_precommitted) {
+ dm_config_destroy(vg->cft_precommitted);
+ vg->cft_precommitted = NULL;
+ }
- if (!(vg->vg_precommitted = import_vg_from_config_tree(cft, vg->fid)))
- stack;
+ if (!(vg->cft_precommitted = export_vg_to_config_tree(vg)))
+ return_0;
- dm_config_destroy(cft);
+ if (!(vg->vg_precommitted = import_vg_from_config_tree(vg->cft_precommitted, vg->fid))) {
+ dm_config_destroy(vg->cft_precommitted);
+ vg->cft_precommitted = NULL;
+ return_0;
+ }
- return vg->vg_precommitted ? 1 : 0;
+ return 1;
}
static int _vg_update_vg_ondisk(struct volume_group *vg)
@@ -893,6 +897,10 @@ static int _vg_update_vg_ondisk(struct volume_group *vg)
vg->vg_ondisk = vg->vg_precommitted;
vg->vg_precommitted = NULL;
+ if (vg->cft_precommitted) {
+ dm_config_destroy(vg->cft_precommitted);
+ vg->cft_precommitted = NULL;
+ }
return 1;
}
@@ -2695,6 +2703,9 @@ int vg_write(struct volume_group *vg)
}
}
+ if (!_vg_update_vg_precommitted(vg)) /* prepare precommited */
+ return_0;
+
/*
* If precommit is not supported, changes take effect immediately.
* FIXME Replace with a more-accurate FMT_COMMIT flag.
@@ -2702,9 +2713,6 @@ int vg_write(struct volume_group *vg)
if (!(vg->fid->fmt->features & FMT_PRECOMMIT) && !lvmetad_vg_update(vg))
return_0;
- if (!_vg_update_vg_precommitted(vg)) /* prepare precommited */
- return_0;
-
return 1;
}
@@ -2773,6 +2781,10 @@ int vg_commit(struct volume_group *vg)
release_vg(vg->vg_ondisk);
vg->vg_ondisk = vg->vg_precommitted;
vg->vg_precommitted = NULL;
+ if (vg->cft_precommitted) {
+ dm_config_destroy(vg->cft_precommitted);
+ vg->cft_precommitted = NULL;
+ }
}
/* If update failed, remove any cached precommitted metadata. */
@@ -2791,6 +2803,10 @@ void vg_revert(struct volume_group *vg)
release_vg(vg->vg_precommitted); /* VG is no longer needed */
vg->vg_precommitted = NULL;
+ if (vg->cft_precommitted) {
+ dm_config_destroy(vg->cft_precommitted);
+ vg->cft_precommitted = NULL;
+ }
dm_list_iterate_items(mda, &vg->fid->metadata_areas_in_use) {
if (mda->ops->vg_revert &&
diff --git a/lib/metadata/vg.c b/lib/metadata/vg.c
index 8f23d56..8ebec99 100644
--- a/lib/metadata/vg.c
+++ b/lib/metadata/vg.c
@@ -90,6 +90,8 @@ void release_vg(struct volume_group *vg)
release_vg(vg->vg_ondisk);
release_vg(vg->vg_precommitted);
+ if (vg->cft_precommitted)
+ dm_config_destroy(vg->cft_precommitted);
_free_vg(vg);
}
diff --git a/lib/metadata/vg.h b/lib/metadata/vg.h
index 028471b..b3b7e93 100644
--- a/lib/metadata/vg.h
+++ b/lib/metadata/vg.h
@@ -57,7 +57,8 @@ struct volume_group {
* _vg_update_vg_ondisk.
*/
struct volume_group *vg_ondisk;
- struct volume_group *vg_precommitted; /* Parsed from precommitted */
+ struct dm_config_tree *cft_precommitted; /* Precommitted metadata */
+ struct volume_group *vg_precommitted; /* Parsed from cft */
alloc_policy_t alloc;
struct profile *profile;
10 years, 1 month
master - lvmetad: move memalloc/free out of lock
by Zdenek Kabelac
Gitweb: http://git.fedorahosted.org/git/?p=lvm2.git;a=commitdiff;h=bda98c4b8dcd17...
Commit: bda98c4b8dcd17d27c582fe6e2bc2d3c2742d4d7
Parent: d8513da9be5c061a85ab35d7d35ad937e8130490
Author: Zdenek Kabelac <zkabelac(a)redhat.com>
AuthorDate: Sat Mar 1 11:38:41 2014 +0100
Committer: Zdenek Kabelac <zkabelac(a)redhat.com>
CommitterDate: Sat Mar 1 14:08:58 2014 +0100
lvmetad: move memalloc/free out of lock
Small code move to lower locking time and make memory
allocation and free outside of lock.
Drop duplicate test of NULL pointer before calling dm_free.
---
daemons/lvmetad/lvmetad-core.c | 56 ++++++++++++++++++---------------------
1 files changed, 26 insertions(+), 30 deletions(-)
diff --git a/daemons/lvmetad/lvmetad-core.c b/daemons/lvmetad/lvmetad-core.c
index bf0892b..f1fb749 100644
--- a/daemons/lvmetad/lvmetad-core.c
+++ b/daemons/lvmetad/lvmetad-core.c
@@ -344,8 +344,8 @@ static response pv_lookup(lvmetad_state *s, request r)
pvid = dm_hash_lookup_binary(s->device_to_pvid, &devt, sizeof(devt));
if (!pvid) {
- WARN(s, "pv_lookup: could not find device %" PRIu64, devt);
unlock_pvid_to_pvmeta(s);
+ WARN(s, "pv_lookup: could not find device %" PRIu64, devt);
dm_config_destroy(res.cft);
return reply_unknown("device not found");
}
@@ -809,30 +809,28 @@ static response pv_gone(lvmetad_state *s, request r)
pvid_old = dm_hash_lookup_binary(s->device_to_pvid, &device, sizeof(device));
vgid = dm_hash_lookup(s->pvid_to_vgid, pvid);
- if (vgid && !(vgid = dm_strdup(vgid))) {
- unlock_pvid_to_pvmeta(s);
- return reply_fail("out of memory");
- }
-
dm_hash_remove_binary(s->device_to_pvid, &device, sizeof(device));
dm_hash_remove(s->pvid_to_pvmeta, pvid);
unlock_pvid_to_pvmeta(s);
+ dm_free(pvid_old);
+
if (vgid) {
+ if (!(vgid = dm_strdup(vgid)))
+ return reply_fail("out of memory");
+
lock_vg(s, vgid);
vg_remove_if_missing(s, vgid, 1);
unlock_vg(s, vgid);
dm_free(vgid);
}
- if (pvid_old)
- dm_free(pvid_old);
-
- if (pvmeta) {
- dm_config_destroy(pvmeta);
- return daemon_reply_simple("OK", NULL);
- } else
+ if (!pvmeta)
return reply_unknown("PVID does not exist");
+
+ dm_config_destroy(pvmeta);
+
+ return daemon_reply_simple("OK", NULL);
}
static response pv_clear_all(lvmetad_state *s, request r)
@@ -876,6 +874,13 @@ static response pv_found(lvmetad_state *s, request r)
if (!dm_config_get_uint64(pvmeta, "pvmeta/device", &device))
return reply_fail("need PV device number");
+ if (!(cft = dm_config_create()) ||
+ (!(pvid_dup = dm_strdup(pvid)))) {
+ if (cft)
+ dm_config_destroy(cft);
+ return reply_fail("out of memory");
+ }
+
lock_pvid_to_pvmeta(s);
if ((old = dm_hash_lookup_binary(s->device_to_pvid, &device, sizeof(device)))) {
@@ -890,21 +895,8 @@ static response pv_found(lvmetad_state *s, request r)
DEBUGLOG(s, "pv_found %s, vgid = %s, device = %" PRIu64 " (previously %" PRIu64 "), old = %s",
pvid, vgid, device, device_old_pvid, old);
- dm_free(old);
-
- if (!(cft = dm_config_create()) ||
- !(cft->root = dm_config_clone_node(cft, pvmeta, 0))) {
- unlock_pvid_to_pvmeta(s);
- if (cft)
- dm_config_destroy(cft);
- return reply_fail("out of memory");
- }
-
- if (!(pvid_dup = dm_strdup(pvid))) {
- unlock_pvid_to_pvmeta(s);
- dm_config_destroy(cft);
- return reply_fail("out of memory");
- }
+ if (!(cft->root = dm_config_clone_node(cft, pvmeta, 0)))
+ goto out_of_mem;
if (pvmeta_old_pvid && device != device_old_pvid) {
DEBUGLOG(s, "pv %s no longer on device %" PRIu64, pvid, device_old_pvid);
@@ -915,19 +907,23 @@ static response pv_found(lvmetad_state *s, request r)
if (!dm_hash_insert(s->pvid_to_pvmeta, pvid, cft) ||
!dm_hash_insert_binary(s->device_to_pvid, &device, sizeof(device), (void*)pvid_dup)) {
dm_hash_remove(s->pvid_to_pvmeta, pvid);
+out_of_mem:
unlock_pvid_to_pvmeta(s);
dm_config_destroy(cft);
dm_free(pvid_dup);
+ dm_free(old);
return reply_fail("out of memory");
}
+ unlock_pvid_to_pvmeta(s);
+
+ dm_free(old);
+
if (pvmeta_old_pvid)
dm_config_destroy(pvmeta_old_pvid);
if (pvmeta_old_dev && pvmeta_old_dev != pvmeta_old_pvid)
dm_config_destroy(pvmeta_old_dev);
- unlock_pvid_to_pvmeta(s);
-
if (metadata) {
if (!vgid)
return reply_fail("need VG UUID");
10 years, 1 month