generic: test MADV_POPULATE_READ with IO errors
[xfstests-dev.git] / tests / xfs / 259
1 #! /bin/bash
2 # SPDX-License-Identifier: GPL-2.0
3 # Copyright (c) 2011 Red Hat.  All Rights Reserved.
4 #
5 # FS QA Test No. 259
6 #
7 # Test fs creation on 4 TB minus few bytes partition
8 #
9 . ./common/preamble
10 _begin_fstest auto quick
11
12 # Override the default cleanup function.
13 _cleanup()
14 {
15     rm -f "$testfile"
16 }
17
18 # Import common functions.
19 . ./common/filter
20
21 # real QA test starts here
22 _supported_fs xfs
23 _require_test
24 _require_loop
25 _require_math
26
27 testfile=$TEST_DIR/259.image
28
29 # Test various sizes slightly less than 4 TB. Need to handle different
30 # minimum block sizes for CRC enabled filesystems, but use a small log so we
31 # don't write lots of zeros unnecessarily.
32 sizes_to_check="4096 2048 1024 512"
33 blocksizes="4096 2048 1024 512"
34 four_TB=$(_math "2^42")
35 # The initial value of _fs_has_crcs is not important, because we start testing
36 # with 4096 block size, it only matters for 512 block size test
37 _fs_has_crcs=0
38 for del in $sizes_to_check; do
39         for bs in $blocksizes; do
40                 echo "Trying to make (4TB - ${del}B) long xfs, block size $bs"
41                 # skip tests with 512 block size if the fs created has crc
42                 # enabled by default
43                 if [ $_fs_has_crcs -eq 1 -a $bs -eq 512 ]; then
44                         break;
45                 fi
46                 ddseek=$(_math "$four_TB - $del")
47                 rm -f "$testfile"
48                 dd if=/dev/zero "of=$testfile" bs=1 count=0 seek=$ddseek \
49                         >/dev/null 2>&1 || echo "dd failed"
50                 lofile=$(losetup -f)
51                 losetup $lofile "$testfile"
52                 $MKFS_XFS_PROG -l size=32m -b size=$bs $lofile |  _filter_mkfs \
53                         >/dev/null 2> $tmp.mkfs || echo "mkfs failed!"
54                 . $tmp.mkfs
55                 sync
56                 losetup -d $lofile
57         done
58 done
59
60 status=0
61 exit