xfs/123: fix remote symlink block size calculation
authorDarrick J. Wong <darrick.wong@oracle.com>
Tue, 18 Dec 2018 20:35:57 +0000 (12:35 -0800)
committerEryu Guan <guaneryu@gmail.com>
Sat, 22 Dec 2018 14:16:04 +0000 (22:16 +0800)
In this test we try to create a remote symlink block by creating a
symlink target buffer large enough to exceed the size of an inode.
Unfortunately we don't use the correct block size or symlink header
size, which on a 1k block filesystem causes there to be two remote
blocks.  This causes crc verification errors in xfs_db (because it's
too dumb to load both blocks as one like the kernel does) which we
don't care about because we're about to corrupt the block anyway.

So, fix the block size calculation so that we end up with one block.

Signed-off-by: Darrick J. Wong <darrick.wong@oracle.com>
Reviewed-by: Eryu Guan <guaneryu@gmail.com>
Signed-off-by: Eryu Guan <guaneryu@gmail.com>
tests/xfs/123

index 8a494ef92470fa4d1240580d2cf6011f201cafe0..f45e94bf14448e23fec636d08d57e754c73aad6f 100755 (executable)
@@ -46,11 +46,12 @@ _scratch_mkfs_xfs > /dev/null
 
 echo "+ mount fs image"
 _scratch_mount
-blksz=1000
+blksz=1024
 
 echo "+ make some files"
 echo "file contents: moo" > "${SCRATCH_MNT}/x"
-str="$(perl -e "print './' x $(( (blksz / 2) - 16));")x"
+reps=$(( (blksz - (56 + 1)) / 2 ))
+str="$(perl -e "print './' x $reps;")x"
 (cd $SCRATCH_MNT; ln -s "${str}" "long_symlink")
 cat "${SCRATCH_MNT}/long_symlink"
 inode="$(stat -c '%i' "${SCRATCH_MNT}/long_symlink")"
@@ -60,7 +61,7 @@ echo "+ check fs"
 _scratch_xfs_repair -n >> $seqres.full 2>&1 || _fail "xfs_repair should not fail"
 
 echo "+ corrupt image"
-_scratch_xfs_db -x -c "inode ${inode}" -c "dblock 0" -c "stack" -c "blocktrash -x 32 -o 256 -y $((blksz * 8)) -z ${FUZZ_ARGS}" >> $seqres.full
+_scratch_xfs_db -x -c "inode ${inode}" -c "dblock 0" -c "stack" -c "blocktrash -x 32 -o 256 -y $((blksz * 4)) -z ${FUZZ_ARGS}" >> $seqres.full
 
 echo "+ mount image"
 if _try_scratch_mount >> $seqres.full 2>&1; then