4 # Regression test for commit:
5 # 688f869 ext4: Initialize fsync transaction ids in ext4_new_inode()
7 #-----------------------------------------------------------------------
8 # Copyright (c) 2016 Fujitsu. All Rights Reserved.
10 # This program is free software; you can redistribute it and/or
11 # modify it under the terms of the GNU General Public License as
12 # published by the Free Software Foundation.
14 # This program is distributed in the hope that it would be useful,
15 # but WITHOUT ANY WARRANTY; without even the implied warranty of
16 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17 # GNU General Public License for more details.
19 # You should have received a copy of the GNU General Public License
20 # along with this program; if not, write the Free Software Foundation,
21 # Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
22 #-----------------------------------------------------------------------
26 seqres=$RESULT_DIR/$seq
27 echo "QA output created by $seq"
31 status=1 # failure is the default!
32 trap "_cleanup; exit \$status" 0 1 2 3 15
40 # get standard environment, filters and checks
43 # remove previous $seqres.full before test
46 # real QA test starts here
51 _require_metadata_journaling $SCRATCH_DEV
54 fssize=$((8 * 1024 * 1024))
55 _scratch_mkfs_sized $fssize >> $seqres.full 2>&1
57 blocksize=`$DUMPE2FS_PROG -h $SCRATCH_DEV 2>/dev/null | grep "Block size" | \
61 # this is the jbd2 journal superblock magic number on disk, in big endian
64 while [ $offset -lt $fssize ]; do
65 if od -j $offset -N 4 -t x1 $SCRATCH_DEV | \
66 grep -i "$magic" >/dev/null; then
67 echo "Found journal: $offset" >> $seqres.full
71 offset=$((offset + blocksize))
73 if [ $found -ne 1 ]; then
74 echo "Found no journal"
78 # Overwrite journal.s_squence to 0x 81d1a480
79 # 0x81d1a480 is hex form of 2178000000, and jbd2 journal is big endian on
80 # disk, the s_squence offset to the beginning of journal superblock is 24
81 # we do this to let jbd2 start to run with a initial big transaction id,
82 # which will reduce the time taken to trigger this bug.
83 $XFS_IO_PROG -c "pwrite -S 0x81 $((offset+24)) 1" \
84 -c "pwrite -S 0xd1 $((offset+25)) 1" \
85 -c "pwrite -S 0xa4 $((offset+26)) 1" \
86 -c "pwrite -S 0x80 $((offset+27)) 1" $SCRATCH_DEV >> $seqres.full 2>&1
88 trans_id=`$DUMPE2FS_PROG $SCRATCH_DEV 2>/dev/null | grep "Journal sequence" | \
90 echo "Initial transaction id is $trans_id"
96 $XFS_IO_PROG -f -c "fdatasync" $SCRATCH_MNT/testfile
103 kill $datasync_work_pid >/dev/null 2>&1