generic: add test for boundary in xfs_attr_shortform_verify
[xfstests-dev.git] / tests / generic / 353
1 #! /bin/bash
2 # SPDX-License-Identifier: GPL-2.0
3 # Copyright (c) 2016 Fujitsu. All Rights Reserved.
4 #
5 # FS QA Test 353
6 #
7 # Check if fiemap ioctl returns correct SHARED flag on reflinked file
8 # before and after sync the fs
9 #
10 # Btrfs has a bug in checking shared extent, which can only handle metadata
11 # already committed to disk, but not delayed extent tree modification.
12 # This caused SHARED flag only occurs after sync.
13 #
14 seq=`basename $0`
15 seqres=$RESULT_DIR/$seq
16 echo "QA output created by $seq"
17
18 here=`pwd`
19 tmp=/tmp/$$
20 status=1        # failure is the default!
21 trap "_cleanup; exit \$status" 0 1 2 3 15
22
23 _cleanup()
24 {
25         cd /
26         rm -f $tmp.*
27 }
28
29 # get standard environment, filters and checks
30 . ./common/rc
31 . ./common/filter
32 . ./common/reflink
33 . ./common/punch
34
35 # remove previous $seqres.full before test
36 rm -f $seqres.full
37
38 # real QA test starts here
39
40 # Modify as appropriate.
41 _supported_fs generic
42 _supported_os Linux
43 _require_scratch_reflink
44 _require_xfs_io_command "fiemap"
45
46 _scratch_mkfs > /dev/null 2>&1
47 _scratch_mount
48
49 blocksize=64k
50 file1="$SCRATCH_MNT/file1"
51 file2="$SCRATCH_MNT/file2"
52
53 # write the initial file
54 _pwrite_byte 0xcdcdcdcd 0 $blocksize $file1 | _filter_xfs_io
55
56 # reflink initial file
57 _reflink_range $file1 0 $file2 0 $blocksize | _filter_xfs_io
58
59 # check their fiemap to make sure it's correct
60 echo "before sync:"
61 echo "$file1" | _filter_scratch
62 $XFS_IO_PROG -c "fiemap -v" $file1 | _filter_fiemap_flags
63 echo "$file2" | _filter_scratch
64 $XFS_IO_PROG -c "fiemap -v" $file2 | _filter_fiemap_flags
65
66 # sync and recheck, to make sure the fiemap doesn't change just
67 # due to sync
68 sync
69 echo "after sync:"
70 echo "$file1" | _filter_scratch
71 $XFS_IO_PROG -c "fiemap -v" $file1 | _filter_fiemap_flags
72 echo "$file2" | _filter_scratch
73 $XFS_IO_PROG -c "fiemap -v" $file2 | _filter_fiemap_flags
74
75 # success, all done
76 status=0
77 exit