master - WHATS_NEW update
by Zdenek Kabelac
Gitweb: http://git.fedorahosted.org/git/?p=lvm2.git;a=commitdiff;h=93d77455eaa06c...
Commit: 93d77455eaa06c111954bc29c052fdaf4f31464e
Parent: c0c55846b0a08454c913758f2709888301835bef
Author: Zdenek Kabelac <zkabelac(a)redhat.com>
AuthorDate: Fri Mar 21 22:00:54 2014 +0100
Committer: Zdenek Kabelac <zkabelac(a)redhat.com>
CommitterDate: Fri Mar 21 22:29:28 2014 +0100
WHATS_NEW update
---
WHATS_NEW | 4 ++++
1 files changed, 4 insertions(+), 0 deletions(-)
diff --git a/WHATS_NEW b/WHATS_NEW
index f07d2a9..bdfe111 100644
--- a/WHATS_NEW
+++ b/WHATS_NEW
@@ -1,5 +1,9 @@
Version 2.02.106 -
====================================
+ Reindent some clvmd.c code.
+ Use dm_malloc function in clvmd.c.
+ Resolve memory release order for clvmd shutdown.
+ Report error when lvm2 activation is released in critical_section.
Fix memory corruption when pvscan reports long pv names.
Do not report internal orphan VG names when reporting pvdisplay/pvscan.
Fix pvdisplay -c man page referencing KB instead of sectors.
9 years, 6 months
master - tests: wait for clvmd.pid file
by Zdenek Kabelac
Gitweb: http://git.fedorahosted.org/git/?p=lvm2.git;a=commitdiff;h=c0c55846b0a084...
Commit: c0c55846b0a08454c913758f2709888301835bef
Parent: 8b1916fd5a5640f357ea50b806840d3981661de6
Author: Zdenek Kabelac <zkabelac(a)redhat.com>
AuthorDate: Fri Mar 21 11:38:20 2014 +0100
Committer: Zdenek Kabelac <zkabelac(a)redhat.com>
CommitterDate: Fri Mar 21 22:29:28 2014 +0100
tests: wait for clvmd.pid file
Just like with dmeventd and lvmetad.
Do few indent changes around.
---
test/Makefile.in | 1 +
test/lib/aux.sh | 38 ++++++++++++++++++--------------------
2 files changed, 19 insertions(+), 20 deletions(-)
diff --git a/test/Makefile.in b/test/Makefile.in
index 4bd90c7..15cdf7e 100644
--- a/test/Makefile.in
+++ b/test/Makefile.in
@@ -141,6 +141,7 @@ lib/paths: $(srcdir)/Makefile.in .lib-dir-stamp
echo 'export THIN=@THIN@' >> $@-t
echo 'export LVMETAD_PIDFILE="@LVMETAD_PIDFILE@"' >> $@-t
echo 'export DMEVENTD_PIDFILE="@DMEVENTD_PIDFILE@"' >> $@-t
+ echo 'export CLVMD_PIDFILE="@CLVMD_PIDFILE@"' >> $@-t
mv $@-t $@
LIB = lib/not lib/should lib/harness \
diff --git a/test/lib/aux.sh b/test/lib/aux.sh
index 42ac0a5..502ed84 100644
--- a/test/lib/aux.sh
+++ b/test/lib/aux.sh
@@ -22,6 +22,7 @@ expect_failure() {
}
prepare_clvmd() {
+ rm -f debug.log
test "${LVM_TEST_LOCKING:-0}" -ne 3 && return # not needed
if pgrep clvmd ; then
@@ -34,25 +35,26 @@ prepare_clvmd() {
# lvs is executed from clvmd - use our version
export LVM_BINARY=$(which lvm)
- # skip if we singlenode is not compiled in
+ # skip if singlenode is not compiled in
(clvmd --help 2>&1 | grep "Available cluster managers" | grep "singlenode") || skip
# lvmconf "activation/monitoring = 1"
local run_valgrind=
test "${LVM_VALGRIND_CLVMD:-0}" -eq 0 || run_valgrind="run_valgrind"
+ rm -f "$CLVMD_PIDFILE"
$run_valgrind lib/clvmd -Isinglenode -d 1 -f &
- local local_clvmd=$!
- sleep .3
- # extra sleep for slow valgrind
- test -z "$run_valgrind" || sleep 7
- # check that it is really running now
- ps $local_clvmd || die
- echo $local_clvmd > LOCAL_CLVMD
+ echo $! > LOCAL_CLVMD
+
+ for i in $(seq 1 100) ; do
+ test $i -eq 100 && die "Startup of clvmd is too slow."
+ test -e "$CLVMD_PIDFILE" && break
+ sleep .2
+ done
}
prepare_dmeventd() {
+ rm -f debug.log
if pgrep dmeventd ; then
- rm -f debug.log
echo "Cannot test dmeventd with real dmeventd ($(pgrep dmeventd)) running."
skip
fi
@@ -77,6 +79,7 @@ prepare_dmeventd() {
}
prepare_lvmetad() {
+ rm -f debug.log
# skip if we don't have our own lvmetad...
(which lvmetad 2>/dev/null | grep "$abs_builddir") || skip
@@ -111,7 +114,7 @@ lvmetad_talk() {
}
lvmetad_dump() {
- (echo 'request="dump"'; echo '##') | lvmetad_talk "$@"
+ (echo 'request="dump"'; echo '##') | lvmetad_talk "$@"
}
notify_lvmetad() {
@@ -713,8 +716,7 @@ wait_for_sync() {
}
# Check if tests are running on 64bit architecture
-can_use_16T()
-{
+can_use_16T() {
test "$(getconf LONG_BIT)" -eq 64
}
@@ -725,8 +727,7 @@ can_use_16T()
# [dm-]target-name major minor revision
#
# i.e. dm_target_at_least dm-thin-pool 1 0
-target_at_least()
-{
+target_at_least() {
rm -f debug.log
case "$1" in
dm-*) modprobe "$1" || true ;;
@@ -759,8 +760,7 @@ target_at_least()
test "$revision" -ge "$3" 2>/dev/null || return 1
}
-have_thin()
-{
+have_thin() {
target_at_least dm-thin-pool "$@" || exit 1
test "$THIN" = shared || test "$THIN" = internal || exit 1
@@ -769,13 +769,11 @@ have_thin()
}
# check if lvm shell is build-in (needs readline)
-have_readline()
-{
+have_readline() {
echo version | lvm &>/dev/null
}
-dmsetup_wrapped()
-{
+dmsetup_wrapped() {
udev_wait
dmsetup "$@"
}
9 years, 6 months
master - tests: simplify
by Zdenek Kabelac
Gitweb: http://git.fedorahosted.org/git/?p=lvm2.git;a=commitdiff;h=8b1916fd5a5640...
Commit: 8b1916fd5a5640f357ea50b806840d3981661de6
Parent: de5683d8d96613f37a21ed37695a5399c03a9257
Author: Zdenek Kabelac <zkabelac(a)redhat.com>
AuthorDate: Wed Mar 19 23:33:01 2014 +0100
Committer: Zdenek Kabelac <zkabelac(a)redhat.com>
CommitterDate: Fri Mar 21 22:29:28 2014 +0100
tests: simplify
---
test/shell/lvcreate-signature-wiping.sh | 8 ++------
test/shell/thin-merge.sh | 1 -
2 files changed, 2 insertions(+), 7 deletions(-)
diff --git a/test/shell/lvcreate-signature-wiping.sh b/test/shell/lvcreate-signature-wiping.sh
index 5618780..be06bce 100644
--- a/test/shell/lvcreate-signature-wiping.sh
+++ b/test/shell/lvcreate-signature-wiping.sh
@@ -13,9 +13,7 @@
. lib/test
-aux prepare_devs 1
-aux pvcreate -f $dev1
-aux vgcreate $vg $dev1
+aux prepare_vg
# lvcreate wipes signatures when found on newly created LV - test this on "swap".
# Test all combinatios with -Z{y|n} and -W{y|n} and related lvm.conf settings.
@@ -92,6 +90,4 @@ mkswap "$DM_DEV_DIR/$vg/$lv1"
blkid -c /dev/null "$DM_DEV_DIR/$vg/$lv1" | grep "swap"
lvremove -f $vg/$lv1
-
-vgremove $vg
-pvremove $dev1
+vgremove -f $vg
diff --git a/test/shell/thin-merge.sh b/test/shell/thin-merge.sh
index 7eb137e..60234a6 100644
--- a/test/shell/thin-merge.sh
+++ b/test/shell/thin-merge.sh
@@ -76,7 +76,6 @@ lvchange -an $vg/$lv1
not lvchange -K -ay $vg/snap
lvs -a -o +tags,thin_id $vg
-dmsetup table
# Test if merge happens
lvchange -ay $vg/$lv1
9 years, 6 months
master - tests: add quotes around device paths
by Zdenek Kabelac
Gitweb: http://git.fedorahosted.org/git/?p=lvm2.git;a=commitdiff;h=de5683d8d96613...
Commit: de5683d8d96613f37a21ed37695a5399c03a9257
Parent: 01efb20bdb78a2f49c72951cedca6ffa11a6ba09
Author: Zdenek Kabelac <zkabelac(a)redhat.com>
AuthorDate: Wed Mar 19 23:32:25 2014 +0100
Committer: Zdenek Kabelac <zkabelac(a)redhat.com>
CommitterDate: Fri Mar 21 22:29:27 2014 +0100
tests: add quotes around device paths
---
test/shell/covercmd.sh | 8 +++---
test/shell/listings.sh | 8 +++---
test/shell/lvchange-raid.sh | 4 +-
test/shell/lvconvert-raid.sh | 4 +-
test/shell/lvcreate-raid.sh | 24 +++++++++---------
test/shell/lvcreate-raid10.sh | 4 +-
test/shell/lvmetad-ambiguous.sh | 8 +++---
test/shell/lvmetad-lvm1.sh | 8 +++---
test/shell/lvmetad-pvscan-filter.sh | 10 ++++----
test/shell/lvmetad-pvscan-nomda.sh | 18 +++++++-------
test/shell/lvmetad-restart.sh | 2 +-
test/shell/lvmetad-test.sh | 4 +-
test/shell/lvmetad-warning.sh | 2 +-
test/shell/lvresize-raid.sh | 2 +-
test/shell/mda-rollback.sh | 6 ++--
test/shell/mirror-names.sh | 2 +-
test/shell/mirror-vgreduce-removemissing.sh | 8 +++---
test/shell/nomda-restoremissing.sh | 2 +-
test/shell/orphan-ondisk.sh | 2 +-
test/shell/process-each-duplicate-vgnames.sh | 32 +++++++++++++-------------
test/shell/pvcreate-ff.sh | 8 +++---
test/shell/pvcreate-operation.sh | 12 +++++-----
test/shell/stray-device-node.sh | 4 +-
test/shell/vg-name-from-env.sh | 8 +++---
test/shell/vgimportclone.sh | 8 +++---
25 files changed, 99 insertions(+), 99 deletions(-)
diff --git a/test/shell/covercmd.sh b/test/shell/covercmd.sh
index ca45c2f..ffa48f0 100644
--- a/test/shell/covercmd.sh
+++ b/test/shell/covercmd.sh
@@ -104,19 +104,19 @@ not lvrename $vg $vg/$lv-rename $vg/$lv
#test vgdisplay -A to select only active VGs
# all LVs active - VG considered active
-pvcreate -f $dev1 $dev2 $dev3
+pvcreate -f "$dev1" "$dev2" "$dev3"
-vgcreate $vg1 $dev1
+vgcreate $vg1 "$dev1"
lvcreate -l1 $vg1
lvcreate -l1 $vg1
# at least one LV active - VG considered active
-vgcreate $vg2 $dev2
+vgcreate $vg2 "$dev2"
lvcreate -l1 $vg2
lvcreate -l1 -an -Zn $vg2
# no LVs active - VG considered inactive
-vgcreate $vg3 $dev3
+vgcreate $vg3 "$dev3"
lvcreate -l1 -an -Zn $vg3
lvcreate -l1 -an -Zn $vg3
diff --git a/test/shell/listings.sh b/test/shell/listings.sh
index bb72055..42c6ba5 100644
--- a/test/shell/listings.sh
+++ b/test/shell/listings.sh
@@ -31,7 +31,7 @@ test $(pvs --noheadings -o seg_all,pv_all,lv_all,vg_all $(cat DEVICES) | wc -l)
vgcreate $vg $(cat DEVICES)
-check pv_field $dev1 pv_uuid BADBEE-BAAD-BAAD-BAAD-BAAD-BAAD-BADBEE
+check pv_field "$dev1" pv_uuid BADBEE-BAAD-BAAD-BAAD-BAAD-BAAD-BADBEE
#COMM pvs and vgs report mda_count, mda_free (bz202886, bz247444)
pvs -o +pv_mda_count,pv_mda_free $(cat DEVICES)
@@ -52,14 +52,14 @@ lvcreate -l4 -s -n $lv2 $vg/$lv1
test $(lvs --noheadings $vg | wc -l) -eq 2
# should lvs -a display cow && real devices? (it doesn't)
test $(lvs -a --noheadings $vg | wc -l) -eq 2
-dmsetup ls|grep $PREFIX|grep -v "LVMTEST.*pv."
+dmsetup ls | grep "$PREFIX" | grep -v "LVMTEST.*pv."
lvremove -f $vg/$lv2
#COMM lvs -a displays mirror legs and log
lvcreate -aey -l4 --type mirror -m2 -n $lv3 $vg
test $(lvs --noheadings $vg | wc -l) -eq 2
test $(lvs -a --noheadings $vg | wc -l) -eq 6
-dmsetup ls|grep $PREFIX|grep -v "LVMTEST.*pv."
+dmsetup ls|grep "$PREFIX"|grep -v "LVMTEST.*pv."
#COMM vgs with options from pvs still treats arguments as VGs (bz193543)
vgs -o pv_name,vg_name $vg
@@ -70,7 +70,7 @@ pvdisplay $(cat DEVICES) >out
pvdisplay --maps $(cat DEVICES) >out2
not diff out out2
-aux disable_dev $dev1
+aux disable_dev "$dev1"
pvs -o +pv_uuid | grep BADBEE-BAAD-BAAD-BAAD-BAAD-BAAD-BADBEE
vgremove -ff $vg
diff --git a/test/shell/lvchange-raid.sh b/test/shell/lvchange-raid.sh
index 0807fff..afa2431 100644
--- a/test/shell/lvchange-raid.sh
+++ b/test/shell/lvchange-raid.sh
@@ -144,7 +144,7 @@ run_syncaction_check() {
size=$(get lv_field $vg/${lv}_rimage_1 size -a --units 1k)
size=$((${size%\.00k} / 2))
- tmp=$(get pv_field $device mda_size --units 1k)
+ tmp=$(get pv_field "$device" mda_size --units 1k)
seek=${tmp%\.00k} # Jump over MDA
tmp=$(get lv_field $vg/${lv}_rmeta_1 size -a --units 1k)
@@ -156,7 +156,7 @@ run_syncaction_check() {
check lv_field $vg/$lv raid_mismatch_count "0"
# Overwrite the last half of one of the PVs with crap
- dd if=/dev/urandom of=$device bs=1k count=$size seek=$seek
+ dd if=/dev/urandom of="$device" bs=1k count=$size seek=$seek
if [ -n "$THIN_POSTFIX" ]; then
#
diff --git a/test/shell/lvconvert-raid.sh b/test/shell/lvconvert-raid.sh
index 2c6a41a..01118cb 100644
--- a/test/shell/lvconvert-raid.sh
+++ b/test/shell/lvconvert-raid.sh
@@ -89,9 +89,9 @@ lvconvert -m +1 $vg/$lv1
lvremove -ff $vg
# 3-way to 2-way convert while specifying devices
-lvcreate --type raid1 -m 2 -l 2 -n $lv1 $vg $dev1 $dev2 $dev3
+lvcreate --type raid1 -m 2 -l 2 -n $lv1 $vg "$dev1" "$dev2" "$dev3"
aux wait_for_sync $vg $lv1
-lvconvert -m1 $vg/$lv1 $dev2
+lvconvert -m1 $vg/$lv1 "$dev2"
lvremove -ff $vg
#
diff --git a/test/shell/lvcreate-raid.sh b/test/shell/lvcreate-raid.sh
index 2791669..77b2347 100644
--- a/test/shell/lvcreate-raid.sh
+++ b/test/shell/lvcreate-raid.sh
@@ -109,11 +109,11 @@ should check lv_field $vg/raid6 size "72.00m"
lvremove -ff $vg
# Eat 18 of 37 extents from dev1, leaving 19
-lvcreate -l 18 -n lv $vg $dev1
+lvcreate -l 18 -n lv $vg "$dev1"
# Using 100% free should take the rest of dev1 and equal from dev2
# 1 meta takes 1 extent
# 1 image = 18 extents = 9.00m = lv_size
-lvcreate --type raid1 -m 1 -l 100%FREE -n raid1 $vg $dev1 $dev2
+lvcreate --type raid1 -m 1 -l 100%FREE -n raid1 $vg "$dev1" "$dev2"
check lv_field $vg/raid1 size "9.00m"
# Ensure image size is the same as the RAID1 size
check lv_field $vg/raid1 size `lvs --noheadings -o size $vg/raid1_rimage_0`
@@ -122,7 +122,7 @@ check pv_field "$dev2" pv_free `lvs --noheadings -o size $vg/lv`
lvremove -ff $vg
# Eat 18 of 37 extents from dev1, leaving 19
-lvcreate -l 18 -n lv $vg $dev1
+lvcreate -l 18 -n lv $vg "$dev1"
# Using 100% free should take the rest of dev1 and equal amount from the rest
# 1 meta takes 1 extent
# 1 image = 18 extents = 9.00m
@@ -134,7 +134,7 @@ check pv_field "$dev6" pv_free `lvs --noheadings -o size $vg/lv`
lvremove -ff $vg
# Eat 18 of 37 extents from dev1, leaving 19
-lvcreate -l 18 -n lv $vg $dev1
+lvcreate -l 18 -n lv $vg "$dev1"
# Using 100% free should take the rest of dev1, an equal amount
# from 2 more devs, and all extents from 3 additional devs
# 1 meta takes 1 extent
@@ -146,7 +146,7 @@ lvremove -ff $vg
# Let's do some stripe tests too
# Eat 18 of 37 extents from dev1, leaving 19
-lvcreate -l 18 -n lv $vg $dev1
+lvcreate -l 18 -n lv $vg "$dev1"
# Using 100% free should take the rest of dev1 and an equal amount from rest
# 1 image = 19 extents
# 6 images = 114 extents = 57.00m = lv_size
@@ -155,7 +155,7 @@ check lv_field $vg/stripe size "57.00m"
lvremove -ff $vg
# Eat 18 of 37 extents from dev1, leaving 19
-lvcreate -l 18 -n lv $vg $dev1
+lvcreate -l 18 -n lv $vg "$dev1"
# Using 100% free should take the rest of dev1, an equal amount from
# one more dev, and all of the remaining 4
# 1 image = 19+37+37 extents
@@ -168,16 +168,16 @@ lvremove -ff $vg
#######################################################
# Not enough drives
-not lvcreate --type raid1 -l1 $vg $dev1
-not lvcreate --type raid5 -l2 $vg $dev1 $dev2
-not lvcreate --type raid6 -l3 $vg $dev1 $dev2 $dev3 $dev4
+not lvcreate --type raid1 -l1 $vg "$dev1"
+not lvcreate --type raid5 -l2 $vg "$dev1" "$dev2"
+not lvcreate --type raid6 -l3 $vg "$dev1" "$dev2" "$dev3" "$dev4"
# Implicit count comes from #PVs given (always 2 for mirror though)
-lvcreate --type raid1 -l1 -n raid1 $vg $dev1 $dev2
+lvcreate --type raid1 -l1 -n raid1 $vg "$dev1" "$dev2"
lv_devices $vg raid1 2
-lvcreate --type raid5 -l2 -n raid5 $vg $dev1 $dev2 $dev3
+lvcreate --type raid5 -l2 -n raid5 $vg "$dev1" "$dev2" "$dev3"
lv_devices $vg raid5 3
-lvcreate --type raid6 -l3 -n raid6 $vg $dev1 $dev2 $dev3 $dev4 $dev5
+lvcreate --type raid6 -l3 -n raid6 $vg "$dev1" "$dev2" "$dev3" "$dev4" "$dev5"
lv_devices $vg raid6 5
lvremove -ff $vg
diff --git a/test/shell/lvcreate-raid10.sh b/test/shell/lvcreate-raid10.sh
index 68a61f7..7ce8100 100644
--- a/test/shell/lvcreate-raid10.sh
+++ b/test/shell/lvcreate-raid10.sh
@@ -65,10 +65,10 @@ lvremove -ff $vg
#######################################################
# Not enough drives
-not lvcreate --type raid10 -l2 $vg $dev1 $dev2 $dev3
+not lvcreate --type raid10 -l2 $vg "$dev1" "$dev2" "$dev3"
# Implicit count comes from #PVs given (always 2-way mirror)
-lvcreate --type raid10 -l2 -n raid10 $vg $dev1 $dev2 $dev3 $dev4
+lvcreate --type raid10 -l2 -n raid10 $vg "$dev1" "$dev2" "$dev3" "$dev4"
lv_devices $vg raid10 4
lvremove -ff $vg
diff --git a/test/shell/lvmetad-ambiguous.sh b/test/shell/lvmetad-ambiguous.sh
index 455aa5d..6ff055a 100644
--- a/test/shell/lvmetad-ambiguous.sh
+++ b/test/shell/lvmetad-ambiguous.sh
@@ -24,11 +24,11 @@ dmsetup create -u TEST-${PREFIX}pv1 ${PREFIX}pv1 ${PREFIX}pv1.table
aux finish_udev_transaction
# re-scan them
-pvscan --cache $dev1
-pvscan --cache $dev2
+pvscan --cache "$dev1"
+pvscan --cache "$dev2"
# expect both to be there
pvs | tee pvs.txt
-grep $dev1 pvs.txt
-grep $dev2 pvs.txt
+grep "$dev1" pvs.txt
+grep "$dev2" pvs.txt
diff --git a/test/shell/lvmetad-lvm1.sh b/test/shell/lvmetad-lvm1.sh
index 043750e..814134c 100644
--- a/test/shell/lvmetad-lvm1.sh
+++ b/test/shell/lvmetad-lvm1.sh
@@ -13,10 +13,10 @@
test -e LOCAL_LVMETAD || skip
aux prepare_devs 2
-pvcreate --metadatatype 1 $dev1
+pvcreate --metadatatype 1 "$dev1"
should vgscan --cache
-pvs | should grep $dev1
-vgcreate --metadatatype 1 $vg1 $dev1
+pvs | should grep "$dev1"
+vgcreate --metadatatype 1 $vg1 "$dev1"
should vgscan --cache
vgs | should grep $vg1
-pvs | should grep $dev1
+pvs | should grep "$dev1"
diff --git a/test/shell/lvmetad-pvscan-filter.sh b/test/shell/lvmetad-pvscan-filter.sh
index 6ece577..73690a0 100644
--- a/test/shell/lvmetad-pvscan-filter.sh
+++ b/test/shell/lvmetad-pvscan-filter.sh
@@ -18,8 +18,8 @@ aux prepare_pvs 2
maj=$(($(stat -L --printf=0x%t "$dev2")))
min=$(($(stat -L --printf=0x%T "$dev2")))
-aux hide_dev $dev2
-not pvscan --cache $dev2 2>&1 | grep "not found"
+aux hide_dev "$dev2"
+not pvscan --cache "$dev2" 2>&1 | grep "not found"
# pvscan with --major/--minor does not fail: lvmetad needs to
# be notified about device removal on REMOVE uevent, hence
# this should not fail so udev does not grab a "failed" state
@@ -27,8 +27,8 @@ not pvscan --cache $dev2 2>&1 | grep "not found"
# exactly the same command "pvscan --cache" - in case of removal,
# this is detected by nonexistence of the device itself.
pvscan --cache --major $maj --minor $min 2>&1 | grep "not found"
-aux unhide_dev $dev2
+aux unhide_dev "$dev2"
-pvscan --cache $dev2 2>&1 | not grep "not found"
+pvscan --cache "$dev2" 2>&1 | not grep "not found"
pvscan --cache --major $maj --minor $min 2>&1 | not grep "not found"
-pvs | grep $dev2
+pvs | grep "$dev2"
diff --git a/test/shell/lvmetad-pvscan-nomda.sh b/test/shell/lvmetad-pvscan-nomda.sh
index 195b8d2..04c9c6b 100644
--- a/test/shell/lvmetad-pvscan-nomda.sh
+++ b/test/shell/lvmetad-pvscan-nomda.sh
@@ -17,32 +17,32 @@ rm LOCAL_LVMETAD
aux prepare_devs 2
-pvcreate --metadatacopies 0 $dev1
-pvcreate --metadatacopies 1 $dev2
-vgcreate $vg1 $dev1 $dev2
+pvcreate --metadatacopies 0 "$dev1"
+pvcreate --metadatacopies 1 "$dev2"
+vgcreate $vg1 "$dev1" "$dev2"
lvcreate -n foo -l 1 -an --zero n $vg1
# start lvmetad but make sure it doesn't know about $dev1 or $dev2
-aux disable_dev $dev1
-aux disable_dev $dev2
+aux disable_dev "$dev1"
+aux disable_dev "$dev2"
aux prepare_lvmetad
lvs
mv LOCAL_LVMETAD XXX
-aux enable_dev $dev2
-aux enable_dev $dev1
+aux enable_dev "$dev2"
+aux enable_dev "$dev1"
mv XXX LOCAL_LVMETAD
aux lvmconf 'global/use_lvmetad = 0'
check inactive $vg1 foo
aux lvmconf 'global/use_lvmetad = 1'
-pvscan --cache $dev2 -aay
+pvscan --cache "$dev2" -aay
aux lvmconf 'global/use_lvmetad = 0'
check inactive $vg1 foo
aux lvmconf 'global/use_lvmetad = 1'
-pvscan --cache $dev1 -aay
+pvscan --cache "$dev1" -aay
aux lvmconf 'global/use_lvmetad = 0'
check active $vg1 foo
diff --git a/test/shell/lvmetad-restart.sh b/test/shell/lvmetad-restart.sh
index 585d63b..6e25f8a 100644
--- a/test/shell/lvmetad-restart.sh
+++ b/test/shell/lvmetad-restart.sh
@@ -14,7 +14,7 @@
test -e LOCAL_LVMETAD || skip
aux prepare_pvs 2
-vgcreate $vg1 $dev1 $dev2
+vgcreate $vg1 "$dev1" "$dev2"
vgs | grep $vg1
kill $(cat LOCAL_LVMETAD)
diff --git a/test/shell/lvmetad-test.sh b/test/shell/lvmetad-test.sh
index 7e801f1..934e985 100644
--- a/test/shell/lvmetad-test.sh
+++ b/test/shell/lvmetad-test.sh
@@ -13,9 +13,9 @@
aux prepare_pvs 2
-vgcreate $vg1 $dev1 $dev2 --test
+vgcreate $vg1 "$dev1" "$dev2" --test
vgs | not grep $vg1
-vgcreate $vg1 $dev1 $dev2
+vgcreate $vg1 "$dev1" "$dev2"
vgs | grep $vg1
lvcreate -n bar -l 1 $vg1 --test
diff --git a/test/shell/lvmetad-warning.sh b/test/shell/lvmetad-warning.sh
index 3fc4cf5..8bb01d1 100644
--- a/test/shell/lvmetad-warning.sh
+++ b/test/shell/lvmetad-warning.sh
@@ -14,7 +14,7 @@
test -e LOCAL_LVMETAD || skip
aux prepare_pvs 2
-vgcreate $vg1 $dev1 $dev2
+vgcreate $vg1 "$dev1" "$dev2"
lvchange -ay $vg1 2>&1 | not grep "Failed to connect"
kill $(cat LOCAL_LVMETAD)
lvchange -ay $vg1 2>&1 | grep "Failed to connect"
diff --git a/test/shell/lvresize-raid.sh b/test/shell/lvresize-raid.sh
index 9b9218d..bc8b36f 100644
--- a/test/shell/lvresize-raid.sh
+++ b/test/shell/lvresize-raid.sh
@@ -50,7 +50,7 @@ done
# Bug 1005434
# Ensure extend is contiguous
-lvcreate --type raid4 -l 2 -i 2 -n $lv1 $vg $dev4 $dev5 $dev6
+lvcreate --type raid4 -l 2 -i 2 -n $lv1 $vg "$dev4" "$dev5" "$dev6"
lvextend -l +2 --alloc contiguous $vg/$lv1
check lv_tree_on $vg $lv1 "$dev4" "$dev5" "$dev6"
diff --git a/test/shell/mda-rollback.sh b/test/shell/mda-rollback.sh
index d47eb8a..aebbfb6 100644
--- a/test/shell/mda-rollback.sh
+++ b/test/shell/mda-rollback.sh
@@ -15,12 +15,12 @@ aux prepare_devs 3
vgcreate --metadatasize 128k $vg1 "$dev1" "$dev2" "$dev3"
-vgreduce $vg1 $dev1
+vgreduce $vg1 "$dev1"
dd if="$dev1" of=badmda bs=256K count=1
-vgextend $vg1 $dev1
+vgextend $vg1 "$dev1"
dd if=badmda of="$dev1" bs=256K count=1
# dev1 is part of vg1 (as witnessed by metadata on dev2 and dev3), but its mda
# was corrupt (written over by a backup from time dev1 was an orphan)
-check pv_field $dev1 vg_name $vg1
+check pv_field "$dev1" vg_name $vg1
diff --git a/test/shell/mirror-names.sh b/test/shell/mirror-names.sh
index de70f43..f5d1322 100644
--- a/test/shell/mirror-names.sh
+++ b/test/shell/mirror-names.sh
@@ -25,7 +25,7 @@ lv_devices_() {
local devs=$(get lv_field $lv devices -a | sed 's/([0-9]*)//g; s/ //g; s/,/ /g')
for d in $devs; do
- (echo $devices | grep $d) || return 1
+ (echo "$devices" | grep $d) || return 1
devices=$(echo $devices | sed "s/$d//")
done
diff --git a/test/shell/mirror-vgreduce-removemissing.sh b/test/shell/mirror-vgreduce-removemissing.sh
index 05a8acd..340a333 100644
--- a/test/shell/mirror-vgreduce-removemissing.sh
+++ b/test/shell/mirror-vgreduce-removemissing.sh
@@ -126,8 +126,8 @@ check_and_cleanup_lvs_
#COMM "basic: fail the 2nd mirror image of 2-way mirrored LV"
prepare_lvs_
lvcreate -an -Zn -l2 --type mirror -m1 --nosync -n $lv1 $vg "$dev1" "$dev2" "$dev3":$BLOCKS
-mimages_are_on_ $lv1 $dev1 $dev2
-mirrorlog_is_on_ $lv1 $dev3
+mimages_are_on_ $lv1 "$dev1" "$dev2"
+mirrorlog_is_on_ $lv1 "$dev3"
aux disable_dev "$dev2"
vgreduce --removemissing --force $vg
lv_is_linear_ $lv1
@@ -234,7 +234,7 @@ test_3way_mirror_plus_1_fail_3_()
lvs -a -o+devices $vg
eval local dev=\$dev$n
check linear $vg $lv1
- check lv_on $vg $lv1 $dev
+ check lv_on $vg $lv1 "$dev"
}
for n in $(seq 1 4); do
@@ -287,7 +287,7 @@ test_2way_mirror_plus_2_fail_3_()
vgreduce --removemissing --force $vg
lvs -a -o+devices $vg
eval local dev=\$dev$n
- mimages_are_on_ $lv1 $dev || lv_is_on_ $lv1 $dev
+ mimages_are_on_ $lv1 "$dev" || lv_is_on_ $lv1 "$dev"
not mirrorlog_is_on_ $lv1 "$dev5"
}
diff --git a/test/shell/nomda-restoremissing.sh b/test/shell/nomda-restoremissing.sh
index eb2e624..3dcd41e 100644
--- a/test/shell/nomda-restoremissing.sh
+++ b/test/shell/nomda-restoremissing.sh
@@ -13,7 +13,7 @@
aux prepare_vg 3
-pvchange --metadataignore y $dev1
+pvchange --metadataignore y "$dev1"
lvcreate -aey --type mirror -m 1 -l 1 -n mirror $vg
lvchange -a n $vg/mirror
diff --git a/test/shell/orphan-ondisk.sh b/test/shell/orphan-ondisk.sh
index 2a820d6..266d74b 100644
--- a/test/shell/orphan-ondisk.sh
+++ b/test/shell/orphan-ondisk.sh
@@ -12,4 +12,4 @@
. lib/test
aux prepare_vg 2
-vgreduce $vg $dev1 2>&1 | not grep -i 'parse error'
+vgreduce $vg "$dev1" 2>&1 | not grep -i 'parse error'
diff --git a/test/shell/process-each-duplicate-vgnames.sh b/test/shell/process-each-duplicate-vgnames.sh
index 6eeaa6f..5138d22 100644
--- a/test/shell/process-each-duplicate-vgnames.sh
+++ b/test/shell/process-each-duplicate-vgnames.sh
@@ -11,29 +11,29 @@ test_description='Test vgs with duplicate vg names'
aux prepare_devs 2
-pvcreate $dev1
-pvcreate $dev2
+pvcreate "$dev1"
+pvcreate "$dev2"
-aux disable_dev $dev1
-aux disable_dev $dev2
+aux disable_dev "$dev1"
+aux disable_dev "$dev2"
-aux enable_dev $dev1
+aux enable_dev "$dev1"
vgscan
-vgcreate $vg1 $dev1
+vgcreate $vg1 "$dev1"
UUID1=$(vgs --noheading -o vg_uuid $vg1)
-aux disable_dev $dev1
+aux disable_dev "$dev1"
-aux enable_dev $dev2
+aux enable_dev "$dev2"
vgscan
-vgcreate $vg1 $dev2
+vgcreate $vg1 "$dev2"
UUID2=$(vgs --noheading -o vg_uuid $vg1)
-aux enable_dev $dev1
+aux enable_dev "$dev1"
# need vgscan after enabling/disabling devs
# so that the next commands properly see them
vgscan
-pvs $dev1
-pvs $dev2
+pvs "$dev1"
+pvs "$dev2"
vgs -o+vg_uuid >err
cat err
@@ -44,19 +44,19 @@ grep $UUID2 err
# vgs --noheading -o vg_uuid $vg1 >err
# grep $UUID1 err
-aux disable_dev $dev2
+aux disable_dev "$dev2"
vgs -o+vg_uuid >err
cat err
grep $UUID1 err
not grep $UUID2 err
-aux enable_dev $dev2
+aux enable_dev "$dev2"
vgscan
-aux disable_dev $dev1
+aux disable_dev "$dev1"
vgs -o+vg_uuid >err
cat err
grep $UUID2 err
not grep $UUID1 err
-aux enable_dev $dev1
+aux enable_dev "$dev1"
vgscan
diff --git a/test/shell/pvcreate-ff.sh b/test/shell/pvcreate-ff.sh
index 38284af..72caf63 100644
--- a/test/shell/pvcreate-ff.sh
+++ b/test/shell/pvcreate-ff.sh
@@ -12,8 +12,8 @@
. lib/test
aux prepare_devs 2
-pvcreate $dev1
-vgcreate foo $dev1
-pvcreate -ff -y $dev1
+pvcreate "$dev1"
+vgcreate foo "$dev1"
+pvcreate -ff -y "$dev1"
vgs
-vgcreate foo $dev1
+vgcreate foo "$dev1"
diff --git a/test/shell/pvcreate-operation.sh b/test/shell/pvcreate-operation.sh
index b885ed2..4a5c42a 100644
--- a/test/shell/pvcreate-operation.sh
+++ b/test/shell/pvcreate-operation.sh
@@ -21,11 +21,11 @@ do
if mke2fs "$dev1"; then
mount "$dev1" mnt
not pvcreate -M$mdatype "$dev1" 2>err
- grep "Can't open "$dev1" exclusively. Mounted filesystem?" err
+ grep "Can't open $dev1 exclusively. Mounted filesystem?" err
umount "$dev1"
# wipe the filesystem signature for next
# pvcreate to not issue any prompts
- dd if=/dev/zero of=$dev1 bs=1K count=2
+ dd if=/dev/zero of="$dev1" bs=1K count=2
fi
# pvcreate (lvm$mdatype) succeeds when run repeatedly (pv not in a vg) (bz178216)
@@ -116,13 +116,13 @@ not pvcreate --uuid $uuid2 --restorefile $backupfile "$dev2"
# vgcfgrestore of a VG containing a PV with zero PEs (bz #820116)
# (use case: one PV in a VG used solely to keep metadata)
-size_mb=$(($(blockdev --getsz $dev1) / 2048))
-pvcreate --metadatasize $size_mb $dev1
-vgcreate $vg1 $dev1
+size_mb=$(($(blockdev --getsz "$dev1") / 2048))
+pvcreate --metadatasize $size_mb "$dev1"
+vgcreate $vg1 "$dev1"
vgcfgbackup -f $backupfile
vgcfgrestore -f $backupfile $vg1
vgremove -f $vg1
-pvremove -f $dev1
+pvremove -f "$dev1"
# pvcreate rejects non-existent uuid given with restorefile
not pvcreate --uuid $uuid1 --restorefile $backupfile "$dev1"
diff --git a/test/shell/stray-device-node.sh b/test/shell/stray-device-node.sh
index 70677a7..8e67caa 100644
--- a/test/shell/stray-device-node.sh
+++ b/test/shell/stray-device-node.sh
@@ -12,9 +12,9 @@
. lib/test
aux prepare_devs 3
-cp -r $dev1 $DM_DEV_DIR/stray
+cp -r "$dev1" "$DM_DEV_DIR/stray"
-vgcreate $vg $dev1 $dev2 $dev3
+vgcreate $vg $(cat DEVICES)
lvcreate -an -Zn --type mirror -m 1 -l 1 -n mirror $vg
aux disable_dev "$dev1"
vgreduce --removemissing --force $vg
diff --git a/test/shell/vg-name-from-env.sh b/test/shell/vg-name-from-env.sh
index dedbfd6..c399bb6 100644
--- a/test/shell/vg-name-from-env.sh
+++ b/test/shell/vg-name-from-env.sh
@@ -11,11 +11,11 @@ test_description='Test the vg name for an lv from env var'
aux prepare_devs 2
-pvcreate $dev1
-pvcreate $dev2
+pvcreate "$dev1"
+pvcreate "$dev2"
-vgcreate $vg1 $dev1
-vgcreate $vg2 $dev2
+vgcreate $vg1 "$dev1"
+vgcreate $vg2 "$dev2"
export LVM_VG_NAME=$vg1
diff --git a/test/shell/vgimportclone.sh b/test/shell/vgimportclone.sh
index cf85518..f2977c9 100644
--- a/test/shell/vgimportclone.sh
+++ b/test/shell/vgimportclone.sh
@@ -21,13 +21,13 @@ dd if="$dev1" of="$dev2" bs=256K count=1
aux notify_lvmetad "$dev2"
# Verify pvs works on each device to give us vgname
-aux hide_dev $dev2
+aux hide_dev "$dev2"
check pv_field "$dev1" vg_name $vg1
-aux unhide_dev $dev2
+aux unhide_dev "$dev2"
-aux hide_dev $dev1
+aux hide_dev "$dev1"
check pv_field "$dev2" vg_name $vg1
-aux unhide_dev $dev1
+aux unhide_dev "$dev1"
# Import the cloned PV to a new VG
vgimportclone --basevgname $vg2 "$dev2"
9 years, 6 months
master - cleanup: clvmd add more info debug message
by Zdenek Kabelac
Gitweb: http://git.fedorahosted.org/git/?p=lvm2.git;a=commitdiff;h=01efb20bdb78a2...
Commit: 01efb20bdb78a2f49c72951cedca6ffa11a6ba09
Parent: 0d449fe183936be5790e7c59d157fe6c8334a914
Author: Zdenek Kabelac <zkabelac(a)redhat.com>
AuthorDate: Thu Mar 20 14:24:06 2014 +0100
Committer: Zdenek Kabelac <zkabelac(a)redhat.com>
CommitterDate: Fri Mar 21 22:29:27 2014 +0100
cleanup: clvmd add more info debug message
---
daemons/clvmd/clvmd.c | 46 +++++++++++++++++++++++++++-------------------
1 files changed, 27 insertions(+), 19 deletions(-)
diff --git a/daemons/clvmd/clvmd.c b/daemons/clvmd/clvmd.c
index ac570b6..4648450 100644
--- a/daemons/clvmd/clvmd.c
+++ b/daemons/clvmd/clvmd.c
@@ -686,7 +686,7 @@ static int local_rendezvous_callback(struct local_client *thisfd, char *buf,
}
if (fcntl(client_fd, F_SETFD, 1))
- DEBUGLOG("setting CLOEXEC on client fd failed: %s\n", strerror(errno));
+ DEBUGLOG("Setting CLOEXEC on client fd failed: %s\n", strerror(errno));
newfd->fd = client_fd;
newfd->type = LOCAL_SOCK;
@@ -714,7 +714,7 @@ static int local_pipe_callback(struct local_client *thisfd, char *buf,
if (len == sizeof(int))
memcpy(&status, buffer, sizeof(int));
- DEBUGLOG("read on PIPE %d: %d bytes: status: %d\n",
+ DEBUGLOG("Read on pipe %d, %d bytes, status %d\n",
thisfd->fd, len, status);
/* EOF on pipe or an error, close it */
@@ -738,11 +738,11 @@ static int local_pipe_callback(struct local_client *thisfd, char *buf,
}
return -1;
} else {
- DEBUGLOG("background routine status was %d, sock_client=%p\n",
+ DEBUGLOG("Background routine status was %d, sock_client (%p)\n",
status, sock_client);
/* But has the client gone away ?? */
if (!sock_client) {
- DEBUGLOG("Got PIPE response for dead client, ignoring it\n");
+ DEBUGLOG("Got pipe response for dead client, ignoring it\n");
} else {
/* If error then just return that code */
if (status)
@@ -1134,6 +1134,7 @@ static void dump_message(char *buf, int len)
static int cleanup_zombie(struct local_client *thisfd)
{
int *status;
+ struct local_client *pipe_client;
if (thisfd->type != LOCAL_SOCK)
return 0;
@@ -1146,8 +1147,12 @@ static int cleanup_zombie(struct local_client *thisfd)
thisfd->bits.localsock.finished = 1;
+ if ((pipe_client = thisfd->bits.localsock.pipe_client))
+ pipe_client = pipe_client->bits.pipe.client;
+
/* If the client went away in mid command then tidy up */
if (thisfd->bits.localsock.in_progress) {
+ DEBUGLOG("Sending SIGUSR2 to pre&post thread (%p in-progress)\n", pipe_client);
pthread_kill(thisfd->bits.localsock.threadid, SIGUSR2);
if (pthread_mutex_trylock(&thisfd->bits.localsock.mutex))
return 1;
@@ -1161,7 +1166,7 @@ static int cleanup_zombie(struct local_client *thisfd)
/* Kill the subthread & free resources */
if (thisfd->bits.localsock.threadid) {
- DEBUGLOG("Waiting for child thread\n");
+ DEBUGLOG("Waiting for pre&post thread (%p)\n", pipe_client);
pthread_mutex_lock(&thisfd->bits.localsock.mutex);
thisfd->bits.localsock.state = PRE_COMMAND;
pthread_cond_signal(&thisfd->bits.localsock.cond);
@@ -1171,7 +1176,7 @@ static int cleanup_zombie(struct local_client *thisfd)
(void **) &status)))
log_sys_error("pthread_join", "");
- DEBUGLOG("Joined child thread\n");
+ DEBUGLOG("Joined pre&post thread\n");
thisfd->bits.localsock.threadid = 0;
pthread_cond_destroy(&thisfd->bits.localsock.cond);
@@ -1389,7 +1394,7 @@ static int read_from_local_sock(struct local_client *thisfd)
return len;
}
- DEBUGLOG("creating pipe, [%d, %d]\n", comms_pipe[0], comms_pipe[1]);
+ DEBUGLOG("Creating pipe, [%d, %d]\n", comms_pipe[0], comms_pipe[1]);
if (fcntl(comms_pipe[0], F_SETFD, 1))
DEBUGLOG("setting CLOEXEC on pipe[0] failed: %s\n", strerror(errno));
@@ -1499,6 +1504,7 @@ static int distribute_command(struct local_client *thisfd)
thisfd->bits.localsock.in_progress = TRUE;
thisfd->bits.localsock.expected_replies = 1;
thisfd->bits.localsock.num_replies = 0;
+ DEBUGLOG("Doing command explicitly on local node only\n");
add_to_lvmqueue(thisfd, inheader, len, NULL);
}
@@ -1665,7 +1671,7 @@ static __attribute__ ((noreturn)) void *pre_and_post_thread(void *arg)
sigset_t ss;
int pipe_fd = client->bits.localsock.pipe;
- DEBUGLOG("in sub thread: client = %p\n", client);
+ DEBUGLOG("Pre&post thread (%p), pipe %d\n", client, pipe_fd);
pthread_mutex_lock(&client->bits.localsock.mutex);
/* Ignore SIGUSR1 (handled by master process) but enable
@@ -1685,7 +1691,8 @@ static __attribute__ ((noreturn)) void *pre_and_post_thread(void *arg)
if ((status = do_pre_command(client)))
client->bits.localsock.all_success = 0;
- DEBUGLOG("Writing status %d down pipe %d\n", status, pipe_fd);
+ DEBUGLOG("Pre&post thread (%p) writes status %d down to pipe %d\n",
+ client, status, pipe_fd);
/* Tell the parent process we have finished this bit */
while ((write_status = write(pipe_fd, &status, sizeof(int))) != sizeof(int))
@@ -1700,15 +1707,15 @@ static __attribute__ ((noreturn)) void *pre_and_post_thread(void *arg)
}
/* We may need to wait for the condition variable before running the post command */
- DEBUGLOG("Waiting to do post command - state = %d\n",
- client->bits.localsock.state);
-
if (client->bits.localsock.state != POST_COMMAND &&
- !client->bits.localsock.finished)
+ !client->bits.localsock.finished) {
+ DEBUGLOG("Pre&post thread (%p) waiting to do post command, state = %d\n",
+ client, client->bits.localsock.state);
pthread_cond_wait(&client->bits.localsock.cond,
&client->bits.localsock.mutex);
+ }
- DEBUGLOG("Got post command condition...\n");
+ DEBUGLOG("Pre&post thread (%p) got post command condition...\n", client);
/* POST function must always run, even if the client aborts */
status = 0;
@@ -1720,18 +1727,18 @@ static __attribute__ ((noreturn)) void *pre_and_post_thread(void *arg)
break;
}
next_pre:
- DEBUGLOG("Waiting for next pre command\n");
-
if (client->bits.localsock.state != PRE_COMMAND &&
!client->bits.localsock.finished) {
+ DEBUGLOG("Pre&post thread (%p) waiting for next pre command\n", client);
pthread_cond_wait(&client->bits.localsock.cond,
&client->bits.localsock.mutex);
}
- DEBUGLOG("Got pre command condition...\n");
+ DEBUGLOG("Pre&post thread (%p) got pre command condition...\n", client);
}
pthread_mutex_unlock(&client->bits.localsock.mutex);
- DEBUGLOG("Subthread finished\n");
+ DEBUGLOG("Pre&post thread (%p) finished\n", client);
+
pthread_exit(NULL);
}
@@ -2008,7 +2015,7 @@ static void *lvm_thread_fn(void *arg)
/* Allow others to get moving */
pthread_barrier_wait(&lvm_start_barrier);
- DEBUGLOG("Sub thread ready for work.\n");
+ DEBUGLOG("LVM thread ready for work.\n");
/* Now wait for some actual work */
pthread_mutex_lock(&lvm_thread_mutex);
@@ -2031,6 +2038,7 @@ static void *lvm_thread_fn(void *arg)
}
pthread_mutex_unlock(&lvm_thread_mutex);
+ DEBUGLOG("LVM thread exits\n");
destroy_lvm();
9 years, 6 months
master - cleanup: clvmd uses struct initializers
by Zdenek Kabelac
Gitweb: http://git.fedorahosted.org/git/?p=lvm2.git;a=commitdiff;h=0d449fe183936b...
Commit: 0d449fe183936be5790e7c59d157fe6c8334a914
Parent: 9196274c1efb16731ec4ce53adb46366411b7c14
Author: Zdenek Kabelac <zkabelac(a)redhat.com>
AuthorDate: Fri Mar 21 12:56:56 2014 +0100
Committer: Zdenek Kabelac <zkabelac(a)redhat.com>
CommitterDate: Fri Mar 21 22:29:27 2014 +0100
cleanup: clvmd uses struct initializers
Code easier to read
---
daemons/clvmd/clvmd.c | 59 ++++++++++++++++++++-----------------------------
1 files changed, 24 insertions(+), 35 deletions(-)
diff --git a/daemons/clvmd/clvmd.c b/daemons/clvmd/clvmd.c
index 9e58fd0..ac570b6 100644
--- a/daemons/clvmd/clvmd.c
+++ b/daemons/clvmd/clvmd.c
@@ -1541,26 +1541,21 @@ static void process_remote_command(struct clvm_header *msg, int msglen, int fd,
ntohl(version_nums[1]), ntohl(version_nums[2]));
if (ntohl(version_nums[0]) != CLVMD_MAJOR_VERSION) {
- struct clvm_header byebyemsg;
- DEBUGLOG
- ("Telling node %s to go away because of incompatible version number\n",
- node);
- log_notice
- ("Telling node %s to go away because of incompatible version number %d.%d.%d\n",
- node, ntohl(version_nums[0]),
- ntohl(version_nums[1]), ntohl(version_nums[2]));
-
- byebyemsg.cmd = CLVMD_CMD_GOAWAY;
- byebyemsg.status = 0;
- byebyemsg.flags = 0;
- byebyemsg.arglen = 0;
- byebyemsg.clientid = 0;
- clops->cluster_send_message(&byebyemsg, sizeof(byebyemsg),
- our_csid,
- "Error Sending GOAWAY message");
- } else {
+ struct clvm_header byebyemsg = {
+ .cmd = CLVMD_CMD_GOAWAY
+ };
+
+ DEBUGLOG("Telling node %s to go away because of incompatible version number\n",
+ node);
+ log_notice("Telling node %s to go away because of incompatible version number %d.%d.%d\n",
+ node, ntohl(version_nums[0]),
+ ntohl(version_nums[1]), ntohl(version_nums[2]));
+
+ clops->cluster_send_message(&byebyemsg, sizeof(byebyemsg), our_csid,
+ "Error Sending GOAWAY message");
+ } else
clops->add_up_node(csid);
- }
+
return;
}
@@ -1594,24 +1589,18 @@ static void process_remote_command(struct clvm_header *msg, int msglen, int fd,
agghead->clientid = msg->clientid;
agghead->arglen = replylen;
agghead->node[0] = '\0';
- send_message(aggreply,
- sizeof(struct clvm_header) +
- replylen, csid, fd,
- "Error sending command reply");
+ send_message(aggreply, sizeof(struct clvm_header) + replylen,
+ csid, fd, "Error sending command reply");
} else {
- struct clvm_header head;
-
- DEBUGLOG("Error attempting to realloc return buffer\n");
/* Return a failure response */
- head.cmd = CLVMD_CMD_REPLY;
- head.status = ENOMEM;
- head.flags = 0;
- head.clientid = msg->clientid;
- head.arglen = 0;
- head.node[0] = '\0';
- send_message(&head, sizeof(struct clvm_header), csid,
- fd, "Error sending ENOMEM command reply");
- return;
+ struct clvm_header reply = {
+ .cmd = CLVMD_CMD_REPLY,
+ .status = ENOMEM,
+ .clientid = msg->clientid
+ };
+ DEBUGLOG("Error attempting to realloc return buffer\n");
+ send_message(&reply, sizeof(reply), csid, fd,
+ "Error sending ENOMEM command reply");
}
}
9 years, 6 months
master - cleanup: clvmd zombie removal loop
by Zdenek Kabelac
Gitweb: http://git.fedorahosted.org/git/?p=lvm2.git;a=commitdiff;h=9196274c1efb16...
Commit: 9196274c1efb16731ec4ce53adb46366411b7c14
Parent: 5740c00f3b6160147a5bb72217dae9ce5359a525
Author: Zdenek Kabelac <zkabelac(a)redhat.com>
AuthorDate: Fri Mar 21 12:56:35 2014 +0100
Committer: Zdenek Kabelac <zkabelac(a)redhat.com>
CommitterDate: Fri Mar 21 22:29:27 2014 +0100
cleanup: clvmd zombie removal loop
Simplier code to start scan from the next node,
and remove matching pipe client.
---
daemons/clvmd/clvmd.c | 23 +++++++----------------
1 files changed, 7 insertions(+), 16 deletions(-)
diff --git a/daemons/clvmd/clvmd.c b/daemons/clvmd/clvmd.c
index 3d7d072..9e58fd0 100644
--- a/daemons/clvmd/clvmd.c
+++ b/daemons/clvmd/clvmd.c
@@ -1179,29 +1179,20 @@ static int cleanup_zombie(struct local_client *thisfd)
/* Remove the pipe client */
if (thisfd->bits.localsock.pipe_client) {
- struct local_client *newfd;
- struct local_client *lastfd = NULL;
- struct local_client *free_fd = NULL;
+ struct local_client *delfd;
+ struct local_client *lastfd;
(void) close(thisfd->bits.localsock.pipe_client->fd); /* Close pipe */
(void) close(thisfd->bits.localsock.pipe);
/* Remove pipe client */
- for (newfd = &local_client_head; newfd != NULL;
- newfd = newfd->next) {
- if (thisfd->bits.localsock.
- pipe_client == newfd) {
- thisfd->bits.localsock.
- pipe_client = NULL;
-
- lastfd->next = newfd->next;
- free_fd = newfd;
- newfd->next = lastfd;
- dm_free(free_fd);
+ for (lastfd = &local_client_head; (delfd = lastfd->next); lastfd = delfd)
+ if (thisfd->bits.localsock.pipe_client == delfd) {
+ thisfd->bits.localsock.pipe_client = NULL;
+ lastfd->next = delfd->next;
+ dm_free(delfd);
break;
}
- lastfd = newfd;
- }
}
}
9 years, 6 months
master - cleanup: clvmd reindent read_from_local_sock
by Zdenek Kabelac
Gitweb: http://git.fedorahosted.org/git/?p=lvm2.git;a=commitdiff;h=5740c00f3b6160...
Commit: 5740c00f3b6160147a5bb72217dae9ce5359a525
Parent: dd17286c90d732845df95f69d4e295103469f2bd
Author: Zdenek Kabelac <zkabelac(a)redhat.com>
AuthorDate: Thu Mar 20 14:45:39 2014 +0100
Committer: Zdenek Kabelac <zkabelac(a)redhat.com>
CommitterDate: Fri Mar 21 22:29:26 2014 +0100
cleanup: clvmd reindent read_from_local_sock
Shift indent of else branch to right since
error path returns in the front.
(Simplier to read)
---
daemons/clvmd/clvmd.c | 364 ++++++++++++++++++++++++-------------------------
1 files changed, 175 insertions(+), 189 deletions(-)
diff --git a/daemons/clvmd/clvmd.c b/daemons/clvmd/clvmd.c
index 53da928..3d7d072 100644
--- a/daemons/clvmd/clvmd.c
+++ b/daemons/clvmd/clvmd.c
@@ -1221,7 +1221,12 @@ static int read_from_local_sock(struct local_client *thisfd)
int len;
int argslen;
int missing_len;
- char buffer[PIPE_BUF + 1] = { 0 };
+ char buffer[PIPE_BUF + 1];
+ char csid[MAX_CSID_LEN];
+ int comms_pipe[2];
+ struct local_client *newfd;
+ struct clvm_header *inheader = (struct clvm_header *) buffer;
+ int status;
len = read(thisfd->fd, buffer, sizeof(buffer) - 1);
if (len == -1 && errno == EINTR)
@@ -1229,15 +1234,12 @@ static int read_from_local_sock(struct local_client *thisfd)
DEBUGLOG("Read on local socket %d, len = %d\n", thisfd->fd, len);
- if (len) {
- int rv = verify_message(buffer, len);
- if (rv < 0) {
- log_error("read_from_local_sock from %d len %d bad verify",
- thisfd->fd, len);
- dump_message(buffer, len);
- /* force error handling below */
- len = 0;
- }
+ if (len && verify_message(buffer, len) < 0) {
+ log_error("read_from_local_sock from %d len %d bad verify.",
+ thisfd->fd, len);
+ dump_message(buffer, len);
+ /* force error handling below */
+ len = 0;
}
/* EOF or error on socket */
@@ -1245,203 +1247,187 @@ static int read_from_local_sock(struct local_client *thisfd)
thisfd->bits.localsock.cleanup_needed = 1;
(void) cleanup_zombie(thisfd); /* ignore errors here */
return 0;
- } else {
- int comms_pipe[2];
- struct local_client *newfd;
- char csid[MAX_CSID_LEN];
- struct clvm_header *inheader;
- int status;
-
- buffer[len] = 0; /* Ensure \0 terminated */
- inheader = (struct clvm_header *) buffer;
-
- /* Fill in the client ID */
- inheader->clientid = htonl(thisfd->fd);
-
- /* If we are already busy then return an error */
- if (thisfd->bits.localsock.in_progress) {
- struct clvm_header reply = {
- .cmd = CLVMD_CMD_REPLY,
- .status = EBUSY
- };
- send_message(&reply, sizeof(reply), our_csid,
- thisfd->fd,
- "Error sending EBUSY reply to local user");
- return len;
- }
+ }
- /* See if we have the whole message */
- argslen =
- len - strlen(inheader->node) - sizeof(struct clvm_header);
- missing_len = inheader->arglen - argslen;
-
- if (missing_len < 0)
- missing_len = 0;
-
- /* We need at least sizeof(struct clvm_header) bytes in buffer */
- if (len < (int)sizeof(struct clvm_header) || argslen < 0 ||
- missing_len > MAX_MISSING_LEN) {
- struct clvm_header reply = {
- .cmd = CLVMD_CMD_REPLY,
- .status = EINVAL
- };
- send_message(&reply, sizeof(reply), our_csid,
- thisfd->fd,
- "Error sending EINVAL reply to local user");
- return 0;
- }
+ buffer[len] = 0; /* Ensure \0 terminated */
- /* Free any old buffer space */
- dm_free(thisfd->bits.localsock.cmd);
-
- /* Save the message */
- if (!(thisfd->bits.localsock.cmd = dm_malloc(len + missing_len))) {
- struct clvm_header reply = {
- .cmd = CLVMD_CMD_REPLY,
- .status = ENOMEM
- };
- send_message(&reply, sizeof(reply), our_csid,
- thisfd->fd,
- "Error sending ENOMEM reply to local user");
- return 0;
- }
- memcpy(thisfd->bits.localsock.cmd, buffer, len);
- thisfd->bits.localsock.cmd_len = len + missing_len;
- inheader = (struct clvm_header *) thisfd->bits.localsock.cmd;
-
- /* If we don't have the full message then read the rest now */
- if (missing_len) {
- char *argptr =
- inheader->node + strlen(inheader->node) + 1;
-
- while (missing_len > 0) {
- DEBUGLOG("got %d bytes, need another %d (total %d)\n",
- argslen, missing_len, inheader->arglen);
- len = read(thisfd->fd, argptr + argslen,
- missing_len);
- if (len == -1 && errno == EINTR)
- continue;
- if (len > 0) {
- missing_len -= len;
- argslen += len;
- } else {
- /* EOF or error on socket */
- DEBUGLOG("EOF on local socket\n");
- dm_free(thisfd->bits.localsock.cmd);
- thisfd->bits.localsock.cmd = NULL;
- return 0;
- }
- }
- }
+ /* Fill in the client ID */
+ inheader->clientid = htonl(thisfd->fd);
- /* Initialise and lock the mutex so the subthread will wait after
- finishing the PRE routine */
- if (!thisfd->bits.localsock.threadid) {
- pthread_mutex_init(&thisfd->bits.localsock.mutex, NULL);
- pthread_cond_init(&thisfd->bits.localsock.cond, NULL);
- pthread_mutex_init(&thisfd->bits.localsock.reply_mutex, NULL);
- }
+ /* If we are already busy then return an error */
+ if (thisfd->bits.localsock.in_progress) {
+ struct clvm_header reply = {
+ .cmd = CLVMD_CMD_REPLY,
+ .status = EBUSY
+ };
+ send_message(&reply, sizeof(reply), our_csid, thisfd->fd,
+ "Error sending EBUSY reply to local user");
+ return len;
+ }
- /* Only run the command if all the cluster nodes are running CLVMD */
- if (((inheader->flags & CLVMD_FLAG_LOCAL) == 0) &&
- (check_all_clvmds_running(thisfd) == -1)) {
- thisfd->bits.localsock.expected_replies = 0;
- thisfd->bits.localsock.num_replies = 0;
- send_local_reply(thisfd, EHOSTDOWN, thisfd->fd);
- return len;
- }
+ /* See if we have the whole message */
+ argslen = len - strlen(inheader->node) - sizeof(struct clvm_header);
+ missing_len = inheader->arglen - argslen;
+
+ if (missing_len < 0)
+ missing_len = 0;
+
+ /* We need at least sizeof(struct clvm_header) bytes in buffer */
+ if (len < (int)sizeof(struct clvm_header) || /* Already handled in verify_message() */
+ argslen < 0 || missing_len > MAX_MISSING_LEN) {
+ struct clvm_header reply = {
+ .cmd = CLVMD_CMD_REPLY,
+ .status = EINVAL
+ };
+ send_message(&reply, sizeof(reply), our_csid, thisfd->fd,
+ "Error sending EINVAL reply to local user");
+ return 0;
+ }
- /* Check the node name for validity */
- if (inheader->node[0] && clops->csid_from_name(csid, inheader->node)) {
- /* Error, node is not in the cluster */
- struct clvm_header reply = {
- .cmd = CLVMD_CMD_REPLY,
- .status = ENOENT
- };
-
- DEBUGLOG("Unknown node: '%s'\n", inheader->node);
- send_message(&reply, sizeof(reply), our_csid,
- thisfd->fd,
- "Error sending ENOENT reply to local user");
- thisfd->bits.localsock.expected_replies = 0;
- thisfd->bits.localsock.num_replies = 0;
- thisfd->bits.localsock.in_progress = FALSE;
- thisfd->bits.localsock.sent_out = FALSE;
- return len;
- }
+ /* Free any old buffer space */
+ dm_free(thisfd->bits.localsock.cmd);
- /* If we already have a subthread then just signal it to start */
- if (thisfd->bits.localsock.threadid) {
- pthread_mutex_lock(&thisfd->bits.localsock.mutex);
- thisfd->bits.localsock.state = PRE_COMMAND;
- pthread_cond_signal(&thisfd->bits.localsock.cond);
- pthread_mutex_unlock(&thisfd->bits.localsock.mutex);
- return len;
- }
+ /* Save the message */
+ if (!(thisfd->bits.localsock.cmd = dm_malloc(len + missing_len))) {
+ struct clvm_header reply = {
+ .cmd = CLVMD_CMD_REPLY,
+ .status = ENOMEM
+ };
+ send_message(&reply, sizeof(reply), our_csid, thisfd->fd,
+ "Error sending ENOMEM reply to local user");
+ return 0;
+ }
+ memcpy(thisfd->bits.localsock.cmd, buffer, len);
+ thisfd->bits.localsock.cmd_len = len + missing_len;
+ inheader = (struct clvm_header *) thisfd->bits.localsock.cmd;
+
+ /* If we don't have the full message then read the rest now */
+ if (missing_len) {
+ char *argptr = inheader->node + strlen(inheader->node) + 1;
+
+ while (missing_len > 0) {
+ DEBUGLOG("got %d bytes, need another %d (total %d)\n",
+ argslen, missing_len, inheader->arglen);
+ len = read(thisfd->fd, argptr + argslen, missing_len);
+ if (len == -1 && errno == EINTR)
+ continue;
- /* Create a pipe and add the reading end to our FD list */
- if (pipe(comms_pipe)) {
- struct clvm_header reply = {
- .cmd = CLVMD_CMD_REPLY,
- .status = EBUSY
- };
-
- DEBUGLOG("creating pipe failed: %s\n", strerror(errno));
- send_message(&reply, sizeof(reply), our_csid,
- thisfd->fd,
- "Error sending EBUSY reply to local user");
- return len;
- }
+ if (len <= 0) {
+ /* EOF or error on socket */
+ DEBUGLOG("EOF on local socket\n");
+ dm_free(thisfd->bits.localsock.cmd);
+ thisfd->bits.localsock.cmd = NULL;
+ return 0;
+ }
- if (!(newfd = dm_malloc(sizeof(*newfd)))) {
- struct clvm_header reply = {
- .cmd = CLVMD_CMD_REPLY,
- .status = ENOMEM
- };
+ missing_len -= len;
+ argslen += len;
+ }
+ }
- (void) close(comms_pipe[0]);
- (void) close(comms_pipe[1]);
+ /*
+ * Initialise and lock the mutex so the subthread will wait
+ * after finishing the PRE routine
+ */
+ if (!thisfd->bits.localsock.threadid) {
+ pthread_mutex_init(&thisfd->bits.localsock.mutex, NULL);
+ pthread_cond_init(&thisfd->bits.localsock.cond, NULL);
+ pthread_mutex_init(&thisfd->bits.localsock.reply_mutex, NULL);
+ }
- send_message(&reply, sizeof(reply), our_csid,
- thisfd->fd,
- "Error sending ENOMEM reply to local user");
- return len;
- }
- DEBUGLOG("creating pipe, [%d, %d]\n", comms_pipe[0],
- comms_pipe[1]);
+ /* Only run the command if all the cluster nodes are running CLVMD */
+ if (((inheader->flags & CLVMD_FLAG_LOCAL) == 0) &&
+ (check_all_clvmds_running(thisfd) == -1)) {
+ thisfd->bits.localsock.expected_replies = 0;
+ thisfd->bits.localsock.num_replies = 0;
+ send_local_reply(thisfd, EHOSTDOWN, thisfd->fd);
+ return len;
+ }
- if (fcntl(comms_pipe[0], F_SETFD, 1))
- DEBUGLOG("setting CLOEXEC on pipe[0] failed: %s\n", strerror(errno));
- if (fcntl(comms_pipe[1], F_SETFD, 1))
- DEBUGLOG("setting CLOEXEC on pipe[1] failed: %s\n", strerror(errno));
+ /* Check the node name for validity */
+ if (inheader->node[0] && clops->csid_from_name(csid, inheader->node)) {
+ /* Error, node is not in the cluster */
+ struct clvm_header reply = {
+ .cmd = CLVMD_CMD_REPLY,
+ .status = ENOENT
+ };
+
+ DEBUGLOG("Unknown node: '%s'\n", inheader->node);
+ send_message(&reply, sizeof(reply), our_csid, thisfd->fd,
+ "Error sending ENOENT reply to local user");
+ thisfd->bits.localsock.expected_replies = 0;
+ thisfd->bits.localsock.num_replies = 0;
+ thisfd->bits.localsock.in_progress = FALSE;
+ thisfd->bits.localsock.sent_out = FALSE;
+ return len;
+ }
- newfd->fd = comms_pipe[0];
- newfd->removeme = 0;
- newfd->type = THREAD_PIPE;
- newfd->callback = local_pipe_callback;
- newfd->next = thisfd->next;
- newfd->bits.pipe.client = thisfd;
- newfd->bits.pipe.threadid = 0;
- thisfd->next = newfd;
+ /* If we already have a subthread then just signal it to start */
+ if (thisfd->bits.localsock.threadid) {
+ pthread_mutex_lock(&thisfd->bits.localsock.mutex);
+ thisfd->bits.localsock.state = PRE_COMMAND;
+ pthread_cond_signal(&thisfd->bits.localsock.cond);
+ pthread_mutex_unlock(&thisfd->bits.localsock.mutex);
+ return len;
+ }
- /* Store a cross link to the pipe */
- thisfd->bits.localsock.pipe_client = newfd;
+ /* Create a pipe and add the reading end to our FD list */
+ if (pipe(comms_pipe)) {
+ struct clvm_header reply = {
+ .cmd = CLVMD_CMD_REPLY,
+ .status = EBUSY
+ };
+
+ DEBUGLOG("Creating pipe failed: %s\n", strerror(errno));
+ send_message(&reply, sizeof(reply), our_csid, thisfd->fd,
+ "Error sending EBUSY reply to local user");
+ return len;
+ }
- thisfd->bits.localsock.pipe = comms_pipe[1];
+ if (!(newfd = dm_zalloc(sizeof(*newfd)))) {
+ struct clvm_header reply = {
+ .cmd = CLVMD_CMD_REPLY,
+ .status = ENOMEM
+ };
- /* Make sure the thread has a copy of it's own ID */
- newfd->bits.pipe.threadid = thisfd->bits.localsock.threadid;
+ (void) close(comms_pipe[0]);
+ (void) close(comms_pipe[1]);
- /* Run the pre routine */
- thisfd->bits.localsock.in_progress = TRUE;
- thisfd->bits.localsock.state = PRE_COMMAND;
- thisfd->bits.localsock.cleanup_needed = 1;
- DEBUGLOG("Creating pre&post thread\n");
- status = pthread_create(&thisfd->bits.localsock.threadid,
- &stack_attr, pre_and_post_thread, thisfd);
- DEBUGLOG("Created pre&post thread, state = %d\n", status);
+ send_message(&reply, sizeof(reply), our_csid, thisfd->fd,
+ "Error sending ENOMEM reply to local user");
+ return len;
}
+ DEBUGLOG("creating pipe, [%d, %d]\n", comms_pipe[0], comms_pipe[1]);
+
+ if (fcntl(comms_pipe[0], F_SETFD, 1))
+ DEBUGLOG("setting CLOEXEC on pipe[0] failed: %s\n", strerror(errno));
+ if (fcntl(comms_pipe[1], F_SETFD, 1))
+ DEBUGLOG("setting CLOEXEC on pipe[1] failed: %s\n", strerror(errno));
+
+ newfd->fd = comms_pipe[0];
+ newfd->type = THREAD_PIPE;
+ newfd->callback = local_pipe_callback;
+ newfd->bits.pipe.client = thisfd;
+ newfd->next = thisfd->next;
+ thisfd->next = newfd;
+
+ /* Store a cross link to the pipe */
+ thisfd->bits.localsock.pipe_client = newfd;
+ thisfd->bits.localsock.pipe = comms_pipe[1];
+
+ /* Make sure the thread has a copy of it's own ID */
+ newfd->bits.pipe.threadid = thisfd->bits.localsock.threadid;
+
+ /* Run the pre routine */
+ thisfd->bits.localsock.in_progress = TRUE;
+ thisfd->bits.localsock.state = PRE_COMMAND;
+ thisfd->bits.localsock.cleanup_needed = 1;
+ DEBUGLOG("Creating pre&post thread\n");
+ status = pthread_create(&thisfd->bits.localsock.threadid,
+ &stack_attr, pre_and_post_thread, thisfd);
+ DEBUGLOG("Created pre&post thread, state = %d\n", status);
+
return len;
}
9 years, 6 months
master - cleanup: clvmd indent change
by Zdenek Kabelac
Gitweb: http://git.fedorahosted.org/git/?p=lvm2.git;a=commitdiff;h=dd17286c90d732...
Commit: dd17286c90d732845df95f69d4e295103469f2bd
Parent: 0b79979bb9dde5fd8bc2ef72431e5ce2a5439a3f
Author: Zdenek Kabelac <zkabelac(a)redhat.com>
AuthorDate: Fri Mar 21 12:56:01 2014 +0100
Committer: Zdenek Kabelac <zkabelac(a)redhat.com>
CommitterDate: Fri Mar 21 22:29:26 2014 +0100
cleanup: clvmd indent change
Plain indent changes.
---
daemons/clvmd/clvmd-openais.c | 4 +-
daemons/clvmd/clvmd.c | 200 ++++++++++++++++++-----------------------
daemons/clvmd/lvm-functions.c | 12 +--
3 files changed, 94 insertions(+), 122 deletions(-)
diff --git a/daemons/clvmd/clvmd-openais.c b/daemons/clvmd/clvmd-openais.c
index c91a238..29a323a 100644
--- a/daemons/clvmd/clvmd-openais.c
+++ b/daemons/clvmd/clvmd-openais.c
@@ -684,6 +684,6 @@ struct cluster_ops *init_openais_cluster(void)
{
if (!_init_cluster())
return &_cluster_openais_ops;
- else
- return NULL;
+
+ return NULL;
}
diff --git a/daemons/clvmd/clvmd.c b/daemons/clvmd/clvmd.c
index a21d53a..53da928 100644
--- a/daemons/clvmd/clvmd.c
+++ b/daemons/clvmd/clvmd.c
@@ -1,6 +1,6 @@
/*
* Copyright (C) 2002-2004 Sistina Software, Inc. All rights reserved.
- * Copyright (C) 2004-2011 Red Hat, Inc. All rights reserved.
+ * Copyright (C) 2004-2014 Red Hat, Inc. All rights reserved.
*
* This file is part of LVM2.
*
@@ -681,7 +681,7 @@ static int local_rendezvous_callback(struct local_client *thisfd, char *buf,
if (client_fd >= 0) {
if (!(newfd = dm_zalloc(sizeof(*newfd)))) {
if (close(client_fd))
- log_sys_error("close", "socket");
+ log_sys_error("close", "socket");
return 1;
}
@@ -843,9 +843,7 @@ static void main_loop(int cmd_timeout)
/* Wait on the cluster FD and all local sockets/pipes */
local_client_head.fd = clops->get_main_cluster_fd();
FD_ZERO(&in);
- for (thisfd = &local_client_head; thisfd != NULL;
- thisfd = thisfd->next) {
-
+ for (thisfd = &local_client_head; thisfd; thisfd = thisfd->next) {
if (thisfd->removeme)
continue;
@@ -872,14 +870,10 @@ static void main_loop(int cmd_timeout)
char csid[MAX_CSID_LEN];
char buf[max_cluster_message];
- for (thisfd = &local_client_head; thisfd != NULL;
- thisfd = thisfd->next) {
-
+ for (thisfd = &local_client_head; thisfd; thisfd = thisfd->next) {
if (thisfd->removeme && !cleanup_zombie(thisfd)) {
- struct local_client *free_fd;
+ struct local_client *free_fd = thisfd;
lastfd->next = thisfd->next;
- free_fd = thisfd;
-
DEBUGLOG("removeme set for fd %d\n", free_fd->fd);
/* Queue cleanup, this also frees the client struct */
@@ -892,13 +886,11 @@ static void main_loop(int cmd_timeout)
int ret;
/* Do callback */
- ret =
- thisfd->callback(thisfd, buf,
- sizeof(buf), csid,
- &newfd);
+ ret = thisfd->callback(thisfd, buf, sizeof(buf),
+ csid, &newfd);
/* Ignore EAGAIN */
- if (ret < 0 && (errno == EAGAIN ||
- errno == EINTR)) continue;
+ if (ret < 0 && (errno == EAGAIN || errno == EINTR))
+ continue;
/* Got error or EOF: Remove it from the list safely */
if (ret <= 0) {
@@ -930,14 +922,11 @@ static void main_loop(int cmd_timeout)
if (select_status == 0) {
time_t the_time = time(NULL);
- for (thisfd = &local_client_head; thisfd != NULL;
- thisfd = thisfd->next) {
- if (thisfd->type == LOCAL_SOCK
- && thisfd->bits.localsock.sent_out
- && thisfd->bits.localsock.sent_time +
- cmd_timeout < the_time
- && thisfd->bits.localsock.
- expected_replies !=
+ for (thisfd = &local_client_head; thisfd; thisfd = thisfd->next) {
+ if (thisfd->type == LOCAL_SOCK &&
+ thisfd->bits.localsock.sent_out &&
+ (thisfd->bits.localsock.sent_time + cmd_timeout) < the_time &&
+ thisfd->bits.localsock.expected_replies !=
thisfd->bits.localsock.num_replies) {
/* Send timed out message + replies we already have */
DEBUGLOG("Request timed-out (send: %ld, now: %ld)\n",
@@ -968,52 +957,49 @@ static void main_loop(int cmd_timeout)
static __attribute__ ((noreturn)) void wait_for_child(int c_pipe, int timeout)
{
int child_status;
- int sstat;
fd_set fds;
struct timeval tv = {timeout, 0};
FD_ZERO(&fds);
FD_SET(c_pipe, &fds);
- sstat = select(c_pipe+1, &fds, NULL, NULL, timeout? &tv: NULL);
- if (sstat == 0) {
+ switch (select(c_pipe+1, &fds, NULL, NULL, timeout? &tv: NULL)) {
+ case 0:
fprintf(stderr, "clvmd startup timed out\n");
exit(DFAIL_TIMEOUT);
- }
- if (sstat == 1) {
+ case 1:
if (read(c_pipe, &child_status, sizeof(child_status)) !=
sizeof(child_status)) {
-
fprintf(stderr, "clvmd failed in initialisation\n");
exit(DFAIL_INIT);
}
- else {
- switch (child_status) {
- case SUCCESS:
- break;
- case DFAIL_INIT:
- fprintf(stderr, "clvmd failed in initialisation\n");
- break;
- case DFAIL_LOCAL_SOCK:
- fprintf(stderr, "clvmd could not create local socket\n");
- fprintf(stderr, "Another clvmd is probably already running\n");
- break;
- case DFAIL_CLUSTER_IF:
- fprintf(stderr, "clvmd could not connect to cluster manager\n");
- fprintf(stderr, "Consult syslog for more information\n");
- break;
- case DFAIL_MALLOC:
- fprintf(stderr, "clvmd failed, not enough memory\n");
- break;
- default:
- fprintf(stderr, "clvmd failed, error was %d\n", child_status);
- break;
- }
- exit(child_status);
+
+ switch (child_status) {
+ case SUCCESS:
+ break;
+ case DFAIL_INIT:
+ fprintf(stderr, "clvmd failed in initialisation\n");
+ break;
+ case DFAIL_LOCAL_SOCK:
+ fprintf(stderr, "clvmd could not create local socket\n");
+ fprintf(stderr, "Another clvmd is probably already running\n");
+ break;
+ case DFAIL_CLUSTER_IF:
+ fprintf(stderr, "clvmd could not connect to cluster manager\n");
+ fprintf(stderr, "Consult syslog for more information\n");
+ break;
+ case DFAIL_MALLOC:
+ fprintf(stderr, "clvmd failed, not enough memory\n");
+ break;
+ default:
+ fprintf(stderr, "clvmd failed, error was %d\n", child_status);
+ break;
}
+ exit(child_status);
+ default:
+ fprintf(stderr, "clvmd startup, select failed: %s\n", strerror(errno));
+ exit(DFAIL_INIT);
}
- fprintf(stderr, "clvmd startup, select failed: %s\n", strerror(errno));
- exit(DFAIL_INIT);
}
/*
@@ -1192,7 +1178,7 @@ static int cleanup_zombie(struct local_client *thisfd)
pthread_mutex_destroy(&thisfd->bits.localsock.mutex);
/* Remove the pipe client */
- if (thisfd->bits.localsock.pipe_client != NULL) {
+ if (thisfd->bits.localsock.pipe_client) {
struct local_client *newfd;
struct local_client *lastfd = NULL;
struct local_client *free_fd = NULL;
@@ -1224,6 +1210,7 @@ static int cleanup_zombie(struct local_client *thisfd)
safe_close(&(thisfd->fd));
thisfd->bits.localsock.cleanup_needed = 0;
+
return 0;
}
@@ -1255,7 +1242,8 @@ static int read_from_local_sock(struct local_client *thisfd)
/* EOF or error on socket */
if (len <= 0) {
- cleanup_zombie(thisfd); /* we ignore errors here */
+ thisfd->bits.localsock.cleanup_needed = 1;
+ (void) cleanup_zombie(thisfd); /* ignore errors here */
return 0;
} else {
int comms_pipe[2];
@@ -1473,7 +1461,7 @@ int add_client(struct local_client *new_client)
static int distribute_command(struct local_client *thisfd)
{
struct clvm_header *inheader =
- (struct clvm_header *) thisfd->bits.localsock.cmd;
+ (struct clvm_header *) thisfd->bits.localsock.cmd;
int len = thisfd->bits.localsock.cmd_len;
thisfd->xid = global_xid++;
@@ -1487,7 +1475,7 @@ static int distribute_command(struct local_client *thisfd)
/* if node is empty then do it on the whole cluster */
if (inheader->node[0] == '\0') {
thisfd->bits.localsock.expected_replies =
- clops->get_num_nodes();
+ clops->get_num_nodes();
thisfd->bits.localsock.num_replies = 0;
thisfd->bits.localsock.sent_time = time(NULL);
thisfd->bits.localsock.in_progress = TRUE;
@@ -1505,30 +1493,28 @@ static int distribute_command(struct local_client *thisfd)
send_message(inheader, len, NULL, -1,
"Error forwarding message to cluster");
} else {
- /* Do it on a single node */
+ /* Do it on a single node */
char csid[MAX_CSID_LEN];
- if (clops->csid_from_name(csid, inheader->node)) {
+ if (clops->csid_from_name(csid, inheader->node))
/* This has already been checked so should not happen */
return 0;
+
+ /* OK, found a node... */
+ thisfd->bits.localsock.in_progress = TRUE;
+ thisfd->bits.localsock.expected_replies = 1;
+ thisfd->bits.localsock.num_replies = 0;
+
+ /* Are we the requested node ?? */
+ if (memcmp(csid, our_csid, max_csid_len) == 0) {
+ DEBUGLOG("Doing command on local node only\n");
+ add_to_lvmqueue(thisfd, inheader, len, NULL);
} else {
- /* OK, found a node... */
- thisfd->bits.localsock.expected_replies = 1;
- thisfd->bits.localsock.num_replies = 0;
- thisfd->bits.localsock.in_progress = TRUE;
-
- /* Are we the requested node ?? */
- if (memcmp(csid, our_csid, max_csid_len) == 0) {
- DEBUGLOG("Doing command on local node only\n");
- add_to_lvmqueue(thisfd, inheader, len, NULL);
- } else {
- DEBUGLOG("Sending message to single node: %s\n",
- inheader->node);
- inheader->xid = thisfd->xid;
- send_message(inheader, len,
- csid, -1,
- "Error forwarding message to cluster node");
- }
+ DEBUGLOG("Sending message to single node: %s\n",
+ inheader->node);
+ inheader->xid = thisfd->xid;
+ send_message(inheader, len, csid, -1,
+ "Error forwarding message to cluster node");
}
}
} else {
@@ -1560,14 +1546,12 @@ static void process_remote_command(struct clvm_header *msg, int msglen, int fd,
/* Check for GOAWAY and sulk */
if (msg->cmd == CLVMD_CMD_GOAWAY) {
-
DEBUGLOG("Told to go away by %s\n", nodename);
log_error("Told to go away by %s.", nodename);
exit(99);
}
- /* Version check is internal - don't bother exposing it in
- clvmd-command.c */
+ /* Version check is internal - don't bother exposing it in clvmd-command.c */
if (msg->cmd == CLVMD_CMD_VERSION) {
int version_nums[3];
char node[256];
@@ -1576,8 +1560,7 @@ static void process_remote_command(struct clvm_header *msg, int msglen, int fd,
clops->name_from_csid(csid, node);
DEBUGLOG("Remote node %s is version %d.%d.%d\n",
- node,
- ntohl(version_nums[0]),
+ node, ntohl(version_nums[0]),
ntohl(version_nums[1]), ntohl(version_nums[2]));
if (ntohl(version_nums[0]) != CLVMD_MAJOR_VERSION) {
@@ -1610,9 +1593,8 @@ static void process_remote_command(struct clvm_header *msg, int msglen, int fd,
/* FIXME: usage of init_test() is unprotected */
status = do_command(NULL, msg, msglen, &replyargs,
buflen, &replylen);
- else {
+ else
status = ENOMEM;
- }
/* If it wasn't a reply, then reply */
if (msg->cmd != CLVMD_CMD_REPLY) {
@@ -2034,6 +2016,7 @@ static int process_work_item(struct lvm_thread_cmd *cmd)
process_remote_command(cmd->msg, cmd->msglen, cmd->client->fd,
cmd->csid);
}
+
return 0;
}
@@ -2108,9 +2091,9 @@ static int add_to_lvmqueue(struct local_client *client, struct clvm_header *msg,
}
memcpy(cmd->msg, msg, msglen);
}
- else {
+ else
cmd->msg = NULL;
- }
+
cmd->client = client;
cmd->msglen = msglen;
cmd->xid = client->xid;
@@ -2118,9 +2101,8 @@ static int add_to_lvmqueue(struct local_client *client, struct clvm_header *msg,
if (csid) {
memcpy(cmd->csid, csid, max_csid_len);
cmd->remote = 1;
- } else {
+ } else
cmd->remote = 0;
- }
DEBUGLOG("add_to_lvmqueue: cmd=%p. client=%p, msg=%p, len=%d, csid=%p, xid=%d\n",
cmd, client, msg, msglen, csid, cmd->xid);
@@ -2189,8 +2171,7 @@ static int open_local_sock(void)
old_mask = umask(0077);
/* Open local socket */
- local_socket = socket(PF_UNIX, SOCK_STREAM, 0);
- if (local_socket < 0) {
+ if ((local_socket = socket(PF_UNIX, SOCK_STREAM, 0)) < 0) {
log_error("Can't create local socket: %m");
goto error;
}
@@ -2225,15 +2206,10 @@ void process_message(struct local_client *client, char *buf, int len,
const char *csid)
{
char nodename[max_cluster_member_name_len];
- struct clvm_header *inheader;
- int rv;
-
- inheader = (struct clvm_header *) buf;
+ struct clvm_header *inheader = (struct clvm_header *) buf;
ntoh_clvm(inheader); /* Byteswap fields */
- rv = verify_message(buf, len);
- if (rv < 0) {
- memset(nodename, 0, sizeof(nodename));
+ if (verify_message(buf, len) < 0) {
clops->name_from_csid(csid, nodename);
log_error("process_message from %s len %d bad verify.", nodename, len);
dump_message(buf, len);
@@ -2251,8 +2227,7 @@ static void check_all_callback(struct local_client *client, const char *csid,
int node_up)
{
if (!node_up)
- add_reply_to_list(client, EHOSTDOWN, csid, "CLVMD not running",
- 18);
+ add_reply_to_list(client, EHOSTDOWN, csid, "CLVMD not running", 18);
}
/* Check to see if all CLVMDs are running (ie one on
@@ -2269,10 +2244,11 @@ static int check_all_clvmds_running(struct local_client *client)
static struct local_client *find_client(int clientid)
{
struct local_client *thisfd;
- for (thisfd = &local_client_head; thisfd != NULL; thisfd = thisfd->next) {
+
+ for (thisfd = &local_client_head; thisfd; thisfd = thisfd->next)
if (thisfd->fd == (int)ntohl(clientid))
return thisfd;
- }
+
return NULL;
}
@@ -2358,27 +2334,27 @@ static if_type_t get_cluster_type(void)
confdb_callbacks_t callbacks = { 0 };
result = confdb_initialize (&handle, &callbacks);
- if (result != CS_OK)
+ if (result != CS_OK)
return type;
- result = confdb_object_find_start(handle, OBJECT_PARENT_HANDLE);
+ result = confdb_object_find_start(handle, OBJECT_PARENT_HANDLE);
if (result != CS_OK)
goto out;
- result = confdb_object_find(handle, OBJECT_PARENT_HANDLE, (void *)"cluster", strlen("cluster"), &cluster_handle);
- if (result != CS_OK)
+ result = confdb_object_find(handle, OBJECT_PARENT_HANDLE, (void *)"cluster", strlen("cluster"), &cluster_handle);
+ if (result != CS_OK)
goto out;
- result = confdb_object_find_start(handle, cluster_handle);
+ result = confdb_object_find_start(handle, cluster_handle);
if (result != CS_OK)
goto out;
- result = confdb_object_find(handle, cluster_handle, (void *)"clvmd", strlen("clvmd"), &clvmd_handle);
- if (result != CS_OK)
+ result = confdb_object_find(handle, cluster_handle, (void *)"clvmd", strlen("clvmd"), &clvmd_handle);
+ if (result != CS_OK)
goto out;
- result = confdb_key_get(handle, clvmd_handle, (void *)"interface", strlen("interface"), buf, &namelen);
- if (result != CS_OK)
+ result = confdb_key_get(handle, clvmd_handle, (void *)"interface", strlen("interface"), buf, &namelen);
+ if (result != CS_OK)
goto out;
if (namelen >= sizeof(buf))
diff --git a/daemons/clvmd/lvm-functions.c b/daemons/clvmd/lvm-functions.c
index e523522..622eb79 100644
--- a/daemons/clvmd/lvm-functions.c
+++ b/daemons/clvmd/lvm-functions.c
@@ -268,16 +268,13 @@ static int hold_lock(char *resource, int mode, int flags)
}
if (lvi) {
/* Already exists - convert it */
- status =
- sync_lock(resource, mode, flags, &lvi->lock_id);
+ status = sync_lock(resource, mode, flags, &lvi->lock_id);
saved_errno = errno;
if (!status)
lvi->lock_mode = mode;
-
- if (status) {
+ else
DEBUGLOG("hold_lock. convert to %d failed: %s\n", mode,
strerror(errno));
- }
errno = saved_errno;
} else {
lvi = malloc(sizeof(struct lv_info));
@@ -607,9 +604,8 @@ int post_lock_lv(unsigned char command, unsigned char lock_flags,
(command & LCK_CLUSTER_VG)) {
int oldmode;
- DEBUGLOG
- ("post_lock_lv: resource '%s', cmd = %s, flags = %s\n",
- resource, decode_locking_cmd(command), decode_flags(lock_flags));
+ DEBUGLOG("post_lock_lv: resource '%s', cmd = %s, flags = %s\n",
+ resource, decode_locking_cmd(command), decode_flags(lock_flags));
/* If the lock state is PW then restore it to what it was */
oldmode = get_current_lock(resource);
9 years, 6 months
master - cleanup: clvmd dump_messages
by Zdenek Kabelac
Gitweb: http://git.fedorahosted.org/git/?p=lvm2.git;a=commitdiff;h=0b79979bb9dde5...
Commit: 0b79979bb9dde5fd8bc2ef72431e5ce2a5439a3f
Parent: f8cd435cd83140e26d35e17f6fbccc1019f67aed
Author: Zdenek Kabelac <zkabelac(a)redhat.com>
AuthorDate: Thu Mar 20 10:22:41 2014 +0100
Committer: Zdenek Kabelac <zkabelac(a)redhat.com>
CommitterDate: Fri Mar 21 22:29:26 2014 +0100
cleanup: clvmd dump_messages
---
daemons/clvmd/clvmd.c | 25 +++++++++++--------------
1 files changed, 11 insertions(+), 14 deletions(-)
diff --git a/daemons/clvmd/clvmd.c b/daemons/clvmd/clvmd.c
index bc831d0..a21d53a 100644
--- a/daemons/clvmd/clvmd.c
+++ b/daemons/clvmd/clvmd.c
@@ -1120,30 +1120,27 @@ static int verify_message(char *buf, int len)
static void dump_message(char *buf, int len)
{
- unsigned char row[8] = { 0 };
+ unsigned char row[8];
char str[9];
- int i, j, pos = 0;
+ int i, j = 0;
+ str[8] = '\0';
if (len > 128)
len = 128;
- for (i = 0; i < len; i++) {
- row[pos++] = buf[i];
+ for (i = 0; i < len; ++i) {
+ row[j] = buf[i];
+ str[j] = (isprint(buf[i])) ? buf[i] : ' ';
- if ((pos == 8) || (i + 1 == len)) {
- memset(str, 0, sizeof(str));
-
- for (j = 0; j < 8; j++) {
- if (isprint(row[j]))
- str[j] = row[j];
- else
- str[j] = ' ';
+ if ((j == 8) || (i + 1 == len)) {
+ for (;j < 8; ++j) {
+ row[j] = 0;
+ str[j] = ' ';
}
log_error("%02x %02x %02x %02x %02x %02x %02x %02x [%s]",
row[0], row[1], row[2], row[3], row[4], row[5], row[6], row[7], str);
- pos = 0;
- memset(row, 0, sizeof(row));
+ j = 0;
}
}
}
9 years, 6 months