master - tests: try harder to kill all dangling procs
by okozina
Gitweb: http://git.fedorahosted.org/git/?p=lvm2.git;a=commitdiff;h=90cbc5576fa851...
Commit: 90cbc5576fa8511c7045700fa7de0bc3b01e2225
Parent: 8c9ab2a4dd827b575a7a8b501c5ca3474508f964
Author: Ondrej Kozina <okozina(a)redhat.com>
AuthorDate: Tue Apr 28 15:31:47 2015 +0200
Committer: Ondrej Kozina <okozina(a)redhat.com>
CommitterDate: Tue Apr 28 22:31:50 2015 +0200
tests: try harder to kill all dangling procs
also simplify and make less prone to an error checks
for running bg processes inside a pvmove-resume tests
---
test/shell/lvconvert-mirror.sh | 10 ++--
test/shell/mirror-names.sh | 2 +-
test/shell/pvmove-background.sh | 4 +-
test/shell/pvmove-resume-1.sh | 94 ++++++++++++++--------------------
test/shell/pvmove-resume-2.sh | 83 +++++++++++++-----------------
test/shell/pvmove-resume-multiseg.sh | 84 +++++++++++++------------------
6 files changed, 117 insertions(+), 160 deletions(-)
diff --git a/test/shell/lvconvert-mirror.sh b/test/shell/lvconvert-mirror.sh
index 6ba2ab2..5dde921 100644
--- a/test/shell/lvconvert-mirror.sh
+++ b/test/shell/lvconvert-mirror.sh
@@ -99,7 +99,7 @@ lvremove -ff $vg
lvcreate -aey -l5 --type mirror -m1 -n $lv1 $vg "$dev1" "$dev2" "$dev3:0"
check mirror $vg $lv1
check mirror_legs $vg $lv1 2
-lvconvert -m+1 -b $vg/$lv1 "$dev4"
+LVM_TEST_TAG="kill_me_$PREFIX" lvconvert -m+1 -b $vg/$lv1 "$dev4"
# Next convert should fail b/c we can't have 2 at once
should not lvconvert -m+1 $vg/$lv1 "$dev5"
@@ -156,7 +156,7 @@ lvremove -ff $vg
# "remove newly added mirror"
lvcreate -aey -l2 --type mirror -m1 -n $lv1 $vg "$dev1" "$dev2" "$dev3:$DEVRANGE"
-lvconvert -m+1 -b $vg/$lv1 "$dev4"
+LVM_TEST_TAG="kill_me_$PREFIX" lvconvert -m+1 -b $vg/$lv1 "$dev4"
lvconvert -m-1 $vg/$lv1 "$dev4"
lvconvert $vg/$lv1 # wait
@@ -167,7 +167,7 @@ lvremove -ff $vg
# "remove one of newly added mirrors"
lvcreate -aey -l2 --type mirror -m1 -n $lv1 $vg "$dev1" "$dev2" "$dev3:$DEVRANGE"
-lvconvert -m+2 -b $vg/$lv1 "$dev4" "$dev5"
+LVM_TEST_TAG="kill_me_$PREFIX" lvconvert -m+2 -b $vg/$lv1 "$dev4" "$dev5"
lvconvert -m-1 $vg/$lv1 "$dev4"
lvconvert $vg/$lv1 # wait
@@ -178,7 +178,7 @@ lvremove -ff $vg
# "remove from original mirror (the original is still mirror)"
lvcreate -aey -l2 --type mirror -m2 -n $lv1 $vg "$dev1" "$dev2" "$dev5" "$dev3:$DEVRANGE"
-lvconvert -m+1 -b $vg/$lv1 "$dev4"
+LVM_TEST_TAG="kill_me_$PREFIX" lvconvert -m+1 -b $vg/$lv1 "$dev4"
# FIXME: Extra wait here for mirror upconvert synchronization
# otherwise we may fail her on parallel upconvert and downconvert
# lvconvert-mirror-updown.sh tests this errornous case separately
@@ -193,7 +193,7 @@ lvremove -ff $vg
# "remove from original mirror (the original becomes linear)"
lvcreate -aey -l2 --type mirror -m1 -n $lv1 $vg "$dev1" "$dev2" "$dev3:$DEVRANGE"
-lvconvert -m+1 -b $vg/$lv1 "$dev4"
+LVM_TEST_TAG="kill_me_$PREFIX" lvconvert -m+1 -b $vg/$lv1 "$dev4"
# FIXME: Extra wait here for mirror upconvert synchronization
# otherwise we may fail her on parallel upconvert and downconvert
# lvconvert-mirror-updown.sh tests this errornous case separately
diff --git a/test/shell/mirror-names.sh b/test/shell/mirror-names.sh
index 9022ff9..aa640c2 100644
--- a/test/shell/mirror-names.sh
+++ b/test/shell/mirror-names.sh
@@ -101,7 +101,7 @@ check_and_cleanup_lvs_
#COMM "converting mirror names is ${lv1}_mimagetmp_2"
lvcreate -aey -l2 --type mirror -m1 -n $lv1 $vg
-lvconvert -m+1 -i+40 -b $vg/$lv1
+LVM_TEST_TAG="kill_me_$PREFIX" lvconvert -m+1 -i+40 -b $vg/$lv1
convlv=$(lv_convert_lv_ $vg/$lv1)
test $convlv = ${lv1}_mimagetmp_2
lv_devices_ $vg/$lv1 $convlv ${lv1}_mimage_2
diff --git a/test/shell/pvmove-background.sh b/test/shell/pvmove-background.sh
index 590c77b..7cb21d5 100644
--- a/test/shell/pvmove-background.sh
+++ b/test/shell/pvmove-background.sh
@@ -20,10 +20,10 @@ do
lvcreate -aey -l1 -n $lv1 $vg "$dev1"
lvs -o +devices | grep "$dev1"
-pvmove $mode -i 1 -b "$dev1" "$dev2"
+LVM_TEST_TAG="kill_me_$PREFIX" pvmove $mode -i 1 -b "$dev1" "$dev2"
sleep 5 # arbitrary...
lvs -o +devices | not grep "pvmove"
lvs -o +devices | grep "$dev2"
lvremove -ff $vg
-done
\ No newline at end of file
+done
diff --git a/test/shell/pvmove-resume-1.sh b/test/shell/pvmove-resume-1.sh
index 0731c48..9825e76 100644
--- a/test/shell/pvmove-resume-1.sh
+++ b/test/shell/pvmove-resume-1.sh
@@ -44,13 +44,6 @@ test_pvmove_resume() {
kill -9 $PVMOVE
if test -e LOCAL_LVMPOLLD ; then
- # inforestart lvmpolld
- kill $(< LOCAL_LVMPOLLD)
- for i in $(seq 1 100) ; do
- test $i -eq 100 && die "Shutdown of lvmpolld is too slow."
- test -e "$LVM_LVMPOLLD_PIDFILE" || break
- sleep .1
- done # wait for the pid removal
aux prepare_lvmpolld
fi
@@ -81,14 +74,7 @@ test_pvmove_resume() {
aux prepare_clvmd
fi
- if test -e LOCAL_LVMETAD ; then
- # Restart lvmetad
- kill $(< LOCAL_LVMETAD)
- aux prepare_lvmetad
- fi
-
- ps h -C lvm | tee out || true
- test $(wc -l < out) -eq 0
+ aux notify_lvmetad "$dev1" "$dev2" "$dev3" "$dev4"
# call resume function (see below)
# with expected number of spawned
@@ -112,47 +98,45 @@ test_pvmove_resume() {
i=$((i + 1))
done
+ aux kill_listed_processes
+
lvremove -ff $vg $vg1
}
lvchange_single() {
- lvchange -aey $vg/$lv1
- lvchange -aey $vg1/$lv1
+ LVM_TEST_TAG="kill_me_$PREFIX" lvchange -aey $vg/$lv1
+ LVM_TEST_TAG="kill_me_$PREFIX" lvchange -aey $vg1/$lv1
- ps h -C lvm | tee out || true
- test $(wc -l < out) -eq $1
+ test $(aux count_processes_with_tag) -eq $1
}
lvchange_all() {
- lvchange -aey $vg/$lv1 $vg1/$lv1
+ LVM_TEST_TAG="kill_me_$PREFIX" lvchange -aey $vg/$lv1 $vg1/$lv1
- ps h -C lvm | tee out || true
- test $(wc -l < out) -eq $1
+ test $(aux count_processes_with_tag) -eq $1
}
vgchange_single() {
- vgchange -aey $vg
- vgchange -aey $vg1
+ LVM_TEST_TAG="kill_me_$PREFIX" vgchange -aey $vg
+ LVM_TEST_TAG="kill_me_$PREFIX" vgchange -aey $vg1
- ps h -C lvm | tee out || true
- test $(wc -l < out) -eq $1
+ test $(aux count_processes_with_tag) -eq $1
}
vgchange_all() {
- vgchange -aey $vg $vg1
+ LVM_TEST_TAG="kill_me_$PREFIX" vgchange -aey $vg $vg1
- ps h -C lvm | tee out || true
- test $(wc -l < out) -eq $1
+ test $(aux count_processes_with_tag) -eq $1
}
pvmove_fg() {
- # pvmove resume requires LVs active
- vgchange -aey --poll n $vg $vg1
+ # pvmove resume requires LVs active...
+ LVM_TEST_TAG="kill_me_$PREFIX" vgchange --config 'activation{polling_interval=10}' -aey --poll n $vg $vg1
- ps h -C lvm | tee out || true
- test $(wc -l < out) -eq 0
+ # ...also vgchange --poll n must not spawn any bg processes...
+ test $(aux count_processes_with_tag) -eq 0
- # vgchange must not spawn (thus finish) background polling
+ # ...thus finish polling
get lv_field $vg name -a | grep "^\[pvmove0\]"
get lv_field $vg1 name -a | grep "^\[pvmove0\]"
@@ -161,31 +145,31 @@ pvmove_fg() {
aux enable_dev "$dev3"
aux enable_dev "$dev4"
- pvmove -i0
+ pvmove
}
pvmove_bg() {
- # pvmove resume requires LVs active
- vgchange -aey --poll n $vg $vg1
+ # pvmove resume requires LVs active...
+ LVM_TEST_TAG="kill_me_$PREFIX" vgchange --config 'activation{polling_interval=10}' -aey --poll n $vg $vg1
- ps h -C lvm | tee out || true
- test $(wc -l < out) -eq 0
+ # ...also vgchange --poll n must not spawn any bg processes...
+ test $(aux count_processes_with_tag) -eq 0
- # vgchange must not spawn (thus finish) background polling
+ # ...thus finish polling
get lv_field $vg name -a | grep "^\[pvmove0\]"
get lv_field $vg1 name -a | grep "^\[pvmove0\]"
- pvmove -b -i0
+ LVM_TEST_TAG="kill_me_$PREFIX" pvmove -b -i0
}
pvmove_fg_single() {
- # pvmove resume requires LVs active
- vgchange -aey --poll n $vg
+ # pvmove resume requires LVs active...
+ LVM_TEST_TAG="kill_me_$PREFIX" vgchange --config 'activation{polling_interval=10}' -aey --poll n $vg
- ps h -C lvm | tee out || true
- test $(wc -l < out) -eq 0
+ # ...also vgchange --poll n must not spawn any bg processes...
+ test $(aux count_processes_with_tag) -eq 0
- # vgchange must not spawn (thus finish) background polling
+ # ...thus finish polling
get lv_field $vg name -a | grep "^\[pvmove0\]"
get lv_field $vg1 name -a | grep "^\[pvmove0\]"
@@ -194,23 +178,23 @@ pvmove_fg_single() {
aux enable_dev "$dev3"
aux enable_dev "$dev4"
- pvmove -i0 "$dev1"
- pvmove -i0 "$dev2"
+ pvmove "$dev1"
+ pvmove "$dev2"
}
pvmove_bg_single() {
- # pvmove resume requires LVs active
- vgchange -aey --poll n $vg
+ # pvmove resume requires LVs active...
+ LVM_TEST_TAG="kill_me_$PREFIX" vgchange --config 'activation{polling_interval=10}' -aey --poll n $vg
- ps h -C lvm | tee out || true
- test $(wc -l < out) -eq 0
+ # ...also vgchange --poll n must not spawn any bg processes...
+ test $(aux count_processes_with_tag) -eq 0
- # vgchange must not spawn (thus finish) background polling
+ # ...thus finish polling
get lv_field $vg name -a | grep "^\[pvmove0\]"
get lv_field $vg1 name -a | grep "^\[pvmove0\]"
- pvmove -i0 -b "$dev1"
- pvmove -i0 -b "$dev2"
+ LVM_TEST_TAG="kill_me_$PREFIX" pvmove -b "$dev1"
+ LVM_TEST_TAG="kill_me_$PREFIX" pvmove -b "$dev2"
}
test -e LOCAL_CLVMD && skip
diff --git a/test/shell/pvmove-resume-2.sh b/test/shell/pvmove-resume-2.sh
index 0b938f8..dee82cc 100644
--- a/test/shell/pvmove-resume-2.sh
+++ b/test/shell/pvmove-resume-2.sh
@@ -16,7 +16,7 @@
. lib/inittest
-aux prepare_pvs 9 30
+aux prepare_pvs 2 30
vgcreate -s 128k $vg "$dev1"
pvcreate --metadatacopies 0 "$dev2"
@@ -35,13 +35,6 @@ test_pvmove_resume() {
kill -9 $PVMOVE
if test -e LOCAL_LVMPOLLD ; then
- # inforestart lvmpolld
- kill $(< LOCAL_LVMPOLLD)
- for i in $(seq 1 100) ; do
- test $i -eq 100 && die "Shutdown of lvmpolld is too slow."
- test -e "$LVM_LVMPOLLD_PIDFILE" || break
- sleep .1
- done # wait for the pid removal
aux prepare_lvmpolld
fi
@@ -70,14 +63,7 @@ test_pvmove_resume() {
aux prepare_clvmd
fi
- if test -e LOCAL_LVMETAD ; then
- # Restart lvmetad
- kill $(< LOCAL_LVMETAD)
- aux prepare_lvmetad
- fi
-
- ps h -C lvm | tee out || true
- test $(wc -l < out) -eq 0
+ aux notify_lvmetad "$dev1" "$dev2"
# call resume function (see below)
# with expected number of spawned
@@ -94,83 +80,84 @@ test_pvmove_resume() {
i=$((i + 1))
done
+ aux kill_listed_processes
+
lvremove -ff $vg
}
lvchange_single() {
- lvchange -aey $vg/$lv1
- lvchange -aey $vg/$lv2
+ LVM_TEST_TAG="kill_me_$PREFIX" lvchange -aey $vg/$lv1
+ LVM_TEST_TAG="kill_me_$PREFIX" lvchange -aey $vg/$lv2
}
lvchange_all() {
- lvchange -aey $vg/$lv1 $vg/$lv2
+ # remove -vvvv
+ LVM_TEST_TAG="kill_me_$PREFIX" lvchange -vvvv -aey $vg/$lv1 $vg/$lv2
# we don't want to spawn more than $1 background pollings
- ps h -C lvm | tee out || true
- test $(wc -l < out) -eq $1 || should false
+ test $(aux count_processes_with_tag) -eq $1 || should false
}
vgchange_single() {
- vgchange -aey $vg
+ LVM_TEST_TAG="kill_me_$PREFIX" vgchange -aey $vg
- ps h -C lvm | tee out || true
- test $(wc -l < out) -eq $1
+ test $(aux count_processes_with_tag) -eq $1
}
pvmove_fg() {
- # pvmove resume requires LVs active
- vgchange -aey --poll n $vg
+ # pvmove resume requires LVs active...
+ LVM_TEST_TAG="kill_me_$PREFIX" vgchange --config 'activation{polling_interval=10}' -aey --poll n $vg
- ps h -C lvm | tee out || true
- test $(wc -l < out) -eq 0
+ # ...also vgchange --poll n must not spawn any bg processes
+ test $(aux count_processes_with_tag) -eq 0
- # vgchange must not spawn (thus finish) background polling
+ # ...thus finish polling
get lv_field $vg name -a | grep "^\[pvmove0\]"
aux enable_dev "$dev2"
- pvmove -i0
+ pvmove
}
pvmove_bg() {
- # pvmove resume requires LVs active
- vgchange -aey --poll n $vg
+ # pvmove resume requires LVs active...
+ LVM_TEST_TAG="kill_me_$PREFIX" vgchange --config 'activation{polling_interval=10}' -aey --poll n $vg
- ps h -C lvm | tee out || true
- test $(wc -l < out) -eq 0
+ # ...also vgchange --poll n must not spawn any bg processes
+ test $(aux count_processes_with_tag) -eq 0
- # vgchange must not spawn (thus finish) background polling
+ # ...thus finish polling
get lv_field $vg name -a | grep "^\[pvmove0\]"
- pvmove -b -i0
+ LVM_TEST_TAG="kill_me_$PREFIX" pvmove -b
}
pvmove_fg_single() {
- # pvmove resume requires LVs active
- vgchange -aey --poll n $vg
+ # pvmove resume requires LVs active...
+ LVM_TEST_TAG="kill_me_$PREFIX" vgchange --config 'activation{polling_interval=10}' -aey --poll n $vg
- ps h -C lvm | tee out || true
- test $(wc -l < out) -eq 0
+ # ...also vgchange --poll n must not spawn any bg processes
+ test $(aux count_processes_with_tag) -eq 0
- # vgchange must not spawn (thus finish) background polling
+ # ...thus finish polling
get lv_field $vg name -a | grep "^\[pvmove0\]"
aux enable_dev "$dev2"
- pvmove -i0 "$dev1"
+ pvmove "$dev1"
}
pvmove_bg_single() {
- # pvmove resume requires LVs active
- vgchange -aey --poll n $vg
+ # pvmove resume requires LVs active...
+ LVM_TEST_TAG="kill_me_$PREFIX" vgchange --config 'activation{polling_interval=10}' -aey --poll n $vg
- ps h -C lvm | tee out || true
- test $(wc -l < out) -eq 0
+ # ...also vgchange --poll n must not spawn any bg processes...
+ test $(aux count_processes_with_tag) -eq 0
- # vgchange must not spawn (thus finish) background polling
+ # ...thus finish polling
get lv_field $vg name -a | grep "^\[pvmove0\]"
- pvmove -i0 -b "$dev1"
+ LVM_TEST_TAG="kill_me_$PREFIX" pvmove -b "$dev1"
}
test -e LOCAL_CLVMD && skip
diff --git a/test/shell/pvmove-resume-multiseg.sh b/test/shell/pvmove-resume-multiseg.sh
index 829178c..d70662d 100644
--- a/test/shell/pvmove-resume-multiseg.sh
+++ b/test/shell/pvmove-resume-multiseg.sh
@@ -44,13 +44,6 @@ test_pvmove_resume() {
kill -9 $PVMOVE
if test -e LOCAL_LVMPOLLD ; then
- # inforestart lvmpolld
- kill $(< LOCAL_LVMPOLLD)
- for i in $(seq 1 100) ; do
- test $i -eq 100 && die "Shutdown of lvmpolld is too slow."
- test -e "$LVM_LVMPOLLD_PIDFILE" || break
- sleep .1
- done # wait for the pid removal
aux prepare_lvmpolld
fi
@@ -81,14 +74,7 @@ test_pvmove_resume() {
aux prepare_clvmd
fi
- if test -e LOCAL_LVMETAD ; then
- # Restart lvmetad
- kill $(< LOCAL_LVMETAD)
- aux prepare_lvmetad
- fi
-
- ps h -C lvm | tee out || true
- test $(wc -l < out) -eq 0
+ aux notify_lvmetad "$dev1" "$dev2" "$dev3" "$dev4" "$dev5"
# call resume function (see below)
# with expected number of spawned
@@ -106,37 +92,37 @@ test_pvmove_resume() {
i=$((i + 1))
done
+ aux kill_listed_processes
+
lvremove -ff $vg
}
lvchange_single() {
- lvchange -aey $vg/$lv1
- lvchange -aey $vg/$lv2
+ LVM_TEST_TAG="kill_me_$PREFIX" lvchange -aey $vg/$lv1
+ LVM_TEST_TAG="kill_me_$PREFIX" lvchange -aey $vg/$lv2
}
lvchange_all() {
- lvchange -aey $vg/$lv1 $vg/$lv2
+ LVM_TEST_TAG="kill_me_$PREFIX" lvchange -aey $vg/$lv1 $vg/$lv2
# we don't want to spawn more than $1 background pollings
- ps h -C lvm | tee out || true
- test $(wc -l < out) -eq $1 || should false
+ test $(aux count_processes_with_tag) -eq $1
}
vgchange_single() {
- vgchange -aey -vvvv $vg
+ LVM_TEST_TAG="kill_me_$PREFIX" vgchange -aey $vg
- ps h -C lvm | tee out || true
- test $(wc -l < out) -eq $1
+ test $(aux count_processes_with_tag) -eq $1
}
pvmove_fg() {
- # pvmove resume requires LVs active
- vgchange -aey --poll n $vg
+ # pvmove resume requires LVs active...
+ LVM_TEST_TAG="kill_me_$PREFIX" vgchange --config 'activation{polling_interval=10}' -aey --poll n $vg
- ps h -C lvm | tee out || true
- test $(wc -l < out) -eq 0
+ # ...also vgchange --poll n must not spawn any bg processes...
+ test $(aux count_processes_with_tag) -eq 0
- # vgchange must not spawn (thus finish) background polling
+ # ...thus finish polling
get lv_field $vg name -a | grep "^\[pvmove0\]"
get lv_field $vg name -a | grep "^\[pvmove1\]"
@@ -145,31 +131,31 @@ pvmove_fg() {
aux enable_dev "$dev4"
aux enable_dev "$dev5"
- pvmove -i0
+ pvmove
}
pvmove_bg() {
- # pvmove resume requires LVs active
- vgchange -aey --poll n $vg
+ # pvmove resume requires LVs active...
+ LVM_TEST_TAG="kill_me_$PREFIX" vgchange --config 'activation{polling_interval=10}' -aey --poll n $vg
- ps h -C lvm | tee out || true
- test $(wc -l < out) -eq 0
+ # ...also vgchange --poll n must not spawn any bg processes...
+ test $(aux count_processes_with_tag) -eq 0
- # vgchange must not spawn (thus finish) background polling
+ # ...thus finish polling
get lv_field $vg name -a | grep "^\[pvmove0\]"
get lv_field $vg name -a | grep "^\[pvmove1\]"
- pvmove -b -i0
+ LVM_TEST_TAG="kill_me_$PREFIX" pvmove -b
}
pvmove_fg_single() {
- # pvmove resume requires LVs active
- vgchange -aey --poll n $vg
+ # pvmove resume requires LVs active...
+ LVM_TEST_TAG="kill_me_$PREFIX" vgchange --config 'activation{polling_interval=10}' -aey --poll n $vg
- ps h -C lvm | tee out || true
- test $(wc -l < out) -eq 0
+ # ...also vgchange --poll n must not spawn any bg processes...
+ test $(aux count_processes_with_tag) -eq 0
- # vgchange must not spawn (thus finish) background polling
+ # ...thus finish polling
get lv_field $vg name -a | grep "^\[pvmove0\]"
get lv_field $vg name -a | grep "^\[pvmove1\]"
@@ -178,23 +164,23 @@ pvmove_fg_single() {
aux enable_dev "$dev4"
aux enable_dev "$dev5"
- pvmove -i0 "$dev1"
- pvmove -i0 "$dev3"
+ pvmove "$dev1"
+ pvmove "$dev3"
}
pvmove_bg_single() {
- # pvmove resume requires LVs active
- vgchange -aey --poll n $vg
+ # pvmove resume requires LVs active...
+ LVM_TEST_TAG="kill_me_$PREFIX" vgchange --config 'activation{polling_interval=10}' -aey --poll n $vg
- ps h -C lvm | tee out || true
- test $(wc -l < out) -eq 0
+ # ...also vgchange --poll n must not spawn any bg processes...
+ test $(aux count_processes_with_tag) -eq 0
- # vgchange must not spawn (thus finish) background polling
+ # ...thus finish polling
get lv_field $vg name -a | grep "^\[pvmove0\]"
get lv_field $vg name -a | grep "^\[pvmove1\]"
- pvmove -i0 -b "$dev1"
- pvmove -i0 -b "$dev3"
+ LVM_TEST_TAG="kill_me_$PREFIX" pvmove -b "$dev1"
+ LVM_TEST_TAG="kill_me_$PREFIX" pvmove -b "$dev3"
}
test -e LOCAL_CLVMD && skip
8 years, 11 months
master - tests: simplify removal of dangling bg procs
by okozina
Gitweb: http://git.fedorahosted.org/git/?p=lvm2.git;a=commitdiff;h=8c9ab2a4dd827b...
Commit: 8c9ab2a4dd827b575a7a8b501c5ca3474508f964
Parent: 3f0434057b8b77efd63fe0c502a962bc9dd13223
Author: Ondrej Kozina <okozina(a)redhat.com>
AuthorDate: Mon Apr 27 10:33:45 2015 +0200
Committer: Ondrej Kozina <okozina(a)redhat.com>
CommitterDate: Tue Apr 28 22:31:40 2015 +0200
tests: simplify removal of dangling bg procs
some tests left dangling bg processes originating in
lvm2 commands being able to spawn any bg polling process
(lvchange, vgchange, pvmove, lvconvert...)
Initial fn 'add_to_kill_list' should collect processes with
specific parameters (proc's command line and parent processes ID).
After testing finishes the fn kill_listed_processes should remove these
listed by 'add_to_kill_list'.
Unfortunately it proved to be prone to an error especially in scenarios
where cmd line of initiating command contained characters required to
be espaced before passing to shell script to make it work correctly.
(Or if cmd spawned more than one bg process with same cmd line. i.e.:
vgchange or lvchange).
The new implementation is much simpler. It uses env. variable (LVM_TEST_TAG)
for marking a process desired to be killed later or during test env. teardown.
(i.e.: LVM_TEST_TAG=kill_me_$PREFIX to kill only processes related to
current test environment)
---
test/lib/aux.sh | 26 +++++++++-----------------
test/shell/pvmove-abort-all.sh | 9 +++------
test/shell/pvmove-abort.sh | 6 ++----
test/shell/pvmove-basic.sh | 4 +---
test/shell/pvmove-restart.sh | 3 ++-
5 files changed, 17 insertions(+), 31 deletions(-)
diff --git a/test/lib/aux.sh b/test/lib/aux.sh
index 0e59d6e..24be323 100644
--- a/test/lib/aux.sh
+++ b/test/lib/aux.sh
@@ -233,26 +233,18 @@ kill_sleep_kill_() {
fi
}
-# $1 cmd line
-# $2 optional parms for pgrep
-add_to_kill_list() {
- local p=$(pgrep ${@:2} -f "$1" 2>/dev/null)
- test -z "$p" || echo "$p:$1" >> kill_list
+print_procs_by_tag_() {
+ ps -o pid=,args= ehax 2>/dev/null | grep -weLVM_TEST_TAG=${1:-kill_me_$PREFIX} 2>/dev/null || true
+}
+
+count_processes_with_tag() {
+ print_procs_by_tag_ | wc -l
}
kill_listed_processes() {
- local tmp
- local pid
- local cmd
- test -f kill_list || return 0
- while read tmp; do
- pid=${tmp%%:*}
- cmd=${tmp##*:}
- for tmp in $(pgrep -f "$cmd" -d ' '); do
- test "$tmp" = "$pid" && kill -9 "$tmp"
- done
- done < kill_list
- rm -f kill_list
+ while read pid b; do
+ test -z "$pid" || kill -9 $pid
+ done <<< $(print_procs_by_tag_ $@)
}
teardown() {
diff --git a/test/shell/pvmove-abort-all.sh b/test/shell/pvmove-abort-all.sh
index de6d8c9..5bca8a2 100644
--- a/test/shell/pvmove-abort-all.sh
+++ b/test/shell/pvmove-abort-all.sh
@@ -50,12 +50,9 @@ if test -z "$backgroundarg" ; then
aux wait_pvmove_lv_ready "$vg1-pvmove0"
lvs -a $vg $vg1
else
- "${cmd1[@]}"
- aux add_to_kill_list "${cmd1[*]}" -P 1
- "${cmd2[@]}"
- aux add_to_kill_list "${cmd2[*]}" -P 1
- "${cmd3[@]}"
- aux add_to_kill_list "${cmd3[*]}" -P 1
+ LVM_TEST_TAG="kill_me_$PREFIX" "${cmd1[@]}"
+ LVM_TEST_TAG="kill_me_$PREFIX" "${cmd2[@]}"
+ LVM_TEST_TAG="kill_me_$PREFIX" "${cmd3[@]}"
fi
# test removal of all pvmove LVs
diff --git a/test/shell/pvmove-abort.sh b/test/shell/pvmove-abort.sh
index 3165c6f..2332521 100644
--- a/test/shell/pvmove-abort.sh
+++ b/test/shell/pvmove-abort.sh
@@ -40,10 +40,8 @@ if test -z "$backgroundarg" ; then
"${cmd2[@]}" &
aux wait_pvmove_lv_ready "$vg-pvmove1"
else
- "${cmd1[@]}"
- aux add_to_kill_list "${cmd1[*]}" -P 1
- "${cmd2[@]}"
- aux add_to_kill_list "${cmd2[*]}" -P 1
+ LVM_TEST_TAG="kill_me_$PREFIX" "${cmd1[@]}"
+ LVM_TEST_TAG="kill_me_$PREFIX" "${cmd2[@]}"
fi
# remove specific device
diff --git a/test/shell/pvmove-basic.sh b/test/shell/pvmove-basic.sh
index d5b7845..f7830da 100644
--- a/test/shell/pvmove-basic.sh
+++ b/test/shell/pvmove-basic.sh
@@ -334,9 +334,7 @@ check_and_cleanup_lvs_
#COMM "pvmove abort"
restore_lvs_
-cmd=(pvmove $mode -i100 -b "$dev1" "$dev3")
-"${cmd[@]}"
-aux add_to_kill_list "${cmd[*]}" -P 1
+LVM_TEST_TAG="kill_me_$PREFIX" pvmove $mode -i100 -b "$dev1" "$dev3"
pvmove --abort
check_and_cleanup_lvs_
diff --git a/test/shell/pvmove-restart.sh b/test/shell/pvmove-restart.sh
index 88dfebe..b91f624 100644
--- a/test/shell/pvmove-restart.sh
+++ b/test/shell/pvmove-restart.sh
@@ -79,7 +79,7 @@ dmsetup table
# Restart pvmove
# use exclusive activation to have usable pvmove without cmirrord
-vgchange -aey $vg
+LVM_TEST_TAG="kill_me_$PREFIX" vgchange --config 'activation{polling_interval=10}' -aey $vg
aux wait_pvmove_lv_ready "$vg-pvmove0"
dmsetup table
@@ -90,6 +90,7 @@ pvmove --abort
lvs -a -o+devices $vg
lvremove -ff $vg
+aux kill_listed_processes
done
# Restore delayed device back
8 years, 11 months
master - config: Introduce lvmconfig.
by Alasdair Kergon
Gitweb: http://git.fedorahosted.org/git/?p=lvm2.git;a=commitdiff;h=3f0434057b8b77...
Commit: 3f0434057b8b77efd63fe0c502a962bc9dd13223
Parent: beb229e1e8e8b95de09920195c2bc4171e89dc19
Author: Alasdair G Kergon <agk(a)redhat.com>
AuthorDate: Tue Apr 28 17:00:37 2015 +0100
Committer: Alasdair G Kergon <agk(a)redhat.com>
CommitterDate: Tue Apr 28 17:00:37 2015 +0100
config: Introduce lvmconfig.
'lvm dumpconfig' now does a lot more than just dumping configuration
information and is no longer only a support tool. Users now need
to run it to find out about configuration information that has been
removed from the lvm.conf man page so we need to promote this to full
command line status as 'lvmconfig'. Also accept 'lvm config' and mention
it in the usage information of lvmconf (which should also get merged in
eventually).
---
WHATS_NEW | 1 +
man/Makefile.in | 6 +-
man/clvmd.8.in | 2 +-
man/lvm-config.8.in | 1 +
man/lvm-dumpconfig.8.in | 163 +---------------------------------------------
man/lvm.8.in | 14 +++--
man/lvm.conf.5.in | 22 +++---
man/lvmconfig.8.in | 166 +++++++++++++++++++++++++++++++++++++++++++++++
man/lvmetad.8.in | 2 +-
scripts/lvmconf.sh | 3 +-
tools/Makefile.in | 2 +-
tools/commands.h | 52 ++++++++++++++-
tools/dumpconfig.c | 10 +++
tools/lvmcmdline.c | 4 +-
14 files changed, 261 insertions(+), 187 deletions(-)
diff --git a/WHATS_NEW b/WHATS_NEW
index ca5ee0f..f0c248c 100644
--- a/WHATS_NEW
+++ b/WHATS_NEW
@@ -1,5 +1,6 @@
Version 2.02.119 -
==================================
+ Introduce lvmconfig as the preferred form of 'lvm dumpconfig'.
Add lv_ancestors and lv_descendants reporting fields.
Add --ignorelocal option to dumpconfig to ignore the local section.
Close connection to lvmetad after fork.
diff --git a/man/Makefile.in b/man/Makefile.in
index a2e19fc..b93c5cb 100644
--- a/man/Makefile.in
+++ b/man/Makefile.in
@@ -42,9 +42,9 @@ endif
MAN5=lvm.conf.5
MAN7=lvmsystemid.7
-MAN8=lvm-dumpconfig.8 \
- lvchange.8 lvconvert.8 lvcreate.8 lvdisplay.8 lvextend.8 lvm.8 \
- lvmchange.8 lvmconf.8 lvmdiskscan.8 lvmdump.8 lvmsadc.8 lvmsar.8 \
+MAN8=lvm-config.8 lvm-dumpconfig.8 \
+ lvchange.8 lvmconfig.8 lvconvert.8 lvcreate.8 lvdisplay.8 lvextend.8 \
+ lvm.8 lvmchange.8 lvmconf.8 lvmdiskscan.8 lvmdump.8 lvmsadc.8 lvmsar.8 \
lvreduce.8 lvremove.8 lvrename.8 lvresize.8 lvs.8 \
lvscan.8 pvchange.8 pvck.8 pvcreate.8 pvdisplay.8 pvmove.8 pvremove.8 \
pvresize.8 pvs.8 pvscan.8 vgcfgbackup.8 vgcfgrestore.8 vgchange.8 \
diff --git a/man/clvmd.8.in b/man/clvmd.8.in
index 9b2bd4e..2c7330b 100644
--- a/man/clvmd.8.in
+++ b/man/clvmd.8.in
@@ -118,7 +118,7 @@ Display the version of the cluster LVM daemon.
.SH ENVIRONMENT VARIABLES
.TP
.B LVM_CLVMD_BINARY
-The CLVMD binary to use when \fBclmvd\fP restart is requested.
+The CLVMD binary to use when \fBclvmd\fP restart is requested.
Defaults to #CLVMD_PATH#.
.TP
.B LVM_BINARY
diff --git a/man/lvm-config.8.in b/man/lvm-config.8.in
new file mode 100644
index 0000000..3d1bec9
--- /dev/null
+++ b/man/lvm-config.8.in
@@ -0,0 +1 @@
+.so man8/lvm-config.8
diff --git a/man/lvm-dumpconfig.8.in b/man/lvm-dumpconfig.8.in
index b16afb4..5050d77 100644
--- a/man/lvm-dumpconfig.8.in
+++ b/man/lvm-dumpconfig.8.in
@@ -1,162 +1 @@
-.TH "LVM-DUMPCONFIG" "8" "LVM TOOLS #VERSION#" "Red Hat, Inc" "\""
-.SH "NAME"
-lvm-dumpconfig \(em dump LVM configuration
-.SH SYNOPSIS
-.B lvm dumpconfig
-.RB [ \-f | \-\-file
-.IR filename ]
-.RB [ \-\-type
-.RI { current | default | diff | missing | new | profilable | profilable-command | profilable-metadata }
-.RB [ \-\-atversion
-.IR version ]
-.RB [ \-\-ignoreadvanced ]
-.RB [ \-\-ignoreunsupported ]
-.RB [ \-\-ignorelocal ]
-.RB [ \-\-config
-.IR ConfigurationString ]
-.RB [ \-\-commandprofile
-.IR ProfileName ]
-.RB [ \-\-profile
-.IR ProfileName ]
-.RB [ \-\-metadataprofile
-.IR ProfileName ]
-.RB [ \-\-mergedconfig ]
-.RB [ \-\-validate ]
-.RB [ \-\-withcomments ]
-.RB [ \-\-withfullcomments ]
-.RB [ \-\-withversions ]
-.RB [ ConfigurationNode... ]
-
-.SH DESCRIPTION
-lvm dumpconfig produces formatted output with LVM configuration tree.
-
-.SH OPTIONS
-.TP
-.BR \-f ", " \-\-file " \fIfilename"
-Dump configuration to a file named 'filename'.
-
-.TP
-.IR \fB\-\-type " {" current | default | diff | missing | new | profilable }
-Select the type of configuration to dump. The configuration settings dumped
-have either default values or currently used values assigned based on the
-type selected (if no type is selected, \fB\-\-type current\fP is used
-by default). Whenever a configuration setting with a default value is
-commented out, it means the setting does not have any concrete default
-value defined. All output can be saved and reused as proper \fBlvm.conf\fP(5)
-file.
-.RS
-.IP current 3
-Dump current \fBlvm.conf\fP configuration merged with any \fBtag config\fP
-if used. See also \fBlvm.conf\fP(5) for more info about LVM configuration methods.
-.IP default 3
-Dump all possible configuration settings with default values assigned.
-.IP diff 3
-Dump all configuration settings for which the values used differ from defaults.
-The value assigned for each configuration setting is the value currently used.
-This is actually minimal LVM configuration which can be used without
-a change to current configured behaviour.
-.IP missing 3
-Dump all configuration settings with default values assigned which are
-missing in the configuration currently used and for which LVM automatically
-fallbacks to using these default values.
-.IP new 3
-Dump all new configuration settings introduced in current LVM version
-or specific version as defined by \fB\-\-atversion\fP option.
-.IP profilable 3
-Dump all profilable configuration settings with default values assigned.
-See \fBlvm.conf\fP(5) for more info about \fBprofile config\fP method.
-.IP profilable-command 3
-Dump all profilable configuration settings with default values assigned
-that can be used in command profile. This is a subset of settings dumped
-by \fB\-\-type \-\-profilable\fP.
-.IP profilable-metadata 3
-Dump all profilable configuration settings with default values assigned
-that can be used in metadata profile. This is a subset of settings dumped
-by \fB\-\-type \-\-profilable\fP.
-.RE
-
-.TP
-.BI \-\-atversion " version"
-Specify an LVM version in x.y.z format where x is the major version,
-the y is the minor version and z is the patchlevel (e.g. 2.2.106).
-When configuration is dumped, the configuration settings recognized
-at this LVM version will be considered only. This can be used
-to dump a configuration that certain LVM version understands and
-which does not contain any newer settings for which LVM would
-issue a warning message when checking the configuration.
-
-.TP
-.B \-\-ignoreadvanced
-Ignore advanced configuration settings on dump.
-
-.TP
-.B \-\-ignoreunsupported
-Ignore unsupported configuration settings on dump. These settings are
-either used for debugging purposes only or their support is not yet
-complete and they are not meant to be used in production.
-
-.TP
-.B \-\-ignorelocal
-Ignore local section.
-
-.TP
-.BI \-\-config " ConfigurationString"
-Use \fBConfigurationString\fP to override existing configuration.
-This configuration is then applied for dumpconfig command itself.
-See also \fBlvm.conf\fP(5) for more info about \fBconfig cascade\fP.
-
-.TP
-.BI \-\-commandprofile " ProfileName"
-Use \fBProfileName\fP to override existing configuration.
-This configuration is then applied for dumpconfig command itself.
-See also \fB\-\-mergedconfig\fP option and \fBlvm.conf\fP(5) for
-more info about \fBconfig cascade\fP.
-
-.TP
-.BI \-\-profile " ProfileName"
-The same as using \fB\-\-commandprofile\fP but the configuration is not
-applied for dumpconfig command itself.
-
-.TP
-.BI \-\-metadataprofile " ProfileName"
-Use \fBProfileName\fP to override existing configuration.
-The configuration defined in metadata profile has no effect for
-dumpconfig command itself, the dumpconfig dumps the configuration only.
-See also \fB\-\-mergedconfig\fP option and \fBlvm.conf\fP(5) for more
-info about \fBconfig cascade\fP.
-
-.TP
-.B \-\-mergedconfig
-When the dumpconfig command is run with the \fB\-\-config\fP option
-and/or \fB\-\-commandprofile\fP (or using \fBLVM_COMMAND_PROFILE\fP
-environment variable), \fB\-\-profile\fP, \fB\-\-metadataprofile\fP
-option, merge all the contents of the \fBconfig cascade\fP before dumping it.
-Without the \fB\-\-mergeconfig\fP option used, only the configuration at
-the front of the cascade is dumped. See also \fBlvm.conf\fP(5) for more
-info about \fBconfig cascade\fP.
-
-.TP
-.B \-\-validate
-Validate current configuration used and exit with appropriate
-return code. The validation is done only for the configuration
-at the front of the \fBconfig cascade\fP. To validate the whole
-merged configuration tree, use also the \fB\-\-mergedconfig\fP option.
-The validation is done even if \fBconfig/checks\fP \fBlvm.conf\fP(5)
-option is disabled.
-
-.TP
-.B \-\-withcomments
-Dump a one line comment for each configuration node.
-
-.TP
-.B \-\-withfullcomments
-Dump a full comment for each configuration node.
-
-.TP
-.B \-\-withversions
-Also dump a comment containing the version of introduction for
-each configuration node.
-
-.SH SEE ALSO
-.BR lvm (8)
-.BR lvm.conf (5)
+.so man8/lvmconfig.8
diff --git a/man/lvm.8.in b/man/lvm.8.in
index 26d94ee..3d408fb 100644
--- a/man/lvm.8.in
+++ b/man/lvm.8.in
@@ -43,11 +43,12 @@ path of \fBlvm\fP.
The following commands are built into lvm without links normally
being created in the filesystem for them.
.TP
-\fBdumpconfig\fP \(em Display the configuration information after
-loading \fBlvm.conf\fP(5) and any other configuration files.
+\fBconfig\fP \(em The same as \fBlvmconfig\fP(8) below.
.TP
\fBdevtypes\fP \(em Display the recognised built-in block device types.
.TP
+\fBdumpconfig\fP \(em The same as \fBlvmconfig\fP(8) below.
+.TP
\fBformats\fP \(em Display recognised metadata formats.
.TP
\fBhelp\fP \(em Display the help text.
@@ -136,6 +137,9 @@ Volumes.
.TP
\fBlvmchange\fP \(em Change attributes of the Logical Volume Manager.
.TP
+\fBlvmconfig\fP \(em Display the configuration information after
+loading \fBlvm.conf\fP(5) and any other configuration files.
+.TP
\fBlvmdiskscan\fP \(em Scan for all devices visible to LVM2.
.TP
\fBlvmdump\fP \(em Create lvm2 information dumps for diagnostic purposes.
@@ -316,8 +320,8 @@ way it fits with other LVM configuration methods.
.IR \fB\-\-profile " " \fIProfileName
A short form of \fB\-\-metadataprofile\fP for \fBvgcreate\fP, \fBlvcreate\fP,
\fBvgchange\fP and \fBlvchange\fP command and a short form of \fB\-\-commandprofile\fP
-for any other command (with the exception of \fBdumpconfig\fP command where the
-\-\-profile has special meaning, see \fBlvm dumpconfig\fP(8) for more information).
+for any other command (with the exception of \fBlvmconfig\fP command where the
+\-\-profile has special meaning, see \fBlvm lvmconfig\fP(8) for more information).
.TP
.IR \fB\-\-config " " \fIConfigurationString
Uses the ConfigurationString as direct string representation of the configuration
@@ -529,7 +533,6 @@ Path for the lvmetad socket file.
.BR lvm.conf (5),
.BR lvmcache (7),
.BR lvmthin (7),
-.BR lvm\ dumpconfig (8),
.BR clvmd (8),
.BR dmsetup (8),
.BR lvchange (8),
@@ -537,6 +540,7 @@ Path for the lvmetad socket file.
.BR lvdisplay (8),
.BR lvextend (8),
.BR lvmchange (8),
+.BR lvmconfig (8),
.BR lvmdiskscan (8),
.BR lvreduce (8),
.BR lvremove (8),
diff --git a/man/lvm.conf.5.in b/man/lvm.conf.5.in
index 074e2e9..2c4effc 100644
--- a/man/lvm.conf.5.in
+++ b/man/lvm.conf.5.in
@@ -65,8 +65,8 @@ For this purpose, there's the \fBcommand_profile_template.profile\fP
(for metadata profiles) which contain all settings that are customizable
by profiles of certain type. Users are encouraged to copy these template
profiles and edit them as needed. Alternatively, the
-\fBlvm dumpconfig \-\-file <ProfileName.profile> \-\-type profilable-command <section>\fP
-or \fBlvm dumpconfig \-\-file <ProfileName.profile> \-\-type profilable-metadata <section>\fP
+\fBlvm lvmconfig \-\-file <ProfileName.profile> \-\-type profilable-command <section>\fP
+or \fBlvm lvmconfig \-\-file <ProfileName.profile> \-\-type profilable-metadata <section>\fP
can be used to generate a configuration with profilable settings in either
of the type for given section and save it to new ProfileName.profile
(if the section is not specified, all profilable settings are reported).
@@ -91,7 +91,7 @@ this \fBconfig cascade\fP from left to right:
No part of this cascade is compulsory. If there's no setting value found at
the end of the cascade, a default value is used for that setting.
-Use \fBlvm dumpconfig\fP to check what settings are in use and what
+Use \fBlvmconfig\fP to check what settings are in use and what
the default values are.
.SH SYNTAX
.LP
@@ -158,38 +158,38 @@ with a letter can be left unquoted.
.SH SETTINGS
The
-.B lvm dumpconfig
+.B lvmconfig
command prints the LVM configuration settings in various ways.
See the man page
-.BR lvm-dumpconfig (8).
+.BR lvmconfig (8).
Command to print a list of all possible config settings, with their
default values:
.br
-.B lvm dumpconfig \-\-type default
+.B lvmconfig \-\-type default
Command to print a list of all possible config settings, with their
default values, and a full description of each as a comment:
.br
-.B lvm dumpconfig \-\-type default --withfullcomments
+.B lvmconfig \-\-type default --withfullcomments
Command to print a list of all possible config settings, with their
current values (configured, non-default values are shown):
.br
-.B lvm dumpconfig \-\-type current
+.B lvmconfig \-\-type current
Command to print all config settings that have been configured with a
different value than the default (configured, non-default values are
shown):
.br
-.B lvm dumpconfig \-\-type diff
+.B lvmconfig \-\-type diff
Command to print a single config setting, with its default value,
and a full description, where "Section" refers to the config section,
e.g. global, and "Setting" refers to the name of the specific setting,
e.g. umask:
.br
-.B lvm dumpconfig \-\-type default --withfullcomments Section/Setting
+.B lvmconfig \-\-type default --withfullcomments Section/Setting
.SH FILES
@@ -209,5 +209,5 @@ e.g. umask:
.SH SEE ALSO
.BR lvm (8)
-.BR lvm-dumpconfig (8)
+.BR lvmconfig (8)
diff --git a/man/lvmconfig.8.in b/man/lvmconfig.8.in
new file mode 100644
index 0000000..76f8ffe
--- /dev/null
+++ b/man/lvmconfig.8.in
@@ -0,0 +1,166 @@
+.TH "LVMCONFIG" "8" "LVM TOOLS #VERSION#" "Red Hat, Inc" "\""
+.SH "NAME"
+lvmconfig, lvm dumpconfig, lvm config \(em Display LVM configuration
+.SH SYNOPSIS
+.B lvmconfig
+.RB [ \-f | \-\-file
+.IR filename ]
+.RB [ \-\-type
+.RI { current | default | diff | missing | new | profilable | profilable-command | profilable-metadata }
+.RB [ \-\-atversion
+.IR version ]
+.RB [ \-\-ignoreadvanced ]
+.RB [ \-\-ignoreunsupported ]
+.RB [ \-\-ignorelocal ]
+.RB [ \-\-config
+.IR ConfigurationString ]
+.RB [ \-\-commandprofile
+.IR ProfileName ]
+.RB [ \-\-profile
+.IR ProfileName ]
+.RB [ \-\-metadataprofile
+.IR ProfileName ]
+.RB [ \-\-mergedconfig ]
+.RB [ \-\-validate ]
+.RB [ \-\-withcomments ]
+.RB [ \-\-withfullcomments ]
+.RB [ \-\-withversions ]
+.RB [ ConfigurationNode... ]
+
+.SH DESCRIPTION
+lvmconfig produces formatted output from the LVM configuration tree.
+The command was added in release 2.02.119 and has an identical longer form
+\fBlvm dumpconfig\fP.
+
+.SH OPTIONS
+.TP
+.BR \-f ", " \-\-file " \fIfilename"
+Send output to a file named 'filename'.
+
+.TP
+.IR \fB\-\-type " {" current | default | diff | missing | new | profilable }
+Select the type of configuration to display. The configuration settings
+displayed have either default values or currently-used values assigned based on
+the type selected. If no type is selected, \fB\-\-type current\fP is used
+by default. Whenever a configuration setting with a default value is
+commented out, it means the setting does not have any concrete default
+value defined. Output can be saved and used as a proper \fBlvm.conf\fP(5)
+file.
+.RS
+.IP current 3
+Display the current \fBlvm.conf\fP configuration merged with any \fBtag
+config\fP if used. See also \fBlvm.conf\fP(5) for more info about LVM
+configuration methods.
+.IP default 3
+Display all possible configuration settings with default values assigned.
+.IP diff 3
+Display all configuration settings for which the values used differ from defaults.
+The value assigned for each configuration setting is the value currently used.
+This is actually minimal LVM configuration which can be used without
+a change to current configured behaviour.
+.IP missing 3
+Display all configuration settings with default values assigned which are
+missing in the configuration currently used and for which LVM automatically
+fallbacks to using these default values.
+.IP new 3
+Display all new configuration settings introduced in current LVM version
+or specific version as defined by \fB\-\-atversion\fP option.
+.IP profilable 3
+Display all profilable configuration settings with default values assigned.
+See \fBlvm.conf\fP(5) for more info about \fBprofile config\fP method.
+.IP profilable-command 3
+Display all profilable configuration settings with default values assigned
+that can be used in command profile. This is a subset of settings displayed
+by \fB\-\-type \-\-profilable\fP.
+.IP profilable-metadata 3
+Display all profilable configuration settings with default values assigned
+that can be used in metadata profile. This is a subset of settings displayed
+by \fB\-\-type \-\-profilable\fP.
+.RE
+
+.TP
+.BI \-\-atversion " version"
+Specify an LVM version in x.y.z format where x is the major version,
+the y is the minor version and z is the patchlevel (e.g. 2.2.106).
+When configuration is displayed, the configuration settings recognized
+at this LVM version will be considered only. This can be used
+to display a configuration that a certain LVM version understands and
+which does not contain any newer settings for which LVM would
+issue a warning message when checking the configuration.
+
+.TP
+.B \-\-ignoreadvanced
+Exclude advanced configuration settings from the output.
+
+.TP
+.B \-\-ignoreunsupported
+Exclude unsupported configuration settings from the output. These settings are
+either used for debugging purposes only or their support is not yet
+complete and they are not meant to be used in production.
+
+.TP
+.B \-\-ignorelocal
+Ignore local section.
+
+.TP
+.BI \-\-config " ConfigurationString"
+Use \fBConfigurationString\fP to override existing configuration.
+This configuration is then applied for the lvmconfig command itself.
+See also \fBlvm.conf\fP(5) for more info about \fBconfig cascade\fP.
+
+.TP
+.BI \-\-commandprofile " ProfileName"
+Use \fBProfileName\fP to override existing configuration.
+This configuration is then applied for the lvmconfig command itself.
+See also \fB\-\-mergedconfig\fP option and \fBlvm.conf\fP(5) for
+more info about \fBconfig cascade\fP.
+
+.TP
+.BI \-\-profile " ProfileName"
+The same as using \fB\-\-commandprofile\fP but the configuration is not
+applied for the lvmconfig command itself.
+
+.TP
+.BI \-\-metadataprofile " ProfileName"
+Use \fBProfileName\fP to override existing configuration.
+The configuration defined in metadata profile has no effect for
+the lvmconfig command itself. lvmconfig displays the configuration only.
+See also \fB\-\-mergedconfig\fP option and \fBlvm.conf\fP(5) for more
+info about \fBconfig cascade\fP.
+
+.TP
+.B \-\-mergedconfig
+When the lvmconfig command is run with the \fB\-\-config\fP option
+and/or \fB\-\-commandprofile\fP (or using \fBLVM_COMMAND_PROFILE\fP
+environment variable), \fB\-\-profile\fP, \fB\-\-metadataprofile\fP
+option, merge all the contents of the \fBconfig cascade\fP before displaying it.
+Without the \fB\-\-mergeconfig\fP option used, only the configuration at
+the front of the cascade is displayed. See also \fBlvm.conf\fP(5) for more
+info about \fBconfig cascade\fP.
+
+.TP
+.B \-\-validate
+Validate current configuration used and exit with appropriate
+return code. The validation is done only for the configuration
+at the front of the \fBconfig cascade\fP. To validate the whole
+merged configuration tree, use also the \fB\-\-mergedconfig\fP option.
+The validation is done even if \fBconfig/checks\fP \fBlvm.conf\fP(5)
+option is disabled.
+
+.TP
+.B \-\-withcomments
+Display a one line comment for each configuration node.
+
+.TP
+.B \-\-withfullcomments
+Display a full comment for each configuration node.
+
+.TP
+.B \-\-withversions
+Also display a comment containing the version of introduction for
+each configuration node.
+
+.SH SEE ALSO
+.BR lvm (8)
+.BR lvmconf (8)
+.BR lvm.conf (5)
diff --git a/man/lvmetad.8.in b/man/lvmetad.8.in
index 4f60249..3ea80c9 100644
--- a/man/lvmetad.8.in
+++ b/man/lvmetad.8.in
@@ -22,7 +22,7 @@ consistent image of the volume groups available in the system.
lvmetad is used by LVM only if it is enabled in \fBlvm.conf\fP(5) by specifying the
\fBglobal/use_lvmetad\fP setting. If this is not defined in the LVM configuration
explicitly then default setting is used instead (see the output of
-\fBlvm dumpconfig \-\-type default global/use_lvmetad\fP command).
+\fBlvmconfig \-\-type default global/use_lvmetad\fP command).
.SH OPTIONS
To run the daemon in a test environment both the pidfile_path and the
diff --git a/scripts/lvmconf.sh b/scripts/lvmconf.sh
index 6c2a167..396f7a1 100644
--- a/scripts/lvmconf.sh
+++ b/scripts/lvmconf.sh
@@ -33,7 +33,7 @@ START_STOP_SERVICES=0
function usage
{
- echo "usage: $0 <command>"
+ echo "Usage: $0 <command>"
echo ""
echo "Commands:"
echo "Enable clvm: --enable-cluster [--lockinglibdir <dir>] [--lockinglib <lib>]"
@@ -46,6 +46,7 @@ function usage
echo "Config file location: --file <configfile>"
echo "Set services: --services [--mirrorservice] [--startstopservices]"
echo ""
+ echo "Use the separate command 'lvmconfig' to display configuration information"
}
function set_default_use_lvmetad_var
diff --git a/tools/Makefile.in b/tools/Makefile.in
index 1d294dd..861ae82 100644
--- a/tools/Makefile.in
+++ b/tools/Makefile.in
@@ -168,7 +168,7 @@ liblvm2cmd.$(LIB_SUFFIX).$(LIB_VERSION): liblvm2cmd.$(LIB_SUFFIX)
.commands: $(srcdir)/commands.h $(srcdir)/cmdnames.h Makefile
$(CC) -E -P $(srcdir)/cmdnames.h 2> /dev/null | \
- egrep -v '^ *(|#.*|devtypes|dumpconfig|formats|help|pvdata|segtypes|systemid|tags|version) *$$' > .commands
+ egrep -v '^ *(|#.*|config|devtypes|dumpconfig|formats|help|pvdata|segtypes|systemid|tags|version) *$$' > .commands
ifneq ("$(CFLOW_CMD)", "")
CFLOW_SOURCES = $(addprefix $(srcdir)/, $(SOURCES))
diff --git a/tools/commands.h b/tools/commands.h
index 64c8bf2..df69c2a 100644
--- a/tools/commands.h
+++ b/tools/commands.h
@@ -28,6 +28,31 @@ xx(e2fsadm,
extents_ARG, size_ARG, nofsck_ARG, test_ARG)
*********/
+xx(config,
+ "Display and manipulate configuration information",
+ PERMITTED_READ_ONLY,
+ "config\n"
+ "\t[-f|--file filename]\n"
+ "\t[--type {current|default|diff|missing|new|profilable|profilable-command|profilable-metadata}\n"
+ "\t[--atversion version]]\n"
+ "\t[--ignoreadvanced]\n"
+ "\t[--ignoreunsupported]\n"
+ "\t[--ignorelocal]\n"
+ "\t[--config ConfigurationString]\n"
+ "\t[--commandprofile ProfileName]\n"
+ "\t[--profile ProfileName]\n"
+ "\t[--metadataprofile ProfileName]\n"
+ "\t[--mergedconfig]\n"
+ "\t[--validate]\n"
+ "\t[--withcomments]\n"
+ "\t[--withfullcomments]\n"
+ "\t[--unconfigured]\n"
+ "\t[--withversions]\n"
+ "\t[ConfigurationNode...]\n",
+ atversion_ARG, configtype_ARG, file_ARG, ignoreadvanced_ARG,
+ ignoreunsupported_ARG, ignorelocal_ARG, mergedconfig_ARG, metadataprofile_ARG,
+ validate_ARG, withcomments_ARG, withfullcomments_ARG, unconfigured_ARG, withversions_ARG)
+
xx(devtypes,
"Display recognised built-in block device types",
PERMITTED_READ_ONLY,
@@ -55,7 +80,7 @@ xx(devtypes,
unbuffered_ARG, unquoted_ARG)
xx(dumpconfig,
- "Dump configuration",
+ "Display and manipulate configuration information",
PERMITTED_READ_ONLY,
"dumpconfig\n"
"\t[-f|--file filename]\n"
@@ -454,6 +479,31 @@ xx(lvmchange,
reset_ARG)
+xx(lvmconfig,
+ "Display and manipulate configuration information",
+ PERMITTED_READ_ONLY,
+ "lvmconfig\n"
+ "\t[-f|--file filename]\n"
+ "\t[--type {current|default|diff|missing|new|profilable|profilable-command|profilable-metadata}\n"
+ "\t[--atversion version]]\n"
+ "\t[--ignoreadvanced]\n"
+ "\t[--ignoreunsupported]\n"
+ "\t[--ignorelocal]\n"
+ "\t[--config ConfigurationString]\n"
+ "\t[--commandprofile ProfileName]\n"
+ "\t[--profile ProfileName]\n"
+ "\t[--metadataprofile ProfileName]\n"
+ "\t[--mergedconfig]\n"
+ "\t[--validate]\n"
+ "\t[--withcomments]\n"
+ "\t[--withfullcomments]\n"
+ "\t[--unconfigured]\n"
+ "\t[--withversions]\n"
+ "\t[ConfigurationNode...]\n",
+ atversion_ARG, configtype_ARG, file_ARG, ignoreadvanced_ARG,
+ ignoreunsupported_ARG, ignorelocal_ARG, mergedconfig_ARG, metadataprofile_ARG,
+ validate_ARG, withcomments_ARG, withfullcomments_ARG, unconfigured_ARG, withversions_ARG)
+
xx(lvmdiskscan,
"List devices that may be used as physical volumes",
PERMITTED_READ_ONLY | ENABLE_ALL_DEVS,
diff --git a/tools/dumpconfig.c b/tools/dumpconfig.c
index d1b4acc..341bffa 100644
--- a/tools/dumpconfig.c
+++ b/tools/dumpconfig.c
@@ -257,3 +257,13 @@ out:
return r;
}
+
+int config(struct cmd_context *cmd, int argc, char **argv)
+{
+ return dumpconfig(cmd, argc, argv);
+}
+
+int lvmconfig(struct cmd_context *cmd, int argc, char **argv)
+{
+ return dumpconfig(cmd, argc, argv);
+}
diff --git a/tools/lvmcmdline.c b/tools/lvmcmdline.c
index 26c48f9..78974df 100644
--- a/tools/lvmcmdline.c
+++ b/tools/lvmcmdline.c
@@ -1286,7 +1286,9 @@ static int _prepare_profiles(struct cmd_context *cmd)
* If --profile is used with dumpconfig, it's used
* to dump the profile without the profile being applied.
*/
- if (!strcmp(cmd->command->name, "dumpconfig"))
+ if (!strcmp(cmd->command->name, "dumpconfig") ||
+ !strcmp(cmd->command->name, "lvmconfig") ||
+ !strcmp(cmd->command->name, "config"))
return 1;
/*
8 years, 11 months
master - devices: improve handling of duplicate PVs
by David Teigland
Gitweb: http://git.fedorahosted.org/git/?p=lvm2.git;a=commitdiff;h=beb229e1e8e8b9...
Commit: beb229e1e8e8b95de09920195c2bc4171e89dc19
Parent: 6cc37275cebdc590f58bbd4e91110fe4d38801ce
Author: David Teigland <teigland(a)redhat.com>
AuthorDate: Fri Apr 24 14:58:58 2015 -0500
Committer: David Teigland <teigland(a)redhat.com>
CommitterDate: Tue Apr 28 10:41:32 2015 -0500
devices: improve handling of duplicate PVs
Example:
/dev/loop0 and /dev/loop1 are duplicates,
created by copying one backing file to the
other.
'identity /dev/loopX' creates an identity
mapping for loopX named idmloopX, which
adds a duplicate for the named device.
The duplicate selection code for lvmetad is
incomplete, and lvmetad is disabled for this
example.
[~]# losetup -f loopfile0
[~]# pvs
PV VG Fmt Attr PSize PFree
/dev/loop0 foo lvm2 a-- 308.00m 296.00m
[~]# losetup -f loopfile1
[~]# pvs
Found duplicate PV LnSOEqzEYED3RvIOa5PZP2s7uyuBLmAV: using /dev/loop1 not /dev/loop0
Using duplicate PV /dev/loop1 which is more recent, replacing /dev/loop0
PV VG Fmt Attr PSize PFree
/dev/loop1 foo lvm2 a-- 308.00m 308.00m
[~]# ./identity /dev/loop0
[~]# pvs
Found duplicate PV LnSOEqzEYED3RvIOa5PZP2s7uyuBLmAV: using /dev/loop1 not /dev/loop0
Using duplicate PV /dev/loop1 without holders, replacing /dev/loop0
Found duplicate PV LnSOEqzEYED3RvIOa5PZP2s7uyuBLmAV: using /dev/mapper/idmloop0 not /dev/loop1
Using duplicate PV /dev/mapper/idmloop0 from subsystem DM, replacing /dev/loop1
PV VG Fmt Attr PSize PFree
/dev/mapper/idmloop0 foo lvm2 a-- 308.00m 296.00m
[~]# ./identity /dev/loop1
[~]# pvs
WARNING: duplicate PV LnSOEqzEYED3RvIOa5PZP2s7uyuBLmAV is being used from both devices /dev/loop0 and /dev/loop1
Found duplicate PV LnSOEqzEYED3RvIOa5PZP2s7uyuBLmAV: using /dev/loop1 not /dev/loop0
Using duplicate PV /dev/loop1 which is more recent, replacing /dev/loop0
Found duplicate PV LnSOEqzEYED3RvIOa5PZP2s7uyuBLmAV: using /dev/mapper/idmloop0 not /dev/loop1
Using duplicate PV /dev/mapper/idmloop0 from subsystem DM, replacing /dev/loop1
Found duplicate PV LnSOEqzEYED3RvIOa5PZP2s7uyuBLmAV: using /dev/mapper/idmloop1 not /dev/mapper/idmloop0
Using duplicate PV /dev/mapper/idmloop1 which is more recent, replacing /dev/mapper/idmloop0
PV VG Fmt Attr PSize PFree
/dev/mapper/idmloop1 foo lvm2 a-- 308.00m 308.00m
---
lib/cache/lvmcache.c | 248 ++++++++++++++++++++++++++++++++++++++++---------
lib/cache/lvmetad.c | 17 +++-
lib/device/dev-type.c | 3 +
3 files changed, 220 insertions(+), 48 deletions(-)
diff --git a/lib/cache/lvmcache.c b/lib/cache/lvmcache.c
index c5f78c8..90e7b28 100644
--- a/lib/cache/lvmcache.c
+++ b/lib/cache/lvmcache.c
@@ -1529,6 +1529,64 @@ void lvmcache_replace_dev(struct cmd_context *cmd, struct physical_volume *pv,
pv->dev = dev;
}
+/*
+ * We can see multiple different devices with the
+ * same pvid, i.e. duplicates.
+ *
+ * There may be different reasons for seeing two
+ * devices with the same pvid:
+ * - multipath showing two paths to the same thing
+ * - one device copied to another, e.g. with dd,
+ * also referred to as cloned devices.
+ * - a "subsystem" taking a device and creating
+ * another device of its own that represents the
+ * underlying device it is using, e.g. using dm
+ * to create an identity mapping of a PV.
+ *
+ * Given duplicate devices, we have to choose one
+ * of them to be the "preferred" dev, i.e. the one
+ * that will be referenced in lvmcache, by pv->dev.
+ * We can keep the existing dev, that's currently
+ * used in lvmcache, or we can replace the existing
+ * dev with the new duplicate.
+ *
+ * Regardless of which device is preferred, we need
+ * to print messages explaining which devices were
+ * found so that a user can sort out for themselves
+ * what has happened if the preferred device is not
+ * the one they are interested in.
+ *
+ * If a user wants to use the non-preferred device,
+ * they will need to filter out the device that
+ * lvm is preferring.
+ *
+ * The dev_subsystem calls check if the major number
+ * of the dev is part of a subsystem like DM/MD/DRBD.
+ * A dev that's part of a subsystem is preferred over a
+ * duplicate of that dev that is not part of a
+ * subsystem.
+ *
+ * The has_holders calls check if the device is being
+ * used by another, and prefers one that's being used.
+ *
+ * FIXME: why do we prefer a device without holders
+ * over a device with holders? We should understand
+ * the reason for that choice.
+ *
+ * FIXME: there may be other reasons to prefer one
+ * device over another:
+ *
+ * . are there other use/open counts we could check
+ * beyond the holders?
+ *
+ * . check if either is bad/usable and prefer
+ * the good one?
+ *
+ * . prefer the one with smaller minor number?
+ * Might avoid disturbing things due to a new
+ * transient duplicate?
+ */
+
struct lvmcache_info *lvmcache_add(struct labeller *labeller, const char *pvid,
struct device *dev,
const char *vgname, const char *vgid,
@@ -1576,54 +1634,156 @@ struct lvmcache_info *lvmcache_add(struct labeller *labeller, const char *pvid,
lvmcache_del_bas(info);
} else {
if (existing->dev != dev) {
- /* Is the existing entry a duplicate pvid e.g. md ? */
- if (dev_subsystem_part_major(dt, existing->dev) &&
- !dev_subsystem_part_major(dt, dev)) {
- log_very_verbose("Ignoring duplicate PV %s on "
- "%s - using %s %s",
- pvid, dev_name(dev),
- dev_subsystem_name(dt, existing->dev),
- dev_name(existing->dev));
- return NULL;
- } else if (dm_is_dm_major(MAJOR(existing->dev->dev)) &&
- !dm_is_dm_major(MAJOR(dev->dev))) {
- log_very_verbose("Ignoring duplicate PV %s on "
- "%s - using dm %s",
- pvid, dev_name(dev),
- dev_name(existing->dev));
+ int old_in_subsystem = 0;
+ int new_in_subsystem = 0;
+ int old_is_dm = 0;
+ int new_is_dm = 0;
+ int old_has_holders = 0;
+ int new_has_holders = 0;
+
+ /*
+ * Here are different devices with the same pvid:
+ * duplicates. See comment above.
+ */
+
+ /*
+ * This flag tells the process_each_pv code to search
+ * the devices list for duplicates, so that devices
+ * can be processed together with their duplicates
+ * (while processing the VG, rather than reporting
+ * pv->dev under the VG, and its duplicate outside
+ * the VG context.)
+ */
+ _found_duplicate_pvs = 1;
+
+ /*
+ * The new dev may not have pvid set.
+ * The process_each_pv code needs to have the pvid
+ * set in each device to detect that the devices
+ * are duplicates.
+ */
+ strncpy(dev->pvid, pvid_s, sizeof(dev->pvid));
+
+ /*
+ * Now decide if we are going to ignore the new
+ * device, or replace the existing/old device in
+ * lvmcache with the new one.
+ */
+ old_in_subsystem = dev_subsystem_part_major(dt, existing->dev);
+ new_in_subsystem = dev_subsystem_part_major(dt, dev);
+
+ old_is_dm = dm_is_dm_major(MAJOR(existing->dev->dev));
+ new_is_dm = dm_is_dm_major(MAJOR(dev->dev));
+
+ old_has_holders = dm_device_has_holders(MAJOR(existing->dev->dev), MINOR(existing->dev->dev));
+ new_has_holders = dm_device_has_holders(MAJOR(dev->dev), MINOR(dev->dev));
+
+ if (old_has_holders && new_has_holders) {
+ /*
+ * This is not a selection of old or new, but
+ * just a warning to be aware of.
+ */
+ log_warn("WARNING: duplicate PV %s is being used from both devices %s and %s",
+ pvid_s,
+ dev_name(existing->dev),
+ dev_name(dev));
+ }
+
+ if (old_in_subsystem && !new_in_subsystem) {
+ /* Use old, ignore new. */
+ log_warn("Found duplicate PV %s: using %s not %s",
+ pvid_s,
+ dev_name(existing->dev),
+ dev_name(dev));
+ log_warn("Using duplicate PV %s from subsystem %s, ignoring %s",
+ dev_name(existing->dev),
+ dev_subsystem_name(dt, existing->dev),
+ dev_name(dev));
return NULL;
- } else if (!dev_subsystem_part_major(dt, existing->dev) &&
- dev_subsystem_part_major(dt, dev))
- log_very_verbose("Duplicate PV %s on %s - "
- "using %s %s", pvid,
- dev_name(existing->dev),
- dev_subsystem_name(dt, existing->dev),
- dev_name(dev));
- else if (!dm_is_dm_major(MAJOR(existing->dev->dev)) &&
- dm_is_dm_major(MAJOR(dev->dev)))
- log_very_verbose("Duplicate PV %s on %s - "
- "using dm %s", pvid,
- dev_name(existing->dev),
- dev_name(dev));
- /* FIXME If both dm, check dependencies */
- //else if (dm_is_dm_major(MAJOR(existing->dev->dev)) &&
- //dm_is_dm_major(MAJOR(dev->dev)))
- //
- else if (!strcmp(pvid_s, existing->dev->pvid)) {
- log_error("Found duplicate PV %s: using %s not %s",
- pvid_s,
- dev_name(existing->dev),
- dev_name(dev));
- strncpy(dev->pvid, pvid_s, sizeof(dev->pvid));
- _found_duplicate_pvs = 1;
+
+ } else if (!old_in_subsystem && new_in_subsystem) {
+ /* Use new, replace old. */
+ log_warn("Found duplicate PV %s: using %s not %s",
+ pvid_s,
+ dev_name(dev),
+ dev_name(existing->dev));
+ log_warn("Using duplicate PV %s from subsystem %s, replacing %s",
+ dev_name(dev),
+ dev_subsystem_name(dt, dev),
+ dev_name(existing->dev));
+
+ } else if (old_has_holders && !new_has_holders) {
+ /* Use new, replace old. */
+ /* FIXME: why choose the one without olders? */
+ log_warn("Found duplicate PV %s: using %s not %s",
+ pvid_s,
+ dev_name(dev),
+ dev_name(existing->dev));
+ log_warn("Using duplicate PV %s without holders, replacing %s",
+ dev_name(dev),
+ dev_name(existing->dev));
+
+ } else if (!old_has_holders && new_has_holders) {
+ /* Use old, ignore new. */
+ log_warn("Found duplicate PV %s: using %s not %s",
+ pvid_s,
+ dev_name(existing->dev),
+ dev_name(dev));
+ log_warn("Using duplicate PV %s without holders, ignoring %s",
+ dev_name(existing->dev),
+ dev_name(dev));
return NULL;
+
+ } else if (old_is_dm && new_is_dm) {
+ /* Use new, replace old. */
+ /* FIXME: why choose the new instead of the old? */
+ log_warn("Found duplicate PV %s: using %s not %s",
+ pvid_s,
+ dev_name(dev),
+ dev_name(existing->dev));
+ log_warn("Using duplicate PV %s which is more recent, replacing %s",
+ dev_name(dev),
+ dev_name(existing->dev));
+
+ } else if (!strcmp(pvid_s, existing->dev->pvid)) {
+ /* No criteria to use for preferring old or new. */
+ /* FIXME: why choose the new instead of the old? */
+ /* FIXME: a transient duplicate would be a reason
+ * to select the old instead of the new. */
+ log_warn("Found duplicate PV %s: using %s not %s",
+ pvid_s,
+ dev_name(dev),
+ dev_name(existing->dev));
+ log_warn("Using duplicate PV %s which is more recent, replacing %s",
+ dev_name(dev),
+ dev_name(existing->dev));
}
+ } else {
+ /*
+ * The new dev is the same as the existing dev.
+ *
+ * FIXME: Why can't we just return NULL here if the
+ * device already exists? Things don't seem to work
+ * if we do that for some reason.
+ */
+ log_verbose("Found same device %s with same pvid %s",
+ dev_name(existing->dev), pvid_s);
}
- if (strcmp(pvid_s, existing->dev->pvid))
- log_debug_cache("Updating pvid cache to %s (%s) from %s (%s)",
- pvid_s, dev_name(dev),
- existing->dev->pvid, dev_name(existing->dev));
- /* Switch over to new preferred device */
+
+ /*
+ * FIXME: when could this ever happen?
+ * If this does happen, identify when/why here, and
+ * if not, remove this code.
+ */
+ if (strcmp(pvid_s, existing->dev->pvid)) {
+ log_warn("Replacing dev %s pvid %s with dev %s pvid %s",
+ dev_name(existing->dev), existing->dev->pvid,
+ dev_name(dev), pvid_s);
+ }
+
+ /*
+ * Switch over to new preferred device.
+ */
existing->dev = dev;
info = existing;
/* Has labeller changed? */
diff --git a/lib/cache/lvmetad.c b/lib/cache/lvmetad.c
index 600a6cb..470a7b3 100644
--- a/lib/cache/lvmetad.c
+++ b/lib/cache/lvmetad.c
@@ -366,10 +366,19 @@ static struct lvmcache_info *_pv_populate_lvmcache(struct cmd_context *cmd,
while (alt_device) {
dev_alternate = dev_cache_get_by_devt(alt_device->v.i, cmd->filter);
- if (dev_alternate)
- lvmcache_add(fmt->labeller, (const char *)&pvid, dev_alternate,
- vgname, (const char *)&vgid, 0);
- else
+ if (dev_alternate) {
+ if ((info = lvmcache_add(fmt->labeller, (const char *)&pvid, dev_alternate,
+ vgname, (const char *)&vgid, 0))) {
+ /*
+ * FIXME: when lvmcache_add returns non-NULL,
+ * it means that it has made dev_alternate
+ * the preferred device in lvmcache.
+ * I think that means it should be followed
+ * by the same steps done above?
+ */
+ log_warn("lvmcache only partially updated for alternate device %s", dev_name(dev));
+ }
+ } else
log_warn("Duplicate of PV %s dev %s exists on unknown device %"PRId64 ":%" PRId64,
pvid_txt, dev_name(dev), MAJOR(alt_device->v.i), MINOR(alt_device->v.i));
alt_device = alt_device->next;
diff --git a/lib/device/dev-type.c b/lib/device/dev-type.c
index d3407d1..5a4c658 100644
--- a/lib/device/dev-type.c
+++ b/lib/device/dev-type.c
@@ -225,6 +225,9 @@ int dev_subsystem_part_major(struct dev_types *dt, struct device *dev)
const char *dev_subsystem_name(struct dev_types *dt, struct device *dev)
{
+ if (MAJOR(dev->dev) == dt->device_mapper_major)
+ return "DM";
+
if (MAJOR(dev->dev) == dt->md_major)
return "MD";
8 years, 11 months
master - config: improve the description of options lists
by David Teigland
Gitweb: http://git.fedorahosted.org/git/?p=lvm2.git;a=commitdiff;h=6cc37275cebdc5...
Commit: 6cc37275cebdc590f58bbd4e91110fe4d38801ce
Parent: ae0014e2dfd84b2348c7c8dd57f83159c79fda85
Author: David Teigland <teigland(a)redhat.com>
AuthorDate: Tue Apr 28 10:06:23 2015 -0500
Committer: David Teigland <teigland(a)redhat.com>
CommitterDate: Tue Apr 28 10:06:23 2015 -0500
config: improve the description of options lists
Describe
thin_check_options, thin_repair_options,
cache_check_option, scache_repair_options
as a "list of options", rather than a "string of options"
because a single string, e.g. "-q --clear-needs-check-flag"
does not work, and needs to be entered as a list,
e.g. ["-q", "--clear-needs-check-flag"]
---
lib/config/config_settings.h | 8 ++++----
1 files changed, 4 insertions(+), 4 deletions(-)
diff --git a/lib/config/config_settings.h b/lib/config/config_settings.h
index 76b040b..e97ada5 100644
--- a/lib/config/config_settings.h
+++ b/lib/config/config_settings.h
@@ -813,7 +813,7 @@ cfg(global_thin_repair_executable_CFG, "thin_repair_executable", global_CFG_SECT
"(For thin tools, see thin_check_executable.)\n")
cfg_array(global_thin_check_options_CFG, "thin_check_options", global_CFG_SECTION, 0, CFG_TYPE_STRING, "#S" DEFAULT_THIN_CHECK_OPTION1 "#S" DEFAULT_THIN_CHECK_OPTION2, vsn(2, 2, 96), NULL,
- "String of options passed to the thin_check command.\n"
+ "List of options passed to the thin_check command.\n"
"With thin_check version 2.1 or newer you can add\n"
"--ignore-non-fatal-errors to let it pass through\n"
"ignorable errors and fix them later.\n"
@@ -821,7 +821,7 @@ cfg_array(global_thin_check_options_CFG, "thin_check_options", global_CFG_SECTIO
"--clear-needs-check-flag.\n")
cfg_array(global_thin_repair_options_CFG, "thin_repair_options", global_CFG_SECTION, CFG_DEFAULT_UNDEFINED, CFG_TYPE_STRING, "#S" DEFAULT_THIN_REPAIR_OPTIONS, vsn(2, 2, 100), NULL,
- "String of options passed to the thin_repair command.\n")
+ "List of options passed to the thin_repair command.\n")
cfg_array(global_thin_disabled_features_CFG, "thin_disabled_features", global_CFG_SECTION, CFG_DEFAULT_UNDEFINED | CFG_ALLOW_EMPTY, CFG_TYPE_STRING, NULL, vsn(2, 2, 99), NULL,
"Features to not use in the thin driver.\n"
@@ -858,10 +858,10 @@ cfg(global_cache_repair_executable_CFG, "cache_repair_executable", global_CFG_SE
"(For cache tools, see cache_check_executable.)\n")
cfg_array(global_cache_check_options_CFG, "cache_check_options", global_CFG_SECTION, 0, CFG_TYPE_STRING, "#S" DEFAULT_CACHE_CHECK_OPTION1, vsn(2, 2, 108), NULL,
- "String of options passed to the cache_check command.\n")
+ "List of options passed to the cache_check command.\n")
cfg_array(global_cache_repair_options_CFG, "cache_repair_options", global_CFG_SECTION, CFG_DEFAULT_UNDEFINED, CFG_TYPE_STRING, "#S" DEFAULT_CACHE_REPAIR_OPTIONS, vsn(2, 2, 108), NULL,
- "String of options passed to the cache_repair command.\n")
+ "List of options passed to the cache_repair command.\n")
cfg(global_system_id_source_CFG, "system_id_source", global_CFG_SECTION, 0, CFG_TYPE_STRING, DEFAULT_SYSTEM_ID_SOURCE, vsn(2, 2, 117), NULL,
"The method LVM uses to set the local system ID.\n"
8 years, 11 months
master - config: also evaluate default unconfigured values in runtime for 'cfg_runtime' settings
by Peter Rajnoha
Gitweb: http://git.fedorahosted.org/git/?p=lvm2.git;a=commitdiff;h=ae0014e2dfd84b...
Commit: ae0014e2dfd84b2348c7c8dd57f83159c79fda85
Parent: afcf47246458a9b1ec37ab1b55348b615c58c81a
Author: Peter Rajnoha <prajnoha(a)redhat.com>
AuthorDate: Tue Apr 28 15:29:08 2015 +0200
Committer: Peter Rajnoha <prajnoha(a)redhat.com>
CommitterDate: Tue Apr 28 15:36:35 2015 +0200
config: also evaluate default unconfigured values in runtime for 'cfg_runtime' settings
The settings which have their default value evaluated in runtime should
have their 'unconfigured' counterparts also evaluated in runtime since
those values can be constructed by using other settings.
For example, before this patch:
$ lvm dumpconfig --type default --unconfigured devices/cache_dir devices/cache
cache_dir="@DEFAULT_SYS_DIR@/@DEFAULT_CACHE_SUBDIR@"
cache="/etc/lvm/cache/.cache
With this patch applied:
$ lvm dumpconfig --type default --unconfigured devices/cache_dir devices/cache
cache_dir="@DEFAULT_SYS_DIR@/@DEFAULT_CACHE_SUBDIR@"
cache="@DEFAULT_SYS_DIR@/@DEFAULT_CACHE_SUBDIR(a)/.cache"
---
lib/config/config.c | 53 ++++++++++++++++++++++++++++++++++++-----
lib/config/config.h | 38 ++++++++++++++++++++---------
lib/config/config_settings.h | 50 +++++++++++++++++++-------------------
3 files changed, 97 insertions(+), 44 deletions(-)
diff --git a/lib/config/config.c b/lib/config/config.c
index 331bd00..fbe7cb9 100644
--- a/lib/config/config.c
+++ b/lib/config/config.c
@@ -65,11 +65,11 @@ struct config_source {
* Map each ID to respective definition of the configuration item.
*/
static struct cfg_def_item _cfg_def_items[CFG_COUNT + 1] = {
-#define cfg_section(id, name, parent, flags, since_version, unconfigured_value, comment) {id, parent, name, CFG_TYPE_SECTION, {0}, flags, since_version, unconfigured_value, comment},
-#define cfg(id, name, parent, flags, type, default_value, since_version, unconfigured_value, comment) {id, parent, name, type, {.v_##type = default_value}, flags, since_version, unconfigured_value, comment},
-#define cfg_runtime(id, name, parent, flags, type, since_version, unconfigured_value, comment) {id, parent, name, type, {.fn_##type = get_default_##id}, flags | CFG_DEFAULT_RUN_TIME, since_version, unconfigured_value, comment},
-#define cfg_array(id, name, parent, flags, types, default_value, since_version, unconfigured_value, comment) {id, parent, name, CFG_TYPE_ARRAY | types, {.v_CFG_TYPE_STRING = default_value}, flags, since_version, unconfigured_value, comment},
-#define cfg_array_runtime(id, name, parent, flags, types, since_version, unconfigured_value, comment) {id, parent, name, CFG_TYPE_ARRAY | types, {.fn_CFG_TYPE_STRING = get_default_##id}, flags | CFG_DEFAULT_RUN_TIME, since_version, unconfigured_value, comment},
+#define cfg_section(id, name, parent, flags, since_version, comment) {id, parent, name, CFG_TYPE_SECTION, {0}, flags, since_version, {0}, comment},
+#define cfg(id, name, parent, flags, type, default_value, since_version, unconfigured_value, comment) {id, parent, name, type, {.v_##type = default_value}, flags, since_version, {.v_UNCONFIGURED = unconfigured_value}, comment},
+#define cfg_runtime(id, name, parent, flags, type, since_version, comment) {id, parent, name, type, {.fn_##type = get_default_##id}, flags | CFG_DEFAULT_RUN_TIME, since_version, {.fn_UNCONFIGURED = get_default_unconfigured_##id}, comment},
+#define cfg_array(id, name, parent, flags, types, default_value, since_version, unconfigured_value, comment) {id, parent, name, CFG_TYPE_ARRAY | types, {.v_CFG_TYPE_STRING = default_value}, flags, since_version, {.v_UNCONFIGURED = unconfigured_value}, comment},
+#define cfg_array_runtime(id, name, parent, flags, types, since_version, comment) {id, parent, name, CFG_TYPE_ARRAY | types, {.fn_CFG_TYPE_STRING = get_default_##id}, flags | CFG_DEFAULT_RUN_TIME, since_version, {.fn_UNCONFIGURED = get_default_unconfigured_##id}, comment},
#include "config_settings.h"
#undef cfg_section
#undef cfg
@@ -604,6 +604,7 @@ struct timespec config_file_timestamp(struct dm_config_tree *cft)
}
#define cfg_def_get_item_p(id) (&_cfg_def_items[id])
+#define cfg_def_get_default_unconfigured_value_hint(cmd,item) ((item->flags & CFG_DEFAULT_RUN_TIME) ? item->default_unconfigured_value.fn_UNCONFIGURED(cmd) : item->default_unconfigured_value.v_UNCONFIGURED)
#define cfg_def_get_default_value_hint(cmd,item,type,profile) ((item->flags & CFG_DEFAULT_RUN_TIME) ? item->default_value.fn_##type(cmd,profile) : item->default_value.v_##type)
#define cfg_def_get_default_value(cmd,item,type,profile) (item->flags & CFG_DEFAULT_UNDEFINED ? 0 : cfg_def_get_default_value_hint(cmd,item,type,profile))
@@ -1675,9 +1676,9 @@ static struct dm_config_node *_add_def_node(struct dm_config_tree *cft,
cn->id = def->id;
- if (spec->unconfigured && def->unconfigured_value) {
+ if (spec->unconfigured && def->default_unconfigured_value.v_UNCONFIGURED) {
cn->v->type = DM_CFG_STRING;
- cn->v->v.str = def->unconfigured_value;
+ cn->v->v.str = cfg_def_get_default_unconfigured_value_hint(spec->cmd, def);
} else if (!(def->type & CFG_TYPE_ARRAY)) {
switch (def->type) {
case CFG_TYPE_SECTION:
@@ -2007,6 +2008,11 @@ const char *get_default_devices_cache_dir_CFG(struct cmd_context *cmd, struct pr
return dm_pool_strdup(cmd->mem, buf);
}
+const char *get_default_unconfigured_devices_cache_dir_CFG(struct cmd_context *cmd)
+{
+ return "@DEFAULT_SYS_DIR@/@DEFAULT_CACHE_SUBDIR@";
+}
+
const char *get_default_devices_cache_CFG(struct cmd_context *cmd, struct profile *profile)
{
const char *cache_dir = NULL, *cache_file_prefix = NULL;
@@ -2041,6 +2047,24 @@ const char *get_default_devices_cache_CFG(struct cmd_context *cmd, struct profil
return dm_pool_strdup(cmd->mem, buf);
}
+const char *get_default_unconfigured_devices_cache_CFG(struct cmd_context *cmd)
+{
+ const char *cache_file_prefix = NULL;
+ static char buf[PATH_MAX];
+
+ if (find_config_tree_node(cmd, devices_cache_file_prefix_CFG, NULL))
+ cache_file_prefix = find_config_tree_str_allow_empty(cmd, devices_cache_file_prefix_CFG, NULL);
+
+ if (dm_snprintf(buf, sizeof(buf), "%s/%s.cache",
+ get_default_unconfigured_devices_cache_dir_CFG(cmd),
+ cache_file_prefix ? : DEFAULT_CACHE_FILE_PREFIX) < 0) {
+ log_error("Persistent cache filename too long.");
+ return NULL;
+ }
+
+ return dm_pool_strdup(cmd->mem, buf);
+}
+
const char *get_default_backup_backup_dir_CFG(struct cmd_context *cmd, struct profile *profile)
{
static char buf[PATH_MAX];
@@ -2054,6 +2078,11 @@ const char *get_default_backup_backup_dir_CFG(struct cmd_context *cmd, struct pr
return dm_pool_strdup(cmd->mem, buf);
}
+const char *get_default_unconfigured_backup_backup_dir_CFG(struct cmd_context *cmd)
+{
+ return "@DEFAULT_SYS_DIR@/@DEFAULT_BACKUP_SUBDIR@";
+}
+
const char *get_default_backup_archive_dir_CFG(struct cmd_context *cmd, struct profile *profile)
{
static char buf[PATH_MAX];
@@ -2067,6 +2096,11 @@ const char *get_default_backup_archive_dir_CFG(struct cmd_context *cmd, struct p
return dm_pool_strdup(cmd->mem, buf);
}
+const char *get_default_unconfigured_backup_archive_dir_CFG(struct cmd_context *cmd)
+{
+ return "@DEFAULT_SYS_DIR@/@DEFAULT_ARCHIVE_SUBDIR@";
+}
+
const char *get_default_config_profile_dir_CFG(struct cmd_context *cmd, struct profile *profile)
{
static char buf[PATH_MAX];
@@ -2080,6 +2114,11 @@ const char *get_default_config_profile_dir_CFG(struct cmd_context *cmd, struct p
return dm_pool_strdup(cmd->mem, buf);
}
+const char *get_default_unconfigured_config_profile_dir_CFG(struct cmd_context *cmd)
+{
+ return "@DEFAULT_SYS_DIR@/@DEFAULT_PROFILE_SUBDIR@";
+}
+
const char *get_default_activation_mirror_image_fault_policy_CFG(struct cmd_context *cmd, struct profile *profile)
{
return find_config_tree_str(cmd, activation_mirror_device_fault_policy_CFG, profile);
diff --git a/lib/config/config.h b/lib/config/config.h
index 1c367bd..193f4e3 100644
--- a/lib/config/config.h
+++ b/lib/config/config.h
@@ -72,6 +72,7 @@ typedef int (*t_fn_CFG_TYPE_INT) (struct cmd_context *cmd, struct profile *profi
typedef float (*t_fn_CFG_TYPE_FLOAT) (struct cmd_context *cmd, struct profile *profile);
typedef const char* (*t_fn_CFG_TYPE_STRING) (struct cmd_context *cmd, struct profile *profile);
typedef const char* (*t_fn_CFG_TYPE_ARRAY) (struct cmd_context *cmd, struct profile *profile);
+typedef const char* (*t_fn_UNCONFIGURED) (struct cmd_context *cmd);
/* configuration definition item value (for item's default value) */
typedef union {
@@ -88,6 +89,11 @@ typedef union {
t_fn_CFG_TYPE_ARRAY fn_CFG_TYPE_ARRAY;
} cfg_def_value_t;
+typedef union {
+ const char *v_UNCONFIGURED;
+ t_fn_UNCONFIGURED fn_UNCONFIGURED;
+} cfg_def_unconfigured_value_t;
+
/* configuration definition item flags: */
@@ -114,15 +120,15 @@ typedef union {
/* configuration definition item structure */
typedef struct cfg_def_item {
- int id; /* ID of this item */
- int parent; /* ID of parent item */
- const char *name; /* name of the item in configuration tree */
- int type; /* configuration item type (bits of cfg_def_type_t) */
- cfg_def_value_t default_value; /* default value (only for settings) */
- uint16_t flags; /* configuration item definition flags */
- uint16_t since_version; /* version this item appeared in */
- const char *unconfigured_value; /* value in terms of @FOO@, pre-configured */
- const char *comment; /* brief comment */
+ int id; /* ID of this item */
+ int parent; /* ID of parent item */
+ const char *name; /* name of the item in configuration tree */
+ int type; /* configuration item type (bits of cfg_def_type_t) */
+ cfg_def_value_t default_value; /* default value (only for settings) */
+ uint16_t flags; /* configuration item definition flags */
+ uint16_t since_version; /* version this item appeared in */
+ cfg_def_unconfigured_value_t default_unconfigured_value; /* default value in terms of @FOO@, pre-configured (only for settings) */
+ const char *comment; /* comment */
} cfg_def_item_t;
/* configuration definition tree types */
@@ -165,11 +171,11 @@ struct config_def_tree_spec {
* Register ID for each possible item in the configuration tree.
*/
enum {
-#define cfg_section(id, name, parent, flags, since_version, unconfigured_value, comment) id,
+#define cfg_section(id, name, parent, flags, since_version, comment) id,
#define cfg(id, name, parent, flags, type, default_value, since_version, unconfigured_value, comment) id,
-#define cfg_runtime(id, name, parent, flags, type, since_version, unconfigured_value, comment) id,
+#define cfg_runtime(id, name, parent, flags, type, since_version, comment) id,
#define cfg_array(id, name, parent, flags, types, default_value, since_version, unconfigured_value, comment) id,
-#define cfg_array_runtime(id, name, parent, flags, types, since_version, unconfigured_value, comment) id,
+#define cfg_array_runtime(id, name, parent, flags, types, since_version, comment) id,
#include "config_settings.h"
#undef cfg_section
#undef cfg
@@ -260,12 +266,20 @@ int find_config_tree_bool(struct cmd_context *cmd, int id, struct profile *profi
* value is evaluated at runtime based on command context.
*/
const char *get_default_devices_cache_dir_CFG(struct cmd_context *cmd, struct profile *profile);
+const char *get_default_unconfigured_devices_cache_dir_CFG(struct cmd_context *cmd);
const char *get_default_devices_cache_CFG(struct cmd_context *cmd, struct profile *profile);
+const char *get_default_unconfigured_devices_cache_CFG(struct cmd_context *cmd);
const char *get_default_backup_backup_dir_CFG(struct cmd_context *cmd, struct profile *profile);
+const char *get_default_unconfigured_backup_backup_dir_CFG(struct cmd_context *cmd);
const char *get_default_backup_archive_dir_CFG(struct cmd_context *cmd, struct profile *profile);
+const char *get_default_unconfigured_backup_archive_dir_CFG(struct cmd_context *cmd);
const char *get_default_config_profile_dir_CFG(struct cmd_context *cmd, struct profile *profile);
+const char *get_default_unconfigured_config_profile_dir_CFG(struct cmd_context *cmd);
const char *get_default_activation_mirror_image_fault_policy_CFG(struct cmd_context *cmd, struct profile *profile);
+#define get_default_unconfigured_activation_mirror_image_fault_policy_CFG NULL
int get_default_allocation_thin_pool_chunk_size_CFG(struct cmd_context *cmd, struct profile *profile);
+#define get_default_unconfigured_allocation_thin_pool_chunk_size_CFG NULL
int get_default_allocation_cache_pool_chunk_size_CFG(struct cmd_context *cmd, struct profile *profile);
+#define get_default_unconfigured_allocation_cache_pool_chunk_size_CFG NULL
#endif
diff --git a/lib/config/config_settings.h b/lib/config/config_settings.h
index dcbc332..76b040b 100644
--- a/lib/config/config_settings.h
+++ b/lib/config/config_settings.h
@@ -71,46 +71,46 @@
*/
#include "defaults.h"
-cfg_section(root_CFG_SECTION, "(root)", root_CFG_SECTION, 0, vsn(0, 0, 0), NULL, NULL)
+cfg_section(root_CFG_SECTION, "(root)", root_CFG_SECTION, 0, vsn(0, 0, 0), NULL)
-cfg_section(config_CFG_SECTION, "config", root_CFG_SECTION, 0, vsn(2, 2, 99), NULL,
+cfg_section(config_CFG_SECTION, "config", root_CFG_SECTION, 0, vsn(2, 2, 99),
"How LVM configuration settings are handled.\n")
-cfg_section(devices_CFG_SECTION, "devices", root_CFG_SECTION, 0, vsn(1, 0, 0), NULL,
+cfg_section(devices_CFG_SECTION, "devices", root_CFG_SECTION, 0, vsn(1, 0, 0),
"How LVM uses block devices.\n")
-cfg_section(allocation_CFG_SECTION, "allocation", root_CFG_SECTION, CFG_PROFILABLE, vsn(2, 2, 77), NULL,
+cfg_section(allocation_CFG_SECTION, "allocation", root_CFG_SECTION, CFG_PROFILABLE, vsn(2, 2, 77),
"How LVM selects free space for Logical Volumes.\n")
-cfg_section(log_CFG_SECTION, "log", root_CFG_SECTION, 0, vsn(1, 0, 0), NULL,
+cfg_section(log_CFG_SECTION, "log", root_CFG_SECTION, 0, vsn(1, 0, 0),
"How LVM log information is reported.\n")
-cfg_section(backup_CFG_SECTION, "backup", root_CFG_SECTION, 0, vsn(1, 0, 0), NULL,
+cfg_section(backup_CFG_SECTION, "backup", root_CFG_SECTION, 0, vsn(1, 0, 0),
"How LVM metadata is backed up and archived.\n"
"In LVM, a 'backup' is a copy of the metadata for the\n"
"current system, and an 'archive' contains old metadata\n"
"configurations. They are stored in a human readable\n"
"text format.\n")
-cfg_section(shell_CFG_SECTION, "shell", root_CFG_SECTION, 0, vsn(1, 0, 0), NULL,
+cfg_section(shell_CFG_SECTION, "shell", root_CFG_SECTION, 0, vsn(1, 0, 0),
"Settings for running LVM in shell (readline) mode.\n")
-cfg_section(global_CFG_SECTION, "global", root_CFG_SECTION, CFG_PROFILABLE, vsn(1, 0, 0), NULL,
+cfg_section(global_CFG_SECTION, "global", root_CFG_SECTION, CFG_PROFILABLE, vsn(1, 0, 0),
"Miscellaneous global LVM settings.\n")
-cfg_section(activation_CFG_SECTION, "activation", root_CFG_SECTION, CFG_PROFILABLE, vsn(1, 0, 0), NULL, NULL)
-cfg_section(metadata_CFG_SECTION, "metadata", root_CFG_SECTION, CFG_ADVANCED, vsn(1, 0, 0), NULL, NULL)
+cfg_section(activation_CFG_SECTION, "activation", root_CFG_SECTION, CFG_PROFILABLE, vsn(1, 0, 0), NULL)
+cfg_section(metadata_CFG_SECTION, "metadata", root_CFG_SECTION, CFG_ADVANCED, vsn(1, 0, 0), NULL)
-cfg_section(report_CFG_SECTION, "report", root_CFG_SECTION, CFG_ADVANCED | CFG_PROFILABLE, vsn(1, 0, 0), NULL,
+cfg_section(report_CFG_SECTION, "report", root_CFG_SECTION, CFG_ADVANCED | CFG_PROFILABLE, vsn(1, 0, 0),
"LVM report command output formatting.\n")
-cfg_section(dmeventd_CFG_SECTION, "dmeventd", root_CFG_SECTION, 0, vsn(1, 2, 3), NULL,
+cfg_section(dmeventd_CFG_SECTION, "dmeventd", root_CFG_SECTION, 0, vsn(1, 2, 3),
"Settings for the LVM event daemon.\n")
-cfg_section(tags_CFG_SECTION, "tags", root_CFG_SECTION, 0, vsn(1, 0, 18), NULL,
+cfg_section(tags_CFG_SECTION, "tags", root_CFG_SECTION, 0, vsn(1, 0, 18),
"Host tag settings.\n")
-cfg_section(local_CFG_SECTION, "local", root_CFG_SECTION, 0, vsn(2, 2, 117), NULL,
+cfg_section(local_CFG_SECTION, "local", root_CFG_SECTION, 0, vsn(2, 2, 117),
"LVM settings that are specific to the local host.\n")
cfg(config_checks_CFG, "checks", config_CFG_SECTION, 0, CFG_TYPE_BOOL, 1, vsn(2, 2, 99), NULL,
@@ -124,7 +124,7 @@ cfg(config_checks_CFG, "checks", config_CFG_SECTION, 0, CFG_TYPE_BOOL, 1, vsn(2,
cfg(config_abort_on_errors_CFG, "abort_on_errors", config_CFG_SECTION, 0, CFG_TYPE_BOOL, 0, vsn(2,2,99), NULL,
"Abort the LVM process if a configuration mismatch is found.\n")
-cfg_runtime(config_profile_dir_CFG, "profile_dir", config_CFG_SECTION, 0, CFG_TYPE_STRING, vsn(2, 2, 99), "@DEFAULT_SYS_DIR@/@DEFAULT_PROFILE_SUBDIR@",
+cfg_runtime(config_profile_dir_CFG, "profile_dir", config_CFG_SECTION, 0, CFG_TYPE_STRING, vsn(2, 2, 99),
"Directory where LVM looks for configuration profiles.\n")
cfg(devices_dir_CFG, "dir", devices_CFG_SECTION, 0, CFG_TYPE_STRING, DEFAULT_DEV_DIR, vsn(1, 0, 0), NULL,
@@ -221,10 +221,10 @@ cfg_array(devices_global_filter_CFG, "global_filter", devices_CFG_SECTION, CFG_D
"system components. The syntax is the same as devices/filter.\n"
"Devices rejected by global_filter are not opened by LVM.\n")
-cfg_runtime(devices_cache_CFG, "cache", devices_CFG_SECTION, 0, CFG_TYPE_STRING, vsn(1, 0, 0), NULL,
+cfg_runtime(devices_cache_CFG, "cache", devices_CFG_SECTION, 0, CFG_TYPE_STRING, vsn(1, 0, 0),
"The path can be set using the devices/cache_dir setting.\n")
-cfg_runtime(devices_cache_dir_CFG, "cache_dir", devices_CFG_SECTION, 0, CFG_TYPE_STRING, vsn(1, 2, 19), "@DEFAULT_SYS_DIR@/@DEFAULT_CACHE_SUBDIR@",
+cfg_runtime(devices_cache_dir_CFG, "cache_dir", devices_CFG_SECTION, 0, CFG_TYPE_STRING, vsn(1, 2, 19),
"Directory in which to store the device cache file.\n"
"The results of filtering are cached on disk to avoid\n"
"rescanning dud devices (which can take a very long time).\n"
@@ -426,7 +426,7 @@ cfg(allocation_cache_pool_cachemode_CFG, "cache_pool_cachemode", allocation_CFG_
"writeback - Data blocks are written from the cache back\n"
"to disk after some delay to improve performance.\n")
-cfg_runtime(allocation_cache_pool_chunk_size_CFG, "cache_pool_chunk_size", allocation_CFG_SECTION, CFG_DEFAULT_UNDEFINED, CFG_TYPE_INT, vsn(2, 2, 106), NULL,
+cfg_runtime(allocation_cache_pool_chunk_size_CFG, "cache_pool_chunk_size", allocation_CFG_SECTION, CFG_DEFAULT_UNDEFINED, CFG_TYPE_INT, vsn(2, 2, 106),
"The minimal chunk size (in kiB) for cache pool volumes.\n"
"Using a chunk_size that is too large can result in wasteful\n"
"use of the cache, where small reads and writes can cause\n"
@@ -461,7 +461,7 @@ cfg(allocation_thin_pool_chunk_size_policy_CFG, "thin_pool_chunk_size_policy", a
"device hints exposed in sysfs - the optimal_io_size.\n"
"The chunk size is always at least 512KiB.\n")
-cfg_runtime(allocation_thin_pool_chunk_size_CFG, "thin_pool_chunk_size", allocation_CFG_SECTION, CFG_PROFILABLE | CFG_PROFILABLE_METADATA | CFG_DEFAULT_UNDEFINED, CFG_TYPE_INT, vsn(2, 2, 99), NULL,
+cfg_runtime(allocation_thin_pool_chunk_size_CFG, "thin_pool_chunk_size", allocation_CFG_SECTION, CFG_PROFILABLE | CFG_PROFILABLE_METADATA | CFG_DEFAULT_UNDEFINED, CFG_TYPE_INT, vsn(2, 2, 99),
"The minimal chunk size (in KB) for thin pool volumes.\n"
"Larger chunk sizes may improve performance for plain\n"
"thin volumes, however using them for snapshot volumes\n"
@@ -533,7 +533,7 @@ cfg(backup_backup_CFG, "backup", backup_CFG_SECTION, 0, CFG_TYPE_BOOL, DEFAULT_B
"Maintain a backup of the current metadata configuration.\n"
"Think very hard before turning this off!\n")
-cfg_runtime(backup_backup_dir_CFG, "backup_dir", backup_CFG_SECTION, 0, CFG_TYPE_STRING, vsn(1, 0, 0), "@DEFAULT_SYS_DIR@/@DEFAULT_BACKUP_SUBDIR@",
+cfg_runtime(backup_backup_dir_CFG, "backup_dir", backup_CFG_SECTION, 0, CFG_TYPE_STRING, vsn(1, 0, 0),
"Location of the metadata backup files.\n"
"Remember to back up this directory regularly!\n")
@@ -541,7 +541,7 @@ cfg(backup_archive_CFG, "archive", backup_CFG_SECTION, 0, CFG_TYPE_BOOL, DEFAULT
"Maintain an archive of old metadata configurations.\n"
"Think very hard before turning this off.\n")
-cfg_runtime(backup_archive_dir_CFG, "archive_dir", backup_CFG_SECTION, 0, CFG_TYPE_STRING, vsn(1, 0, 0), "@DEFAULT_SYS_DIR@/@DEFAULT_ARCHIVE_SUBDIR@",
+cfg_runtime(backup_archive_dir_CFG, "archive_dir", backup_CFG_SECTION, 0, CFG_TYPE_STRING, vsn(1, 0, 0),
"Location of the metdata archive files.\n"
"Remember to back up this directory regularly!\n")
@@ -1053,7 +1053,7 @@ cfg(activation_raid_fault_policy_CFG, "raid_fault_policy", activation_CFG_SECTIO
"allocate - Attempt to use any extra physical volumes in the\n"
"volume group as spares and replace faulty devices.\n")
-cfg_runtime(activation_mirror_image_fault_policy_CFG, "mirror_image_fault_policy", activation_CFG_SECTION, 0, CFG_TYPE_STRING, vsn(2, 2, 57), NULL,
+cfg_runtime(activation_mirror_image_fault_policy_CFG, "mirror_image_fault_policy", activation_CFG_SECTION, 0, CFG_TYPE_STRING, vsn(2, 2, 57),
"Defines how a device failure in a 'mirror' LV is handled.\n"
"An LV with the 'mirror' segment type is composed of mirror\n"
"images (copies) and a mirror log.\n"
@@ -1252,8 +1252,8 @@ cfg_array(metadata_dirs_CFG, "dirs", metadata_CFG_SECTION, CFG_ADVANCED | CFG_DE
"Example:\n"
"dirs = [ \"/etc/lvm/metadata\", \"/mnt/disk2/lvm/metadata2\" ]\n")
-cfg_section(metadata_disk_areas_CFG_SUBSECTION, "disk_areas", metadata_CFG_SECTION, CFG_ADVANCED | CFG_UNSUPPORTED | CFG_DEFAULT_UNDEFINED, vsn(1, 0, 0), NULL, NULL)
-cfg_section(disk_area_CFG_SUBSECTION, "disk_area", metadata_disk_areas_CFG_SUBSECTION, CFG_NAME_VARIABLE | CFG_ADVANCED | CFG_UNSUPPORTED | CFG_DEFAULT_UNDEFINED, vsn(1, 0, 0), NULL, NULL)
+cfg_section(metadata_disk_areas_CFG_SUBSECTION, "disk_areas", metadata_CFG_SECTION, CFG_ADVANCED | CFG_UNSUPPORTED | CFG_DEFAULT_UNDEFINED, vsn(1, 0, 0), NULL)
+cfg_section(disk_area_CFG_SUBSECTION, "disk_area", metadata_disk_areas_CFG_SUBSECTION, CFG_NAME_VARIABLE | CFG_ADVANCED | CFG_UNSUPPORTED | CFG_DEFAULT_UNDEFINED, vsn(1, 0, 0), NULL)
cfg(disk_area_start_sector_CFG, "start_sector", disk_area_CFG_SUBSECTION, CFG_ADVANCED | CFG_UNSUPPORTED | CFG_DEFAULT_UNDEFINED, CFG_TYPE_INT, 0, vsn(1, 0, 0), NULL, NULL)
cfg(disk_area_size_CFG, "size", disk_area_CFG_SUBSECTION, CFG_ADVANCED | CFG_UNSUPPORTED | CFG_DEFAULT_UNDEFINED, CFG_TYPE_INT, 0, vsn(1, 0, 0), NULL, NULL)
cfg(disk_area_id_CFG, "id", disk_area_CFG_SUBSECTION, CFG_ADVANCED | CFG_UNSUPPORTED | CFG_DEFAULT_UNDEFINED, CFG_TYPE_STRING, NULL, vsn(1, 0, 0), NULL, NULL)
@@ -1402,7 +1402,7 @@ cfg(tags_hosttags_CFG, "hosttags", tags_CFG_SECTION, 0, CFG_TYPE_BOOL, DEFAULT_H
"Create a host tag using the machine name.\n"
"The machine name is nodename returned by uname(2).\n")
-cfg_section(tag_CFG_SUBSECTION, "tag", tags_CFG_SECTION, CFG_NAME_VARIABLE | CFG_DEFAULT_UNDEFINED, vsn(1, 0, 18), NULL,
+cfg_section(tag_CFG_SUBSECTION, "tag", tags_CFG_SECTION, CFG_NAME_VARIABLE | CFG_DEFAULT_UNDEFINED, vsn(1, 0, 18),
"Replace this subsection name with a custom tag name.\n"
"Multiple subsections like this can be created.\n"
"The '@' prefix for tags is optional.\n"
8 years, 11 months
master - config: make it possible to set default unconfigured_value for settings of all types, not just strings
by Peter Rajnoha
Gitweb: http://git.fedorahosted.org/git/?p=lvm2.git;a=commitdiff;h=afcf47246458a9...
Commit: afcf47246458a9b1ec37ab1b55348b615c58c81a
Parent: de6deec3b8a981d8d1ebb7ada826d2e661735a30
Author: Peter Rajnoha <prajnoha(a)redhat.com>
AuthorDate: Tue Apr 28 13:50:23 2015 +0200
Committer: Peter Rajnoha <prajnoha(a)redhat.com>
CommitterDate: Tue Apr 28 15:32:38 2015 +0200
config: make it possible to set default unconfigured_value for settings of all types, not just strings
The @something@ used for unconfigured default value is not bound to
CFG_TYPE_STRING settings defined in config_settings.h, it can be
used for any other config type too.
---
lib/config/config.c | 8 ++++----
1 files changed, 4 insertions(+), 4 deletions(-)
diff --git a/lib/config/config.c b/lib/config/config.c
index bf1edcf..331bd00 100644
--- a/lib/config/config.c
+++ b/lib/config/config.c
@@ -1675,7 +1675,10 @@ static struct dm_config_node *_add_def_node(struct dm_config_tree *cft,
cn->id = def->id;
- if (!(def->type & CFG_TYPE_ARRAY)) {
+ if (spec->unconfigured && def->unconfigured_value) {
+ cn->v->type = DM_CFG_STRING;
+ cn->v->v.str = def->unconfigured_value;
+ } else if (!(def->type & CFG_TYPE_ARRAY)) {
switch (def->type) {
case CFG_TYPE_SECTION:
cn->v = NULL;
@@ -1697,9 +1700,6 @@ static struct dm_config_node *_add_def_node(struct dm_config_tree *cft,
if (!(str = cfg_def_get_default_value_hint(spec->cmd, def, CFG_TYPE_STRING, NULL)))
str = "";
cn->v->v.str = str;
-
- if (spec->unconfigured && def->unconfigured_value)
- cn->v->v.str = def->unconfigured_value;
break;
default:
log_error(INTERNAL_ERROR "_add_def_node: unknown type");
8 years, 11 months
master - refactor: rename struct cfg_def_item's 'unconfigured_path' to 'unconfigured_value'
by Peter Rajnoha
Gitweb: http://git.fedorahosted.org/git/?p=lvm2.git;a=commitdiff;h=de6deec3b8a981...
Commit: de6deec3b8a981d8d1ebb7ada826d2e661735a30
Parent: d0c46c9ed5247732e46fcb9ca4ad5be9f77a64a0
Author: Peter Rajnoha <prajnoha(a)redhat.com>
AuthorDate: Tue Apr 28 13:29:18 2015 +0200
Committer: Peter Rajnoha <prajnoha(a)redhat.com>
CommitterDate: Tue Apr 28 15:30:48 2015 +0200
refactor: rename struct cfg_def_item's 'unconfigured_path' to 'unconfigured_value'
It's not only path that can be used for setting's default value
in unconfigured form as @something@.
---
lib/config/config.c | 14 +++++++-------
lib/config/config.h | 12 ++++++------
2 files changed, 13 insertions(+), 13 deletions(-)
diff --git a/lib/config/config.c b/lib/config/config.c
index 4051fa4..bf1edcf 100644
--- a/lib/config/config.c
+++ b/lib/config/config.c
@@ -65,11 +65,11 @@ struct config_source {
* Map each ID to respective definition of the configuration item.
*/
static struct cfg_def_item _cfg_def_items[CFG_COUNT + 1] = {
-#define cfg_section(id, name, parent, flags, since_version, unconfigured_path, comment) {id, parent, name, CFG_TYPE_SECTION, {0}, flags, since_version, unconfigured_path, comment},
-#define cfg(id, name, parent, flags, type, default_value, since_version, unconfigured_path, comment) {id, parent, name, type, {.v_##type = default_value}, flags, since_version, unconfigured_path, comment},
-#define cfg_runtime(id, name, parent, flags, type, since_version, unconfigured_path, comment) {id, parent, name, type, {.fn_##type = get_default_##id}, flags | CFG_DEFAULT_RUN_TIME, since_version, unconfigured_path, comment},
-#define cfg_array(id, name, parent, flags, types, default_value, since_version, unconfigured_path, comment) {id, parent, name, CFG_TYPE_ARRAY | types, {.v_CFG_TYPE_STRING = default_value}, flags, since_version, unconfigured_path, comment},
-#define cfg_array_runtime(id, name, parent, flags, types, since_version, unconfigured_path, comment) {id, parent, name, CFG_TYPE_ARRAY | types, {.fn_CFG_TYPE_STRING = get_default_##id}, flags | CFG_DEFAULT_RUN_TIME, since_version, unconfigured_path, comment},
+#define cfg_section(id, name, parent, flags, since_version, unconfigured_value, comment) {id, parent, name, CFG_TYPE_SECTION, {0}, flags, since_version, unconfigured_value, comment},
+#define cfg(id, name, parent, flags, type, default_value, since_version, unconfigured_value, comment) {id, parent, name, type, {.v_##type = default_value}, flags, since_version, unconfigured_value, comment},
+#define cfg_runtime(id, name, parent, flags, type, since_version, unconfigured_value, comment) {id, parent, name, type, {.fn_##type = get_default_##id}, flags | CFG_DEFAULT_RUN_TIME, since_version, unconfigured_value, comment},
+#define cfg_array(id, name, parent, flags, types, default_value, since_version, unconfigured_value, comment) {id, parent, name, CFG_TYPE_ARRAY | types, {.v_CFG_TYPE_STRING = default_value}, flags, since_version, unconfigured_value, comment},
+#define cfg_array_runtime(id, name, parent, flags, types, since_version, unconfigured_value, comment) {id, parent, name, CFG_TYPE_ARRAY | types, {.fn_CFG_TYPE_STRING = get_default_##id}, flags | CFG_DEFAULT_RUN_TIME, since_version, unconfigured_value, comment},
#include "config_settings.h"
#undef cfg_section
#undef cfg
@@ -1698,8 +1698,8 @@ static struct dm_config_node *_add_def_node(struct dm_config_tree *cft,
str = "";
cn->v->v.str = str;
- if (spec->unconfigured && def->unconfigured_path)
- cn->v->v.str = def->unconfigured_path;
+ if (spec->unconfigured && def->unconfigured_value)
+ cn->v->v.str = def->unconfigured_value;
break;
default:
log_error(INTERNAL_ERROR "_add_def_node: unknown type");
diff --git a/lib/config/config.h b/lib/config/config.h
index cc5681c..1c367bd 100644
--- a/lib/config/config.h
+++ b/lib/config/config.h
@@ -121,7 +121,7 @@ typedef struct cfg_def_item {
cfg_def_value_t default_value; /* default value (only for settings) */
uint16_t flags; /* configuration item definition flags */
uint16_t since_version; /* version this item appeared in */
- const char *unconfigured_path; /* path in terms of @FOO@, pre-configured */
+ const char *unconfigured_value; /* value in terms of @FOO@, pre-configured */
const char *comment; /* brief comment */
} cfg_def_item_t;
@@ -165,11 +165,11 @@ struct config_def_tree_spec {
* Register ID for each possible item in the configuration tree.
*/
enum {
-#define cfg_section(id, name, parent, flags, since_version, unconfigured_path, comment) id,
-#define cfg(id, name, parent, flags, type, default_value, since_version, unconfigured_path, comment) id,
-#define cfg_runtime(id, name, parent, flags, type, since_version, unconfigured_path, comment) id,
-#define cfg_array(id, name, parent, flags, types, default_value, since_version, unconfigured_path, comment) id,
-#define cfg_array_runtime(id, name, parent, flags, types, since_version, unconfigured_path, comment) id,
+#define cfg_section(id, name, parent, flags, since_version, unconfigured_value, comment) id,
+#define cfg(id, name, parent, flags, type, default_value, since_version, unconfigured_value, comment) id,
+#define cfg_runtime(id, name, parent, flags, type, since_version, unconfigured_value, comment) id,
+#define cfg_array(id, name, parent, flags, types, default_value, since_version, unconfigured_value, comment) id,
+#define cfg_array_runtime(id, name, parent, flags, types, since_version, unconfigured_value, comment) id,
#include "config_settings.h"
#undef cfg_section
#undef cfg
8 years, 11 months
master - conf: Avoid temp files when generating config.
by Alasdair Kergon
Gitweb: http://git.fedorahosted.org/git/?p=lvm2.git;a=commitdiff;h=d0c46c9ed52477...
Commit: d0c46c9ed5247732e46fcb9ca4ad5be9f77a64a0
Parent: 71dbfd7c2077fc5d83eac37da68b55ef1a195d29
Author: Alasdair G Kergon <agk(a)redhat.com>
AuthorDate: Tue Apr 28 13:02:19 2015 +0100
Committer: Alasdair G Kergon <agk(a)redhat.com>
CommitterDate: Tue Apr 28 13:02:19 2015 +0100
conf: Avoid temp files when generating config.
---
conf/Makefile.in | 10 +++-------
1 files changed, 3 insertions(+), 7 deletions(-)
diff --git a/conf/Makefile.in b/conf/Makefile.in
index ee78f6a..c427a2e 100644
--- a/conf/Makefile.in
+++ b/conf/Makefile.in
@@ -27,12 +27,8 @@ include $(top_builddir)/make.tmpl
.PHONY: install_conf install_localconf install_profiles
generate:
- LD_LIBRARY_PATH=$(top_builddir)/libdm:$(LD_LIBRARY_PATH) $(top_builddir)/tools/lvm dumpconfig --type default --unconfigured --withfullcomments --ignorelocal > example.conf.gen
- cat example.conf.base example.conf.gen > example.conf.in
- $(RM) example.conf.gen
- LD_LIBRARY_PATH=$(top_builddir)/libdm:$(LD_LIBRARY_PATH) $(top_builddir)/tools/lvm dumpconfig --type default --unconfigured --withfullcomments local > lvmlocal.conf.gen
- cat lvmlocal.conf.base lvmlocal.conf.gen > lvmlocal.conf.in
- $(RM) lvmlocal.conf.gen
+ (cat $(top_srcdir)/conf/example.conf.base && LD_LIBRARY_PATH=$(top_builddir)/libdm:$(LD_LIBRARY_PATH) $(top_builddir)/tools/lvm dumpconfig --type default --unconfigured --withfullcomments --ignorelocal) > example.conf.in
+ (cat $(top_srcdir)/conf/lvmlocal.conf.base && LD_LIBRARY_PATH=$(top_builddir)/libdm:$(LD_LIBRARY_PATH) $(top_builddir)/tools/lvm dumpconfig --type default --unconfigured --withfullcomments local) > lvmlocal.conf.in
install_conf: $(CONFSRC)
@if [ ! -e $(confdir)/$(CONFDEST) ]; then \
@@ -54,4 +50,4 @@ install_lvm2: install_conf install_localconf install_profiles
install: install_lvm2
-DISTCLEAN_TARGETS += $(CONFSRC) $(CONFLOCAL) $(PROFILE_TEMPLATES) $(CONFSRC).gen $(CONFLOCAL).gen
+DISTCLEAN_TARGETS += $(CONFSRC) $(CONFLOCAL) $(PROFILE_TEMPLATES)
8 years, 11 months
master - tests: more help#
by Zdenek Kabelac
Gitweb: http://git.fedorahosted.org/git/?p=lvm2.git;a=commitdiff;h=71dbfd7c2077fc...
Commit: 71dbfd7c2077fc5d83eac37da68b55ef1a195d29
Parent: 3fbb7b6e35b12c36838139eb365b526129b63baf
Author: Zdenek Kabelac <zkabelac(a)redhat.com>
AuthorDate: Tue Apr 28 11:35:56 2015 +0200
Committer: Zdenek Kabelac <zkabelac(a)redhat.com>
CommitterDate: Tue Apr 28 11:35:56 2015 +0200
tests: more help#
---
test/Makefile.in | 1 +
1 files changed, 1 insertions(+), 0 deletions(-)
diff --git a/test/Makefile.in b/test/Makefile.in
index bf9b58e..04fbea0 100644
--- a/test/Makefile.in
+++ b/test/Makefile.in
@@ -76,6 +76,7 @@ help:
@echo " clean Clean dir."
@echo " help Display callable targets."
@echo -e "\nSupported variables:"
+ @echo " LVM_TEST_BACKING_DEVICE Set device used for testing (see also LVM_TEST_DIR)."
@echo " LVM_TEST_CAN_CLOBBER_DMESG Allow to clobber dmesg buffer without /dev/kmsg. (1)"
@echo " LVM_TEST_DEVDIR Set to '/dev' to run on real /dev."
@echo " LVM_TEST_DIR Where to create test files [$(LVM_TEST_DIR)]."
8 years, 11 months