2 # SPDX-License-Identifier: GPL-2.0
3 # Copyright (c) 2016, Oracle and/or its affiliates. All Rights Reserved.
7 # Create 100 reflinked files, CoW them all, and see if xfs_repair will
8 # clear the reflink flag. There was a buffer handling bug in xfs_repair
9 # that (fortunately) triggered asserts in the rmap code when clearing
13 seqres=$RESULT_DIR/$seq
14 echo "QA output created by $seq"
18 status=1 # failure is the default!
19 trap "_cleanup; exit \$status" 0 1 2 3 15
24 _scratch_unmount > /dev/null 2>&1
28 # get standard environment, filters and checks
33 # real QA test starts here
36 _require_scratch_reflink
40 nr=128 # spanning at least one inode chunk tickles a bug in xfs_repair
41 echo "Format filesystem"
42 _scratch_mkfs >/dev/null 2>&1
43 _scratch_mount >> $seqres.full
46 _pwrite_byte 0x66 0 1 $SCRATCH_MNT/file.0 >> $seqres.full
47 seq 1 $nr | while read i; do
48 _cp_reflink $SCRATCH_MNT/file.0 $SCRATCH_MNT/file.$i
52 ino_0=$(stat -c '%i' $SCRATCH_MNT/file.0)
53 ino_64=$(stat -c '%i' $SCRATCH_MNT/file.64)
54 ino_128=$(stat -c '%i' $SCRATCH_MNT/file.128)
56 echo "Check filesystem"
58 _scratch_xfs_db -c "inode $ino_0" -c print \
59 -c "inode $ino_64" -c print \
60 -c "inode $ino_128" -c print | grep reflink | sed -e 's/^v[0-9]*/vX/g'
64 for i in 0 $((nr / 2)) $nr; do
65 md5sum $SCRATCH_MNT/file.$i | _filter_scratch
66 $XFS_IO_PROG -c 'lsattr -v' $SCRATCH_MNT/file.$i >> $seqres.full
70 seq 1 $nr | while read i; do
71 echo m >> $SCRATCH_MNT/file.$i
74 echo "Repair filesystem"
76 _repair_scratch_fs >> $seqres.full
77 _scratch_xfs_db -c "inode $ino_0" -c print \
78 -c "inode $ino_64" -c print \
79 -c "inode $ino_128" -c print | grep reflink | sed -e 's/^v[0-9]*/vX/g'
82 echo "Check files again"
83 for i in 0 $((nr / 2)) $nr; do
84 md5sum $SCRATCH_MNT/file.$i | _filter_scratch
85 $XFS_IO_PROG -c 'lsattr -v' $SCRATCH_MNT/file.$i >> $seqres.full