]> git.apps.os.sepia.ceph.com Git - xfstests-dev.git/commitdiff
common: use fiemap to count extents and holes
authorJaegeuk Kim <jaegeuk@kernel.org>
Thu, 12 Feb 2015 03:18:23 +0000 (14:18 +1100)
committerDave Chinner <david@fromorbit.com>
Thu, 12 Feb 2015 03:18:23 +0000 (14:18 +1100)
For the follwoing tests, this patch adds general script to get extent and
hole counts.

 xfs/137         (data vs filesize)
 xfs/138         (data vs filesize vs truncate)
 xfs/139         (data vs filesize vs partial truncate)
 xfs/140         (data vs filesize vs extending truncate)
 xfs/179         (data vs filesize w/ fsync)
 xfs/180         (data vs filesize w/ sync)
 xfs/182         (data vs filesize w/ recovery)

It also requires these tests to check for fiemap support.

[dchinner: use _require_xfs_io_command "fiemap" for consistency]

Signed-off-by: Jaegeuk Kim <jaegeuk@kernel.org>
Reviewed-by: Dave Chinner <dchinner@redhat.com>
Signed-off-by: Dave Chinner <david@fromorbit.com>
common/rc
tests/xfs/137
tests/xfs/138
tests/xfs/139
tests/xfs/140
tests/xfs/179
tests/xfs/180
tests/xfs/182

index b916ea01e3a2bc94cc1361f9df7a189e640bc236..9d91ce041166ac1bae7dd2a3c4b9fb1a0cd95204 100644 (file)
--- a/common/rc
+++ b/common/rc
@@ -2332,6 +2332,24 @@ _require_scratch_shutdown()
        _scratch_unmount
 }
 
+# Does fiemap support?
+_require_fiemap()
+{
+       _require_xfs_io_command "fiemap"
+}
+
+_count_extents()
+{
+       res=`$XFS_IO_PROG -c "fiemap" $1 | tail -n +2`
+       echo $res | grep -v hole | wc -l | $AWK_PROG '{print $1}'
+}
+
+_count_holes()
+{
+       res=`$XFS_IO_PROG -c "fiemap" $1 | tail -n +2`
+       echo $res | grep hole | wc -l | $AWK_PROG '{print $1}'
+}
+
 # arg 1 is dev to remove and is output of the below eg.
 # ls -l /sys/class/block/sdd | rev | cut -d "/" -f 3 | rev
 _devmgt_remove()
index 662a2677f9a7dddb550b855ceb27806a8b654599..eb9a5fabd46ea08ed7e4d979bcadad564f20bb90 100755 (executable)
@@ -41,6 +41,7 @@ _supported_os Linux IRIX
 
 _require_scratch
 _require_scratch_shutdown
+_require_fiemap
 _scratch_mkfs_xfs >/dev/null 2>&1
 _scratch_mount
 
@@ -85,11 +86,11 @@ do
                if [ -s $file ]
                then
                        # if file has non-zero size but no extents then it's contents will be NULLs, bad.
-                       if xfs_bmap $file | grep 'no extents' > /dev/null
-                       then
+                       num_extents=`_count_extents $file`
+                       num_holes=`_count_holes $file`
+                       if [ $num_extents -eq 0 ]; then
                                echo corrupt file $file - non-zero size but no extents
-                       elif xfs_bmap $file | grep 'hole' > /dev/null
-                       then
+                       elif [ $num_holes -ne 0 ]; then
                                echo corrupt file $file - contains holes
                        else
                                rm -f $file
index 3fb182c368a8c239fadb22d52e96de9c26a26f30..809a8ee5d42eef36877491d8a7249502eef6aa80 100755 (executable)
@@ -41,6 +41,7 @@ _supported_os Linux IRIX
 
 _require_scratch
 _require_scratch_shutdown
+_require_fiemap
 _scratch_mkfs_xfs >/dev/null 2>&1
 _scratch_mount
 
@@ -91,11 +92,11 @@ do
                if [ -s $file ]
                then
                        # if file has non-zero size but no extents then it's contents will be NULLs, bad.
-                       if xfs_bmap $file | grep 'no extents' > /dev/null
-                       then
+                       num_extents=`_count_extents $file`
+                       num_holes=`_count_holes $file`
+                       if [ $num_extents -eq 0 ]; then
                                echo corrupt file $file - non-zero size but no extents
-                       elif xfs_bmap $file | grep 'hole' > /dev/null
-                       then
+                       elif [ $num_holes -ne 0 ]; then
                                echo corrupt file $file - contains holes
                        else
                                rm -f $file
