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
31 _require_scratch_nocheck
32 _require_block_device $SCRATCH_DEV
36 echo "Silence is golden"
38 # clear MKFS_OPTIONS which may contain user specified block size value, and
39 # _scratch_mkfs_sized will always use that value to create filesystem.
42 echo "Starting test" > $seqres.full
43 devsize=$(blockdev --getsize64 $SCRATCH_DEV)
44 for blocksize in 512 1024 2048 4096 8192 16384 32768 65536; do
45 echo "+ Format blocksize $blocksize and mount" >> $seqres.full
46 _scratch_unmount > /dev/null 2>&1
47 # Try to format and mount with the given blocksize. If they don't
48 # succeed, move on to the next block size.
49 if ! _scratch_mkfs_sized $devsize $blocksize >> $seqres.full 2>&1 ||
50 ! _try_scratch_mount >> $seqres.full 2>&1 ||
51 test "$(stat -f -c '%S' $SCRATCH_MNT)" -ne "$blocksize"; then
52 echo "+++ Format and mount failed" >> $seqres.full
56 testdir=$SCRATCH_MNT/test-$seq
59 echo "++ Create the original files" >> $seqres.full
60 bigoff=$(echo "2^63 - 2" | $BC_PROG)
61 len=$(echo "2^63 - 1" | $BC_PROG)
62 $XFS_IO_PROG -f -c "truncate $len" $testdir/file0 >> $seqres.full 2>&1
63 if [ ! -s $testdir/file0 ]; then
64 # If we can't set a large file size then don't bother
65 # with this blocksize because the fs doesn't support it.
66 echo "+++ High offset ftruncate failed" >> $seqres.full
69 _pwrite_byte 0x61 $bigoff 1 $testdir/file1 >> $seqres.full
71 echo "++ Check file creation" >> $seqres.full
74 expected="7ffffffffffffffe: 61 a"
75 actual="$($XFS_IO_PROG -c "pread -v -q $bigoff 1" $testdir/file1)"
76 if [ "$expected" = "$actual" ]; then
77 echo "+++ Success!" >> $seqres.full
79 echo "+++ Discrepancy @ blocksize $blocksize" >> $seqres.full
80 echo "Discrepancy @ blocksize $blocksize"
83 echo "++ Check scratchfs" >> $seqres.full