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
37 _scratch_mkfs >> $seqres.full 2>&1
39 blocksize=$(_get_block_size $SCRATCH_MNT)
42 # With 4k block size, this amounts to 10M FS instance.
43 fssize=$((2560 * $blocksize))
44 _scratch_mkfs_sized $fssize >> $seqres.full 2>&1
45 _require_metadata_journaling $SCRATCH_DEV
49 # this is the jbd2 journal superblock magic number on disk, in big endian
52 while [ $offset -lt $fssize ]; do
53 if od -j $offset -N 4 -t x1 $SCRATCH_DEV | \
54 grep -i "$magic" >/dev/null; then
55 echo "Found journal: $offset" >> $seqres.full
59 offset=$((offset + blocksize))
61 if [ $found -ne 1 ]; then
62 echo "Found no journal"
66 # Overwrite journal.s_squence to 0x 81d1a480
67 # 0x81d1a480 is hex form of 2178000000, and jbd2 journal is big endian on
68 # disk, the s_squence offset to the beginning of journal superblock is 24
69 # we do this to let jbd2 start to run with a initial big transaction id,
70 # which will reduce the time taken to trigger this bug.
71 $XFS_IO_PROG -c "pwrite -S 0x81 $((offset+24)) 1" \
72 -c "pwrite -S 0xd1 $((offset+25)) 1" \
73 -c "pwrite -S 0xa4 $((offset+26)) 1" \
74 -c "pwrite -S 0x80 $((offset+27)) 1" $SCRATCH_DEV >> $seqres.full 2>&1
76 trans_id=`$DUMPE2FS_PROG $SCRATCH_DEV 2>/dev/null | grep "Journal sequence" | \
78 echo "Initial transaction id is $trans_id"
83 # Wait for running subcommand before exitting so that
84 # mountpoint is not busy when we try to unmount it
85 trap "wait; exit" SIGTERM
88 $XFS_IO_PROG -f -c "fdatasync" $SCRATCH_MNT/testfile
95 kill $datasync_work_pid >/dev/null 2>&1