2 # SPDX-License-Identifier: GPL-2.0
3 # Copyright (c) 2017, Oracle and/or its affiliates. All Rights Reserved.
7 # Check that high-offset reads and writes work.
10 seqres=$RESULT_DIR/$seq
11 echo "QA output created by $seq"
15 status=1 # failure is the default!
16 trap "_cleanup; exit \$status" 0 1 2 3 15
24 # get standard environment, filters and checks
28 # real QA test starts here
30 _require_scratch_nocheck
31 _require_block_device $SCRATCH_DEV
35 echo "Silence is golden"
37 # clear MKFS_OPTIONS which may contain user specified block size value, and
38 # _scratch_mkfs_sized will always use that value to create filesystem.
41 echo "Starting test" > $seqres.full
42 devsize=$(blockdev --getsize64 $SCRATCH_DEV)
43 for blocksize in 512 1024 2048 4096 8192 16384 32768 65536; do
44 echo "+ Format blocksize $blocksize and mount" >> $seqres.full
45 _scratch_unmount > /dev/null 2>&1
46 # Try to format and mount with the given blocksize. If they don't
47 # succeed, move on to the next block size.
48 if ! _scratch_mkfs_sized $devsize $blocksize >> $seqres.full 2>&1 ||
49 ! _try_scratch_mount >> $seqres.full 2>&1 ||
50 test "$(stat -f -c '%S' $SCRATCH_MNT)" -ne "$blocksize"; then
51 echo "+++ Format and mount failed" >> $seqres.full
55 testdir=$SCRATCH_MNT/test-$seq
58 echo "++ Create the original files" >> $seqres.full
59 bigoff=$(echo "2^63 - 2" | $BC_PROG)
60 len=$(echo "2^63 - 1" | $BC_PROG)
61 $XFS_IO_PROG -f -c "truncate $len" $testdir/file0 >> $seqres.full 2>&1
62 if [ ! -s $testdir/file0 ]; then
63 # If we can't set a large file size then don't bother
64 # with this blocksize because the fs doesn't support it.
65 echo "+++ High offset ftruncate failed" >> $seqres.full
68 _pwrite_byte 0x61 $bigoff 1 $testdir/file1 >> $seqres.full
70 echo "++ Check file creation" >> $seqres.full
73 expected="7ffffffffffffffe: 61 a"
74 actual="$($XFS_IO_PROG -c "pread -v -q $bigoff 1" $testdir/file1)"
75 if [ "$expected" = "$actual" ]; then
76 echo "+++ Success!" >> $seqres.full
78 echo "+++ Discrepancy @ blocksize $blocksize" >> $seqres.full
79 echo "Discrepancy @ blocksize $blocksize"
82 echo "++ Check scratchfs" >> $seqres.full