generic: shutdown fs after log recovery
[xfstests-dev.git] / tests / generic / 347
1 #! /bin/bash
2 # FS QA Test No. generic/347
3 #
4 # Test very basic thin device usage, exhaustion, and growth
5 #
6 # Copyright (c) 2015 Red Hat, Inc.  All Rights Reserved.
7 #
8 # This program is free software; you can redistribute it and/or
9 # modify it under the terms of the GNU General Public License as
10 # published by the Free Software Foundation.
11 #
12 # This program is distributed in the hope that it would be useful,
13 # but WITHOUT ANY WARRANTY; without even the implied warranty of
14 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
15 # GNU General Public License for more details.
16 #
17 # You should have received a copy of the GNU General Public License
18 # along with this program; if not, write the Free Software Foundation,
19 # Inc.,  51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
20 #
21
22 seq=`basename $0`
23 seqres=$RESULT_DIR/$seq
24 echo "QA output created by $seq"
25
26 here=`pwd`
27 tmp=/tmp/$$
28
29 status=1        # failure is the default!
30 trap "_cleanup; exit \$status" 0 1 2 3 15
31
32 BACKING_SIZE=$((500 * 1024 * 1024 / 512))       # 500M
33 VIRTUAL_SIZE=$((10 * $BACKING_SIZE))            # 5000M
34 GROW_SIZE=$((100 * 1024 * 1024 / 512))          # 100M
35
36 _cleanup()
37 {
38         _dmthin_cleanup
39         rm -f $tmp.*
40 }
41
42 _setup_thin()
43 {
44         _dmthin_init $BACKING_SIZE $VIRTUAL_SIZE
45         _dmthin_set_queue
46         _mkfs_dev $DMTHIN_VOL_DEV
47         _dmthin_mount
48 }
49
50 _workout()
51 {
52         # Overfill it by a bit
53         for I in `seq 1 500`; do
54                 $XFS_IO_PROG -f -c "pwrite -W 0 1M" $SCRATCH_MNT/file$I &>/dev/null
55         done
56
57         sync
58
59         _dmthin_grow  $GROW_SIZE
60
61         # Write a little more, but don't fill
62         for I in `seq 501 510`; do
63                 $XFS_IO_PROG -f -c "pwrite 0 1M" $SCRATCH_MNT/file$I &>/dev/null
64         done
65 }
66
67 # get standard environment, filters and checks
68 . ./common/rc
69 . ./common/dmthin
70
71 _supported_fs generic
72 _supported_os Linux
73 _require_scratch_nocheck
74 _require_dm_target thin-pool
75
76 _setup_thin
77 _workout
78 _dmthin_check_fs
79 _dmthin_cleanup
80
81 echo "=== completed"
82
83 status=0
84 exit