2 # SPDX-License-Identifier: GPL-2.0
3 # Copyright (c) 2020 IBM Corporation. All Rights Reserved.
5 # FS QA Test No. ext4/046
7 # Test writes to falloc file with filesize > 4GB and make sure to verify
8 # the file checksum both before and after mount.
9 # This test is to check whether unwritten extents gets properly converted
10 # to written extent on a filesystem with bs < ps with dioread_nolock.
13 seqres=$RESULT_DIR/$seq
14 echo "QA output created by $seq"
18 status=1 # failure is the default!
19 trap "_cleanup; exit \$status" 0 1 2 3 15
27 # get standard environment, filters and checks
31 # remove previous $seqres.full before test
36 _require_xfs_io_command "falloc"
37 _require_scratch_size $((6 * 1024 * 1024)) #kB
39 _scratch_mkfs >> $seqres.full 2>&1
40 _scratch_mount "-o dioread_nolock" >> $seqres.full 2>&1
43 blksz=$(_get_file_block_size $SCRATCH_MNT)
45 testfile=$SCRATCH_MNT/testfile-$seq
47 # Fallocate testfile with size > 4G
48 fsize=$((5 * 1024 * 1024 * 1024))
49 $XFS_IO_PROG -f -c "falloc 0 $fsize" $testfile >> $seqres.full 2>&1
51 # First write at offset < 4G (at few alternative blks)
52 off=$((3 * 1024 * 1024 * 1024))
55 -c "pwrite $off $blksz" \
56 $testfile >> $seqres.full 2>&1
57 off=$(($off + (2*$blksz)))
60 # Then write at offset > 4G (at few alternative blks) to check
61 # any 32bit overflow case in map.m_lblk
62 off=$((4 * 1024 * 1024 * 1024))
65 -c "pwrite $off $blksz" \
66 $testfile >> $seqres.full 2>&1
67 off=$(($off + (2*$blksz)))
70 # ==== Pre-Remount ===
71 md5_pre=`md5sum $testfile | cut -d' ' -f1`
72 echo "Pre-Remount md5sum of $testfile = $md5_pre" >> $seqres.full
76 # ==== Post-Remount ===
77 md5_post=`md5sum $testfile | cut -d' ' -f1`
78 echo "Post-Remount md5sum of $testfile = $md5_post" >> $seqres.full
79 test $md5_pre != $md5_post && echo "md5sum mismatch"
82 echo "Silence is golden"