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
37 _require_xfs_io_command "falloc"
38 _require_scratch_size $((6 * 1024 * 1024)) #kB
40 _scratch_mkfs >> $seqres.full 2>&1
41 if ! _try_scratch_mount "-o dioread_nolock" >> $seqres.full 2>&1; then
42 err_str="can't mount with dioread_nolock if block size != PAGE_SIZE"
43 _check_dmesg_for ${err_str}
45 _notrun "mount failed, ext4 doesn't support bs < ps with dioread_nolock"
47 _fail "mount failed with dioread_nolock"
52 blksz=$(_get_file_block_size $SCRATCH_MNT)
54 testfile=$SCRATCH_MNT/testfile-$seq
56 # Fallocate testfile with size > 4G
57 fsize=$((5 * 1024 * 1024 * 1024))
58 $XFS_IO_PROG -f -c "falloc 0 $fsize" $testfile >> $seqres.full 2>&1
60 # First write at offset < 4G (at few alternative blks)
61 off=$((3 * 1024 * 1024 * 1024))
64 -c "pwrite $off $blksz" \
65 $testfile >> $seqres.full 2>&1
66 off=$(($off + (2*$blksz)))
69 # Then write at offset > 4G (at few alternative blks) to check
70 # any 32bit overflow case in map.m_lblk
71 off=$((4 * 1024 * 1024 * 1024))
74 -c "pwrite $off $blksz" \
75 $testfile >> $seqres.full 2>&1
76 off=$(($off + (2*$blksz)))
79 # ==== Pre-Remount ===
80 md5_pre=`md5sum $testfile | cut -d' ' -f1`
81 echo "Pre-Remount md5sum of $testfile = $md5_pre" >> $seqres.full
85 # ==== Post-Remount ===
86 md5_post=`md5sum $testfile | cut -d' ' -f1`
87 echo "Post-Remount md5sum of $testfile = $md5_post" >> $seqres.full
88 test $md5_pre != $md5_post && echo "md5sum mismatch"
91 echo "Silence is golden"