index 6986c1758f945bbefb76879474629d7e8072e4cd..de91a291a1beaa8aee997689132600b7167243cd 100755 (executable)
@@ -41,6 +41,7 @@ _supported_os Linux IRIX
 
 _require_scratch
 _require_scratch_shutdown
+_require_fiemap
 _scratch_mkfs_xfs >/dev/null 2>&1
 _scratch_mount
 
@@ -91,11 +92,11 @@ do
                if [ -s $file ]
                then
                        # if file has non-zero size but no extents then it's contents will be NULLs, bad.
-                       if xfs_bmap $file | grep 'no extents' > /dev/null
-                       then
+                       num_extents=`_count_extents $file`
+                       num_holes=`_count_holes $file`
+                       if [ $num_extents -eq 0 ]; then
                                echo corrupt file $file - non-zero size but no extents
-                       elif xfs_bmap $file | grep 'hole' > /dev/null
-                       then
+                       elif [ $num_holes -ne 0 ]; then
                                echo corrupt file $file - contains holes
                        else
                                rm -f $file
index b82e43b9e767d63c5ddfd7fbc63cfc075292d675..4882abdd00dd88694c38dae336c5b701dcfaacb6 100755 (executable)
@@ -41,6 +41,7 @@ _supported_os Linux IRIX
 
 _require_scratch
 _require_scratch_shutdown
+_require_fiemap
 _scratch_mkfs_xfs >/dev/null 2>&1
 _scratch_mount
 
@@ -91,8 +92,8 @@ do
                if [ -s $file ]
                then
                        # if file has non-zero size but no extents then it's contents will be NULLs, bad.
-                       if xfs_bmap $file | grep 'no extents' > /dev/null
-                       then
+                       num_extents=`_count_extents $file`
+                       if [ $num_extents -eq 0 ]; then
                                echo corrupt file $file - non-zero size but no extents
                        else
                                rm -f $file
index 87fac8a19d6085648d7053d31185b2631ecae0a2..2f3673e5681cac5dacfba27ec589b56409342ff1 100755 (executable)
@@ -42,6 +42,7 @@ _supported_os Linux IRIX
 
 _require_scratch
 _require_scratch_shutdown
+_require_fiemap
 _scratch_mkfs_xfs >/dev/null 2>&1
 _scratch_mount
 
@@ -59,8 +60,8 @@ _check_files()
                        if [ `ls -l $file | tr -s ' ' | cut -d ' ' -f 5` -eq 32768 ]
                        then
                                # if file has non-zero size but no extents then it's contents will be NULLs, bad.
-                               if xfs_bmap $file | grep 'no extents' > /dev/null
-                               then
+                               num_extents=`_count_extents $file`
+                               if [ $num_extents -eq 0 ]; then
                                        echo corrupt file $file - non-zero size but no extents
                                else
                                        rm -f $file
index b3b0fe4b83cf13404ee650bd5c65df80f1f5a348..40a186a6797896f6a2b3849a2715b7852dc7827d 100755 (executable)
@@ -42,6 +42,7 @@ _supported_os Linux IRIX
 
 _require_scratch
 _require_scratch_shutdown
+_require_fiemap
 _scratch_mkfs_xfs >/dev/null 2>&1
 _scratch_mount
 
@@ -62,8 +63,8 @@ _check_files()
                        if [ `ls -l $file | tr -s ' ' | cut -d ' ' -f 5` -eq 10485760 ]
                        then
                                # if file has non-zero size but no extents then it's contents will be NULLs, bad.
-                               if xfs_bmap $file | grep 'no extents' > /dev/null
-                               then
+                               num_extents=`_count_extents $file`
+                               if [ $num_extents -eq 0 ]; then
                                        echo corrupt file $file - non-zero size but no extents
                                else
                                        rm -f $file
index dac15d4c8580a086bc614f538109794f4d99eb7d..028e121dfb8c80bfc324033ff5c30a3d4c4f0711 100755 (executable)
@@ -42,6 +42,7 @@ _supported_os Linux IRIX
 
 _require_scratch
 _require_scratch_shutdown
+_require_fiemap
 _scratch_mkfs_xfs >/dev/null 2>&1
 _scratch_mount
 
@@ -59,8 +60,8 @@ _check_files()
                        if [ `ls -l $file | tr -s ' ' | cut -d ' ' -f 5` -eq 32768 ]
                        then
                                # if file has non-zero size but no extents then it's contents will be NULLs, bad.
-                               if xfs_bmap $file | grep 'no extents' > /dev/null
-                               then
+                               num_extents=`_count_extents $file`
+                               if [ $num_extents -eq 0 ]; then
                                        echo corrupt file $file - non-zero size but no extents
                                else
                                        rm -f $file