tests: remove IRIX support from tests also supported on Linux
[xfstests-dev.git] / tests / xfs / 118
1 #! /bin/bash
2 # FS QA Test 118
3 #
4 # Test xfs_fsr's handling of 2-extent files with preallocation
5 #
6 # An error in xfs_swap_extent_forks() incorrectly set up the
7 # temporary inode's if_extents pointer to inline, leading to
8 # in-memory corruption when the temporary inode was released
9 # and torn down; i_itemp and d_ops got overwritten with zeros,
10 # which led to an oops in xfs_trans_log_inode down the fput path.
11 #
12 # Fixed upstream by proper nextents counting using
13 # ip->i_df.if_bytes not ip->i_d.di_nextents in xfs_swap_extent_forks
14 #
15 #-----------------------------------------------------------------------
16 # Copyright (c) 2016 Red Hat, inc.  All Rights Reserved.
17 #
18 # This program is free software; you can redistribute it and/or
19 # modify it under the terms of the GNU General Public License as
20 # published by the Free Software Foundation.
21 #
22 # This program is distributed in the hope that it would be useful,
23 # but WITHOUT ANY WARRANTY; without even the implied warranty of
24 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
25 # GNU General Public License for more details.
26 #
27 # You should have received a copy of the GNU General Public License
28 # along with this program; if not, write the Free Software Foundation,
29 # Inc.,  51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
30 #-----------------------------------------------------------------------
31 #
32
33 seq=`basename $0`
34 seqres=$RESULT_DIR/$seq
35 echo "QA output created by $seq"
36
37 here=`pwd`
38 tmp=/tmp/$$
39 status=1        # failure is the default!
40 trap "_cleanup; exit \$status" 0 1 2 3 15
41
42 _cleanup()
43 {
44         cd /
45         rm -f $tmp.*
46 }
47
48 # get standard environment, filters and checks
49 . ./common/rc
50 . ./common/filter
51
52 # remove previous $seqres.full before test
53 rm -f $seqres.full
54
55 _supported_fs xfs
56 _supported_os Linux
57
58 _require_scratch
59 _require_command "$XFS_FSR_PROG" "xfs_fsr"
60
61 # 50M
62 _scratch_mkfs_sized $((50 * 1024 * 1024)) >> $seqres.full 2>&1
63 _scratch_mount
64
65 echo "Silence is golden"
66
67 # Fragment freespace
68 # The aim is to create a fragmented two-extent file *with* prealloc
69 # so make the free holes big enough that a 2-extent file will have
70 # preallocation added.  Let's say... 64k free chunks.
71
72 $XFS_IO_PROG -fs -c "falloc 0 40000k" $SCRATCH_MNT/fill >> $seqres.full 2>&1
73 sync
74
75 dd if=/dev/zero of=$SCRATCH_MNT/remainder oflag=direct > /dev/null 2>&1
76
77 # Free up a bunch of 64k chunks
78 for i in `seq 0 68 40000`; do
79         $XFS_IO_PROG -fs -c "unresvsp ${i}k 64k" $SCRATCH_MNT/fill
80 done
81
82 # Create 2-extent files w/ preallocation (via extending writes)
83 for I in `seq 1 64`; do
84         $XFS_IO_PROG -f -c "pwrite 0 64k" $SCRATCH_MNT/newfile-$I \
85                                                  >> $seqres.full 2>&1
86         $XFS_IO_PROG -f -c "pwrite 64k 64k" $SCRATCH_MNT/newfile-$I \
87                                                 >> $seqres.full 2>&1
88 done
89 # sync to get extents on disk so fsr sees them
90 sync
91
92 # Free up some space for defragmentation temp file
93 rm -f $SCRATCH_MNT/fill
94
95 $XFS_FSR_PROG -vd $SCRATCH_MNT/newfile* >> $seqres.full 2>&1
96
97 # success, all done
98 status=0
99 exit