generic: test MADV_POPULATE_READ with IO errors
[xfstests-dev.git] / tests / generic / 347
1 #! /bin/bash
2 # SPDX-License-Identifier: GPL-2.0
3 # Copyright (c) 2015 Red Hat, Inc.  All Rights Reserved.
4 #
5 # FS QA Test No. generic/347
6 #
7 # Test very basic thin device usage, exhaustion, and growth
8 #
9 #
10 . ./common/preamble
11 _begin_fstest auto quick rw thin
12
13 BACKING_SIZE=$((500 * 1024 * 1024 / 512))       # 500M
14 VIRTUAL_SIZE=$((10 * $BACKING_SIZE))            # 5000M
15 GROW_SIZE=$((100 * 1024 * 1024 / 512))          # 100M
16
17 # Override the default cleanup function.
18 _cleanup()
19 {
20         _dmthin_cleanup
21         rm -f $tmp.*
22 }
23
24 _setup_thin()
25 {
26         _dmthin_init $BACKING_SIZE $VIRTUAL_SIZE
27         _dmthin_set_queue
28         _dmthin_mkfs
29         _dmthin_mount
30 }
31
32 _workout()
33 {
34         # Overfill it by a bit
35         for I in `seq 1 500`; do
36                 $XFS_IO_PROG -f -c "pwrite -W 0 1M" $SCRATCH_MNT/file$I &>/dev/null
37         done
38
39         sync
40
41         _dmthin_grow  $GROW_SIZE
42
43         # Write a little more, but don't fill
44         for I in `seq 501 510`; do
45                 $XFS_IO_PROG -f -c "pwrite 0 1M" $SCRATCH_MNT/file$I &>/dev/null
46         done
47 }
48
49 # Import common functions.
50 . ./common/dmthin
51
52 _supported_fs generic
53 _require_scratch_nocheck
54 _require_dm_target thin-pool
55
56 _setup_thin
57 _workout
58 _dmthin_check_fs
59 _dmthin_cleanup
60
61 echo "=== completed"
62
63 status=0
64 exit