]> sourceware.org Git - lvm2.git/commitdiff
Avoid using pipes on lv commands
authorZdenek Kabelac <zkabelac@redhat.com>
Thu, 3 Mar 2011 15:46:05 +0000 (15:46 +0000)
committerZdenek Kabelac <zkabelac@redhat.com>
Thu, 3 Mar 2011 15:46:05 +0000 (15:46 +0000)
Failure on pipe kills lv command and produces memory stacktrace.
Add 'true' for empty grep/sed to avoid generating stacktrace.

This should help with long time (7min) for this test on Lenny testing maching
(mimage was filler with stacktrace and each word was used as LV name).

test/t-mirror-vgreduce-removemissing.sh

index 146c2d42f14ca3ebcd053d754a48936242d31ae9..2a1bd955a4a7e36dc78223c4833a6e3f8b8ca81a 100755 (executable)
@@ -24,8 +24,8 @@ lv_is_on_ ()
        echo $pvs | sed 's/ /\n/g' | sort | uniq > out1
 
        lvs -a -o+devices $lv
-       lvs -a -odevices --noheadings $lv | \
-       sed 's/([^)]*)//g; s/[ ,]/\n/g' | sort | uniq > out2
+       lvs -a -odevices --noheadings $lv > lvs_log
+       sed 's/([^)]*)//g; s/[ ,]/\n/g' lvs_log | sort | uniq > out2 || true
 
        diff --ignore-blank-lines out1 out2
 }
@@ -41,14 +41,15 @@ mimages_are_on_ ()
        echo "Check if mirror images of $lv are on PVs $pvs"
        rm -f out1 out2
        echo $pvs | sed 's/ /\n/g' | sort | uniq > out1
-
-       mimages=$(lvs --noheadings -a -o lv_name $vg | grep "${lv}_mimage_" | \
-               sed 's/\[//g; s/\]//g')
+       lvs --noheadings -a -o lv_name $vg > lvs_log
+       mimages=$(grep "${lv}_mimage_" lvs_log | \
+               sed 's/\[//g; s/\]//g' || true)
+       
        for i in $mimages; do
                echo "Checking $vg/$i"
                lvs -a -o+devices $vg/$i
-               lvs -a -odevices --noheadings $vg/$i | \
-                       sed 's/([^)]*)//g; s/ //g; s/,/ /g' | sort | uniq >> out2
+               lvs -a -odevices --noheadings $vg/$i > lvs_log
+               sed 's/([^)]*)//g; s/ //g; s/,/ /g' lvs_log | sort | uniq >> out2 || true
        done
 
        diff --ignore-blank-lines out1 out2
This page took 0.035498 seconds and 5 git commands to generate.