@@ -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()
@@ -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
@@ -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
@@ -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
@@ -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
@@ -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
@@ -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
@@ -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
Change log from v5: o split _count_extents and _count_holes -- >8 -- This is to detect whether fiemap tool supports or not. 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) Signed-off-by: Jaegeuk Kim <jaegeuk@kernel.org> --- common/rc | 18 ++++++++++++++++++ tests/xfs/137 | 9 +++++---- tests/xfs/138 | 9 +++++---- tests/xfs/139 | 9 +++++---- tests/xfs/140 | 5 +++-- tests/xfs/179 | 5 +++-- tests/xfs/180 | 5 +++-- tests/xfs/182 | 5 +++-- 8 files changed, 45 insertions(+), 20 deletions(-)