fsx/fsstress: round blocksize properly
[xfstests-dev.git] / tests / xfs / 327
1 #! /bin/bash
2 # SPDX-License-Identifier: GPL-2.0
3 # Copyright (c) 2016, Oracle and/or its affiliates.  All Rights Reserved.
4 #
5 # FS QA Test No. 327
6 #
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
10 # the reflink flag.
11 #
12 seq=`basename $0`
13 seqres=$RESULT_DIR/$seq
14 echo "QA output created by $seq"
15
16 here=`pwd`
17 tmp=/tmp/$$
18 status=1    # failure is the default!
19 trap "_cleanup; exit \$status" 0 1 2 3 15
20
21 _cleanup()
22 {
23         cd /
24         _scratch_unmount > /dev/null 2>&1
25         rm -rf $tmp.*
26 }
27
28 # get standard environment, filters and checks
29 . ./common/rc
30 . ./common/filter
31 . ./common/reflink
32
33 # real QA test starts here
34 _supported_fs xfs
35 _require_cp_reflink
36 _require_scratch_reflink
37
38 rm -f $seqres.full
39
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
44
45 echo "Create files"
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
49 done
50 sync
51
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)
55
56 echo "Check filesystem"
57 _scratch_unmount
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'
61 _scratch_mount
62
63 echo "Check files"
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
67 done
68
69 echo "CoW all files"
70 seq 1 $nr | while read i; do
71         echo m >> $SCRATCH_MNT/file.$i
72 done
73
74 echo "Repair filesystem"
75 _scratch_unmount
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'
80 _scratch_mount
81
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
86 done
87
88 echo "Done"
89
90 # success, all done
91 status=0
92 exit