1) xfs/133 and xfs/134 work abnornamlly on RHEL6.8GA and RHEL6.9Beta
because xfs_db fails to set negative i_size and reports "usage:
write fieldname value". The special argument "--" is only used to
end option-scanning in getopt(). So we can run two xfs_db commands
to set negative i_size regardless of the special argument "--" is
needed or not. getopt() has been produced by 'commit
c9f5e3db22098
("xfs_db: Allow writes of corrupted data")'.
2) xfs/134 passes unexpectedly on RHEL6.8GA due to EINVAL, so we use
touch command to create 512-aligned test file.
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>
echo "Corrupt filesystem"
_scratch_unmount
echo "Corrupt filesystem"
_scratch_unmount
-_scratch_xfs_db -x -c "inode ${inum}" -c 'write core.size -- -1' >> $seqres.full
+
+# run two xfs_db commands to set core.size regardless of the special argument "--"
+# is needed or not.
+_scratch_xfs_db -x -c "inode ${inum}" -c 'write core.size -- -1' >> $seqres.full 2>&1
+_scratch_xfs_db -x -c "inode ${inum}" -c 'write core.size -1' >> $seqres.full 2>&1
+
+# check core.size and _notrun if it's not set correctly
+i_size=`_scratch_xfs_db -c "inode ${inum}" -c "print core.size" | $AWK_PROG '{print $3}'`
+if [ $i_size -ne -1 ]; then
+ _notrun "Could not set i_size to -1 successfully, skip test."
+fi
echo "Remount, try to append"
_scratch_mount
echo "Remount, try to append"
_scratch_mount
_scratch_mount
testdir=$SCRATCH_MNT
_scratch_mount
testdir=$SCRATCH_MNT
+# make sure the write offset is 512-aligned
+touch $testdir/a
inum=$(stat -c "%i" $testdir/a)
echo "Corrupt filesystem"
_scratch_unmount
inum=$(stat -c "%i" $testdir/a)
echo "Corrupt filesystem"
_scratch_unmount
-# Set the file size to the highest multiple of 512 below
-# -1 so that we can perform a dio write.
-_scratch_xfs_db -x -c "inode ${inum}" -c 'write core.size -- -512' >> $seqres.full
+
+# 1) Set the file size to the highest multiple of 512 below -1 so
+# that we can perform a dio write.
+# 2) run two xfs_db commands to set core.size regardless of the special
+# argument "--" is needed or not.
+_scratch_xfs_db -x -c "inode ${inum}" -c 'write core.size -- -512' >> $seqres.full 2>&1
+_scratch_xfs_db -x -c "inode ${inum}" -c 'write core.size -512' >> $seqres.full 2>&1
+
+# check core.size and _notrun if it's not set correctly
+i_size=`_scratch_xfs_db -c "inode ${inum}" -c "print core.size" | $AWK_PROG '{print $3}'`
+if [ $i_size -ne -512 ]; then
+ _notrun "Could not set i_size to -512 successfully, skip test."
+fi
echo "Remount, try to append"
_scratch_mount
echo "Remount, try to append"
_scratch_mount