shared/005,7: fix making sure debugfs sets negative i_size
authorXiao Yang <yangx.jy@cn.fujitsu.com>
Wed, 22 Feb 2017 08:17:03 +0000 (16:17 +0800)
committerEryu Guan <eguan@redhat.com>
Wed, 22 Feb 2017 10:15:22 +0000 (18:15 +0800)
If the kernel bug has been fixed, stat command fails to get i_size
and reports "Structure needs cleaning".  So we use debugfs -R "stat"
instead of stat command to make sure debugfs sets negative i_size.
These cases have been broken by commit 0e13e40b247a1 ("shared/005,7:
make sure debugfs sets negative i_size").

Signed-off-by: Xiao Yang <yangx.jy@cn.fujitsu.com>
Reviewed-by: Eryu Guan <eguan@redhat.com>
Signed-off-by: Eryu Guan <eguan@redhat.com>
tests/shared/005
tests/shared/007

index 76c551c104a67b63bef672abc899f3107e4acac1..de7b84ffd7602202a38b13593051e495e019c1fa 100755 (executable)
@@ -65,15 +65,12 @@ echo "Corrupt filesystem"
 _scratch_unmount
 $DEBUGFS_PROG -w -R "sif /a size -1" $SCRATCH_DEV >> $seqres.full 2>&1
 
-echo "Remount, try to append"
-_scratch_mount
-
 # check whether debugfs succeeds to set i_size to -1 or not
-i_size=$(stat -c "%s" $testdir/a)
-if [ $i_size -ne -1 ]; then
+$DEBUGFS_PROG -R "stat /a" $SCRATCH_DEV 2>&1 | grep -q "Size: 18446744073709551615" || \
        _notrun "Could not set i_size to -1 successfully, skip test."
-fi
 
+echo "Remount, try to append"
+_scratch_mount
 dd if=/dev/zero of=$testdir/a bs=512 count=1 oflag=append conv=notrunc >> $seqres.full 2>&1 || echo "Write did not succeed (ok)."
 sync
 
index 77636f4011d83fb9fda0b8579ccbbe1653b22560..785f19f3dcc6660683d6543b4b7f738be099d16b 100755 (executable)
@@ -67,15 +67,12 @@ _scratch_unmount
 # -1 so that we can perform a dio write.
 $DEBUGFS_PROG -w -R "sif /a size 0xFFFFFFFFFFFFFE00" $SCRATCH_DEV >> $seqres.full 2>&1
 
-echo "Remount, try to append"
-_scratch_mount
-
 # check whether debugfs succeeds to set i_size to -512 or not
-i_size=$(stat -c "%s" $testdir/a)
-if [ $i_size -ne -512 ]; then
+$DEBUGFS_PROG -R "stat /a" $SCRATCH_DEV 2>&1 | grep -q "Size: 18446744073709551104" || \
        _notrun "Could not set i_size to -512 successfully, skip test."
-fi
 
+echo "Remount, try to append"
+_scratch_mount
 dd if=/dev/zero of=$testdir/a bs=512 count=1 oflag=direct,append conv=notrunc >> $seqres.full 2>&1 || echo "Write did not succeed (ok)."
 sync