mirror of
https://github.com/linux-apfs/apfstests.git
synced 2026-05-01 15:01:44 -07:00
xfs: Fix the situation that mount operation rejects corrupted XFS
On upstream kernel, running some tests which corrupt XFS on purpose
got the mismatched output. e.g. running xfs/087:
------------------------------------------------
+ check fs
+ corrupt image
+ mount image
-+ modify files
-broken: 1
+ repair fs
+ mount image (2)
------------------------------------------------
It is reasonable for corrupted XFS to be caught and rejected by mount
or read/write operation.
Fixes: 0828657542 ("xfs: fix blocktrash fuzzers")
Signed-off-by: Xiao Yang <yangx.jy@cn.fujitsu.com>
Reviewed-by: Darrick J. Wong <darrick.wong@oracle.com>
Signed-off-by: Eryu Guan <guaneryu@gmail.com>
This commit is contained in:
+1
-2
@@ -77,10 +77,9 @@ for ag in $(seq 1 $((agcount - 1))) 0; do
|
|||||||
done
|
done
|
||||||
|
|
||||||
# Try to append to files; this should fail
|
# Try to append to files; this should fail
|
||||||
echo "+ mount image"
|
echo "+ mount image && modify files"
|
||||||
if _try_scratch_mount >> $seqres.full 2>&1; then
|
if _try_scratch_mount >> $seqres.full 2>&1; then
|
||||||
|
|
||||||
echo "+ modify files"
|
|
||||||
for x in `seq 1 64`; do
|
for x in `seq 1 64`; do
|
||||||
$XFS_IO_PROG -f -c "pwrite -S 0x62 0 ${blksz}" "${TESTFILE}.${x}" >> $seqres.full
|
$XFS_IO_PROG -f -c "pwrite -S 0x62 0 ${blksz}" "${TESTFILE}.${x}" >> $seqres.full
|
||||||
done
|
done
|
||||||
|
|||||||
+1
-2
@@ -4,8 +4,7 @@ QA output created by 086
|
|||||||
+ make some files
|
+ make some files
|
||||||
+ check fs
|
+ check fs
|
||||||
+ corrupt image
|
+ corrupt image
|
||||||
+ mount image
|
+ mount image && modify files
|
||||||
+ modify files
|
|
||||||
+ repair fs
|
+ repair fs
|
||||||
+ mount image
|
+ mount image
|
||||||
+ chattr -R -i
|
+ chattr -R -i
|
||||||
|
|||||||
+4
-5
@@ -75,17 +75,16 @@ for ag in $(seq 1 $((agcount - 1))) 0; do
|
|||||||
_scratch_xfs_db -x -c "agi ${ag}" -c "agi ${ag}" -c "stack" -c "blocktrash -x 32 -o +64 -y 4096 -z ${FUZZ_ARGS}" >> $seqres.full 2>&1
|
_scratch_xfs_db -x -c "agi ${ag}" -c "agi ${ag}" -c "stack" -c "blocktrash -x 32 -o +64 -y 4096 -z ${FUZZ_ARGS}" >> $seqres.full 2>&1
|
||||||
done
|
done
|
||||||
|
|
||||||
echo "+ mount image"
|
echo "+ mount image && modify files"
|
||||||
|
broken=1
|
||||||
if _try_scratch_mount >> $seqres.full 2>&1; then
|
if _try_scratch_mount >> $seqres.full 2>&1; then
|
||||||
|
|
||||||
echo "+ modify files"
|
|
||||||
broken=0
|
|
||||||
for x in `seq 65 70`; do
|
for x in `seq 65 70`; do
|
||||||
touch "${TESTFILE}.${x}" 2> /dev/null || broken=1
|
touch "${TESTFILE}.${x}" 2> /dev/null && broken=0
|
||||||
done
|
done
|
||||||
echo "broken: ${broken}"
|
|
||||||
umount "${SCRATCH_MNT}"
|
umount "${SCRATCH_MNT}"
|
||||||
fi
|
fi
|
||||||
|
echo "broken: ${broken}"
|
||||||
|
|
||||||
echo "+ repair fs"
|
echo "+ repair fs"
|
||||||
_scratch_xfs_repair >> $seqres.full 2>&1
|
_scratch_xfs_repair >> $seqres.full 2>&1
|
||||||
|
|||||||
+1
-2
@@ -4,8 +4,7 @@ QA output created by 087
|
|||||||
+ make some files
|
+ make some files
|
||||||
+ check fs
|
+ check fs
|
||||||
+ corrupt image
|
+ corrupt image
|
||||||
+ mount image
|
+ mount image && modify files
|
||||||
+ modify files
|
|
||||||
broken: 1
|
broken: 1
|
||||||
+ repair fs
|
+ repair fs
|
||||||
+ mount image (2)
|
+ mount image (2)
|
||||||
|
|||||||
+1
-2
@@ -76,10 +76,9 @@ for ag in $(seq 1 $((agcount - 1))) 0; do
|
|||||||
done
|
done
|
||||||
|
|
||||||
# Try to append to files; this should fail
|
# Try to append to files; this should fail
|
||||||
echo "+ mount image"
|
echo "+ mount image && modify files"
|
||||||
if _try_scratch_mount >> $seqres.full 2>&1; then
|
if _try_scratch_mount >> $seqres.full 2>&1; then
|
||||||
|
|
||||||
echo "+ modify files"
|
|
||||||
for x in `seq 1 64`; do
|
for x in `seq 1 64`; do
|
||||||
$XFS_IO_PROG -f -c "pwrite -S 0x62 0 ${blksz}" "${TESTFILE}.${x}" >> $seqres.full
|
$XFS_IO_PROG -f -c "pwrite -S 0x62 0 ${blksz}" "${TESTFILE}.${x}" >> $seqres.full
|
||||||
done
|
done
|
||||||
|
|||||||
+1
-2
@@ -4,8 +4,7 @@ QA output created by 088
|
|||||||
+ make some files
|
+ make some files
|
||||||
+ check fs
|
+ check fs
|
||||||
+ corrupt image
|
+ corrupt image
|
||||||
+ mount image
|
+ mount image && modify files
|
||||||
+ modify files
|
|
||||||
+ repair fs
|
+ repair fs
|
||||||
+ mount image
|
+ mount image
|
||||||
+ chattr -R -i
|
+ chattr -R -i
|
||||||
|
|||||||
+1
-2
@@ -76,10 +76,9 @@ for ag in $(seq 1 $((agcount - 1))) 0; do
|
|||||||
done
|
done
|
||||||
|
|
||||||
# Try to append to files; this should fail
|
# Try to append to files; this should fail
|
||||||
echo "+ mount image"
|
echo "+ mount image && modify files"
|
||||||
if _try_scratch_mount >> $seqres.full 2>&1; then
|
if _try_scratch_mount >> $seqres.full 2>&1; then
|
||||||
|
|
||||||
echo "+ modify files"
|
|
||||||
for x in `seq 1 64`; do
|
for x in `seq 1 64`; do
|
||||||
$XFS_IO_PROG -f -c "pwrite -S 0x62 0 ${blksz}" "${TESTFILE}.${x}" >> $seqres.full
|
$XFS_IO_PROG -f -c "pwrite -S 0x62 0 ${blksz}" "${TESTFILE}.${x}" >> $seqres.full
|
||||||
done
|
done
|
||||||
|
|||||||
+1
-2
@@ -4,8 +4,7 @@ QA output created by 089
|
|||||||
+ make some files
|
+ make some files
|
||||||
+ check fs
|
+ check fs
|
||||||
+ corrupt image
|
+ corrupt image
|
||||||
+ mount image
|
+ mount image && modify files
|
||||||
+ modify files
|
|
||||||
+ repair fs
|
+ repair fs
|
||||||
+ mount image
|
+ mount image
|
||||||
+ chattr -R -i
|
+ chattr -R -i
|
||||||
|
|||||||
+1
-2
@@ -76,10 +76,9 @@ for ag in $(seq 1 $((agcount - 1))) 0; do
|
|||||||
done
|
done
|
||||||
|
|
||||||
# Try to append to files; this should fail
|
# Try to append to files; this should fail
|
||||||
echo "+ mount image"
|
echo "+ mount image && modify files"
|
||||||
if _try_scratch_mount >> $seqres.full 2>&1; then
|
if _try_scratch_mount >> $seqres.full 2>&1; then
|
||||||
|
|
||||||
echo "+ modify files"
|
|
||||||
for x in `seq 1 64`; do
|
for x in `seq 1 64`; do
|
||||||
$XFS_IO_PROG -f -c "pwrite -S 0x62 0 ${blksz}" "${TESTFILE}.${x}" >> $seqres.full
|
$XFS_IO_PROG -f -c "pwrite -S 0x62 0 ${blksz}" "${TESTFILE}.${x}" >> $seqres.full
|
||||||
done
|
done
|
||||||
|
|||||||
+1
-2
@@ -4,8 +4,7 @@ QA output created by 091
|
|||||||
+ make some files
|
+ make some files
|
||||||
+ check fs
|
+ check fs
|
||||||
+ corrupt image
|
+ corrupt image
|
||||||
+ mount image
|
+ mount image && modify files
|
||||||
+ modify files
|
|
||||||
+ repair fs
|
+ repair fs
|
||||||
+ mount image
|
+ mount image
|
||||||
+ chattr -R -i
|
+ chattr -R -i
|
||||||
|
|||||||
+4
-5
@@ -75,17 +75,16 @@ for ag in $(seq 1 $((agcount - 1))) 0; do
|
|||||||
_scratch_xfs_db -x -c "agi ${ag}" -c "agi ${ag}" -c "addr root" -c "stack" -c "blocktrash -x 32 -y $((blksz * 8)) -z ${FUZZ_ARGS}" >> $seqres.full 2>&1
|
_scratch_xfs_db -x -c "agi ${ag}" -c "agi ${ag}" -c "addr root" -c "stack" -c "blocktrash -x 32 -y $((blksz * 8)) -z ${FUZZ_ARGS}" >> $seqres.full 2>&1
|
||||||
done
|
done
|
||||||
|
|
||||||
echo "+ mount image"
|
echo "+ mount image && modify files"
|
||||||
|
broken=1
|
||||||
if _try_scratch_mount >> $seqres.full 2>&1; then
|
if _try_scratch_mount >> $seqres.full 2>&1; then
|
||||||
|
|
||||||
echo "+ modify files"
|
|
||||||
broken=0
|
|
||||||
for x in `seq 65 70`; do
|
for x in `seq 65 70`; do
|
||||||
touch "${TESTFILE}.${x}" 2> /dev/null || broken=1
|
touch "${TESTFILE}.${x}" 2> /dev/null && broken=0
|
||||||
done
|
done
|
||||||
echo "broken: ${broken}"
|
|
||||||
umount "${SCRATCH_MNT}"
|
umount "${SCRATCH_MNT}"
|
||||||
fi
|
fi
|
||||||
|
echo "broken: ${broken}"
|
||||||
|
|
||||||
echo "+ repair fs"
|
echo "+ repair fs"
|
||||||
_scratch_xfs_repair >> $seqres.full 2>&1
|
_scratch_xfs_repair >> $seqres.full 2>&1
|
||||||
|
|||||||
+1
-2
@@ -4,8 +4,7 @@ QA output created by 093
|
|||||||
+ make some files
|
+ make some files
|
||||||
+ check fs
|
+ check fs
|
||||||
+ corrupt image
|
+ corrupt image
|
||||||
+ mount image
|
+ mount image && modify files
|
||||||
+ modify files
|
|
||||||
broken: 1
|
broken: 1
|
||||||
+ repair fs
|
+ repair fs
|
||||||
+ mount image (2)
|
+ mount image (2)
|
||||||
|
|||||||
+4
-4
@@ -78,17 +78,17 @@ for ag in $(seq 1 $((agcount - 1))) 0; do
|
|||||||
_scratch_xfs_db -x -c "agi ${ag}" -c "agi ${ag}" -c "addr free_root" -c "stack" -c "blocktrash -x 32 -y $((blksz * 8)) -z ${FUZZ_ARGS}" >> $seqres.full 2>&1
|
_scratch_xfs_db -x -c "agi ${ag}" -c "agi ${ag}" -c "addr free_root" -c "stack" -c "blocktrash -x 32 -y $((blksz * 8)) -z ${FUZZ_ARGS}" >> $seqres.full 2>&1
|
||||||
done
|
done
|
||||||
|
|
||||||
echo "+ mount image"
|
echo "+ mount image && modify files"
|
||||||
|
broken=1
|
||||||
if _try_scratch_mount >> $seqres.full 2>&1; then
|
if _try_scratch_mount >> $seqres.full 2>&1; then
|
||||||
|
|
||||||
echo "+ modify files"
|
|
||||||
broken=0
|
broken=0
|
||||||
for x in `seq 65 70`; do
|
for x in `seq 65 70`; do
|
||||||
touch "${TESTFILE}.${x}" 2> /dev/null || broken=1
|
touch "${TESTFILE}.${x}" 2> /dev/null && broken=0
|
||||||
done
|
done
|
||||||
echo "broken: ${broken}"
|
|
||||||
umount "${SCRATCH_MNT}"
|
umount "${SCRATCH_MNT}"
|
||||||
fi
|
fi
|
||||||
|
echo "broken: ${broken}"
|
||||||
|
|
||||||
echo "+ repair fs"
|
echo "+ repair fs"
|
||||||
_scratch_xfs_repair >> $seqres.full 2>&1
|
_scratch_xfs_repair >> $seqres.full 2>&1
|
||||||
|
|||||||
+1
-2
@@ -4,8 +4,7 @@ QA output created by 097
|
|||||||
+ make some files
|
+ make some files
|
||||||
+ check fs
|
+ check fs
|
||||||
+ corrupt image
|
+ corrupt image
|
||||||
+ mount image
|
+ mount image && modify files
|
||||||
+ modify files
|
|
||||||
broken: 1
|
broken: 1
|
||||||
+ repair fs
|
+ repair fs
|
||||||
+ mount image (2)
|
+ mount image (2)
|
||||||
|
|||||||
+1
-2
@@ -66,10 +66,9 @@ __populate_check_xfs_dir "${inode}" block
|
|||||||
echo "+ corrupt dir"
|
echo "+ corrupt dir"
|
||||||
_scratch_xfs_db -x -c "inode ${inode}" -c 'dblock 0' -c "stack" -c "blocktrash -x 32 -y $((blksz * 8)) -z ${FUZZ_ARGS}" >> $seqres.full
|
_scratch_xfs_db -x -c "inode ${inode}" -c 'dblock 0' -c "stack" -c "blocktrash -x 32 -y $((blksz * 8)) -z ${FUZZ_ARGS}" >> $seqres.full
|
||||||
|
|
||||||
echo "+ mount image"
|
echo "+ mount image && modify dir"
|
||||||
if _try_scratch_mount >> $seqres.full 2>&1; then
|
if _try_scratch_mount >> $seqres.full 2>&1; then
|
||||||
|
|
||||||
echo "+ modify dir"
|
|
||||||
rm -rf "${SCRATCH_MNT}/blockdir/00000000" 2> /dev/null && _fail "modified corrupt directory"
|
rm -rf "${SCRATCH_MNT}/blockdir/00000000" 2> /dev/null && _fail "modified corrupt directory"
|
||||||
mkdir "${SCRATCH_MNT}/blockdir/xxxxxxxx" 2> /dev/null && _fail "add to corrupt directory"
|
mkdir "${SCRATCH_MNT}/blockdir/xxxxxxxx" 2> /dev/null && _fail "add to corrupt directory"
|
||||||
umount "${SCRATCH_MNT}"
|
umount "${SCRATCH_MNT}"
|
||||||
|
|||||||
+1
-2
@@ -5,8 +5,7 @@ QA output created by 099
|
|||||||
+ check fs
|
+ check fs
|
||||||
+ check dir
|
+ check dir
|
||||||
+ corrupt dir
|
+ corrupt dir
|
||||||
+ mount image
|
+ mount image && modify dir
|
||||||
+ modify dir
|
|
||||||
+ repair fs
|
+ repair fs
|
||||||
+ mount image (2)
|
+ mount image (2)
|
||||||
+ chattr -R -i
|
+ chattr -R -i
|
||||||
|
|||||||
+1
-2
@@ -71,10 +71,9 @@ while true; do
|
|||||||
loff="$((loff + 1))"
|
loff="$((loff + 1))"
|
||||||
done
|
done
|
||||||
|
|
||||||
echo "+ mount image"
|
echo "+ mount image && modify dir"
|
||||||
if _try_scratch_mount >> $seqres.full 2>&1; then
|
if _try_scratch_mount >> $seqres.full 2>&1; then
|
||||||
|
|
||||||
echo "+ modify dir"
|
|
||||||
rm -rf "${SCRATCH_MNT}/blockdir/00000000" 2> /dev/null && _fail "modified corrupt directory"
|
rm -rf "${SCRATCH_MNT}/blockdir/00000000" 2> /dev/null && _fail "modified corrupt directory"
|
||||||
mkdir "${SCRATCH_MNT}/blockdir/xxxxxxxx" 2> /dev/null && _fail "add to corrupt directory"
|
mkdir "${SCRATCH_MNT}/blockdir/xxxxxxxx" 2> /dev/null && _fail "add to corrupt directory"
|
||||||
umount "${SCRATCH_MNT}"
|
umount "${SCRATCH_MNT}"
|
||||||
|
|||||||
+1
-2
@@ -5,8 +5,7 @@ QA output created by 100
|
|||||||
+ check fs
|
+ check fs
|
||||||
+ check dir
|
+ check dir
|
||||||
+ corrupt dir
|
+ corrupt dir
|
||||||
+ mount image
|
+ mount image && modify dir
|
||||||
+ modify dir
|
|
||||||
+ repair fs
|
+ repair fs
|
||||||
+ mount image (2)
|
+ mount image (2)
|
||||||
+ chattr -R -i
|
+ chattr -R -i
|
||||||
|
|||||||
+1
-2
@@ -66,10 +66,9 @@ __populate_check_xfs_dir "${inode}" leaf
|
|||||||
echo "+ corrupt dir"
|
echo "+ corrupt dir"
|
||||||
_scratch_xfs_db -x -c "inode ${inode}" -c "dblock ${leaf_lblk}" -c "stack" -c "blocktrash -x 32 -y $((blksz * 8)) -z ${FUZZ_ARGS}" >> $seqres.full
|
_scratch_xfs_db -x -c "inode ${inode}" -c "dblock ${leaf_lblk}" -c "stack" -c "blocktrash -x 32 -y $((blksz * 8)) -z ${FUZZ_ARGS}" >> $seqres.full
|
||||||
|
|
||||||
echo "+ mount image"
|
echo "+ mount image && modify dir"
|
||||||
if _try_scratch_mount >> $seqres.full 2>&1; then
|
if _try_scratch_mount >> $seqres.full 2>&1; then
|
||||||
|
|
||||||
echo "+ modify dir"
|
|
||||||
rm -rf "${SCRATCH_MNT}/blockdir/00000000" 2> /dev/null && _fail "modified corrupt directory"
|
rm -rf "${SCRATCH_MNT}/blockdir/00000000" 2> /dev/null && _fail "modified corrupt directory"
|
||||||
mkdir "${SCRATCH_MNT}/blockdir/xxxxxxxx" 2> /dev/null && _fail "add to corrupt directory"
|
mkdir "${SCRATCH_MNT}/blockdir/xxxxxxxx" 2> /dev/null && _fail "add to corrupt directory"
|
||||||
umount "${SCRATCH_MNT}"
|
umount "${SCRATCH_MNT}"
|
||||||
|
|||||||
+1
-2
@@ -5,8 +5,7 @@ QA output created by 101
|
|||||||
+ check fs
|
+ check fs
|
||||||
+ check dir
|
+ check dir
|
||||||
+ corrupt dir
|
+ corrupt dir
|
||||||
+ mount image
|
+ mount image && modify dir
|
||||||
+ modify dir
|
|
||||||
+ repair fs
|
+ repair fs
|
||||||
+ mount image (2)
|
+ mount image (2)
|
||||||
+ chattr -R -i
|
+ chattr -R -i
|
||||||
|
|||||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user