4 # Check that getfsmap agrees with getbmap for reflinked files.
6 #-----------------------------------------------------------------------
7 # Copyright (c) 2016, Oracle and/or its affiliates. All Rights Reserved.
9 # This program is free software; you can redistribute it and/or
10 # modify it under the terms of the GNU General Public License as
11 # published by the Free Software Foundation.
13 # This program is distributed in the hope that it would be useful,
14 # but WITHOUT ANY WARRANTY; without even the implied warranty of
15 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 # GNU General Public License for more details.
18 # You should have received a copy of the GNU General Public License
19 # along with this program; if not, write the Free Software Foundation,
20 # Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
21 #-----------------------------------------------------------------------
24 seqres="$RESULT_DIR/$seq"
25 echo "QA output created by $seq"
29 status=1 # failure is the default!
30 trap "_cleanup; exit \$status" 0 1 2 3 15
35 rm -rf "$tmp".* $TEST_DIR/fsmap $TEST_DIR/bmap
38 # get standard environment, filters and checks
43 # real QA test starts here
46 _require_scratch_reflink
47 _require_xfs_scratch_rmapbt
48 _require_xfs_io_command "fsmap"
49 _require_test_program "punch-alternating"
53 echo "Format and mount"
54 _scratch_mkfs > "$seqres.full" 2>&1
57 _pwrite_byte 0x80 0 737373 $SCRATCH_MNT/f1 >> $seqres.full
59 ./src/punch-alternating $SCRATCH_MNT/f1 >> $seqres.full
60 _cp_reflink $SCRATCH_MNT/f1 $SCRATCH_MNT/f2
61 ino=$(stat -c '%i' $SCRATCH_MNT/f1)
63 echo "Get fsmap" | tee -a $seqres.full
64 $XFS_IO_PROG -c 'fsmap -v' $SCRATCH_MNT >> $seqres.full
65 $XFS_IO_PROG -c 'fsmap -v' $SCRATCH_MNT | tr '[]()' ' ' > $TEST_DIR/fsmap
67 echo "Get f1 bmap" | tee -a $seqres.full
68 $XFS_IO_PROG -c 'bmap -v' $SCRATCH_MNT/f1 >> $seqres.full
69 $XFS_IO_PROG -c 'bmap -v' $SCRATCH_MNT/f1 | grep '^[[:space:]]*[0-9]*:' | grep -v 'hole' | tr '[]()' ' ' > $TEST_DIR/bmap
71 echo "Check f1 bmap and fsmap" | tee -a $seqres.full
72 cat $TEST_DIR/bmap | while read ext offrange colon blockrange ag agrange total crap; do
73 qstr="^[[:space:]]*[0-9]*:[[:space:]]*[0-9]*:[0-9]*[[:space:]]*${blockrange} :[[:space:]]*${ino}[[:space:]]*${offrange}[[:space:]]*${ag}[[:space:]]*${agrange}[[:space:]]*${total} 1000000$"
74 echo "${qstr}" >> $seqres.full
75 grep "${qstr}" $TEST_DIR/fsmap >> $seqres.full
76 found=$(grep -c "${qstr}" $TEST_DIR/fsmap)
77 test $found -eq 1 || echo "Unexpected output for offset ${offrange}."
80 echo "Get f2 bmap" | tee -a $seqres.full
81 $XFS_IO_PROG -c 'bmap -v' $SCRATCH_MNT/f2 >> $seqres.full
82 $XFS_IO_PROG -c 'bmap -v' $SCRATCH_MNT/f2 | grep '^[[:space:]]*[0-9]*:' | grep -v 'hole' | tr '[]()' ' ' > $TEST_DIR/bmap
84 echo "Check f2 bmap and fsmap" | tee -a $seqres.full
85 cat $TEST_DIR/bmap | while read ext offrange colon blockrange ag agrange total crap; do
86 qstr="^[[:space:]]*[0-9]*:[[:space:]]*[0-9]*:[0-9]*[[:space:]]*${blockrange} :[[:space:]]*${ino}[[:space:]]*${offrange}[[:space:]]*${ag}[[:space:]]*${agrange}[[:space:]]*${total} 1000000$"
87 echo "${qstr}" >> $seqres.full
88 grep "${qstr}" $TEST_DIR/fsmap >> $seqres.full
89 found=$(grep -c "${qstr}" $TEST_DIR/fsmap)
90 test $found -eq 1 || echo "Unexpected output for offset ${offrange}."