2 # SPDX-License-Identifier: GPL-2.0
3 # Copyright (c) 2016 Fujitsu. All Rights Reserved.
7 # Regression test for commit:
8 # 688f869 ext4: Initialize fsync transaction ids in ext4_new_inode()
11 seqres=$RESULT_DIR/$seq
12 echo "QA output created by $seq"
16 status=1 # failure is the default!
17 trap "_cleanup; exit \$status" 0 1 2 3 15
25 # get standard environment, filters and checks
28 # remove previous $seqres.full before test
31 # real QA test starts here
36 _scratch_mkfs >> $seqres.full 2>&1
38 blocksize=$(_get_block_size $SCRATCH_MNT)
41 # With 4k block size, this amounts to 10M FS instance.
42 fssize=$((2560 * $blocksize))
43 _scratch_mkfs_sized $fssize >> $seqres.full 2>&1
44 _require_metadata_journaling $SCRATCH_DEV
48 # this is the jbd2 journal superblock magic number on disk, in big endian
51 while [ $offset -lt $fssize ]; do
52 if od -j $offset -N 4 -t x1 $SCRATCH_DEV | \
53 grep -i "$magic" >/dev/null; then
54 echo "Found journal: $offset" >> $seqres.full
58 offset=$((offset + blocksize))
60 if [ $found -ne 1 ]; then
61 echo "Found no journal"
65 # Overwrite journal.s_squence to 0x 81d1a480
66 # 0x81d1a480 is hex form of 2178000000, and jbd2 journal is big endian on
67 # disk, the s_squence offset to the beginning of journal superblock is 24
68 # we do this to let jbd2 start to run with a initial big transaction id,
69 # which will reduce the time taken to trigger this bug.
70 $XFS_IO_PROG -c "pwrite -S 0x81 $((offset+24)) 1" \
71 -c "pwrite -S 0xd1 $((offset+25)) 1" \
72 -c "pwrite -S 0xa4 $((offset+26)) 1" \
73 -c "pwrite -S 0x80 $((offset+27)) 1" $SCRATCH_DEV >> $seqres.full 2>&1
75 trans_id=`$DUMPE2FS_PROG $SCRATCH_DEV 2>/dev/null | grep "Journal sequence" | \
77 echo "Initial transaction id is $trans_id"
82 # Wait for running subcommand before exitting so that
83 # mountpoint is not busy when we try to unmount it
84 trap "wait; exit" SIGTERM
87 $XFS_IO_PROG -f -c "fdatasync" $SCRATCH_MNT/testfile
94 kill $datasync_work_pid >/dev/null 2>&1