generic: test MADV_POPULATE_READ with IO errors
[xfstests-dev.git] / tests / xfs / 032
1 #! /bin/bash
2 # SPDX-License-Identifier: GPL-2.0
3 # Copyright (c) 2014 Red Hat, Inc.  All Rights Reserved.
4 #
5 # FS QA Test No. 032
6 #
7 # Test xfs_copy for all filesystem sector size / block size
8 # combinations possible on this platform.
9 #
10 . ./common/preamble
11 _begin_fstest copy auto quick
12
13 status=0        # success is the default!
14
15 # Import common functions.
16
17 # real QA test starts here
18 _supported_fs xfs
19
20 _require_scratch
21 _require_test_program "feature"
22 _require_xfs_copy
23
24 SECTORSIZE=`blockdev --getss $SCRATCH_DEV`
25 PAGESIZE=`$here/src/feature -s`
26 IMGFILE=$TEST_DIR/${seq}_copy.img
27
28 echo "Silence is golden."
29
30 do_copy()
31 {
32         local opts="$*"
33
34         $XFS_COPY_PROG $opts $SCRATCH_DEV $IMGFILE >> $seqres.full 2>&1 || \
35                 _fail "xfs_copy $opts failed for Sector size $SECTORSIZE Block size $BLOCKSIZE"
36         # Must use "-n" to get exit code; without it xfs_repair always returns 0
37         $XFS_REPAIR_PROG -n -f $IMGFILE >> $seqres.full 2>&1 || \
38                 _fail "xfs_copy $opts corrupted for Sector size $SECTORSIZE Block size $BLOCKSIZE"
39 }
40
41 while [ $SECTORSIZE -le $PAGESIZE ]; do
42         BLOCKSIZE=$SECTORSIZE;
43
44         while [ $BLOCKSIZE -le $PAGESIZE ]; do
45
46                 echo "=== Sector size $SECTORSIZE Block size $BLOCKSIZE ==" >> $seqres.full
47                 _scratch_mkfs -s size=$SECTORSIZE -b size=$BLOCKSIZE -d size=1g >> $seqres.full 2>&1
48                 # Maybe return error at here, e.g: mkfs.xfs -m crc=1 -b size=512
49                 if [ $? -ne 0 ]; then
50                         BLOCKSIZE=$(($BLOCKSIZE * 2))
51                         continue
52                 fi
53                 _scratch_mount
54                 # light population of the fs
55                 $FSSTRESS_PROG -n 100 -d $SCRATCH_MNT >> $seqres.full 2>&1
56                 _scratch_unmount
57
58                 # Test "duplicate" copy at first, if $XFS_COPY_PROG won't do it.
59                 if [[ ! "$XFS_COPY_PROG" =~ -d ]]; then
60                         do_copy -d
61                 fi
62                 do_copy
63
64                 BLOCKSIZE=$(($BLOCKSIZE * 2));
65         done
66         SECTORSIZE=$(($SECTORSIZE * 2));
67 done
68
69 # success, all done
70 exit