generic: shutdown fs after log recovery
[xfstests-dev.git] / tests / generic / 353
1 #! /bin/bash
2 # FS QA Test 353
3 #
4 # Check if fiemap ioctl returns correct SHARED flag on reflinked file
5 # before and after sync the fs
6 #
7 # Btrfs has a bug in checking shared extent, which can only handle metadata
8 # already committed to disk, but not delayed extent tree modification.
9 # This caused SHARED flag only occurs after sync.
10 #
11 #-----------------------------------------------------------------------
12 # Copyright (c) 2016 Fujitsu. All Rights Reserved.
13 #
14 # This program is free software; you can redistribute it and/or
15 # modify it under the terms of the GNU General Public License as
16 # published by the Free Software Foundation.
17 #
18 # This program is distributed in the hope that it would be useful,
19 # but WITHOUT ANY WARRANTY; without even the implied warranty of
20 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
21 # GNU General Public License for more details.
22 #
23 # You should have received a copy of the GNU General Public License
24 # along with this program; if not, write the Free Software Foundation,
25 # Inc.,  51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
26 #-----------------------------------------------------------------------
27 #
28
29 seq=`basename $0`
30 seqres=$RESULT_DIR/$seq
31 echo "QA output created by $seq"
32
33 here=`pwd`
34 tmp=/tmp/$$
35 status=1        # failure is the default!
36 trap "_cleanup; exit \$status" 0 1 2 3 15
37
38 _cleanup()
39 {
40         cd /
41         rm -f $tmp.*
42 }
43
44 # get standard environment, filters and checks
45 . ./common/rc
46 . ./common/filter
47 . ./common/reflink
48 . ./common/punch
49
50 # remove previous $seqres.full before test
51 rm -f $seqres.full
52
53 # real QA test starts here
54
55 # Modify as appropriate.
56 _supported_fs generic
57 _supported_os Linux
58 _require_scratch_reflink
59 _require_fiemap
60
61 _scratch_mkfs > /dev/null 2>&1
62 _scratch_mount
63
64 blocksize=64k
65 file1="$SCRATCH_MNT/file1"
66 file2="$SCRATCH_MNT/file2"
67
68 # write the initial file
69 _pwrite_byte 0xcdcdcdcd 0 $blocksize $file1 | _filter_xfs_io
70
71 # reflink initial file
72 _reflink_range $file1 0 $file2 0 $blocksize | _filter_xfs_io
73
74 # check their fiemap to make sure it's correct
75 echo "before sync:"
76 echo "$file1" | _filter_scratch
77 $XFS_IO_PROG -c "fiemap -v" $file1 | _filter_fiemap_flags
78 echo "$file2" | _filter_scratch
79 $XFS_IO_PROG -c "fiemap -v" $file2 | _filter_fiemap_flags
80
81 # sync and recheck, to make sure the fiemap doesn't change just
82 # due to sync
83 sync
84 echo "after sync:"
85 echo "$file1" | _filter_scratch
86 $XFS_IO_PROG -c "fiemap -v" $file1 | _filter_fiemap_flags
87 echo "$file2" | _filter_scratch
88 $XFS_IO_PROG -c "fiemap -v" $file2 | _filter_fiemap_flags
89
90 # success, all done
91 status=0
92 exit