]> git.apps.os.sepia.ceph.com Git - xfstests-dev.git/commitdiff
common: fix _count_extents and _count_holes
authorEryu Guan <eguan@redhat.com>
Tue, 4 Aug 2015 04:10:49 +0000 (14:10 +1000)
committerDave Chinner <david@fromorbit.com>
Tue, 4 Aug 2015 04:10:49 +0000 (14:10 +1000)
In _count_extents and _count_holes, the output of 'xfs_io -c "fiemap"'
is saved in var res, but the following "echo $res" will merge the
original output into one line. e.g.

0: [0..63]: 96..159
1: [64..127]: hole

will be

0: [0..63]: 96..159 1: [64..127]: hole

so the extent count is always 0 if there's a hole.

This makes generic/046 fail occasionally. (Seems it's easier to
reproduce when the system is under some presure, e.g. with fsstress
running.)

Tested the new _count_extents and _count_holes with generic/04[3-9] and
tests all passed as expect.

Reported-by: Zorro Lang <zlang@redhat.com>
Signed-off-by: Eryu Guan <eguan@redhat.com>
Reviewed-by: Dave Chinner <dchinner@redhat.com>
Signed-off-by: Dave Chinner <david@fromorbit.com>
common/rc

index 1dcebf91fc6668b51aaf8f92f0a0ff7ee77d4a06..70d2fa8760767ce2d66b18ce79230819d1732d0a 100644 (file)
--- a/common/rc
+++ b/common/rc
@@ -2447,14 +2447,12 @@ _require_fiemap()
 
 _count_extents()
 {
-       res=`$XFS_IO_PROG -c "fiemap" $1 | tail -n +2`
-       echo $res | grep -v hole | wc -l | $AWK_PROG '{print $1}'
+       $XFS_IO_PROG -c "fiemap" $1 | tail -n +2 | grep -v hole | wc -l
 }
 
 _count_holes()
 {
-       res=`$XFS_IO_PROG -c "fiemap" $1 | tail -n +2`
-       echo $res | grep hole | wc -l | $AWK_PROG '{print $1}'
+       $XFS_IO_PROG -c "fiemap" $1 | tail -n +2 | grep hole | wc -l
 }
 
 # arg 1 is dev to remove and is output of the below eg.